Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,32 @@ DEFAULT_NOTIFICATION_CHANNEL_ID=default_channel
PLATFORM_COMMISSION_RATE=0.10

# Provider payout (default: 90%)
PROVIDER_PAYOUT_RATE=0.90
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
52 changes: 52 additions & 0 deletions lib/config/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
19 changes: 12 additions & 7 deletions lib/core/constants/app_constants.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import 'package:connect/config/app_config.dart';

/// App-wide constants
class AppConstants {
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';
}
Expand Down
10 changes: 5 additions & 5 deletions lib/core/services/notification_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NotificationService {
if (kIsWeb) return;

try {
const channel = AndroidNotificationChannel(
final channel = AndroidNotificationChannel(
AppConstants.notificationChannelId,
AppConstants.notificationChannelName,
description: AppConstants.notificationChannelDescription,
Expand All @@ -27,7 +27,7 @@ class NotificationService {
enableVibration: true,
);

const androidSettings = AndroidInitializationSettings(
final androidSettings = AndroidInitializationSettings(
AppConstants.notificationIcon,
);

Expand All @@ -37,7 +37,7 @@ class NotificationService {
requestSoundPermission: true,
);

const initializationSettings = InitializationSettings(
final initializationSettings = InitializationSettings(
android: androidSettings,
iOS: iosSettings,
);
Expand Down Expand Up @@ -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,
Expand All @@ -103,7 +103,7 @@ class NotificationService {
ledOnMs: AppConstants.ledOnMs,
ledOffMs: AppConstants.ledOffMs,
),
iOS: DarwinNotificationDetails(
iOS: const DarwinNotificationDetails(
presentAlert: true,
presentBadge: true,
presentSound: true,
Expand Down
4 changes: 3 additions & 1 deletion lib/search_tasks/mappoints/points.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class _TaskMapScreenState extends State<TaskMapScreen> {
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;
Expand Down