Skip to content

Commit 374cf49

Browse files
committed
refactor(app_state): update AppState to use AppSettings model
This commit modifies the `AppState` to hold an `AppSettings` object instead of `UserAppSettings`, aligning with the core package model changes. The `copyWith` method and `props` list are updated accordingly.
1 parent f0d3b14 commit 374cf49

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

lib/app/bloc/app_state.dart

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,46 @@
11
part of 'app_bloc.dart';
22

3-
/// Represents the application's authentication status.
43
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.
66
initial,
77

8-
/// The user is authenticated.
8+
/// The user is authenticated and has a valid session.
99
authenticated,
1010

11-
/// The user is unauthenticated.
11+
/// The user is unauthenticated, meaning they are not logged in.
1212
unauthenticated,
1313

14-
/// The user is anonymous (signed in using an anonymous provider).
14+
/// The user is authenticated anonymously.
1515
anonymous,
1616
}
1717

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 {
2419
const AppState({
25-
this.status = AppStatus.initial,
20+
required this.environment, this.status = AppStatus.initial,
2621
this.user,
27-
this.environment,
2822
this.appSettings,
2923
});
3024

31-
/// The current authentication status of the application.
3225
final AppStatus status;
33-
34-
/// The current user details. Null if unauthenticated.
3526
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.
4127
final AppSettings? appSettings;
28+
final local_config.AppEnvironment environment;
4229

43-
/// Creates a copy of the current state with updated values.
4430
AppState copyWith({
4531
AppStatus? status,
4632
User? user,
47-
local_config.AppEnvironment? environment,
4833
AppSettings? appSettings,
49-
bool clearEnvironment = false,
5034
bool clearAppSettings = false,
5135
}) {
5236
return AppState(
5337
status: status ?? this.status,
5438
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,
6041
);
6142
}
6243

6344
@override
64-
List<Object?> get props => [
65-
status,
66-
user,
67-
environment,
68-
appSettings,
69-
];
45+
List<Object?> get props => [status, user, appSettings, environment];
7046
}

0 commit comments

Comments
 (0)