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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user