Files
.github
.vscode
android
assets
buildtools
ios
lib
database
models
pods
screens
account
auth
chat
creators
posts
list.dart
stickers
hub.dart
hub.g.dart
publishers.dart
publishers.g.dart
posts
realm
account.dart
explore.dart
explore.g.dart
notification.dart
notification.g.dart
settings.dart
tabs.dart
wallet.dart
wallet.g.dart
services
widgets
firebase_options.dart
main.dart
route.dart
route.gr.dart
linux
macos
web
windows
.gitignore
.metadata
README.md
analysis_options.yaml
build.yaml
devtools_options.yaml
firebase.json
pubspec.lock
pubspec.yaml
App/lib/screens/creators/posts/list.dart
2025-06-19 23:38:38 +08:00

80 lines
2.6 KiB
Dart

import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/content/sheet.dart';
import 'package:island/widgets/post/post_list.dart';
import 'package:material_symbols_icons/symbols.dart';
@RoutePage()
class CreatorPostListScreen extends HookConsumerWidget {
final String pubName;
const CreatorPostListScreen({
super.key,
@PathParam('name') required this.pubName,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final refreshKey = useState(0);
void showCreatePostSheet() {
showModalBottomSheet(
context: context,
builder:
(context) => SheetScaffold(
titleText: 'create'.tr(),
child: Column(
children: [
ListTile(
leading: const Icon(Symbols.edit),
title: Text('postContent'.tr()),
subtitle: Text('Create a regular post'),
onTap: () async {
Navigator.pop(context);
final result = await context.router.pushPath(
'/posts/compose?type=0',
);
if (result == true) {
refreshKey.value++;
}
},
),
ListTile(
leading: const Icon(Symbols.article),
title: Text('Article'),
subtitle: Text('Create a detailed article'),
onTap: () async {
Navigator.pop(context);
final result = await context.router.pushPath(
'/posts/compose?type=1',
);
if (result == true) {
refreshKey.value++;
}
},
),
],
),
),
);
}
return AppScaffold(
appBar: AppBar(title: Text('posts').tr()),
body: CustomScrollView(
key: ValueKey(refreshKey.value),
slivers: [
SliverPostList(pubName: pubName, itemType: PostItemType.creator),
],
),
floatingActionButton: FloatingActionButton(
onPressed: showCreatePostSheet,
child: const Icon(Symbols.add),
),
);
}
}