✨ Shuffle post
This commit is contained in:
@@ -864,5 +864,6 @@
|
||||
"mimeType": "MIME Type",
|
||||
"fileSize": "File Size",
|
||||
"fileHash": "File Hash",
|
||||
"exifData": "EXIF Data"
|
||||
"exifData": "EXIF Data",
|
||||
"postShuffle": "Shuffle Posts"
|
||||
}
|
||||
|
@@ -53,6 +53,7 @@ import 'package:island/screens/account/event_calendar.dart';
|
||||
import 'package:island/screens/discovery/realms.dart';
|
||||
import 'package:island/screens/reports/report_detail.dart';
|
||||
import 'package:island/screens/reports/report_list.dart';
|
||||
import 'package:island/widgets/post/post_shuffle.dart';
|
||||
|
||||
// Shell route keys for nested navigation
|
||||
final rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||
@@ -376,6 +377,11 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
path: '/posts/search',
|
||||
builder: (context, state) => const PostSearchScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postShuffle',
|
||||
path: '/posts/shuffle',
|
||||
builder: (context, state) => const PostShuffleScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postCategories',
|
||||
path: '/posts/categories',
|
||||
|
@@ -200,6 +200,18 @@ class ExploreScreen extends HookConsumerWidget {
|
||||
context.pushNamed('postTags');
|
||||
},
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Symbols.shuffle),
|
||||
const Gap(12),
|
||||
Text('postShuffle').tr(),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
context.pushNamed('postShuffle');
|
||||
},
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
|
@@ -145,7 +145,7 @@ class PostCategoriesListScreen extends ConsumerWidget {
|
||||
final categoriesState = ref.watch(postCategoriesNotifierProvider);
|
||||
|
||||
return AppScaffold(
|
||||
appBar: AppBar(title: const Text('Categories')),
|
||||
appBar: AppBar(title: const Text('categories').tr()),
|
||||
body: categoriesState.when(
|
||||
data: (data) {
|
||||
if (data.items.isEmpty) {
|
||||
@@ -197,7 +197,7 @@ class PostTagsListScreen extends ConsumerWidget {
|
||||
final tagsState = ref.watch(postTagsNotifierProvider);
|
||||
|
||||
return AppScaffold(
|
||||
appBar: AppBar(title: const Text('Tags')),
|
||||
appBar: AppBar(title: const Text('tags').tr()),
|
||||
body: tagsState.when(
|
||||
data: (data) {
|
||||
if (data.items.isEmpty) {
|
||||
|
@@ -21,6 +21,7 @@ class PostListNotifier extends _$PostListNotifier
|
||||
int? type,
|
||||
List<String>? categories,
|
||||
List<String>? tags,
|
||||
bool shuffle = false,
|
||||
}) {
|
||||
return fetch(cursor: null);
|
||||
}
|
||||
@@ -38,6 +39,7 @@ class PostListNotifier extends _$PostListNotifier
|
||||
if (type != null) 'type': type,
|
||||
if (tags != null) 'tags': tags,
|
||||
if (categories != null) 'categories': categories,
|
||||
if (shuffle) 'shuffle': true,
|
||||
};
|
||||
|
||||
final response = await client.get(
|
||||
@@ -74,6 +76,7 @@ class SliverPostList extends HookConsumerWidget {
|
||||
final int? type;
|
||||
final List<String>? categories;
|
||||
final List<String>? tags;
|
||||
final bool shuffle;
|
||||
final PostItemType itemType;
|
||||
final Color? backgroundColor;
|
||||
final EdgeInsets? padding;
|
||||
@@ -88,6 +91,7 @@ class SliverPostList extends HookConsumerWidget {
|
||||
this.type,
|
||||
this.categories,
|
||||
this.tags,
|
||||
this.shuffle = false,
|
||||
this.itemType = PostItemType.regular,
|
||||
this.backgroundColor,
|
||||
this.padding,
|
||||
@@ -105,6 +109,7 @@ class SliverPostList extends HookConsumerWidget {
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
shuffle: shuffle,
|
||||
),
|
||||
futureRefreshable:
|
||||
postListNotifierProvider(
|
||||
@@ -113,6 +118,7 @@ class SliverPostList extends HookConsumerWidget {
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
shuffle: shuffle,
|
||||
).future,
|
||||
notifierRefreshable:
|
||||
postListNotifierProvider(
|
||||
@@ -121,6 +127,7 @@ class SliverPostList extends HookConsumerWidget {
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
shuffle: shuffle,
|
||||
).notifier,
|
||||
contentBuilder:
|
||||
(data, widgetCount, endItemView) => SliverList.builder(
|
||||
|
@@ -6,7 +6,7 @@ part of 'post_list.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$postListNotifierHash() => r'9784b282b3ee14b7109e263c5841a082cf0be78e';
|
||||
String _$postListNotifierHash() => r'27dc73b92a057b396e8ac026d4392508aedea4f5';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
@@ -36,6 +36,7 @@ abstract class _$PostListNotifier
|
||||
late final int? type;
|
||||
late final List<String>? categories;
|
||||
late final List<String>? tags;
|
||||
late final bool shuffle;
|
||||
|
||||
FutureOr<CursorPagingData<SnPost>> build({
|
||||
String? pubName,
|
||||
@@ -43,6 +44,7 @@ abstract class _$PostListNotifier
|
||||
int? type,
|
||||
List<String>? categories,
|
||||
List<String>? tags,
|
||||
bool shuffle = false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -63,6 +65,7 @@ class PostListNotifierFamily
|
||||
int? type,
|
||||
List<String>? categories,
|
||||
List<String>? tags,
|
||||
bool shuffle = false,
|
||||
}) {
|
||||
return PostListNotifierProvider(
|
||||
pubName: pubName,
|
||||
@@ -70,6 +73,7 @@ class PostListNotifierFamily
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
shuffle: shuffle,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -83,6 +87,7 @@ class PostListNotifierFamily
|
||||
type: provider.type,
|
||||
categories: provider.categories,
|
||||
tags: provider.tags,
|
||||
shuffle: provider.shuffle,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -115,6 +120,7 @@ class PostListNotifierProvider
|
||||
int? type,
|
||||
List<String>? categories,
|
||||
List<String>? tags,
|
||||
bool shuffle = false,
|
||||
}) : this._internal(
|
||||
() =>
|
||||
PostListNotifier()
|
||||
@@ -122,7 +128,8 @@ class PostListNotifierProvider
|
||||
..realm = realm
|
||||
..type = type
|
||||
..categories = categories
|
||||
..tags = tags,
|
||||
..tags = tags
|
||||
..shuffle = shuffle,
|
||||
from: postListNotifierProvider,
|
||||
name: r'postListNotifierProvider',
|
||||
debugGetCreateSourceHash:
|
||||
@@ -137,6 +144,7 @@ class PostListNotifierProvider
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
shuffle: shuffle,
|
||||
);
|
||||
|
||||
PostListNotifierProvider._internal(
|
||||
@@ -151,6 +159,7 @@ class PostListNotifierProvider
|
||||
required this.type,
|
||||
required this.categories,
|
||||
required this.tags,
|
||||
required this.shuffle,
|
||||
}) : super.internal();
|
||||
|
||||
final String? pubName;
|
||||
@@ -158,6 +167,7 @@ class PostListNotifierProvider
|
||||
final int? type;
|
||||
final List<String>? categories;
|
||||
final List<String>? tags;
|
||||
final bool shuffle;
|
||||
|
||||
@override
|
||||
FutureOr<CursorPagingData<SnPost>> runNotifierBuild(
|
||||
@@ -169,6 +179,7 @@ class PostListNotifierProvider
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
shuffle: shuffle,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -183,7 +194,8 @@ class PostListNotifierProvider
|
||||
..realm = realm
|
||||
..type = type
|
||||
..categories = categories
|
||||
..tags = tags,
|
||||
..tags = tags
|
||||
..shuffle = shuffle,
|
||||
from: from,
|
||||
name: null,
|
||||
dependencies: null,
|
||||
@@ -194,6 +206,7 @@ class PostListNotifierProvider
|
||||
type: type,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
shuffle: shuffle,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -214,7 +227,8 @@ class PostListNotifierProvider
|
||||
other.realm == realm &&
|
||||
other.type == type &&
|
||||
other.categories == categories &&
|
||||
other.tags == tags;
|
||||
other.tags == tags &&
|
||||
other.shuffle == shuffle;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -225,6 +239,7 @@ 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);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
@@ -248,6 +263,9 @@ mixin PostListNotifierRef
|
||||
|
||||
/// The parameter `tags` of this provider.
|
||||
List<String>? get tags;
|
||||
|
||||
/// The parameter `shuffle` of this provider.
|
||||
bool get shuffle;
|
||||
}
|
||||
|
||||
class _PostListNotifierProviderElement
|
||||
@@ -270,6 +288,8 @@ class _PostListNotifierProviderElement
|
||||
(origin as PostListNotifierProvider).categories;
|
||||
@override
|
||||
List<String>? get tags => (origin as PostListNotifierProvider).tags;
|
||||
@override
|
||||
bool get shuffle => (origin as PostListNotifierProvider).shuffle;
|
||||
}
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
17
lib/widgets/post/post_shuffle.dart
Normal file
17
lib/widgets/post/post_shuffle.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/widgets/app_scaffold.dart';
|
||||
import 'package:island/widgets/post/post_list.dart';
|
||||
|
||||
class PostShuffleScreen extends HookConsumerWidget {
|
||||
const PostShuffleScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return AppScaffold(
|
||||
appBar: AppBar(title: const Text('postShuffle').tr()),
|
||||
body: CustomScrollView(slivers: [SliverPostList(shuffle: true)]),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user