Compare commits

..

No commits in common. "bb77b74356020ebf4bdca1c1e0c85765774f5ffe" and "58bb549217a0dfb8fa404f1e413289820cd58492" have entirely different histories.

5 changed files with 5 additions and 67 deletions

View File

@ -94,7 +94,6 @@ class PostEditorController extends GetxController {
'repost_to': repostTo.value?.toJson(),
'edit_to': editTo.value?.toJson(),
'realm': realmZone.value?.toJson(),
'type': type,
}),
);
}
@ -132,7 +131,6 @@ class PostEditorController extends GetxController {
return;
}
type = value.type;
editTo.value = value;
isDraft.value = value.isDraft ?? false;
titleController.text = value.body['title'] ?? '';
@ -144,37 +142,6 @@ class PostEditorController extends GetxController {
contentLength.value = contentController.text.length;
}
String get typeEndpoint {
switch(mode.value) {
case 0:
return 'stories';
case 1:
return 'articles';
default:
return 'stories';
}
}
String get type {
switch(mode.value) {
case 0:
return 'story';
case 1:
return 'article';
default:
return 'story';
}
}
set type(String value) {
switch (value) {
case 'story':
mode.value = 0;
case 'article':
mode.value = 1;
}
}
String? get title {
if (titleController.text.isEmpty) return null;
return titleController.text;
@ -201,7 +168,6 @@ class PostEditorController extends GetxController {
}
set payload(Map<String, dynamic> value) {
type = value['type'];
titleController.text = value['title'] ?? '';
descriptionController.text = value['description'] ?? '';
contentController.text = value['content'] ?? '';

View File

@ -12,7 +12,6 @@ class Post {
List<Tag>? tags;
List<Category>? categories;
List<Post>? replies;
String type;
int? replyId;
int? repostId;
int? realmId;
@ -32,7 +31,6 @@ class Post {
required this.updatedAt,
required this.editedAt,
required this.deletedAt,
required this.type,
required this.body,
required this.tags,
required this.categories,
@ -58,7 +56,6 @@ class Post {
deletedAt: json['deleted_at'] != null
? DateTime.parse(json['deleted_at'])
: null,
type: json['type'],
body: json['body'],
tags: json['tags']?.map((x) => Tag.fromJson(x)).toList().cast<Tag>(),
categories: json['categories']
@ -96,7 +93,6 @@ class Post {
'updated_at': updatedAt.toIso8601String(),
'edited_at': editedAt?.toIso8601String(),
'deleted_at': deletedAt?.toIso8601String(),
'type': type,
'body': body,
'tags': tags,
'categories': categories,

View File

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

View File

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

View File

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