From d891d6fc531475b2b84d8072bf4536546fc3906e Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Mon, 23 Dec 2024 15:47:14 -0500 Subject: [PATCH] Add Followed Tags panel to Explorer Screen --- lib/screens/explore_screen.dart | 53 +++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/lib/screens/explore_screen.dart b/lib/screens/explore_screen.dart index 080b5f9..51bd1ca 100644 --- a/lib/screens/explore_screen.dart +++ b/lib/screens/explore_screen.dart @@ -18,6 +18,7 @@ import '../models/networking/paging_data.dart'; import '../models/timeline_entry.dart'; import '../riverpod_controllers/account_services.dart'; import '../riverpod_controllers/entry_tree_item_services.dart'; +import '../riverpod_controllers/hashtag_service.dart'; import '../riverpod_controllers/networking/friendica_trending_client_services.dart'; import '../routes.dart'; import '../utils/snackbar_builder.dart'; @@ -28,19 +29,24 @@ class ExploreScreen extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return DefaultTabController( - length: 2, + length: 3, child: Scaffold( drawer: const StandardAppDrawer(skipPopDismiss: false), appBar: AppBar( leading: const CurrentProfileButton(), title: const TabBar( - tabs: [Tab(icon: Icon(Icons.search)), Tab(icon: Icon(Icons.bolt))], + tabs: [ + Tab(icon: Icon(Icons.search)), + Tab(icon: Icon(Icons.bolt)), + Tab(icon: Icon(Icons.tag)), + ], ), ), body: SafeArea( child: TabBarView(children: [ const SearchPanel(), _TrendsPanel(), + const _FollowedTagsPanel(), ]), ), bottomNavigationBar: const AppBottomNavBar( @@ -259,3 +265,46 @@ class _TrendingStatusesWidget extends ConsumerWidget { }); } } + +class _FollowedTagsPanel extends ConsumerWidget { + const _FollowedTagsPanel(); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final profile = ref.watch(activeProfileProvider); + return SafeArea( + child: Column(children: [ + Text( + 'Followed Tags', + style: Theme.of(context).textTheme.headlineSmall, + ), + Expanded( + child: ResponsiveMaxWidth( + child: AsyncValueWidget( + ref.watch(followedTagsMapProvider(profile)), + valueBuilder: (vbContext, vbRef, result) => result.fold( + onSuccess: (followedTags) { + final tags = followedTags.keys.toList(); + return ListView.builder( + itemCount: tags.length, + itemBuilder: (_, index) { + final tag = tags[index]; + return ListTile( + title: Text('#$tag'), + onTap: () { + vbContext.push('${ScreenPaths.tagView}/$tag'); + }, + ); + }); + }, + onError: (error) => Center( + child: Column( + children: [ErrorMessageWidget(message: error.message)], + ), + ), + ), + )), + ), + ])); + } +}