♻️ Refactored web feed, poll

This commit is contained in:
2025-10-12 12:19:50 +08:00
parent bbb07d574a
commit 27157e7cc1
9 changed files with 415 additions and 476 deletions

View File

@@ -1,12 +1,9 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.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';
class CreatorPostListScreen extends HookConsumerWidget {
final String pubName;
@@ -16,63 +13,20 @@ class CreatorPostListScreen extends HookConsumerWidget {
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('Post'),
subtitle: Text('Create a regular post'),
onTap: () async {
Navigator.pop(context);
final result = await context.pushNamed(
'postCompose',
queryParameters: {'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.pushNamed(
'postCompose',
queryParameters: {'type': '1'},
);
if (result == true) {
refreshKey.value++;
}
},
),
],
),
),
);
}
return AppScaffold(
isNoBackground: false,
appBar: AppBar(title: Text('posts').tr()),
body: CustomScrollView(
key: ValueKey(refreshKey.value),
slivers: [
SliverPostList(pubName: pubName, itemType: PostItemType.creator),
SliverPostList(
pubName: pubName,
itemType: PostItemType.creator,
maxWidth: 640,
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: showCreatePostSheet,
child: const Icon(Symbols.add),
),
);
}
}