From 8c19c32c76fc9ed7f3432db4eddcb4a101c21afe Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 2 Nov 2025 23:36:42 +0800 Subject: [PATCH] :sparkles: Publisher profile collapsible pinned post --- assets/i18n/en-US.json | 3 +- lib/screens/posts/publisher_profile.dart | 57 +++++++++++++++++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/assets/i18n/en-US.json b/assets/i18n/en-US.json index a0d48712..e0674dcb 100644 --- a/assets/i18n/en-US.json +++ b/assets/i18n/en-US.json @@ -1318,5 +1318,6 @@ "toDate": "To Date", "popularity": "Popularity", "descendingOrder": "Descending Order", - "selectDate": "Select Date" + "selectDate": "Select Date", + "pinnedPosts": "Pinned Posts" } diff --git a/lib/screens/posts/publisher_profile.dart b/lib/screens/posts/publisher_profile.dart index ed73a34f..651c0a26 100644 --- a/lib/screens/posts/publisher_profile.dart +++ b/lib/screens/posts/publisher_profile.dart @@ -676,6 +676,7 @@ class PublisherProfileScreen extends HookConsumerWidget { final periodEnd = useState(null); final showAdvancedFilters = useState(false); final subscribing = useState(false); + final isPinnedExpanded = useState(true); Future subscribe() async { final apiClient = ref.watch(apiClientProvider); @@ -746,7 +747,36 @@ class PublisherProfileScreen extends HookConsumerWidget { child: CustomScrollView( slivers: [ SliverGap(16), - SliverPostList(pubName: name, pinned: true), + SliverToBoxAdapter( + child: Card( + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: ListTile( + title: Text('pinnedPosts'.tr()), + leading: const Icon(Symbols.push_pin), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(8), + ), + ), + trailing: Icon( + isPinnedExpanded.value + ? Symbols.expand_less + : Symbols.expand_more, + ), + onTap: + () => + isPinnedExpanded.value = + !isPinnedExpanded.value, + ), + ), + ), + ...[ + if (isPinnedExpanded.value) + SliverPostList(pubName: name, pinned: true), + ], SliverToBoxAdapter( child: _PublisherCategoryTabWidget( categoryTabController: categoryTabController, @@ -885,7 +915,30 @@ class PublisherProfileScreen extends HookConsumerWidget { heatmap: heatmap, ).padding(vertical: 4), ), - SliverPostList(pubName: name, pinned: true), + SliverToBoxAdapter( + child: Card( + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: ListTile( + title: Text('pinnedPosts'.tr()), + trailing: Icon( + isPinnedExpanded.value + ? Symbols.expand_less + : Symbols.expand_more, + ), + onTap: + () => + isPinnedExpanded.value = + !isPinnedExpanded.value, + ), + ), + ), + ...[ + if (isPinnedExpanded.value) + SliverPostList(pubName: name, pinned: true), + ], SliverToBoxAdapter( child: _PublisherCategoryTabWidget( categoryTabController: categoryTabController,