✨ Optimize post editor
This commit is contained in:
parent
85e48ce03b
commit
28a4c86dbf
@ -153,6 +153,7 @@ class _PostEditorScreenState extends State<PostEditorScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
maxLines: 2,
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
@ -250,121 +251,130 @@ class _PostEditorScreenState extends State<PostEditorScreen> {
|
|||||||
),
|
),
|
||||||
const Divider(height: 1),
|
const Divider(height: 1),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: Stack(
|
||||||
padding: EdgeInsets.only(bottom: 8),
|
children: [
|
||||||
child: Column(
|
SingleChildScrollView(
|
||||||
children: [
|
padding: EdgeInsets.only(bottom: 160),
|
||||||
// Replying Notice
|
child: Column(
|
||||||
if (_writeController.replyingPost != null)
|
children: [
|
||||||
Column(
|
// Replying Notice
|
||||||
children: [
|
if (_writeController.replyingPost != null)
|
||||||
ExpansionTile(
|
Column(
|
||||||
minTileHeight: 48,
|
children: [
|
||||||
leading: const Icon(Symbols.reply).padding(left: 4),
|
ExpansionTile(
|
||||||
title: Text('postReplyingNotice')
|
minTileHeight: 48,
|
||||||
.fontSize(15)
|
leading: const Icon(Symbols.reply).padding(left: 4),
|
||||||
.tr(args: ['@${_writeController.replyingPost!.publisher.name}']),
|
title: Text('postReplyingNotice')
|
||||||
children: <Widget>[PostItem(data: _writeController.replyingPost!)],
|
.fontSize(15)
|
||||||
),
|
.tr(args: ['@${_writeController.replyingPost!.publisher.name}']),
|
||||||
const Divider(height: 1),
|
children: <Widget>[PostItem(data: _writeController.replyingPost!)],
|
||||||
],
|
),
|
||||||
),
|
const Divider(height: 1),
|
||||||
// Reposting Notice
|
|
||||||
if (_writeController.repostingPost != null)
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
ExpansionTile(
|
|
||||||
minTileHeight: 48,
|
|
||||||
leading: const Icon(Symbols.forward).padding(left: 4),
|
|
||||||
title: Text('postRepostingNotice')
|
|
||||||
.fontSize(15)
|
|
||||||
.tr(args: ['@${_writeController.repostingPost!.publisher.name}']),
|
|
||||||
children: <Widget>[
|
|
||||||
PostItem(
|
|
||||||
data: _writeController.repostingPost!,
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const Divider(height: 1),
|
// Reposting Notice
|
||||||
],
|
if (_writeController.repostingPost != null)
|
||||||
),
|
Column(
|
||||||
// Editing Notice
|
children: [
|
||||||
if (_writeController.editingPost != null)
|
ExpansionTile(
|
||||||
Column(
|
minTileHeight: 48,
|
||||||
children: [
|
leading: const Icon(Symbols.forward).padding(left: 4),
|
||||||
ExpansionTile(
|
title: Text('postRepostingNotice')
|
||||||
minTileHeight: 48,
|
.fontSize(15)
|
||||||
leading: const Icon(Symbols.edit_note).padding(left: 4),
|
.tr(args: ['@${_writeController.repostingPost!.publisher.name}']),
|
||||||
title: Text('postEditingNotice')
|
children: <Widget>[
|
||||||
.fontSize(15)
|
PostItem(
|
||||||
.tr(args: ['@${_writeController.editingPost!.publisher.name}']),
|
data: _writeController.repostingPost!,
|
||||||
children: <Widget>[PostItem(data: _writeController.editingPost!)],
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Divider(height: 1),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const Divider(height: 1),
|
// Editing Notice
|
||||||
],
|
if (_writeController.editingPost != null)
|
||||||
),
|
Column(
|
||||||
// Content Input Area
|
children: [
|
||||||
Container(
|
ExpansionTile(
|
||||||
constraints: const BoxConstraints(maxWidth: 640),
|
minTileHeight: 48,
|
||||||
child: TextField(
|
leading: const Icon(Symbols.edit_note).padding(left: 4),
|
||||||
controller: _writeController.contentController,
|
title: Text('postEditingNotice')
|
||||||
maxLines: null,
|
.fontSize(15)
|
||||||
decoration: InputDecoration(
|
.tr(args: ['@${_writeController.editingPost!.publisher.name}']),
|
||||||
hintText: 'fieldPostContent'.tr(),
|
children: <Widget>[PostItem(data: _writeController.editingPost!)],
|
||||||
hintStyle: TextStyle(fontSize: 14),
|
),
|
||||||
isCollapsed: true,
|
const Divider(height: 1),
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
],
|
||||||
horizontal: 16,
|
),
|
||||||
|
// Content Input Area
|
||||||
|
Container(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 640),
|
||||||
|
child: TextField(
|
||||||
|
controller: _writeController.contentController,
|
||||||
|
maxLines: null,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'fieldPostContent'.tr(),
|
||||||
|
hintStyle: TextStyle(fontSize: 14),
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
),
|
||||||
|
border: InputBorder.none,
|
||||||
|
),
|
||||||
|
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
),
|
),
|
||||||
border: InputBorder.none,
|
|
||||||
),
|
),
|
||||||
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
|
]
|
||||||
),
|
.expandIndexed(
|
||||||
|
(idx, ele) => [
|
||||||
|
if (idx != 0 || _writeController.isRelatedNull) const Gap(8),
|
||||||
|
ele,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
),
|
),
|
||||||
]
|
),
|
||||||
.expandIndexed(
|
if (_writeController.attachments.isNotEmpty || _writeController.thumbnail != null)
|
||||||
(idx, ele) => [
|
Positioned(
|
||||||
if (idx != 0 || _writeController.isRelatedNull) const Gap(8),
|
bottom: 0,
|
||||||
ele,
|
left: 0,
|
||||||
],
|
right: 0,
|
||||||
)
|
child: PostMediaPendingList(
|
||||||
.toList(),
|
thumbnail: _writeController.thumbnail,
|
||||||
),
|
attachments: _writeController.attachments,
|
||||||
|
isBusy: _writeController.isBusy,
|
||||||
|
onUpload: (int idx) async {
|
||||||
|
await _writeController.uploadSingleAttachment(context, idx);
|
||||||
|
},
|
||||||
|
onPostSetThumbnail: (int? idx) {
|
||||||
|
_writeController.setThumbnail(idx);
|
||||||
|
},
|
||||||
|
onInsertLink: (int idx) async {
|
||||||
|
_writeController.contentController.text +=
|
||||||
|
'\n';
|
||||||
|
},
|
||||||
|
onUpdate: (int idx, PostWriteMedia updatedMedia) async {
|
||||||
|
_writeController.setIsBusy(true);
|
||||||
|
try {
|
||||||
|
_writeController.setAttachmentAt(idx, updatedMedia);
|
||||||
|
} finally {
|
||||||
|
_writeController.setIsBusy(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRemove: (int idx) async {
|
||||||
|
_writeController.setIsBusy(true);
|
||||||
|
try {
|
||||||
|
_writeController.removeAttachmentAt(idx);
|
||||||
|
} finally {
|
||||||
|
_writeController.setIsBusy(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onUpdateBusy: (state) => _writeController.setIsBusy(state),
|
||||||
|
).padding(bottom: 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_writeController.attachments.isNotEmpty || _writeController.thumbnail != null)
|
|
||||||
PostMediaPendingList(
|
|
||||||
thumbnail: _writeController.thumbnail,
|
|
||||||
attachments: _writeController.attachments,
|
|
||||||
isBusy: _writeController.isBusy,
|
|
||||||
onUpload: (int idx) async {
|
|
||||||
await _writeController.uploadSingleAttachment(context, idx);
|
|
||||||
},
|
|
||||||
onPostSetThumbnail: (int? idx) {
|
|
||||||
_writeController.setThumbnail(idx);
|
|
||||||
},
|
|
||||||
onInsertLink: (int idx) async {
|
|
||||||
_writeController.contentController.text +=
|
|
||||||
'\n';
|
|
||||||
},
|
|
||||||
onUpdate: (int idx, PostWriteMedia updatedMedia) async {
|
|
||||||
_writeController.setIsBusy(true);
|
|
||||||
try {
|
|
||||||
_writeController.setAttachmentAt(idx, updatedMedia);
|
|
||||||
} finally {
|
|
||||||
_writeController.setIsBusy(false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onRemove: (int idx) async {
|
|
||||||
_writeController.setIsBusy(true);
|
|
||||||
try {
|
|
||||||
_writeController.removeAttachmentAt(idx);
|
|
||||||
} finally {
|
|
||||||
_writeController.setIsBusy(false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onUpdateBusy: (state) => _writeController.setIsBusy(state),
|
|
||||||
).padding(bottom: 8),
|
|
||||||
Material(
|
Material(
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user