|
1 | 1 | part of 'app_bloc.dart'; |
2 | 2 |
|
3 | | -/// Represents the application's authentication status. |
4 | 3 | enum AppStatus { |
5 | | - /// The application is initializing and the status is unknown. |
| 4 | + /// The app is in its initial state, typically before any authentication |
| 5 | + /// checks have been performed. |
6 | 6 | initial, |
7 | 7 |
|
8 | | - /// The user is authenticated. |
| 8 | + /// The user is authenticated and has a valid session. |
9 | 9 | authenticated, |
10 | 10 |
|
11 | | - /// The user is unauthenticated. |
| 11 | + /// The user is unauthenticated, meaning they are not logged in. |
12 | 12 | unauthenticated, |
13 | 13 |
|
14 | | - /// The user is anonymous (signed in using an anonymous provider). |
| 14 | + /// The user is authenticated anonymously. |
15 | 15 | anonymous, |
16 | 16 | } |
17 | 17 |
|
18 | | -/// {@template app_state} |
19 | | -/// Represents the overall state of the application, including authentication |
20 | | -/// status, current user, environment, and user-specific settings. |
21 | | -/// {@endtemplate} |
22 | | -class AppState extends Equatable { |
23 | | - /// {@macro app_state} |
| 18 | +final class AppState extends Equatable { |
24 | 19 | const AppState({ |
25 | | - this.status = AppStatus.initial, |
| 20 | + required this.environment, this.status = AppStatus.initial, |
26 | 21 | this.user, |
27 | | - this.environment, |
28 | 22 | this.appSettings, |
29 | 23 | }); |
30 | 24 |
|
31 | | - /// The current authentication status of the application. |
32 | 25 | final AppStatus status; |
33 | | - |
34 | | - /// The current user details. Null if unauthenticated. |
35 | 26 | final User? user; |
36 | | - |
37 | | - /// The current application environment (e.g., production, development, demo). |
38 | | - final local_config.AppEnvironment? environment; |
39 | | - |
40 | | - /// The current user application settings. Null if not loaded or unauthenticated. |
41 | 27 | final AppSettings? appSettings; |
| 28 | + final local_config.AppEnvironment environment; |
42 | 29 |
|
43 | | - /// Creates a copy of the current state with updated values. |
44 | 30 | AppState copyWith({ |
45 | 31 | AppStatus? status, |
46 | 32 | User? user, |
47 | | - local_config.AppEnvironment? environment, |
48 | 33 | AppSettings? appSettings, |
49 | | - bool clearEnvironment = false, |
50 | 34 | bool clearAppSettings = false, |
51 | 35 | }) { |
52 | 36 | return AppState( |
53 | 37 | status: status ?? this.status, |
54 | 38 | user: user ?? this.user, |
55 | | - environment: clearEnvironment ? null : environment ?? this.environment, |
56 | | - appSettings: |
57 | | - clearAppSettings // Corrected property name |
58 | | - ? null |
59 | | - : appSettings ?? this.appSettings, |
| 39 | + appSettings: clearAppSettings ? null : appSettings ?? this.appSettings, |
| 40 | + environment: environment, |
60 | 41 | ); |
61 | 42 | } |
62 | 43 |
|
63 | 44 | @override |
64 | | - List<Object?> get props => [ |
65 | | - status, |
66 | | - user, |
67 | | - environment, |
68 | | - appSettings, |
69 | | - ]; |
| 45 | + List<Object?> get props => [status, user, appSettings, environment]; |
70 | 46 | } |
0 commit comments