feat: Upgrade Firebase Functions dependencies, enhance notification service with APNS support and FCM

This commit is contained in:
Van Leemput Dayron
2025-11-28 20:18:24 +01:00
parent 68f546d0e8
commit b4bcc8f498
14 changed files with 7101 additions and 4405 deletions

View File

@@ -1,7 +1,7 @@
import 'package:equatable/equatable.dart';
/// Abstract base class for all user-related states.
///
///
/// This class extends [Equatable] to enable value equality for state comparison.
/// All user states in the application should inherit from this class.
abstract class UserState extends Equatable {
@@ -10,79 +10,82 @@ abstract class UserState extends Equatable {
}
/// Initial state of the user bloc.
///
///
/// This state represents the initial state before any user operations
/// have been performed or when the user has logged out.
class UserInitial extends UserState {}
/// State indicating that a user operation is in progress.
///
///
/// This state is used to show loading indicators during user data
/// operations like loading, updating, or initializing user information.
class UserLoading extends UserState {}
/// State indicating that user data has been successfully loaded.
///
///
/// This state contains the loaded user information and is used
/// throughout the app to access current user data.
class UserLoaded extends UserState {
/// The loaded user data.
final UserModel user;
/// Creates a [UserLoaded] state with the given [user] data.
UserLoaded(this.user);
@override
List<Object?> get props => [user];
}
/// State indicating that a user operation has failed.
///
///
/// This state contains an error message that can be displayed to the user
/// when user operations fail.
class UserError extends UserState {
/// The error message describing what went wrong.
final String message;
/// Creates a [UserError] state with the given error [message].
UserError(this.message);
@override
List<Object?> get props => [message];
}
/// Simple user model for representing user data in the application.
///
///
/// This model contains basic user information and provides methods for
/// serialization/deserialization with Firestore operations.
/// Simple user model for representing user data in the application.
///
///
/// This model contains basic user information and provides methods for
/// serialization/deserialization with Firestore operations.
class UserModel {
/// Unique identifier for the user (Firebase UID).
final String id;
/// User's email address.
final String email;
/// User's first name.
final String prenom;
/// User's last name (optional).
final String? nom;
/// Platform used for authentication (e.g., 'google', 'apple', 'email').
final String? authMethod;
/// User's phone number (optional).
final String? phoneNumber;
/// User's profile picture URL (optional).
final String? profilePictureUrl;
/// Firebase Cloud Messaging token for push notifications.
final String? fcmToken;
/// Creates a new [UserModel] instance.
///
///
/// [id], [email], and [prenom] are required fields.
/// [nom], [authMethod], [phoneNumber], and [profilePictureUrl] are optional and can be null.
UserModel({
@@ -93,10 +96,11 @@ class UserModel {
this.authMethod,
this.phoneNumber,
this.profilePictureUrl,
this.fcmToken,
});
/// Creates a [UserModel] instance from a JSON map.
///
///
/// Handles null values gracefully by providing default values.
/// [prenom] defaults to 'Voyageur' (Traveler) if not provided.
factory UserModel.fromJson(Map<String, dynamic> json) {
@@ -108,11 +112,12 @@ class UserModel {
authMethod: json['authMethod'] ?? json['platform'],
phoneNumber: json['phoneNumber'],
profilePictureUrl: json['profilePictureUrl'],
fcmToken: json['fcmToken'],
);
}
/// Converts the [UserModel] instance to a JSON map.
///
///
/// Useful for storing user data in Firestore or other JSON-based operations.
Map<String, dynamic> toJson() {
return {
@@ -123,6 +128,7 @@ class UserModel {
'authMethod': authMethod,
'phoneNumber': phoneNumber,
'profilePictureUrl': profilePictureUrl,
'fcmToken': fcmToken,
};
}
}