Skip to content

Commit 7864a19

Browse files
committed
style: misc
1 parent 3da1508 commit 7864a19

File tree

10 files changed

+292
-219
lines changed

10 files changed

+292
-219
lines changed

lib/account/view/manage_followed_items/categories/followed_categories_list_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ class FollowedCategoriesListPage extends StatelessWidget {
112112
)
113113
: const Icon(Icons.category_outlined),
114114
title: Text(category.name),
115-
onTap: () { // Added onTap for navigation
115+
onTap: () {
116+
// Added onTap for navigation
116117
context.push(
117118
Routes.categoryDetails,
118119
extra: EntityDetailsPageArguments(entity: category),

lib/account/view/manage_followed_items/sources/followed_sources_list_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class FollowedSourcesListPage extends StatelessWidget {
9696
margin: const EdgeInsets.only(bottom: AppSpacing.sm),
9797
child: ListTile(
9898
title: Text(source.name),
99-
onTap: () { // Added onTap for navigation
99+
onTap: () {
100+
// Added onTap for navigation
100101
context.push(
101102
Routes.sourceDetails,
102103
extra: EntityDetailsPageArguments(entity: source),

lib/entity_details/bloc/entity_details_bloc.dart

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
1616
required HtDataRepository<Category> categoryRepository,
1717
required HtDataRepository<Source> sourceRepository,
1818
required AccountBloc accountBloc, // Changed to AccountBloc
19-
}) : _headlinesRepository = headlinesRepository,
20-
_categoryRepository = categoryRepository,
21-
_sourceRepository = sourceRepository,
22-
_accountBloc = accountBloc,
23-
super(const EntityDetailsState()) {
19+
}) : _headlinesRepository = headlinesRepository,
20+
_categoryRepository = categoryRepository,
21+
_sourceRepository = sourceRepository,
22+
_accountBloc = accountBloc,
23+
super(const EntityDetailsState()) {
2424
on<EntityDetailsLoadRequested>(_onEntityDetailsLoadRequested);
25-
on<EntityDetailsToggleFollowRequested>(_onEntityDetailsToggleFollowRequested);
25+
on<EntityDetailsToggleFollowRequested>(
26+
_onEntityDetailsToggleFollowRequested,
27+
);
2628
on<EntityDetailsLoadMoreHeadlinesRequested>(
2729
_onEntityDetailsLoadMoreHeadlinesRequested,
2830
);
@@ -50,7 +52,9 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
5052
EntityDetailsLoadRequested event,
5153
Emitter<EntityDetailsState> emit,
5254
) async {
53-
emit(state.copyWith(status: EntityDetailsStatus.loading, clearEntity: true));
55+
emit(
56+
state.copyWith(status: EntityDetailsStatus.loading, clearEntity: true),
57+
);
5458

5559
dynamic entityToLoad = event.entity;
5660
EntityType? entityTypeToLoad = event.entityType;
@@ -62,8 +66,7 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
6266
event.entityType != null) {
6367
entityTypeToLoad = event.entityType; // Ensure type is set
6468
if (event.entityType == EntityType.category) {
65-
entityToLoad =
66-
await _categoryRepository.read(id: event.entityId!);
69+
entityToLoad = await _categoryRepository.read(id: event.entityId!);
6770
} else if (event.entityType == EntityType.source) {
6871
entityToLoad = await _sourceRepository.read(id: event.entityId!);
6972
} else {
@@ -109,11 +112,15 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
109112
if (currentAccountState.preferences != null) {
110113
if (entityTypeToLoad == EntityType.category &&
111114
entityToLoad is Category) {
112-
isCurrentlyFollowing = currentAccountState.preferences!.followedCategories
115+
isCurrentlyFollowing = currentAccountState
116+
.preferences!
117+
.followedCategories
113118
.any((cat) => cat.id == entityToLoad.id);
114119
} else if (entityTypeToLoad == EntityType.source &&
115-
entityToLoad is Source) {
116-
isCurrentlyFollowing = currentAccountState.preferences!.followedSources
120+
entityToLoad is Source) {
121+
isCurrentlyFollowing = currentAccountState
122+
.preferences!
123+
.followedSources
117124
.any((src) => src.id == entityToLoad.id);
118125
}
119126
}
@@ -173,7 +180,7 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
173180
AccountFollowCategoryToggled(category: state.entity as Category),
174181
);
175182
} else if (state.entityType == EntityType.source &&
176-
state.entity is Source) {
183+
state.entity is Source) {
177184
_accountBloc.add(
178185
AccountFollowSourceToggled(source: state.entity as Source),
179186
);
@@ -264,13 +271,15 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
264271

265272
if (state.entityType == EntityType.category && state.entity is Category) {
266273
final currentCategory = state.entity as Category;
267-
isCurrentlyFollowing = preferences.followedCategories
268-
.any((cat) => cat.id == currentCategory.id);
274+
isCurrentlyFollowing = preferences.followedCategories.any(
275+
(cat) => cat.id == currentCategory.id,
276+
);
269277
} else if (state.entityType == EntityType.source &&
270-
state.entity is Source) {
278+
state.entity is Source) {
271279
final currentSource = state.entity as Source;
272-
isCurrentlyFollowing = preferences.followedSources
273-
.any((src) => src.id == currentSource.id);
280+
isCurrentlyFollowing = preferences.followedSources.any(
281+
(src) => src.id == currentSource.id,
282+
);
274283
}
275284

276285
if (state.isFollowing != isCurrentlyFollowing) {

lib/entity_details/bloc/entity_details_event.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class EntityDetailsLoadRequested extends EntityDetailsEvent {
1515
this.entityType,
1616
this.entity,
1717
}) : assert(
18-
(entityId != null && entityType != null) || entity != null,
19-
'Either entityId/entityType or entity must be provided.',
20-
);
18+
(entityId != null && entityType != null) || entity != null,
19+
'Either entityId/entityType or entity must be provided.',
20+
);
2121

2222
final String? entityId;
2323
final EntityType? entityType;

lib/entity_details/bloc/entity_details_state.dart

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
part of 'entity_details_bloc.dart';
22

33
/// Status for the overall entity details page.
4-
enum EntityDetailsStatus {
5-
initial,
6-
loading,
7-
success,
8-
failure,
9-
}
4+
enum EntityDetailsStatus { initial, loading, success, failure }
105

116
/// Status for fetching headlines within the entity details page.
12-
enum EntityHeadlinesStatus {
13-
initial,
14-
loadingMore,
15-
success,
16-
failure,
17-
}
7+
enum EntityHeadlinesStatus { initial, loadingMore, success, failure }
188

199
class EntityDetailsState extends Equatable {
2010
const EntityDetailsState({
@@ -61,24 +51,23 @@ class EntityDetailsState extends Equatable {
6151
headlines: headlines ?? this.headlines,
6252
headlinesStatus: headlinesStatus ?? this.headlinesStatus,
6353
hasMoreHeadlines: hasMoreHeadlines ?? this.hasMoreHeadlines,
64-
headlinesCursor: clearHeadlinesCursor
65-
? null
66-
: headlinesCursor ?? this.headlinesCursor,
54+
headlinesCursor:
55+
clearHeadlinesCursor ? null : headlinesCursor ?? this.headlinesCursor,
6756
errorMessage:
6857
clearErrorMessage ? null : errorMessage ?? this.errorMessage,
6958
);
7059
}
7160

7261
@override
7362
List<Object?> get props => [
74-
status,
75-
entityType,
76-
entity,
77-
isFollowing,
78-
headlines,
79-
headlinesStatus,
80-
hasMoreHeadlines,
81-
headlinesCursor,
82-
errorMessage,
83-
];
63+
status,
64+
entityType,
65+
entity,
66+
isFollowing,
67+
headlines,
68+
headlinesStatus,
69+
hasMoreHeadlines,
70+
headlinesCursor,
71+
errorMessage,
72+
];
8473
}

0 commit comments

Comments
 (0)