1/// Environment Configuration for Coves Mobile 2/// 3/// Supports multiple environments: 4/// - Production: Real Bluesky infrastructure 5/// - Local: Local PDS + PLC for development/testing 6/// 7/// Set via ENVIRONMENT environment variable or flutter run --dart-define 8enum Environment { 9 production, 10 local, 11} 12 13class EnvironmentConfig { 14 15 const EnvironmentConfig({ 16 required this.environment, 17 required this.apiUrl, 18 required this.handleResolverUrl, 19 required this.plcDirectoryUrl, 20 }); 21 final Environment environment; 22 final String apiUrl; 23 final String handleResolverUrl; 24 final String plcDirectoryUrl; 25 26 /// Production configuration (default) 27 /// Uses real Bluesky infrastructure 28 static const production = EnvironmentConfig( 29 environment: Environment.production, 30 apiUrl: 'https://coves.social', // TODO: Update when production is live 31 handleResolverUrl: 'https://bsky.social/xrpc/com.atproto.identity.resolveHandle', 32 plcDirectoryUrl: 'https://plc.directory', 33 ); 34 35 /// Local development configuration 36 /// Uses localhost via adb reverse port forwarding 37 /// 38 /// IMPORTANT: Before testing, run these commands to forward ports: 39 /// adb reverse tcp:3001 tcp:3001 # PDS 40 /// adb reverse tcp:3002 tcp:3002 # PLC 41 /// adb reverse tcp:8081 tcp:8081 # AppView 42 /// 43 /// Note: For physical devices not connected via USB, use ngrok URLs instead 44 static const local = EnvironmentConfig( 45 environment: Environment.local, 46 apiUrl: 'http://localhost:8081', 47 handleResolverUrl: 'http://localhost:3001/xrpc/com.atproto.identity.resolveHandle', 48 plcDirectoryUrl: 'http://localhost:3002', 49 ); 50 51 /// Get current environment based on build configuration 52 static EnvironmentConfig get current { 53 // Read from --dart-define=ENVIRONMENT=local 54 const envString = String.fromEnvironment('ENVIRONMENT', defaultValue: 'production'); 55 56 switch (envString) { 57 case 'local': 58 return local; 59 case 'production': 60 default: 61 return production; 62 } 63 } 64 65 bool get isProduction => environment == Environment.production; 66 bool get isLocal => environment == Environment.local; 67}