diff --git a/.env.example b/.env.example index 665ac03..20d4b0a 100644 --- a/.env.example +++ b/.env.example @@ -98,4 +98,32 @@ DEFAULT_NOTIFICATION_CHANNEL_ID=default_channel PLATFORM_COMMISSION_RATE=0.10 # Provider payout (default: 90%) -PROVIDER_PAYOUT_RATE=0.90 \ No newline at end of file +PROVIDER_PAYOUT_RATE=0.90 + +# ============================================================================ +# NOTIFICATION CONFIGURATION +# ============================================================================ + +# Notification channel ID (default: high_importance_channel) +NOTIFICATION_CHANNEL_ID=high_importance_channel + +# Notification channel name (default: High Importance Notifications) +NOTIFICATION_CHANNEL_NAME=High Importance Notifications + +# Notification channel description +NOTIFICATION_CHANNEL_DESCRIPTION=This channel is used for important notifications. + +# LED timing for notifications (in milliseconds) +LED_ON_MS=1000 +LED_OFF_MS=500 + +# Notification icon (default: @mipmap/ic_launcher) +NOTIFICATION_ICON=@mipmap/ic_launcher + +# ============================================================================ +# MAP CONFIGURATION +# ============================================================================ + +# Near distance threshold in meters (default: 5000 for 5km) +# Used to determine if a task location is considered "near" the user +NEAR_DISTANCE_THRESHOLD=5000 \ No newline at end of file diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 437eff7..a7f4a19 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -210,4 +210,56 @@ class AppConfig { return 0.90; } } + + // ============================================================================ + // NOTIFICATION CONFIGURATION + // ============================================================================ + + /// Notification Channel ID + static String get notificationChannelId => + _getEnv('NOTIFICATION_CHANNEL_ID', 'high_importance_channel'); + + /// Notification Channel Name + static String get notificationChannelName => + _getEnv('NOTIFICATION_CHANNEL_NAME', 'High Importance Notifications'); + + /// Notification Channel Description + static String get notificationChannelDescription => + _getEnv('NOTIFICATION_CHANNEL_DESCRIPTION', 'This channel is used for important notifications.'); + + /// LED On Duration in milliseconds + static int get ledOnMs { + try { + return int.tryParse(_getEnv('LED_ON_MS', '1000')) ?? 1000; + } catch (e) { + return 1000; + } + } + + /// LED Off Duration in milliseconds + static int get ledOffMs { + try { + return int.tryParse(_getEnv('LED_OFF_MS', '500')) ?? 500; + } catch (e) { + return 500; + } + } + + /// Notification Icon + static String get notificationIcon => + _getEnv('NOTIFICATION_ICON', '@mipmap/ic_launcher'); + + // ============================================================================ + // MAP CONFIGURATION + // ============================================================================ + + /// Near Distance Threshold in meters (e.g., 5000 for 5km) + /// Used to determine if a task location is considered "near" the user + static double get nearDistanceThreshold { + try { + return double.tryParse(_getEnv('NEAR_DISTANCE_THRESHOLD', '5000')) ?? 5000; + } catch (e) { + return 5000; + } + } } diff --git a/lib/core/constants/app_constants.dart b/lib/core/constants/app_constants.dart index 80cc88f..96d9b57 100644 --- a/lib/core/constants/app_constants.dart +++ b/lib/core/constants/app_constants.dart @@ -1,3 +1,5 @@ +import 'package:connect/config/app_config.dart'; + /// App-wide constants class AppConstants { AppConstants._(); @@ -5,14 +7,17 @@ class AppConstants { static const String appName = 'Connect'; static const String appTitle = 'Connect'; - static const String notificationChannelId = 'high_importance_channel'; - static const String notificationChannelName = 'High Importance Notifications'; - static const String notificationChannelDescription = - 'This channel is used for important notifications.'; + /// Notification channel configuration loaded from AppConfig + static String get notificationChannelId => AppConfig.notificationChannelId; + static String get notificationChannelName => AppConfig.notificationChannelName; + static String get notificationChannelDescription => AppConfig.notificationChannelDescription; - static const int ledOnMs = 1000; - static const int ledOffMs = 500; - static const String notificationIcon = '@mipmap/ic_launcher'; + /// LED timing configuration loaded from AppConfig (in milliseconds) + static int get ledOnMs => AppConfig.ledOnMs; + static int get ledOffMs => AppConfig.ledOffMs; + + /// Notification icon loaded from AppConfig + static String get notificationIcon => AppConfig.notificationIcon; static const String envFileName = '.env'; } diff --git a/lib/core/services/notification_service.dart b/lib/core/services/notification_service.dart index 39ed62e..13c90bb 100644 --- a/lib/core/services/notification_service.dart +++ b/lib/core/services/notification_service.dart @@ -18,7 +18,7 @@ class NotificationService { if (kIsWeb) return; try { - const channel = AndroidNotificationChannel( + final channel = AndroidNotificationChannel( AppConstants.notificationChannelId, AppConstants.notificationChannelName, description: AppConstants.notificationChannelDescription, @@ -27,7 +27,7 @@ class NotificationService { enableVibration: true, ); - const androidSettings = AndroidInitializationSettings( + final androidSettings = AndroidInitializationSettings( AppConstants.notificationIcon, ); @@ -37,7 +37,7 @@ class NotificationService { requestSoundPermission: true, ); - const initializationSettings = InitializationSettings( + final initializationSettings = InitializationSettings( android: androidSettings, iOS: iosSettings, ); @@ -89,7 +89,7 @@ class NotificationService { /// Get notification details for Android and iOS static NotificationDetails _getNotificationDetails() { - return const NotificationDetails( + return NotificationDetails( android: AndroidNotificationDetails( AppConstants.notificationChannelId, AppConstants.notificationChannelName, @@ -103,7 +103,7 @@ class NotificationService { ledOnMs: AppConstants.ledOnMs, ledOffMs: AppConstants.ledOffMs, ), - iOS: DarwinNotificationDetails( + iOS: const DarwinNotificationDetails( presentAlert: true, presentBadge: true, presentSound: true, diff --git a/lib/search_tasks/mappoints/points.dart b/lib/search_tasks/mappoints/points.dart index 8155ead..3a9eefa 100644 --- a/lib/search_tasks/mappoints/points.dart +++ b/lib/search_tasks/mappoints/points.dart @@ -38,7 +38,9 @@ class _TaskMapScreenState extends State { BitmapDescriptor? _customMarkerIcon; BitmapDescriptor? _nearMarkerIcon; BitmapDescriptor? _farMarkerIcon; - static const double _nearDistanceThreshold = 5000; // 5km threshold + + // Get near distance threshold from configuration (in meters) + double get _nearDistanceThreshold => AppConfig.nearDistanceThreshold; // Route-related variables bool _isRouteLoading = false;