@@ -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
- import 'package:ht_main/shared/widgets/widgets .dart' ;
8
+ import 'package:ht_main/shared/widgets/widgets .dart' ; // For common widgets
9
+ import 'package:ht_shared/ht_shared .dart' ;
10
10
11
11
/// {@template followed_sources_list_page}
12
- /// Displays a list of sources the user is currently following.
13
- /// Allows unfollowing and navigating to add more sources.
12
+ /// Page to display and manage sources followed by the user.
14
13
/// {@endtemplate}
15
14
class FollowedSourcesListPage extends StatelessWidget {
16
15
/// {@macro followed_sources_list_page}
@@ -19,14 +18,16 @@ class FollowedSourcesListPage extends StatelessWidget {
19
18
@override
20
19
Widget build (BuildContext context) {
21
20
final l10n = context.l10n;
21
+ final followedSources =
22
+ context.watch <AccountBloc >().state.preferences? .followedSources ?? [];
22
23
23
24
return Scaffold (
24
25
appBar: AppBar (
25
- title: Text (l10n.followedSourcesPageTitle),
26
+ title: const Text ('Followed Sources' ), // Placeholder
26
27
actions: [
27
28
IconButton (
28
29
icon: const Icon (Icons .add_circle_outline),
29
- tooltip: l10n.addSourcesTooltip,
30
+ tooltip: 'Add Source to Follow' , // Placeholder
30
31
onPressed: () {
31
32
context.goNamed (Routes .addSourceToFollowName);
32
33
},
@@ -35,87 +36,68 @@ class FollowedSourcesListPage extends StatelessWidget {
35
36
),
36
37
body: BlocBuilder <AccountBloc , AccountState >(
37
38
builder: (context, state) {
38
- if (state.status == AccountStatus .initial ||
39
- (state.status == AccountStatus .loading &&
40
- state.preferences == null )) {
41
- return const Center (child: CircularProgressIndicator ());
39
+ if (state.status == AccountStatus .loading &&
40
+ state.preferences == null ) {
41
+ return LoadingStateWidget (
42
+ icon: Icons .source_outlined,
43
+ headline: 'Loading Followed Sources...' , // Placeholder
44
+ subheadline: l10n.pleaseWait, // Assuming this exists
45
+ );
42
46
}
43
47
44
48
if (state.status == AccountStatus .failure &&
45
49
state.preferences == null ) {
46
50
return FailureStateWidget (
47
- message: state.errorMessage ?? l10n.unknownError,
51
+ message: state.errorMessage ?? 'Could not load followed sources.' , // Placeholder
48
52
onRetry: () {
49
53
if (state.user? .id != null ) {
50
54
context.read <AccountBloc >().add (
51
- AccountLoadContentPreferencesRequested (
52
- userId: state.user! .id,
53
- ),
54
- );
55
+ AccountLoadUserPreferences ( // Corrected event name
56
+ userId: state.user! .id,
57
+ ),
58
+ );
55
59
}
56
60
},
57
61
);
58
62
}
59
63
60
- final followedSources = state.preferences? .followedSources;
61
-
62
- if (followedSources == null || followedSources.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 .source_outlined, size: 48 ),
70
- const SizedBox (height: AppSpacing .md),
71
- Text (
72
- l10n.noFollowedSourcesMessage,
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.addSourcesButtonLabel),
80
- onPressed: () {
81
- context.goNamed (Routes .addSourceToFollowName);
82
- },
83
- ),
84
- ],
85
- ),
86
- ),
64
+ if (followedSources.isEmpty) {
65
+ return const InitialStateWidget (
66
+ icon: Icons .no_sim_outlined, // Placeholder icon
67
+ headline: 'No Followed Sources' , // Placeholder
68
+ subheadline: 'Start following sources to see them here.' , // Placeholder
87
69
);
88
70
}
89
71
90
72
return ListView .builder (
91
- padding: const EdgeInsets .all (AppSpacing .md),
92
73
itemCount: followedSources.length,
93
74
itemBuilder: (context, index) {
94
75
final source = followedSources[index];
95
- return Card (
96
- margin: const EdgeInsets .only (bottom: AppSpacing .sm),
97
- child: ListTile (
98
- title: Text (source.name),
99
- onTap: () {
100
- // Added onTap for navigation
101
- context.push (
102
- Routes .sourceDetails,
103
- extra: EntityDetailsPageArguments (entity: source),
104
- );
76
+ return ListTile (
77
+ leading: const Icon (Icons .source_outlined), // Generic icon
78
+ title: Text (source.name),
79
+ subtitle: source.description != null
80
+ ? Text (
81
+ source.description! ,
82
+ maxLines: 1 ,
83
+ overflow: TextOverflow .ellipsis,
84
+ )
85
+ : null ,
86
+ trailing: IconButton (
87
+ icon: const Icon (Icons .remove_circle_outline, color: Colors .red),
88
+ tooltip: 'Unfollow Source' , // Placeholder
89
+ onPressed: () {
90
+ context.read <AccountBloc >().add (
91
+ AccountFollowSourceToggled (source: source),
92
+ );
105
93
},
106
- trailing: IconButton (
107
- icon: Icon (
108
- Icons .remove_circle_outline,
109
- color: Theme .of (context).colorScheme.error,
110
- ),
111
- tooltip: l10n.unfollowSourceTooltip (source.name),
112
- onPressed: () {
113
- context.read <AccountBloc >().add (
114
- AccountFollowSourceToggled (source: source),
115
- );
116
- },
117
- ),
118
94
),
95
+ onTap: () {
96
+ context.push (
97
+ Routes .sourceDetails, // Navigate to source details
98
+ extra: EntityDetailsPageArguments (entity: source),
99
+ );
100
+ },
119
101
);
120
102
},
121
103
);
0 commit comments