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