@@ -2,15 +2,14 @@ import 'package:flutter/material.dart';
2
2
import 'package:flutter_bloc/flutter_bloc.dart' ;
3
3
import 'package:go_router/go_router.dart' ;
4
4
import 'package:ht_main/account/bloc/account_bloc.dart' ;
5
- import 'package:ht_main/entity_details/view/entity_details_page.dart' ; // Added
5
+ import 'package:ht_main/entity_details/view/entity_details_page.dart' ; // Import for Arguments
6
6
import 'package:ht_main/l10n/l10n.dart' ;
7
7
import 'package:ht_main/router/routes.dart' ;
8
- import 'package:ht_main/shared/constants/app_spacing.dart' ;
9
8
import 'package:ht_main/shared/widgets/widgets.dart' ;
9
+ import 'package:ht_shared/ht_shared.dart' ;
10
10
11
11
/// {@template followed_categories_list_page}
12
- /// Displays a list of categories the user is currently following.
13
- /// Allows unfollowing and navigating to add more categories.
12
+ /// Page to display and manage categories followed by the user.
14
13
/// {@endtemplate}
15
14
class FollowedCategoriesListPage extends StatelessWidget {
16
15
/// {@macro followed_categories_list_page}
@@ -19,14 +18,17 @@ class FollowedCategoriesListPage extends StatelessWidget {
19
18
@override
20
19
Widget build (BuildContext context) {
21
20
final l10n = context.l10n;
21
+ final followedCategories =
22
+ context.watch <AccountBloc >().state.preferences? .followedCategories ??
23
+ [];
22
24
23
25
return Scaffold (
24
26
appBar: AppBar (
25
- title: Text (l10n.followedCategoriesPageTitle),
27
+ title: const Text ('Followed Categories' ), // Placeholder
26
28
actions: [
27
29
IconButton (
28
30
icon: const Icon (Icons .add_circle_outline),
29
- tooltip: l10n.addCategoriesTooltip,
31
+ tooltip: 'Add Category to Follow' , // Placeholder
30
32
onPressed: () {
31
33
context.goNamed (Routes .addCategoryToFollowName);
32
34
},
@@ -35,103 +37,78 @@ class FollowedCategoriesListPage extends StatelessWidget {
35
37
),
36
38
body: BlocBuilder <AccountBloc , AccountState >(
37
39
builder: (context, state) {
38
- if (state.status == AccountStatus .initial ||
39
- (state.status == AccountStatus .loading &&
40
- state.preferences == null )) {
41
- return const Center (child: CircularProgressIndicator ());
40
+ if (state.status == AccountStatus .loading &&
41
+ state.preferences == null ) {
42
+ return LoadingStateWidget (
43
+ icon: Icons .category_outlined,
44
+ headline: 'Loading Followed Categories...' , // Placeholder
45
+ subheadline: l10n.pleaseWait, // Assuming this exists
46
+ );
42
47
}
43
48
44
49
if (state.status == AccountStatus .failure &&
45
50
state.preferences == null ) {
46
51
return FailureStateWidget (
47
- message: state.errorMessage ?? l10n.unknownError,
52
+ message: state.errorMessage ?? 'Could not load followed categories.' , // Placeholder
48
53
onRetry: () {
49
54
if (state.user? .id != null ) {
50
55
context.read <AccountBloc >().add (
51
- AccountLoadContentPreferencesRequested (
52
- userId: state.user! .id,
53
- ),
54
- );
56
+ AccountLoadUserPreferences (
57
+ userId: state.user! .id,
58
+ ),
59
+ );
55
60
}
56
61
},
57
62
);
58
63
}
59
64
60
- final followedCategories = state.preferences? .followedCategories;
61
-
62
- if (followedCategories == null || followedCategories.isEmpty) {
63
- return Center (
64
- child: Padding (
65
- padding: const EdgeInsets .all (AppSpacing .lg),
66
- child: Column (
67
- mainAxisAlignment: MainAxisAlignment .center,
68
- children: [
69
- const Icon (Icons .category_outlined, size: 48 ),
70
- const SizedBox (height: AppSpacing .md),
71
- Text (
72
- l10n.noFollowedCategoriesMessage,
73
- style: Theme .of (context).textTheme.titleMedium,
74
- textAlign: TextAlign .center,
75
- ),
76
- const SizedBox (height: AppSpacing .lg),
77
- ElevatedButton .icon (
78
- icon: const Icon (Icons .add_circle_outline),
79
- label: Text (l10n.addCategoriesButtonLabel),
80
- onPressed: () {
81
- context.goNamed (Routes .addCategoryToFollowName);
82
- },
83
- ),
84
- ],
85
- ),
86
- ),
65
+ if (followedCategories.isEmpty) {
66
+ return const InitialStateWidget (
67
+ icon: Icons .no_sim_outlined, // Placeholder icon
68
+ headline: 'No Followed Categories' , // Placeholder
69
+ subheadline: 'Start following categories to see them here.' , // Placeholder
87
70
);
88
71
}
89
72
90
73
return ListView .builder (
91
- padding: const EdgeInsets .all (AppSpacing .md),
92
74
itemCount: followedCategories.length,
93
75
itemBuilder: (context, index) {
94
76
final category = followedCategories[index];
95
- return Card (
96
- margin: const EdgeInsets .only (bottom: AppSpacing .sm),
97
- child: ListTile (
98
- leading:
99
- category.iconUrl != null &&
100
- Uri .tryParse (category.iconUrl! )? .isAbsolute ==
101
- true
102
- ? SizedBox (
103
- width: 36 ,
104
- height: 36 ,
105
- child: Image .network (
106
- category.iconUrl! ,
107
- fit: BoxFit .contain,
108
- errorBuilder:
109
- (context, error, stackTrace) =>
110
- const Icon (Icons .category_outlined),
111
- ),
112
- )
113
- : const Icon (Icons .category_outlined),
114
- title: Text (category.name),
115
- onTap: () {
116
- // Added onTap for navigation
117
- context.push (
118
- Routes .categoryDetails,
119
- extra: EntityDetailsPageArguments (entity: category),
120
- );
77
+ return ListTile (
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),
89
+ title: Text (category.name),
90
+ subtitle: category.description != null
91
+ ? Text (
92
+ category.description! ,
93
+ maxLines: 1 ,
94
+ overflow: TextOverflow .ellipsis,
95
+ )
96
+ : null ,
97
+ trailing: IconButton (
98
+ icon: const Icon (Icons .remove_circle_outline, color: Colors .red),
99
+ tooltip: 'Unfollow Category' , // Placeholder
100
+ onPressed: () {
101
+ context.read <AccountBloc >().add (
102
+ AccountFollowCategoryToggled (category: category),
103
+ );
121
104
},
122
- trailing: IconButton (
123
- icon: Icon (
124
- Icons .remove_circle_outline,
125
- color: Theme .of (context).colorScheme.error,
126
- ),
127
- tooltip: l10n.unfollowCategoryTooltip (category.name),
128
- onPressed: () {
129
- context.read <AccountBloc >().add (
130
- AccountFollowCategoryToggled (category: category),
131
- );
132
- },
133
- ),
134
105
),
106
+ onTap: () {
107
+ context.push (
108
+ Routes .categoryDetails,
109
+ extra: EntityDetailsPageArguments (entity: category),
110
+ );
111
+ },
135
112
);
136
113
},
137
114
);
0 commit comments