Add Followed Tags panel to Explorer Screen

merge-requests/67/head
Hank Grabowski 2024-12-23 15:47:14 -05:00
rodzic 2743648b40
commit d891d6fc53
1 zmienionych plików z 51 dodań i 2 usunięć

Wyświetl plik

@ -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)],
),
),
),
)),
),
]));
}
}