Skip to content

Commit e132ef6

Browse files
authored
Merge pull request #51 from headlines-toolkit/fix_feed_setting_not_applied
Fix_feed_setting_not_applied
2 parents d1300c8 + fe99f08 commit e132ef6

40 files changed

+1005
-1124
lines changed

lib/account/bloc/account_state.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ class AccountState extends Equatable {
2828
status: status ?? this.status,
2929
user: clearUser ? null : user ?? this.user,
3030
preferences: clearPreferences ? null : preferences ?? this.preferences,
31-
errorMessage:
32-
clearErrorMessage ? null : errorMessage ?? this.errorMessage,
31+
errorMessage: clearErrorMessage
32+
? null
33+
: errorMessage ?? this.errorMessage,
3334
);
3435
}
3536

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

Lines changed: 68 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ class AddCategoryToFollowPage extends StatelessWidget {
2222
final textTheme = theme.textTheme; // Get textTheme
2323

2424
return BlocProvider(
25-
create:
26-
(context) => CategoriesFilterBloc(
27-
categoriesRepository: context.read<HtDataRepository<Category>>(),
28-
)..add(CategoriesFilterRequested()),
25+
create: (context) => CategoriesFilterBloc(
26+
categoriesRepository: context.read<HtDataRepository<Category>>(),
27+
)..add(CategoriesFilterRequested()),
2928
child: Scaffold(
3029
appBar: AppBar(
3130
title: Text(
@@ -56,10 +55,9 @@ class AddCategoryToFollowPage extends StatelessWidget {
5655
}
5756
return FailureStateWidget(
5857
message: errorMessage,
59-
onRetry:
60-
() => context.read<CategoriesFilterBloc>().add(
61-
CategoriesFilterRequested(),
62-
),
58+
onRetry: () => context.read<CategoriesFilterBloc>().add(
59+
CategoriesFilterRequested(),
60+
),
6361
);
6462
}
6563
if (categoriesState.categories.isEmpty &&
@@ -79,23 +77,23 @@ class AddCategoryToFollowPage extends StatelessWidget {
7977
categoriesState.status == CategoriesFilterStatus.loadingMore;
8078

8179
return BlocBuilder<AccountBloc, AccountState>(
82-
buildWhen:
83-
(previous, current) =>
84-
previous.preferences?.followedCategories !=
85-
current.preferences?.followedCategories ||
86-
previous.status != current.status,
80+
buildWhen: (previous, current) =>
81+
previous.preferences?.followedCategories !=
82+
current.preferences?.followedCategories ||
83+
previous.status != current.status,
8784
builder: (context, accountState) {
8885
final followedCategories =
8986
accountState.preferences?.followedCategories ?? [];
9087

9188
return ListView.builder(
92-
padding: const EdgeInsets.symmetric(
93-
// Consistent padding
94-
horizontal: AppSpacing.paddingMedium,
95-
vertical: AppSpacing.paddingSmall,
96-
).copyWith(
97-
bottom: AppSpacing.xxl,
98-
), // Ensure bottom space for loader
89+
padding:
90+
const EdgeInsets.symmetric(
91+
// Consistent padding
92+
horizontal: AppSpacing.paddingMedium,
93+
vertical: AppSpacing.paddingSmall,
94+
).copyWith(
95+
bottom: AppSpacing.xxl,
96+
), // Ensure bottom space for loader
9997
itemCount: categories.length + (isLoadingMore ? 1 : 0),
10098
itemBuilder: (context, index) {
10199
if (index == categories.length && isLoadingMore) {
@@ -130,73 +128,66 @@ class AddCategoryToFollowPage extends StatelessWidget {
130128
height: AppSpacing.xl + AppSpacing.xs,
131129
child:
132130
category.iconUrl != null &&
133-
Uri.tryParse(
134-
category.iconUrl!,
135-
)?.isAbsolute ==
136-
true
137-
? ClipRRect(
138-
borderRadius: BorderRadius.circular(
139-
AppSpacing.xs,
140-
),
141-
child: Image.network(
142-
category.iconUrl!,
143-
fit: BoxFit.contain,
144-
errorBuilder:
145-
(context, error, stackTrace) => Icon(
146-
Icons.category_outlined,
147-
color: colorScheme.onSurfaceVariant,
148-
size: AppSpacing.lg,
149-
),
150-
loadingBuilder: (
151-
context,
152-
child,
153-
loadingProgress,
154-
) {
155-
if (loadingProgress == null) {
156-
return child;
157-
}
158-
return Center(
159-
child: CircularProgressIndicator(
160-
strokeWidth: 2,
161-
value:
162-
loadingProgress
163-
.expectedTotalBytes !=
164-
null
165-
? loadingProgress
131+
Uri.tryParse(category.iconUrl!)?.isAbsolute ==
132+
true
133+
? ClipRRect(
134+
borderRadius: BorderRadius.circular(
135+
AppSpacing.xs,
136+
),
137+
child: Image.network(
138+
category.iconUrl!,
139+
fit: BoxFit.contain,
140+
errorBuilder:
141+
(context, error, stackTrace) => Icon(
142+
Icons.category_outlined,
143+
color: colorScheme.onSurfaceVariant,
144+
size: AppSpacing.lg,
145+
),
146+
loadingBuilder:
147+
(context, child, loadingProgress) {
148+
if (loadingProgress == null) {
149+
return child;
150+
}
151+
return Center(
152+
child: CircularProgressIndicator(
153+
strokeWidth: 2,
154+
value:
155+
loadingProgress
156+
.expectedTotalBytes !=
157+
null
158+
? loadingProgress
166159
.cumulativeBytesLoaded /
167160
loadingProgress
168161
.expectedTotalBytes!
169-
: null,
170-
),
171-
);
172-
},
173-
),
174-
)
175-
: Icon(
176-
Icons.category_outlined,
177-
color: colorScheme.onSurfaceVariant,
178-
size: AppSpacing.lg,
162+
: null,
163+
),
164+
);
165+
},
179166
),
167+
)
168+
: Icon(
169+
Icons.category_outlined,
170+
color: colorScheme.onSurfaceVariant,
171+
size: AppSpacing.lg,
172+
),
180173
),
181174
title: Text(
182175
category.name,
183176
style: textTheme.titleMedium,
184177
),
185178
trailing: IconButton(
186-
icon:
187-
isFollowed
188-
? Icon(
189-
Icons.check_circle,
190-
color: colorScheme.primary,
191-
)
192-
: Icon(
193-
Icons.add_circle_outline,
194-
color: colorScheme.onSurfaceVariant,
195-
),
196-
tooltip:
197-
isFollowed
198-
? l10n.unfollowCategoryTooltip(category.name)
199-
: l10n.followCategoryTooltip(category.name),
179+
icon: isFollowed
180+
? Icon(
181+
Icons.check_circle,
182+
color: colorScheme.primary,
183+
)
184+
: Icon(
185+
Icons.add_circle_outline,
186+
color: colorScheme.onSurfaceVariant,
187+
),
188+
tooltip: isFollowed
189+
? l10n.unfollowCategoryTooltip(category.name)
190+
: l10n.followCategoryTooltip(category.name),
200191
onPressed: () {
201192
context.read<AccountBloc>().add(
202193
AccountFollowCategoryToggled(category: category),

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

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,25 @@ class FollowedCategoriesListPage extends StatelessWidget {
7575
itemBuilder: (context, index) {
7676
final category = followedCategories[index];
7777
return ListTile(
78-
leading:
79-
category.iconUrl != null
80-
? SizedBox(
81-
width: 40,
82-
height: 40,
83-
child: Image.network(
84-
category.iconUrl!,
85-
errorBuilder:
86-
(context, error, stackTrace) =>
87-
const Icon(Icons.category_outlined),
88-
),
89-
)
90-
: const Icon(Icons.category_outlined),
78+
leading: category.iconUrl != null
79+
? SizedBox(
80+
width: 40,
81+
height: 40,
82+
child: Image.network(
83+
category.iconUrl!,
84+
errorBuilder: (context, error, stackTrace) =>
85+
const Icon(Icons.category_outlined),
86+
),
87+
)
88+
: const Icon(Icons.category_outlined),
9189
title: Text(category.name),
92-
subtitle:
93-
category.description != null
94-
? Text(
95-
category.description!,
96-
maxLines: 1,
97-
overflow: TextOverflow.ellipsis,
98-
)
99-
: null,
90+
subtitle: category.description != null
91+
? Text(
92+
category.description!,
93+
maxLines: 1,
94+
overflow: TextOverflow.ellipsis,
95+
)
96+
: null,
10097
trailing: IconButton(
10198
icon: const Icon(
10299
Icons.remove_circle_outline,

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

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ class AddSourceToFollowPage extends StatelessWidget {
1919
Widget build(BuildContext context) {
2020
final l10n = context.l10n;
2121
return BlocProvider(
22-
create:
23-
(context) => SourcesFilterBloc(
24-
sourcesRepository: context.read<HtDataRepository<Source>>(),
25-
countriesRepository: context.read<HtDataRepository<Country>>(),
26-
)..add(const LoadSourceFilterData()),
22+
create: (context) => SourcesFilterBloc(
23+
sourcesRepository: context.read<HtDataRepository<Source>>(),
24+
countriesRepository: context.read<HtDataRepository<Country>>(),
25+
)..add(const LoadSourceFilterData()),
2726
child: Scaffold(
2827
appBar: AppBar(title: Text(l10n.addSourcesPageTitle)),
2928
body: BlocBuilder<SourcesFilterBloc, SourcesFilterState>(
@@ -38,10 +37,9 @@ class AddSourceToFollowPage extends StatelessWidget {
3837
SourceFilterDataLoadingStatus.failure) {
3938
return FailureStateWidget(
4039
message: sourcesState.errorMessage ?? l10n.sourceFilterError,
41-
onRetry:
42-
() => context.read<SourcesFilterBloc>().add(
43-
const LoadSourceFilterData(),
44-
),
40+
onRetry: () => context.read<SourcesFilterBloc>().add(
41+
const LoadSourceFilterData(),
42+
),
4543
);
4644
}
4745
if (sourcesState.allAvailableSources.isEmpty) {
@@ -51,11 +49,10 @@ class AddSourceToFollowPage extends StatelessWidget {
5149
}
5250

5351
return BlocBuilder<AccountBloc, AccountState>(
54-
buildWhen:
55-
(previous, current) =>
56-
previous.preferences?.followedSources !=
57-
current.preferences?.followedSources ||
58-
previous.status != current.status,
52+
buildWhen: (previous, current) =>
53+
previous.preferences?.followedSources !=
54+
current.preferences?.followedSources ||
55+
previous.status != current.status,
5956
builder: (context, accountState) {
6057
final followedSources =
6158
accountState.preferences?.followedSources ?? [];
@@ -74,18 +71,15 @@ class AddSourceToFollowPage extends StatelessWidget {
7471
child: ListTile(
7572
title: Text(source.name),
7673
trailing: IconButton(
77-
icon:
78-
isFollowed
79-
? Icon(
80-
Icons.check_circle,
81-
color:
82-
Theme.of(context).colorScheme.primary,
83-
)
84-
: const Icon(Icons.add_circle_outline),
85-
tooltip:
86-
isFollowed
87-
? l10n.unfollowSourceTooltip(source.name)
88-
: l10n.followSourceTooltip(source.name),
74+
icon: isFollowed
75+
? Icon(
76+
Icons.check_circle,
77+
color: Theme.of(context).colorScheme.primary,
78+
)
79+
: const Icon(Icons.add_circle_outline),
80+
tooltip: isFollowed
81+
? l10n.unfollowSourceTooltip(source.name)
82+
: l10n.followSourceTooltip(source.name),
8983
onPressed: () {
9084
context.read<AccountBloc>().add(
9185
AccountFollowSourceToggled(source: source),

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,13 @@ class FollowedSourcesListPage extends StatelessWidget {
7979
return ListTile(
8080
leading: const Icon(Icons.source_outlined), // Generic icon
8181
title: Text(source.name),
82-
subtitle:
83-
source.description != null
84-
? Text(
85-
source.description!,
86-
maxLines: 1,
87-
overflow: TextOverflow.ellipsis,
88-
)
89-
: null,
82+
subtitle: source.description != null
83+
? Text(
84+
source.description!,
85+
maxLines: 1,
86+
overflow: TextOverflow.ellipsis,
87+
)
88+
: null,
9089
trailing: IconButton(
9190
icon: const Icon(
9291
Icons.remove_circle_outline,

0 commit comments

Comments
 (0)