feat: Add services for managing trip-related data

- Implement EmergencyService for handling emergency contacts per trip.
- Create GuestFlagService to manage guest mode flags for trips.
- Introduce NotificationService with local notification capabilities.
- Add OfflineFlagService for managing offline caching flags.
- Develop PackingService for shared packing lists per trip.
- Implement ReminderService for managing reminders/to-dos per trip.
- Create SosService for dispatching SOS events to a backend.
- Add StorageService with album image upload functionality.
- Implement TransportService for managing transport segments per trip.
- Create TripChecklistService for storing and retrieving trip checklists.
- Add TripDocumentService for persisting trip documents metadata.

test: Add unit tests for new services

- Implement tests for AlbumService, BudgetService, EmergencyService, GuestFlagService, PackingService, ReminderService, SosService, TransportService, TripChecklistService, and TripDocumentService.
- Ensure tests cover adding, loading, deleting, and handling corrupted payloads for each service.
This commit is contained in:
Van Leemput Dayron
2026-03-13 15:02:23 +01:00
parent 3215a990d1
commit 9b08b2896c
36 changed files with 4731 additions and 2 deletions

View File

@@ -50,6 +50,43 @@ class StorageService {
: _storage = storage ?? FirebaseStorage.instance,
_errorService = errorService ?? ErrorService();
/// Uploads an album image for a trip with compression.
///
/// Saves the file under `album/<tripId>/` with a unique name, and returns
/// the download URL. Uses the same compression pipeline as receipts.
Future<String> uploadAlbumImage(String tripId, File imageFile) async {
try {
_validateImageFile(imageFile);
final compressedImage = await _compressImage(imageFile);
final fileName =
'album_${DateTime.now().millisecondsSinceEpoch}_${path.basename(imageFile.path)}';
final storageRef = _storage.ref().child('album/$tripId/$fileName');
final metadata = SettableMetadata(
contentType: 'image/jpeg',
customMetadata: {
'tripId': tripId,
'uploadedAt': DateTime.now().toIso8601String(),
'compressed': 'true',
},
);
final uploadTask = storageRef.putData(compressedImage, metadata);
final snapshot = await uploadTask;
final downloadUrl = await snapshot.ref.getDownloadURL();
_errorService.logSuccess(
'StorageService',
'Album image uploaded: $fileName',
);
return downloadUrl;
} catch (e) {
_errorService.logError('StorageService', 'Error uploading album image: $e');
rethrow;
}
}
/// Uploads a receipt image for an expense with automatic compression.
///
/// Validates the image file, compresses it to JPEG format with 85% quality,