From d62ed4c37521d6948c6d951015f770deab12a11a Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 8 Mar 2025 22:40:17 +0800 Subject: [PATCH] :wheelchair: Adjust explore categorized mode --- lib/screens/explore.dart | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index 343d4c8..542810e 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -91,8 +91,12 @@ class _ExploreScreenState extends State _showCategories = !_showCategories; if (_showCategories) { _tabController = TabController(length: _categories.length, vsync: this); + _listKey.currentState?.setCategory(_categories[_tabController.index]); + _listKey.currentState?.refreshPosts(); } else { _tabController = TabController(length: kPostChannels.length, vsync: this); + _listKey.currentState?.setCategory(null); + _listKey.currentState?.refreshPosts(); } _tabListen(); setState(() {}); @@ -226,7 +230,7 @@ class _ExploreScreenState extends State icon: _listKey.currentState?.realm != null ? AccountImage( content: _listKey.currentState!.realm!.avatar, - radius: 14, + radius: 18, ) : const Icon(Symbols.group), onPressed: () { @@ -248,6 +252,24 @@ class _ExploreScreenState extends State ); }, ), + IconButton( + icon: const Icon(Symbols.category), + style: _showCategories + ? ButtonStyle( + foregroundColor: WidgetStateProperty.all( + Theme.of(context).colorScheme.primary, + ), + backgroundColor: MaterialStateProperty.all( + Theme.of(context) + .colorScheme + .secondaryContainer, + ), + ) + : null, + onPressed: () { + _toggleShowCategories(); + }, + ), Expanded( child: Center( child: Text('screenExplore').tr(), @@ -258,22 +280,6 @@ class _ExploreScreenState extends State floating: true, snap: true, actions: [ - IconButton( - icon: const Icon(Symbols.category), - style: _showCategories - ? ButtonStyle( - foregroundColor: WidgetStateProperty.all( - Theme.of(context).colorScheme.primary, - ), - backgroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.secondaryContainer, - ), - ) - : null, - onPressed: () { - _toggleShowCategories(); - }, - ), IconButton( icon: const Icon(Symbols.search), onPressed: () {