From 709a0620b60096c659c724a23fcd0d22f3e23fbf Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 25 Aug 2025 17:09:24 +0800 Subject: [PATCH] :sparkles: Show pinned posts on realms, publishers --- lib/screens/posts/pub_profile.dart | 3 ++ lib/screens/realm/realm_detail.dart | 8 +++-- lib/widgets/post/post_list.dart | 8 ++--- lib/widgets/post/post_list.g.dart | 48 ++++++++++++++--------------- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/lib/screens/posts/pub_profile.dart b/lib/screens/posts/pub_profile.dart index dbc77075..7e42a8a6 100644 --- a/lib/screens/posts/pub_profile.dart +++ b/lib/screens/posts/pub_profile.dart @@ -356,6 +356,7 @@ class PublisherProfileScreen extends HookConsumerWidget { SliverPostList( key: ValueKey(categoryTab.value), pubName: name, + pinned: false, type: switch (categoryTab.value) { 1 => 0, 2 => 1, @@ -438,10 +439,12 @@ class PublisherProfileScreen extends HookConsumerWidget { child: publisherVerificationWidget(data), ), SliverToBoxAdapter(child: publisherBioWidget(data)), + SliverPostList(pubName: name, pinned: true), SliverToBoxAdapter(child: publisherCategoryTabWidget()), SliverPostList( key: ValueKey(categoryTab.value), pubName: name, + pinned: false, type: switch (categoryTab.value) { 1 => 0, 2 => 1, diff --git a/lib/screens/realm/realm_detail.dart b/lib/screens/realm/realm_detail.dart index 3e3e17ff..c3a65c52 100644 --- a/lib/screens/realm/realm_detail.dart +++ b/lib/screens/realm/realm_detail.dart @@ -244,7 +244,10 @@ class RealmDetailScreen extends HookConsumerWidget { Flexible( flex: 3, child: CustomScrollView( - slivers: [SliverPostList(realm: slug)], + slivers: [ + SliverPostList(realm: slug, pinned: true), + SliverPostList(realm: slug, pinned: false), + ], ), ), Flexible( @@ -359,7 +362,8 @@ class RealmDetailScreen extends HookConsumerWidget { SliverToBoxAdapter( child: realmChatRoomListWidget(realm), ), - SliverPostList(realm: slug), + SliverPostList(realm: slug, pinned: true), + SliverPostList(realm: slug, pinned: false), ], ), ), diff --git a/lib/widgets/post/post_list.dart b/lib/widgets/post/post_list.dart index cc2eba66..d8fd79ae 100644 --- a/lib/widgets/post/post_list.dart +++ b/lib/widgets/post/post_list.dart @@ -21,8 +21,8 @@ class PostListNotifier extends _$PostListNotifier int? type, List? categories, List? tags, + bool? pinned, bool shuffle = false, - bool pinned = false, }) { return fetch(cursor: null); } @@ -41,7 +41,7 @@ class PostListNotifier extends _$PostListNotifier if (tags != null) 'tags': tags, if (categories != null) 'categories': categories, if (shuffle) 'shuffle': true, - if (pinned) 'pinned': true, + if (pinned != null) 'pinned': pinned, }; final response = await client.get( @@ -79,7 +79,7 @@ class SliverPostList extends HookConsumerWidget { final List? categories; final List? tags; final bool shuffle; - final bool pinned; + final bool? pinned; final PostItemType itemType; final Color? backgroundColor; final EdgeInsets? padding; @@ -96,7 +96,7 @@ class SliverPostList extends HookConsumerWidget { this.categories, this.tags, this.shuffle = false, - this.pinned = false, + this.pinned, this.itemType = PostItemType.regular, this.backgroundColor, this.padding, diff --git a/lib/widgets/post/post_list.g.dart b/lib/widgets/post/post_list.g.dart index 132a0ca0..8175bf5d 100644 --- a/lib/widgets/post/post_list.g.dart +++ b/lib/widgets/post/post_list.g.dart @@ -6,7 +6,7 @@ part of 'post_list.dart'; // RiverpodGenerator // ************************************************************************** -String _$postListNotifierHash() => r'7be076e6cee1c52c258d0fad2cd9fe9ac5e100ac'; +String _$postListNotifierHash() => r'3c0a8154ded4bcd8f5456f7a4ea2e542f57efa85'; /// Copied from Dart SDK class _SystemHash { @@ -36,8 +36,8 @@ abstract class _$PostListNotifier late final int? type; late final List? categories; late final List? tags; + late final bool? pinned; late final bool shuffle; - late final bool pinned; FutureOr> build({ String? pubName, @@ -45,8 +45,8 @@ abstract class _$PostListNotifier int? type, List? categories, List? tags, + bool? pinned, bool shuffle = false, - bool pinned = false, }); } @@ -67,8 +67,8 @@ class PostListNotifierFamily int? type, List? categories, List? tags, + bool? pinned, bool shuffle = false, - bool pinned = false, }) { return PostListNotifierProvider( pubName: pubName, @@ -76,8 +76,8 @@ class PostListNotifierFamily type: type, categories: categories, tags: tags, - shuffle: shuffle, pinned: pinned, + shuffle: shuffle, ); } @@ -91,8 +91,8 @@ class PostListNotifierFamily type: provider.type, categories: provider.categories, tags: provider.tags, - shuffle: provider.shuffle, pinned: provider.pinned, + shuffle: provider.shuffle, ); } @@ -125,8 +125,8 @@ class PostListNotifierProvider int? type, List? categories, List? tags, + bool? pinned, bool shuffle = false, - bool pinned = false, }) : this._internal( () => PostListNotifier() @@ -135,8 +135,8 @@ class PostListNotifierProvider ..type = type ..categories = categories ..tags = tags - ..shuffle = shuffle - ..pinned = pinned, + ..pinned = pinned + ..shuffle = shuffle, from: postListNotifierProvider, name: r'postListNotifierProvider', debugGetCreateSourceHash: @@ -151,8 +151,8 @@ class PostListNotifierProvider type: type, categories: categories, tags: tags, - shuffle: shuffle, pinned: pinned, + shuffle: shuffle, ); PostListNotifierProvider._internal( @@ -167,8 +167,8 @@ class PostListNotifierProvider required this.type, required this.categories, required this.tags, - required this.shuffle, required this.pinned, + required this.shuffle, }) : super.internal(); final String? pubName; @@ -176,8 +176,8 @@ class PostListNotifierProvider final int? type; final List? categories; final List? tags; + final bool? pinned; final bool shuffle; - final bool pinned; @override FutureOr> runNotifierBuild( @@ -189,8 +189,8 @@ class PostListNotifierProvider type: type, categories: categories, tags: tags, - shuffle: shuffle, pinned: pinned, + shuffle: shuffle, ); } @@ -206,8 +206,8 @@ class PostListNotifierProvider ..type = type ..categories = categories ..tags = tags - ..shuffle = shuffle - ..pinned = pinned, + ..pinned = pinned + ..shuffle = shuffle, from: from, name: null, dependencies: null, @@ -218,8 +218,8 @@ class PostListNotifierProvider type: type, categories: categories, tags: tags, - shuffle: shuffle, pinned: pinned, + shuffle: shuffle, ), ); } @@ -241,8 +241,8 @@ class PostListNotifierProvider other.type == type && other.categories == categories && other.tags == tags && - other.shuffle == shuffle && - other.pinned == pinned; + other.pinned == pinned && + other.shuffle == shuffle; } @override @@ -253,8 +253,8 @@ class PostListNotifierProvider hash = _SystemHash.combine(hash, type.hashCode); hash = _SystemHash.combine(hash, categories.hashCode); hash = _SystemHash.combine(hash, tags.hashCode); - hash = _SystemHash.combine(hash, shuffle.hashCode); hash = _SystemHash.combine(hash, pinned.hashCode); + hash = _SystemHash.combine(hash, shuffle.hashCode); return _SystemHash.finish(hash); } @@ -279,11 +279,11 @@ mixin PostListNotifierRef /// The parameter `tags` of this provider. List? get tags; + /// The parameter `pinned` of this provider. + bool? get pinned; + /// The parameter `shuffle` of this provider. bool get shuffle; - - /// The parameter `pinned` of this provider. - bool get pinned; } class _PostListNotifierProviderElement @@ -307,9 +307,9 @@ class _PostListNotifierProviderElement @override List? get tags => (origin as PostListNotifierProvider).tags; @override - bool get shuffle => (origin as PostListNotifierProvider).shuffle; + bool? get pinned => (origin as PostListNotifierProvider).pinned; @override - bool get pinned => (origin as PostListNotifierProvider).pinned; + bool get shuffle => (origin as PostListNotifierProvider).shuffle; } // ignore_for_file: type=lint