Able to post article

This commit is contained in:
LittleSheep 2024-07-30 16:53:13 +08:00
parent fc77c8693f
commit bb77b74356
3 changed files with 27 additions and 3 deletions

View File

@ -83,6 +83,7 @@ abstract class AppRouter {
reply: arguments?.reply, reply: arguments?.reply,
repost: arguments?.repost, repost: arguments?.repost,
realm: arguments?.realm, realm: arguments?.realm,
mode: int.tryParse(state.uri.queryParameters['mode'] ?? '0') ?? 0,
); );
}, },
), ),

View File

@ -136,11 +136,25 @@ class PostCreatePopup extends StatelessWidget {
final List<dynamic> actionList = [ final List<dynamic> actionList = [
( (
icon: const Icon(Icons.edit_square), icon: const Icon(Icons.post_add),
label: 'postEditorModeStory'.tr, label: 'postEditorModeStory'.tr,
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
AppRouter.instance.pushNamed('postEditor').then((val) { AppRouter.instance.pushNamed('postEditor', queryParameters: {
'mode': 0.toString(),
}).then((val) {
if (val != null && onCreated != null) onCreated!();
});
},
),
(
icon: const Icon(Icons.description),
label: 'postEditorModeArticle'.tr,
onTap: () {
Navigator.pop(context);
AppRouter.instance.pushNamed('postEditor', queryParameters: {
'mode': 1.toString(),
}).then((val) {
if (val != null && onCreated != null) onCreated!(); if (val != null && onCreated != null) onCreated!();
}); });
}, },

View File

@ -29,6 +29,7 @@ class PostPublishScreen extends StatefulWidget {
final Post? reply; final Post? reply;
final Post? repost; final Post? repost;
final Realm? realm; final Realm? realm;
final int mode;
const PostPublishScreen({ const PostPublishScreen({
super.key, super.key,
@ -36,6 +37,7 @@ class PostPublishScreen extends StatefulWidget {
this.reply, this.reply,
this.repost, this.repost,
this.realm, this.realm,
required this.mode,
}); });
@override @override
@ -79,6 +81,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
} }
void syncWidget() { void syncWidget() {
_editorController.mode.value = widget.mode;
if (widget.edit != null) { if (widget.edit != null) {
_editorController.editTarget = widget.edit; _editorController.editTarget = widget.edit;
} }
@ -108,7 +111,13 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
leading: AppBarLeadingButton.adaptive(context), leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle('postEditorModeStory'.tr), title: Obx(
() => AppBarTitle(
_editorController.mode.value == 0
? 'postEditorModeStory'.tr
: 'postEditorModeArticle'.tr,
),
),
centerTitle: false, centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context), toolbarHeight: SolianTheme.toolbarHeight(context),
actions: [ actions: [