Compare commits
No commits in common. "bb77b74356020ebf4bdca1c1e0c85765774f5ffe" and "58bb549217a0dfb8fa404f1e413289820cd58492" have entirely different histories.
bb77b74356
...
58bb549217
@ -94,7 +94,6 @@ class PostEditorController extends GetxController {
|
|||||||
'repost_to': repostTo.value?.toJson(),
|
'repost_to': repostTo.value?.toJson(),
|
||||||
'edit_to': editTo.value?.toJson(),
|
'edit_to': editTo.value?.toJson(),
|
||||||
'realm': realmZone.value?.toJson(),
|
'realm': realmZone.value?.toJson(),
|
||||||
'type': type,
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -132,7 +131,6 @@ class PostEditorController extends GetxController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = value.type;
|
|
||||||
editTo.value = value;
|
editTo.value = value;
|
||||||
isDraft.value = value.isDraft ?? false;
|
isDraft.value = value.isDraft ?? false;
|
||||||
titleController.text = value.body['title'] ?? '';
|
titleController.text = value.body['title'] ?? '';
|
||||||
@ -144,37 +142,6 @@ class PostEditorController extends GetxController {
|
|||||||
contentLength.value = contentController.text.length;
|
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 {
|
String? get title {
|
||||||
if (titleController.text.isEmpty) return null;
|
if (titleController.text.isEmpty) return null;
|
||||||
return titleController.text;
|
return titleController.text;
|
||||||
@ -201,7 +168,6 @@ class PostEditorController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set payload(Map<String, dynamic> value) {
|
set payload(Map<String, dynamic> value) {
|
||||||
type = value['type'];
|
|
||||||
titleController.text = value['title'] ?? '';
|
titleController.text = value['title'] ?? '';
|
||||||
descriptionController.text = value['description'] ?? '';
|
descriptionController.text = value['description'] ?? '';
|
||||||
contentController.text = value['content'] ?? '';
|
contentController.text = value['content'] ?? '';
|
||||||
|
@ -12,7 +12,6 @@ class Post {
|
|||||||
List<Tag>? tags;
|
List<Tag>? tags;
|
||||||
List<Category>? categories;
|
List<Category>? categories;
|
||||||
List<Post>? replies;
|
List<Post>? replies;
|
||||||
String type;
|
|
||||||
int? replyId;
|
int? replyId;
|
||||||
int? repostId;
|
int? repostId;
|
||||||
int? realmId;
|
int? realmId;
|
||||||
@ -32,7 +31,6 @@ class Post {
|
|||||||
required this.updatedAt,
|
required this.updatedAt,
|
||||||
required this.editedAt,
|
required this.editedAt,
|
||||||
required this.deletedAt,
|
required this.deletedAt,
|
||||||
required this.type,
|
|
||||||
required this.body,
|
required this.body,
|
||||||
required this.tags,
|
required this.tags,
|
||||||
required this.categories,
|
required this.categories,
|
||||||
@ -58,7 +56,6 @@ class Post {
|
|||||||
deletedAt: json['deleted_at'] != null
|
deletedAt: json['deleted_at'] != null
|
||||||
? DateTime.parse(json['deleted_at'])
|
? DateTime.parse(json['deleted_at'])
|
||||||
: null,
|
: null,
|
||||||
type: json['type'],
|
|
||||||
body: json['body'],
|
body: json['body'],
|
||||||
tags: json['tags']?.map((x) => Tag.fromJson(x)).toList().cast<Tag>(),
|
tags: json['tags']?.map((x) => Tag.fromJson(x)).toList().cast<Tag>(),
|
||||||
categories: json['categories']
|
categories: json['categories']
|
||||||
@ -96,7 +93,6 @@ class Post {
|
|||||||
'updated_at': updatedAt.toIso8601String(),
|
'updated_at': updatedAt.toIso8601String(),
|
||||||
'edited_at': editedAt?.toIso8601String(),
|
'edited_at': editedAt?.toIso8601String(),
|
||||||
'deleted_at': deletedAt?.toIso8601String(),
|
'deleted_at': deletedAt?.toIso8601String(),
|
||||||
'type': type,
|
|
||||||
'body': body,
|
'body': body,
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
'categories': categories,
|
'categories': categories,
|
||||||
|
@ -83,7 +83,6 @@ 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,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -136,25 +136,11 @@ class PostCreatePopup extends StatelessWidget {
|
|||||||
|
|
||||||
final List<dynamic> actionList = [
|
final List<dynamic> actionList = [
|
||||||
(
|
(
|
||||||
icon: const Icon(Icons.post_add),
|
icon: const Icon(Icons.edit_square),
|
||||||
label: 'postEditorModeStory'.tr,
|
label: 'postEditorModeStory'.tr,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
AppRouter.instance.pushNamed('postEditor', queryParameters: {
|
AppRouter.instance.pushNamed('postEditor').then((val) {
|
||||||
'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!();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -29,7 +29,6 @@ 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,
|
||||||
@ -37,7 +36,6 @@ class PostPublishScreen extends StatefulWidget {
|
|||||||
this.reply,
|
this.reply,
|
||||||
this.repost,
|
this.repost,
|
||||||
this.realm,
|
this.realm,
|
||||||
required this.mode,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -61,12 +59,12 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
Response resp;
|
Response resp;
|
||||||
if (widget.edit != null) {
|
if (widget.edit != null) {
|
||||||
resp = await client.put(
|
resp = await client.put(
|
||||||
'/${_editorController.typeEndpoint}/${widget.edit!.id}',
|
'/stories/${widget.edit!.id}',
|
||||||
_editorController.payload,
|
_editorController.payload,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
resp = await client.post(
|
resp = await client.post(
|
||||||
'/${_editorController.typeEndpoint}',
|
'/stories',
|
||||||
_editorController.payload,
|
_editorController.payload,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -81,7 +79,6 @@ 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;
|
||||||
}
|
}
|
||||||
@ -111,13 +108,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: AppBarLeadingButton.adaptive(context),
|
leading: AppBarLeadingButton.adaptive(context),
|
||||||
title: Obx(
|
title: AppBarTitle('postEditorModeStory'.tr),
|
||||||
() => AppBarTitle(
|
|
||||||
_editorController.mode.value == 0
|
|
||||||
? 'postEditorModeStory'.tr
|
|
||||||
: 'postEditorModeArticle'.tr,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
actions: [
|
actions: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user