✨ Post category details
This commit is contained in:
@@ -216,6 +216,7 @@ class ComposeSettingsSheet extends HookConsumerWidget {
|
||||
|
||||
return SheetScaffold(
|
||||
titleText: 'postSettings'.tr(),
|
||||
heightFactor: 0.6,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
|
@@ -587,7 +587,12 @@ class PostItem extends HookConsumerWidget {
|
||||
in isFullPost ? item.tags : item.tags.take(3))
|
||||
InkWell(
|
||||
child: Text('#${tag.name ?? tag.slug}'),
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'postTagDetail',
|
||||
pathParameters: {'slug': tag.slug},
|
||||
);
|
||||
},
|
||||
),
|
||||
if (!isFullPost && item.tags.length > 3)
|
||||
Text('+${item.tags.length - 3}').opacity(0.6),
|
||||
@@ -605,7 +610,12 @@ class PostItem extends HookConsumerWidget {
|
||||
: item.categories.take(2))
|
||||
InkWell(
|
||||
child: Text(category.categoryDisplayTitle),
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'postCategoryDetail',
|
||||
pathParameters: {'slug': category.slug},
|
||||
);
|
||||
},
|
||||
),
|
||||
if (!isFullPost && item.categories.length > 2)
|
||||
Text('+${item.categories.length - 2}').opacity(0.6),
|
||||
|
@@ -15,7 +15,12 @@ class PostListNotifier extends _$PostListNotifier
|
||||
static const int _pageSize = 20;
|
||||
|
||||
@override
|
||||
Future<CursorPagingData<SnPost>> build(String? pubName, int? type) {
|
||||
Future<CursorPagingData<SnPost>> build(
|
||||
String? pubName, {
|
||||
int? type,
|
||||
List<String>? categories,
|
||||
List<String>? tags,
|
||||
}) {
|
||||
return fetch(cursor: null);
|
||||
}
|
||||
|
||||
@@ -29,6 +34,8 @@ class PostListNotifier extends _$PostListNotifier
|
||||
'take': _pageSize,
|
||||
if (pubName != null) 'pub': pubName,
|
||||
if (type != null) 'type': type,
|
||||
if (tags != null) 'tags': tags,
|
||||
if (categories != null) 'categories': categories,
|
||||
};
|
||||
|
||||
final response = await client.get(
|
||||
@@ -62,6 +69,8 @@ enum PostItemType {
|
||||
class SliverPostList extends HookConsumerWidget {
|
||||
final String? pubName;
|
||||
final int? type;
|
||||
final List<String>? categories;
|
||||
final List<String>? tags;
|
||||
final PostItemType itemType;
|
||||
final Color? backgroundColor;
|
||||
final EdgeInsets? padding;
|
||||
@@ -73,6 +82,8 @@ class SliverPostList extends HookConsumerWidget {
|
||||
super.key,
|
||||
this.pubName,
|
||||
this.type,
|
||||
this.categories,
|
||||
this.tags,
|
||||
this.itemType = PostItemType.regular,
|
||||
this.backgroundColor,
|
||||
this.padding,
|
||||
@@ -84,9 +95,26 @@ class SliverPostList extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return PagingHelperSliverView(
|
||||
provider: postListNotifierProvider(pubName, type),
|
||||
futureRefreshable: postListNotifierProvider(pubName, type).future,
|
||||
notifierRefreshable: postListNotifierProvider(pubName, type).notifier,
|
||||
provider: postListNotifierProvider(
|
||||
pubName,
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
),
|
||||
futureRefreshable:
|
||||
postListNotifierProvider(
|
||||
pubName,
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
).future,
|
||||
notifierRefreshable:
|
||||
postListNotifierProvider(
|
||||
pubName,
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
).notifier,
|
||||
contentBuilder:
|
||||
(data, widgetCount, endItemView) => SliverList.builder(
|
||||
itemCount: widgetCount,
|
||||
|
@@ -6,7 +6,7 @@ part of 'post_list.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$postListNotifierHash() => r'78222d62957f85713d17aecd95af0305b764e86c';
|
||||
String _$postListNotifierHash() => r'dc57fc6aaff6bfb4e9b4d1185984162b099b8773';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
@@ -33,8 +33,15 @@ abstract class _$PostListNotifier
|
||||
extends BuildlessAutoDisposeAsyncNotifier<CursorPagingData<SnPost>> {
|
||||
late final String? pubName;
|
||||
late final int? type;
|
||||
late final List<String>? categories;
|
||||
late final List<String>? tags;
|
||||
|
||||
FutureOr<CursorPagingData<SnPost>> build(String? pubName, int? type);
|
||||
FutureOr<CursorPagingData<SnPost>> build(
|
||||
String? pubName, {
|
||||
int? type,
|
||||
List<String>? categories,
|
||||
List<String>? tags,
|
||||
});
|
||||
}
|
||||
|
||||
/// See also [PostListNotifier].
|
||||
@@ -48,15 +55,30 @@ class PostListNotifierFamily
|
||||
const PostListNotifierFamily();
|
||||
|
||||
/// See also [PostListNotifier].
|
||||
PostListNotifierProvider call(String? pubName, int? type) {
|
||||
return PostListNotifierProvider(pubName, type);
|
||||
PostListNotifierProvider call(
|
||||
String? pubName, {
|
||||
int? type,
|
||||
List<String>? categories,
|
||||
List<String>? tags,
|
||||
}) {
|
||||
return PostListNotifierProvider(
|
||||
pubName,
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
PostListNotifierProvider getProviderOverride(
|
||||
covariant PostListNotifierProvider provider,
|
||||
) {
|
||||
return call(provider.pubName, provider.type);
|
||||
return call(
|
||||
provider.pubName,
|
||||
type: provider.type,
|
||||
categories: provider.categories,
|
||||
tags: provider.tags,
|
||||
);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
@@ -82,24 +104,32 @@ class PostListNotifierProvider
|
||||
CursorPagingData<SnPost>
|
||||
> {
|
||||
/// See also [PostListNotifier].
|
||||
PostListNotifierProvider(String? pubName, int? type)
|
||||
: this._internal(
|
||||
() =>
|
||||
PostListNotifier()
|
||||
..pubName = pubName
|
||||
..type = type,
|
||||
from: postListNotifierProvider,
|
||||
name: r'postListNotifierProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$postListNotifierHash,
|
||||
dependencies: PostListNotifierFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
PostListNotifierFamily._allTransitiveDependencies,
|
||||
pubName: pubName,
|
||||
type: type,
|
||||
);
|
||||
PostListNotifierProvider(
|
||||
String? pubName, {
|
||||
int? type,
|
||||
List<String>? categories,
|
||||
List<String>? tags,
|
||||
}) : this._internal(
|
||||
() =>
|
||||
PostListNotifier()
|
||||
..pubName = pubName
|
||||
..type = type
|
||||
..categories = categories
|
||||
..tags = tags,
|
||||
from: postListNotifierProvider,
|
||||
name: r'postListNotifierProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$postListNotifierHash,
|
||||
dependencies: PostListNotifierFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
PostListNotifierFamily._allTransitiveDependencies,
|
||||
pubName: pubName,
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
);
|
||||
|
||||
PostListNotifierProvider._internal(
|
||||
super._createNotifier, {
|
||||
@@ -110,16 +140,25 @@ class PostListNotifierProvider
|
||||
required super.from,
|
||||
required this.pubName,
|
||||
required this.type,
|
||||
required this.categories,
|
||||
required this.tags,
|
||||
}) : super.internal();
|
||||
|
||||
final String? pubName;
|
||||
final int? type;
|
||||
final List<String>? categories;
|
||||
final List<String>? tags;
|
||||
|
||||
@override
|
||||
FutureOr<CursorPagingData<SnPost>> runNotifierBuild(
|
||||
covariant PostListNotifier notifier,
|
||||
) {
|
||||
return notifier.build(pubName, type);
|
||||
return notifier.build(
|
||||
pubName,
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -130,7 +169,9 @@ class PostListNotifierProvider
|
||||
() =>
|
||||
create()
|
||||
..pubName = pubName
|
||||
..type = type,
|
||||
..type = type
|
||||
..categories = categories
|
||||
..tags = tags,
|
||||
from: from,
|
||||
name: null,
|
||||
dependencies: null,
|
||||
@@ -138,6 +179,8 @@ class PostListNotifierProvider
|
||||
debugGetCreateSourceHash: null,
|
||||
pubName: pubName,
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -155,7 +198,9 @@ class PostListNotifierProvider
|
||||
bool operator ==(Object other) {
|
||||
return other is PostListNotifierProvider &&
|
||||
other.pubName == pubName &&
|
||||
other.type == type;
|
||||
other.type == type &&
|
||||
other.categories == categories &&
|
||||
other.tags == tags;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -163,6 +208,8 @@ class PostListNotifierProvider
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, pubName.hashCode);
|
||||
hash = _SystemHash.combine(hash, type.hashCode);
|
||||
hash = _SystemHash.combine(hash, categories.hashCode);
|
||||
hash = _SystemHash.combine(hash, tags.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
@@ -177,6 +224,12 @@ mixin PostListNotifierRef
|
||||
|
||||
/// The parameter `type` of this provider.
|
||||
int? get type;
|
||||
|
||||
/// The parameter `categories` of this provider.
|
||||
List<String>? get categories;
|
||||
|
||||
/// The parameter `tags` of this provider.
|
||||
List<String>? get tags;
|
||||
}
|
||||
|
||||
class _PostListNotifierProviderElement
|
||||
@@ -192,6 +245,11 @@ class _PostListNotifierProviderElement
|
||||
String? get pubName => (origin as PostListNotifierProvider).pubName;
|
||||
@override
|
||||
int? get type => (origin as PostListNotifierProvider).type;
|
||||
@override
|
||||
List<String>? get categories =>
|
||||
(origin as PostListNotifierProvider).categories;
|
||||
@override
|
||||
List<String>? get tags => (origin as PostListNotifierProvider).tags;
|
||||
}
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
Reference in New Issue
Block a user