Skip to content

Commit 75b1e4a

Browse files
committed
docs: add UserAppSettings model description
- Added UserAppSettings description
1 parent b351208 commit 75b1e4a

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This package provides the following core data models:
2727
* **`Category`**: Represents a news category with an ID, name, and optional description and icon URL.
2828
* **`Source`**: Represents a news source, including ID, name, description, URL, language, optional headquarters (`Country`), and a `SourceType` enum (e.g., `newsAgency`, `blog`).
2929
* **`Country`**: Represents a country with an ID, ISO code, name, and flag URL.
30+
* **`UserAppSettings`**: Represents a collection of user-specific application settings, unifying display preferences (`DisplaySettings`) and language selection (`AppLanguage`). This model is designed for management via a generic data client (`HtDataClient`).
3031
* **`User`**: Represents a user within the system, including their assigned `role`.
3132
* **`PaginatedResponse<T>`**: A generic class for handling paginated API responses, containing a list of items (`items`), a `cursor` for the next page, and a `hasMore` flag.
3233
* **`AuthSuccessResponse`**: Represents the successful result of an authentication operation, typically containing the authenticated user details and an access token.

lib/src/models/user-app-settings/user_app_settings.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class UserAppSettings extends Equatable {
2424
required this.id,
2525
DisplaySettings? displaySettings,
2626
AppLanguage? language,
27-
}) : displaySettings = displaySettings ?? const DisplaySettings(),
28-
language = language ?? 'en'; // Default language is English
27+
}) : displaySettings = displaySettings ?? const DisplaySettings(),
28+
language = language ?? 'en'; // Default language is English
2929

3030
/// Factory method to create a [UserAppSettings] instance from a JSON map.
3131
factory UserAppSettings.fromJson(Map<String, dynamic> json) =>
@@ -44,11 +44,7 @@ class UserAppSettings extends Equatable {
4444
Map<String, dynamic> toJson() => _$UserAppSettingsToJson(this);
4545

4646
@override
47-
List<Object?> get props => [
48-
id,
49-
displaySettings,
50-
language,
51-
];
47+
List<Object?> get props => [id, displaySettings, language];
5248

5349
/// Creates a copy of this [UserAppSettings] but with the given fields
5450
/// replaced with the new values.

test/src/models/user-app-settings/user_app_settings_test.dart

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ void main() {
3838
expect(
3939
createSubject(
4040
id: userId,
41-
displaySettings: const DisplaySettings(
42-
baseTheme: AppBaseTheme.dark,
43-
),
41+
displaySettings: const DisplaySettings(baseTheme: AppBaseTheme.dark),
4442
language: 'fr',
4543
),
4644
equals(
@@ -66,11 +64,7 @@ void main() {
6664
displaySettings: customDisplaySettings,
6765
language: customLanguage,
6866
).props,
69-
equals([
70-
userId,
71-
customDisplaySettings,
72-
customLanguage,
73-
]),
67+
equals([userId, customDisplaySettings, customLanguage]),
7468
);
7569
});
7670

@@ -90,9 +84,7 @@ void main() {
9084
test('retains old values if null is provided', () {
9185
final original = createSubject(
9286
id: userId,
93-
displaySettings: const DisplaySettings(
94-
baseTheme: AppBaseTheme.dark,
95-
),
87+
displaySettings: const DisplaySettings(baseTheme: AppBaseTheme.dark),
9688
language: 'fr',
9789
);
9890
expect(original.copyWith(), equals(original));
@@ -126,7 +118,10 @@ void main() {
126118
group('fromJson/toJson', () {
127119
test('works correctly with default nested values', () {
128120
final json = createJson(id: userId);
129-
expect(UserAppSettings.fromJson(json), equals(createSubject(id: userId)));
121+
expect(
122+
UserAppSettings.fromJson(json),
123+
equals(createSubject(id: userId)),
124+
);
130125
});
131126

132127
test('works correctly with custom nested values', () {

0 commit comments

Comments
 (0)