Show pinned posts on realms, publishers

This commit is contained in:
2025-08-25 17:09:24 +08:00
parent f9b2a96c7c
commit 709a0620b6
4 changed files with 37 additions and 30 deletions

View File

@@ -356,6 +356,7 @@ class PublisherProfileScreen extends HookConsumerWidget {
SliverPostList( SliverPostList(
key: ValueKey(categoryTab.value), key: ValueKey(categoryTab.value),
pubName: name, pubName: name,
pinned: false,
type: switch (categoryTab.value) { type: switch (categoryTab.value) {
1 => 0, 1 => 0,
2 => 1, 2 => 1,
@@ -438,10 +439,12 @@ class PublisherProfileScreen extends HookConsumerWidget {
child: publisherVerificationWidget(data), child: publisherVerificationWidget(data),
), ),
SliverToBoxAdapter(child: publisherBioWidget(data)), SliverToBoxAdapter(child: publisherBioWidget(data)),
SliverPostList(pubName: name, pinned: true),
SliverToBoxAdapter(child: publisherCategoryTabWidget()), SliverToBoxAdapter(child: publisherCategoryTabWidget()),
SliverPostList( SliverPostList(
key: ValueKey(categoryTab.value), key: ValueKey(categoryTab.value),
pubName: name, pubName: name,
pinned: false,
type: switch (categoryTab.value) { type: switch (categoryTab.value) {
1 => 0, 1 => 0,
2 => 1, 2 => 1,

View File

@@ -244,7 +244,10 @@ class RealmDetailScreen extends HookConsumerWidget {
Flexible( Flexible(
flex: 3, flex: 3,
child: CustomScrollView( child: CustomScrollView(
slivers: [SliverPostList(realm: slug)], slivers: [
SliverPostList(realm: slug, pinned: true),
SliverPostList(realm: slug, pinned: false),
],
), ),
), ),
Flexible( Flexible(
@@ -359,7 +362,8 @@ class RealmDetailScreen extends HookConsumerWidget {
SliverToBoxAdapter( SliverToBoxAdapter(
child: realmChatRoomListWidget(realm), child: realmChatRoomListWidget(realm),
), ),
SliverPostList(realm: slug), SliverPostList(realm: slug, pinned: true),
SliverPostList(realm: slug, pinned: false),
], ],
), ),
), ),

View File

@@ -21,8 +21,8 @@ class PostListNotifier extends _$PostListNotifier
int? type, int? type,
List<String>? categories, List<String>? categories,
List<String>? tags, List<String>? tags,
bool? pinned,
bool shuffle = false, bool shuffle = false,
bool pinned = false,
}) { }) {
return fetch(cursor: null); return fetch(cursor: null);
} }
@@ -41,7 +41,7 @@ class PostListNotifier extends _$PostListNotifier
if (tags != null) 'tags': tags, if (tags != null) 'tags': tags,
if (categories != null) 'categories': categories, if (categories != null) 'categories': categories,
if (shuffle) 'shuffle': true, if (shuffle) 'shuffle': true,
if (pinned) 'pinned': true, if (pinned != null) 'pinned': pinned,
}; };
final response = await client.get( final response = await client.get(
@@ -79,7 +79,7 @@ class SliverPostList extends HookConsumerWidget {
final List<String>? categories; final List<String>? categories;
final List<String>? tags; final List<String>? tags;
final bool shuffle; final bool shuffle;
final bool pinned; final bool? pinned;
final PostItemType itemType; final PostItemType itemType;
final Color? backgroundColor; final Color? backgroundColor;
final EdgeInsets? padding; final EdgeInsets? padding;
@@ -96,7 +96,7 @@ class SliverPostList extends HookConsumerWidget {
this.categories, this.categories,
this.tags, this.tags,
this.shuffle = false, this.shuffle = false,
this.pinned = false, this.pinned,
this.itemType = PostItemType.regular, this.itemType = PostItemType.regular,
this.backgroundColor, this.backgroundColor,
this.padding, this.padding,

View File

@@ -6,7 +6,7 @@ part of 'post_list.dart';
// RiverpodGenerator // RiverpodGenerator
// ************************************************************************** // **************************************************************************
String _$postListNotifierHash() => r'7be076e6cee1c52c258d0fad2cd9fe9ac5e100ac'; String _$postListNotifierHash() => r'3c0a8154ded4bcd8f5456f7a4ea2e542f57efa85';
/// Copied from Dart SDK /// Copied from Dart SDK
class _SystemHash { class _SystemHash {
@@ -36,8 +36,8 @@ abstract class _$PostListNotifier
late final int? type; late final int? type;
late final List<String>? categories; late final List<String>? categories;
late final List<String>? tags; late final List<String>? tags;
late final bool? pinned;
late final bool shuffle; late final bool shuffle;
late final bool pinned;
FutureOr<CursorPagingData<SnPost>> build({ FutureOr<CursorPagingData<SnPost>> build({
String? pubName, String? pubName,
@@ -45,8 +45,8 @@ abstract class _$PostListNotifier
int? type, int? type,
List<String>? categories, List<String>? categories,
List<String>? tags, List<String>? tags,
bool? pinned,
bool shuffle = false, bool shuffle = false,
bool pinned = false,
}); });
} }
@@ -67,8 +67,8 @@ class PostListNotifierFamily
int? type, int? type,
List<String>? categories, List<String>? categories,
List<String>? tags, List<String>? tags,
bool? pinned,
bool shuffle = false, bool shuffle = false,
bool pinned = false,
}) { }) {
return PostListNotifierProvider( return PostListNotifierProvider(
pubName: pubName, pubName: pubName,
@@ -76,8 +76,8 @@ class PostListNotifierFamily
type: type, type: type,
categories: categories, categories: categories,
tags: tags, tags: tags,
shuffle: shuffle,
pinned: pinned, pinned: pinned,
shuffle: shuffle,
); );
} }
@@ -91,8 +91,8 @@ class PostListNotifierFamily
type: provider.type, type: provider.type,
categories: provider.categories, categories: provider.categories,
tags: provider.tags, tags: provider.tags,
shuffle: provider.shuffle,
pinned: provider.pinned, pinned: provider.pinned,
shuffle: provider.shuffle,
); );
} }
@@ -125,8 +125,8 @@ class PostListNotifierProvider
int? type, int? type,
List<String>? categories, List<String>? categories,
List<String>? tags, List<String>? tags,
bool? pinned,
bool shuffle = false, bool shuffle = false,
bool pinned = false,
}) : this._internal( }) : this._internal(
() => () =>
PostListNotifier() PostListNotifier()
@@ -135,8 +135,8 @@ class PostListNotifierProvider
..type = type ..type = type
..categories = categories ..categories = categories
..tags = tags ..tags = tags
..shuffle = shuffle ..pinned = pinned
..pinned = pinned, ..shuffle = shuffle,
from: postListNotifierProvider, from: postListNotifierProvider,
name: r'postListNotifierProvider', name: r'postListNotifierProvider',
debugGetCreateSourceHash: debugGetCreateSourceHash:
@@ -151,8 +151,8 @@ class PostListNotifierProvider
type: type, type: type,
categories: categories, categories: categories,
tags: tags, tags: tags,
shuffle: shuffle,
pinned: pinned, pinned: pinned,
shuffle: shuffle,
); );
PostListNotifierProvider._internal( PostListNotifierProvider._internal(
@@ -167,8 +167,8 @@ class PostListNotifierProvider
required this.type, required this.type,
required this.categories, required this.categories,
required this.tags, required this.tags,
required this.shuffle,
required this.pinned, required this.pinned,
required this.shuffle,
}) : super.internal(); }) : super.internal();
final String? pubName; final String? pubName;
@@ -176,8 +176,8 @@ class PostListNotifierProvider
final int? type; final int? type;
final List<String>? categories; final List<String>? categories;
final List<String>? tags; final List<String>? tags;
final bool? pinned;
final bool shuffle; final bool shuffle;
final bool pinned;
@override @override
FutureOr<CursorPagingData<SnPost>> runNotifierBuild( FutureOr<CursorPagingData<SnPost>> runNotifierBuild(
@@ -189,8 +189,8 @@ class PostListNotifierProvider
type: type, type: type,
categories: categories, categories: categories,
tags: tags, tags: tags,
shuffle: shuffle,
pinned: pinned, pinned: pinned,
shuffle: shuffle,
); );
} }
@@ -206,8 +206,8 @@ class PostListNotifierProvider
..type = type ..type = type
..categories = categories ..categories = categories
..tags = tags ..tags = tags
..shuffle = shuffle ..pinned = pinned
..pinned = pinned, ..shuffle = shuffle,
from: from, from: from,
name: null, name: null,
dependencies: null, dependencies: null,
@@ -218,8 +218,8 @@ class PostListNotifierProvider
type: type, type: type,
categories: categories, categories: categories,
tags: tags, tags: tags,
shuffle: shuffle,
pinned: pinned, pinned: pinned,
shuffle: shuffle,
), ),
); );
} }
@@ -241,8 +241,8 @@ class PostListNotifierProvider
other.type == type && other.type == type &&
other.categories == categories && other.categories == categories &&
other.tags == tags && other.tags == tags &&
other.shuffle == shuffle && other.pinned == pinned &&
other.pinned == pinned; other.shuffle == shuffle;
} }
@override @override
@@ -253,8 +253,8 @@ class PostListNotifierProvider
hash = _SystemHash.combine(hash, type.hashCode); hash = _SystemHash.combine(hash, type.hashCode);
hash = _SystemHash.combine(hash, categories.hashCode); hash = _SystemHash.combine(hash, categories.hashCode);
hash = _SystemHash.combine(hash, tags.hashCode); hash = _SystemHash.combine(hash, tags.hashCode);
hash = _SystemHash.combine(hash, shuffle.hashCode);
hash = _SystemHash.combine(hash, pinned.hashCode); hash = _SystemHash.combine(hash, pinned.hashCode);
hash = _SystemHash.combine(hash, shuffle.hashCode);
return _SystemHash.finish(hash); return _SystemHash.finish(hash);
} }
@@ -279,11 +279,11 @@ mixin PostListNotifierRef
/// The parameter `tags` of this provider. /// The parameter `tags` of this provider.
List<String>? get tags; List<String>? get tags;
/// The parameter `pinned` of this provider.
bool? get pinned;
/// The parameter `shuffle` of this provider. /// The parameter `shuffle` of this provider.
bool get shuffle; bool get shuffle;
/// The parameter `pinned` of this provider.
bool get pinned;
} }
class _PostListNotifierProviderElement class _PostListNotifierProviderElement
@@ -307,9 +307,9 @@ class _PostListNotifierProviderElement
@override @override
List<String>? get tags => (origin as PostListNotifierProvider).tags; List<String>? get tags => (origin as PostListNotifierProvider).tags;
@override @override
bool get shuffle => (origin as PostListNotifierProvider).shuffle; bool? get pinned => (origin as PostListNotifierProvider).pinned;
@override @override
bool get pinned => (origin as PostListNotifierProvider).pinned; bool get shuffle => (origin as PostListNotifierProvider).shuffle;
} }
// ignore_for_file: type=lint // ignore_for_file: type=lint