2024-05-19 10:01:00 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_animate/flutter_animate.dart';
|
2024-05-23 12:00:26 +00:00
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
2024-05-19 10:01:00 +00:00
|
|
|
import 'package:get/get.dart';
|
2024-07-30 08:29:30 +00:00
|
|
|
import 'package:intl/intl.dart';
|
2024-08-01 06:46:01 +00:00
|
|
|
import 'package:markdown_toolbar/markdown_toolbar.dart';
|
2024-07-30 06:49:26 +00:00
|
|
|
import 'package:solian/controllers/post_editor_controller.dart';
|
2024-08-01 17:00:31 +00:00
|
|
|
import 'package:solian/controllers/post_list_controller.dart';
|
2024-05-19 16:08:20 +00:00
|
|
|
import 'package:solian/exts.dart';
|
2024-05-21 16:05:03 +00:00
|
|
|
import 'package:solian/models/post.dart';
|
2024-05-29 14:42:11 +00:00
|
|
|
import 'package:solian/models/realm.dart';
|
2024-08-01 14:36:00 +00:00
|
|
|
import 'package:solian/providers/attachment_uploader.dart';
|
2024-05-19 10:01:00 +00:00
|
|
|
import 'package:solian/providers/auth.dart';
|
|
|
|
import 'package:solian/router.dart';
|
2024-06-22 15:59:11 +00:00
|
|
|
import 'package:solian/theme.dart';
|
2024-07-12 14:31:45 +00:00
|
|
|
import 'package:solian/widgets/app_bar_leading.dart';
|
2024-06-22 15:59:11 +00:00
|
|
|
import 'package:solian/widgets/app_bar_title.dart';
|
2024-05-21 16:05:03 +00:00
|
|
|
import 'package:solian/widgets/posts/post_item.dart';
|
2024-07-09 13:23:38 +00:00
|
|
|
import 'package:badges/badges.dart' as badges;
|
2024-05-21 16:05:03 +00:00
|
|
|
|
2024-07-09 13:23:38 +00:00
|
|
|
class PostPublishArguments {
|
2024-05-21 16:05:03 +00:00
|
|
|
final Post? edit;
|
|
|
|
final Post? reply;
|
|
|
|
final Post? repost;
|
2024-05-29 14:42:11 +00:00
|
|
|
final Realm? realm;
|
2024-08-01 17:00:31 +00:00
|
|
|
final PostListController? postListController;
|
2024-05-21 16:05:03 +00:00
|
|
|
|
2024-08-01 17:00:31 +00:00
|
|
|
PostPublishArguments({
|
|
|
|
this.edit,
|
|
|
|
this.reply,
|
|
|
|
this.repost,
|
|
|
|
this.realm,
|
|
|
|
this.postListController,
|
|
|
|
});
|
2024-05-21 16:05:03 +00:00
|
|
|
}
|
2024-05-19 10:01:00 +00:00
|
|
|
|
2024-07-09 13:23:38 +00:00
|
|
|
class PostPublishScreen extends StatefulWidget {
|
2024-05-21 16:05:03 +00:00
|
|
|
final Post? edit;
|
|
|
|
final Post? reply;
|
|
|
|
final Post? repost;
|
2024-05-29 14:42:11 +00:00
|
|
|
final Realm? realm;
|
2024-08-01 17:00:31 +00:00
|
|
|
final PostListController? postListController;
|
2024-07-30 08:53:13 +00:00
|
|
|
final int mode;
|
2024-05-21 16:05:03 +00:00
|
|
|
|
2024-07-09 13:23:38 +00:00
|
|
|
const PostPublishScreen({
|
2024-05-21 16:05:03 +00:00
|
|
|
super.key,
|
|
|
|
this.edit,
|
|
|
|
this.reply,
|
|
|
|
this.repost,
|
|
|
|
this.realm,
|
2024-08-01 17:00:31 +00:00
|
|
|
this.postListController,
|
2024-07-30 08:53:13 +00:00
|
|
|
required this.mode,
|
2024-05-21 16:05:03 +00:00
|
|
|
});
|
2024-05-19 10:01:00 +00:00
|
|
|
|
|
|
|
@override
|
2024-07-09 13:23:38 +00:00
|
|
|
State<PostPublishScreen> createState() => _PostPublishScreenState();
|
2024-05-19 10:01:00 +00:00
|
|
|
}
|
|
|
|
|
2024-07-09 13:23:38 +00:00
|
|
|
class _PostPublishScreenState extends State<PostPublishScreen> {
|
2024-07-30 06:49:26 +00:00
|
|
|
final _editorController = PostEditorController();
|
2024-08-01 06:46:01 +00:00
|
|
|
final _contentFocusNode = FocusNode();
|
2024-05-19 10:01:00 +00:00
|
|
|
|
2024-05-25 16:11:00 +00:00
|
|
|
bool _isBusy = false;
|
2024-05-19 10:01:00 +00:00
|
|
|
|
2024-07-30 06:49:26 +00:00
|
|
|
void _applyPost() async {
|
2024-05-19 10:01:00 +00:00
|
|
|
final AuthProvider auth = Get.find();
|
2024-07-24 17:18:47 +00:00
|
|
|
if (auth.isAuthorized.isFalse) return;
|
2024-07-30 06:49:26 +00:00
|
|
|
if (_editorController.isEmpty) return;
|
2024-05-19 10:01:00 +00:00
|
|
|
|
2024-08-01 14:36:00 +00:00
|
|
|
final AttachmentUploaderController uploader = Get.find();
|
|
|
|
if (uploader.queueOfUpload.any(
|
|
|
|
((x) => x.usage == 'i.attachment' && x.isUploading),
|
|
|
|
)) {
|
|
|
|
context.showErrorDialog('attachmentUploadInProgress'.tr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-05-25 16:11:00 +00:00
|
|
|
setState(() => _isBusy = true);
|
2024-05-19 10:01:00 +00:00
|
|
|
|
2024-06-22 14:39:32 +00:00
|
|
|
final client = auth.configureClient('interactive');
|
2024-05-19 10:01:00 +00:00
|
|
|
|
2024-05-21 16:05:03 +00:00
|
|
|
Response resp;
|
|
|
|
if (widget.edit != null) {
|
2024-07-30 06:49:26 +00:00
|
|
|
resp = await client.put(
|
2024-07-30 08:44:04 +00:00
|
|
|
'/${_editorController.typeEndpoint}/${widget.edit!.id}',
|
2024-07-30 06:49:26 +00:00
|
|
|
_editorController.payload,
|
|
|
|
);
|
2024-05-21 16:05:03 +00:00
|
|
|
} else {
|
2024-07-30 06:49:26 +00:00
|
|
|
resp = await client.post(
|
2024-07-30 08:44:04 +00:00
|
|
|
'/${_editorController.typeEndpoint}',
|
2024-07-30 06:49:26 +00:00
|
|
|
_editorController.payload,
|
|
|
|
);
|
2024-05-21 16:05:03 +00:00
|
|
|
}
|
2024-05-19 10:01:00 +00:00
|
|
|
if (resp.statusCode != 200) {
|
2024-05-19 16:08:20 +00:00
|
|
|
context.showErrorDialog(resp.bodyString);
|
2024-05-19 10:01:00 +00:00
|
|
|
} else {
|
2024-07-30 08:29:30 +00:00
|
|
|
_editorController.localClear();
|
2024-08-01 17:00:31 +00:00
|
|
|
if (widget.postListController != null) {
|
|
|
|
widget.postListController!.reloadAllOver();
|
|
|
|
}
|
2024-05-19 10:01:00 +00:00
|
|
|
AppRouter.instance.pop(resp.body);
|
|
|
|
}
|
|
|
|
|
2024-05-25 16:11:00 +00:00
|
|
|
setState(() => _isBusy = false);
|
2024-05-19 10:01:00 +00:00
|
|
|
}
|
|
|
|
|
2024-08-01 07:49:42 +00:00
|
|
|
void _syncWidget() {
|
2024-07-30 08:53:13 +00:00
|
|
|
_editorController.mode.value = widget.mode;
|
2024-05-21 16:05:03 +00:00
|
|
|
if (widget.edit != null) {
|
2024-07-30 06:49:26 +00:00
|
|
|
_editorController.editTarget = widget.edit;
|
2024-05-21 16:05:03 +00:00
|
|
|
}
|
2024-08-01 07:21:43 +00:00
|
|
|
if (widget.realm != null) {
|
|
|
|
_editorController.realmZone.value = widget.realm;
|
|
|
|
}
|
2024-05-21 16:05:03 +00:00
|
|
|
}
|
|
|
|
|
2024-08-01 14:36:00 +00:00
|
|
|
void _cancelAction() {
|
2024-08-01 08:09:09 +00:00
|
|
|
_editorController.localClear();
|
2024-05-21 16:05:03 +00:00
|
|
|
AppRouter.instance.pop();
|
|
|
|
}
|
|
|
|
|
2024-08-01 03:49:28 +00:00
|
|
|
Post? get _editTo => _editorController.editTo.value;
|
2024-08-01 14:36:00 +00:00
|
|
|
|
2024-08-01 03:49:28 +00:00
|
|
|
Post? get _replyTo => _editorController.replyTo.value;
|
2024-08-01 14:36:00 +00:00
|
|
|
|
2024-08-01 03:49:28 +00:00
|
|
|
Post? get _repostTo => _editorController.repostTo.value;
|
|
|
|
|
2024-05-21 16:05:03 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2024-08-04 04:55:05 +00:00
|
|
|
if (widget.edit == null && widget.reply == null && widget.repost == null) {
|
|
|
|
_editorController.localRead();
|
|
|
|
}
|
|
|
|
if (widget.reply != null) {
|
|
|
|
_editorController.replyTo.value = widget.reply;
|
|
|
|
}
|
|
|
|
if (widget.repost != null) {
|
|
|
|
_editorController.repostTo.value = widget.repost;
|
|
|
|
}
|
2024-08-01 06:46:01 +00:00
|
|
|
_editorController.contentController.addListener(() => setState(() {}));
|
2024-08-01 07:49:42 +00:00
|
|
|
_syncWidget();
|
2024-05-21 16:05:03 +00:00
|
|
|
}
|
|
|
|
|
2024-05-19 10:01:00 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-05-21 16:05:03 +00:00
|
|
|
final notifyBannerActions = [
|
|
|
|
TextButton(
|
2024-08-01 14:36:00 +00:00
|
|
|
onPressed: _cancelAction,
|
2024-05-21 16:05:03 +00:00
|
|
|
child: Text('cancel'.tr),
|
|
|
|
)
|
|
|
|
];
|
|
|
|
|
2024-05-19 10:01:00 +00:00
|
|
|
return Material(
|
2024-05-21 16:05:03 +00:00
|
|
|
color: Theme.of(context).colorScheme.surface,
|
2024-05-19 10:01:00 +00:00
|
|
|
child: Scaffold(
|
|
|
|
appBar: AppBar(
|
2024-07-12 14:37:58 +00:00
|
|
|
leading: AppBarLeadingButton.adaptive(context),
|
2024-07-30 08:53:13 +00:00
|
|
|
title: Obx(
|
|
|
|
() => AppBarTitle(
|
|
|
|
_editorController.mode.value == 0
|
|
|
|
? 'postEditorModeStory'.tr
|
|
|
|
: 'postEditorModeArticle'.tr,
|
|
|
|
),
|
|
|
|
),
|
2024-06-22 15:59:11 +00:00
|
|
|
centerTitle: false,
|
|
|
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
2024-05-19 10:01:00 +00:00
|
|
|
actions: [
|
|
|
|
TextButton(
|
2024-07-30 06:49:26 +00:00
|
|
|
onPressed: _isBusy ? null : () => _applyPost(),
|
|
|
|
child: Obx(
|
|
|
|
() => Text(
|
|
|
|
_editorController.isDraft.isTrue
|
|
|
|
? 'draftSave'.tr.toUpperCase()
|
|
|
|
: 'postAction'.tr.toUpperCase(),
|
|
|
|
),
|
2024-07-09 13:23:38 +00:00
|
|
|
),
|
2024-05-19 10:01:00 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2024-07-30 06:49:26 +00:00
|
|
|
body: Column(
|
2024-08-01 06:46:01 +00:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2024-07-09 14:39:44 +00:00
|
|
|
children: [
|
2024-07-30 06:49:26 +00:00
|
|
|
ListTile(
|
|
|
|
tileColor: Theme.of(context).colorScheme.surfaceContainerLow,
|
|
|
|
title: Text(
|
|
|
|
_editorController.title ?? 'title'.tr,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
_editorController.description ?? 'description'.tr,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
contentPadding: const EdgeInsets.only(
|
2024-07-30 12:49:01 +00:00
|
|
|
left: 17,
|
2024-07-30 06:49:26 +00:00
|
|
|
right: 8,
|
|
|
|
top: 0,
|
|
|
|
bottom: 0,
|
|
|
|
),
|
|
|
|
trailing: IconButton(
|
|
|
|
icon: const Icon(Icons.edit),
|
|
|
|
onPressed: () {
|
|
|
|
_editorController.editOverview(context).then((_) {
|
|
|
|
setState(() {});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2024-08-01 06:46:01 +00:00
|
|
|
if (_editTo != null && _editTo!.isDraft != true)
|
|
|
|
MaterialBanner(
|
|
|
|
leading: const Icon(Icons.edit),
|
|
|
|
leadingPadding: const EdgeInsets.only(left: 10, right: 20),
|
|
|
|
dividerColor: Colors.transparent,
|
|
|
|
content: Text('postEditingNotify'.tr),
|
|
|
|
actions: notifyBannerActions,
|
|
|
|
),
|
|
|
|
if (_replyTo != null)
|
|
|
|
ExpansionTile(
|
|
|
|
leading: const FaIcon(
|
|
|
|
FontAwesomeIcons.reply,
|
|
|
|
size: 18,
|
|
|
|
).paddingOnly(left: 2),
|
|
|
|
title: Text('postReplyingNotify'.trParams(
|
|
|
|
{'username': '@${widget.reply!.author.name}'},
|
|
|
|
)),
|
|
|
|
collapsedBackgroundColor:
|
|
|
|
Theme.of(context).colorScheme.surfaceContainer,
|
|
|
|
children: [
|
2024-08-04 04:55:05 +00:00
|
|
|
Container(
|
|
|
|
constraints: const BoxConstraints(maxHeight: 280),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: PostItem(
|
|
|
|
item: _replyTo!,
|
|
|
|
isReactable: false,
|
|
|
|
).paddingOnly(bottom: 8),
|
|
|
|
),
|
|
|
|
),
|
2024-08-01 06:46:01 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
if (_repostTo != null)
|
|
|
|
ExpansionTile(
|
|
|
|
leading: const FaIcon(
|
|
|
|
FontAwesomeIcons.retweet,
|
|
|
|
size: 18,
|
|
|
|
).paddingOnly(left: 2),
|
|
|
|
title: Text('postRepostingNotify'.trParams(
|
|
|
|
{'username': '@${widget.repost!.author.name}'},
|
|
|
|
)),
|
|
|
|
collapsedBackgroundColor:
|
|
|
|
Theme.of(context).colorScheme.surfaceContainer,
|
|
|
|
children: [
|
2024-08-04 04:55:05 +00:00
|
|
|
Container(
|
|
|
|
constraints: const BoxConstraints(maxHeight: 280),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: PostItem(
|
|
|
|
item: _repostTo!,
|
|
|
|
isReactable: false,
|
|
|
|
).paddingOnly(bottom: 8),
|
|
|
|
),
|
|
|
|
),
|
2024-08-01 06:46:01 +00:00
|
|
|
],
|
|
|
|
),
|
2024-07-30 06:49:26 +00:00
|
|
|
Expanded(
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
|
|
|
if (_isBusy)
|
|
|
|
const LinearProgressIndicator().animate().scaleX(),
|
|
|
|
Container(
|
2024-07-30 12:49:01 +00:00
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 16,
|
|
|
|
vertical: 8,
|
|
|
|
),
|
2024-07-30 06:49:26 +00:00
|
|
|
child: TextField(
|
|
|
|
maxLines: null,
|
|
|
|
autofocus: true,
|
|
|
|
autocorrect: true,
|
|
|
|
keyboardType: TextInputType.multiline,
|
|
|
|
controller: _editorController.contentController,
|
2024-08-01 06:46:01 +00:00
|
|
|
focusNode: _contentFocusNode,
|
|
|
|
decoration: InputDecoration.collapsed(
|
2024-07-30 06:49:26 +00:00
|
|
|
hintText: 'postContentPlaceholder'.tr,
|
|
|
|
),
|
|
|
|
onTapOutside: (_) =>
|
|
|
|
FocusManager.instance.primaryFocus?.unfocus(),
|
2024-05-19 10:01:00 +00:00
|
|
|
),
|
|
|
|
),
|
2024-07-30 06:49:26 +00:00
|
|
|
const SizedBox(height: 120)
|
|
|
|
],
|
|
|
|
),
|
2024-07-09 14:39:44 +00:00
|
|
|
),
|
2024-07-30 06:49:26 +00:00
|
|
|
Material(
|
|
|
|
color: Theme.of(context).colorScheme.surface,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2024-07-30 08:29:30 +00:00
|
|
|
Obx(() {
|
|
|
|
final textStyle = TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.onSurface
|
|
|
|
.withOpacity(0.75),
|
|
|
|
);
|
|
|
|
final showFactors = [
|
|
|
|
_editorController.isRestoreFromLocal.value,
|
|
|
|
_editorController.lastSaveTime.value != null,
|
|
|
|
];
|
|
|
|
final doShow = showFactors.any((x) => x);
|
|
|
|
return Container(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
vertical: 4,
|
|
|
|
horizontal: 16,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
if (showFactors[0])
|
|
|
|
Text('postRestoreFromLocal'.tr, style: textStyle)
|
|
|
|
.paddingOnly(right: 4),
|
|
|
|
if (showFactors[0])
|
|
|
|
InkWell(
|
|
|
|
child: Text('clear'.tr, style: textStyle),
|
|
|
|
onTap: () {
|
|
|
|
_editorController.localClear();
|
|
|
|
_editorController.currentClear();
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
if (showFactors.where((x) => x).length > 1)
|
|
|
|
Text(
|
|
|
|
'·',
|
|
|
|
style: textStyle,
|
|
|
|
).paddingSymmetric(horizontal: 8),
|
|
|
|
if (showFactors[1])
|
|
|
|
Text(
|
|
|
|
'postAutoSaveAt'.trParams({
|
|
|
|
'date': DateFormat('HH:mm:ss').format(
|
|
|
|
_editorController.lastSaveTime.value ??
|
|
|
|
DateTime.now(),
|
|
|
|
)
|
|
|
|
}),
|
|
|
|
style: textStyle,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
2024-07-30 12:49:01 +00:00
|
|
|
.animate(
|
|
|
|
key: const Key('post-editor-hint-animation'),
|
|
|
|
target: doShow ? 1 : 0,
|
|
|
|
)
|
2024-07-30 08:29:30 +00:00
|
|
|
.fade(curve: Curves.easeInOut, duration: 300.ms);
|
|
|
|
}),
|
2024-07-30 06:49:26 +00:00
|
|
|
if (_editorController.mode.value == 0)
|
|
|
|
Obx(
|
|
|
|
() => TweenAnimationBuilder<double>(
|
|
|
|
tween: Tween(
|
|
|
|
begin: 0,
|
|
|
|
end: _editorController.contentLength.value / 4096,
|
|
|
|
),
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
curve: Curves.easeInOut,
|
|
|
|
builder: (context, value, _) => LinearProgressIndicator(
|
|
|
|
minHeight: 2,
|
|
|
|
color: _editorController.contentLength.value > 4096
|
|
|
|
? Colors.red[900]
|
|
|
|
: Theme.of(context).colorScheme.primary,
|
|
|
|
value: value,
|
|
|
|
),
|
|
|
|
),
|
2024-07-07 03:46:48 +00:00
|
|
|
),
|
2024-07-30 06:49:26 +00:00
|
|
|
SizedBox(
|
|
|
|
height: 56,
|
|
|
|
child: ListView(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
children: [
|
2024-07-30 12:49:01 +00:00
|
|
|
Obx(() {
|
|
|
|
final isDraft = _editorController.isDraft.value;
|
|
|
|
return IconButton(
|
|
|
|
icon: const Icon(
|
|
|
|
Icons.drive_file_rename_outline,
|
|
|
|
color: Colors.grey,
|
|
|
|
)
|
|
|
|
.animate(
|
|
|
|
target: isDraft ? 0 : 1,
|
|
|
|
)
|
|
|
|
.fadeOut(duration: 150.ms)
|
|
|
|
.swap(
|
|
|
|
duration: 150.ms,
|
|
|
|
builder: (_, __) => const Icon(
|
|
|
|
Icons.public,
|
|
|
|
color: Colors.green,
|
|
|
|
).animate().fadeIn(duration: 150.ms),
|
|
|
|
),
|
2024-07-09 13:23:38 +00:00
|
|
|
onPressed: () {
|
2024-07-30 06:49:26 +00:00
|
|
|
_editorController.toggleDraftMode();
|
2024-07-09 13:23:38 +00:00
|
|
|
},
|
2024-07-30 12:49:01 +00:00
|
|
|
);
|
|
|
|
}),
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.disabled_visible),
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
onPressed: () {
|
|
|
|
_editorController.editVisibility(context);
|
|
|
|
},
|
2024-07-30 06:49:26 +00:00
|
|
|
),
|
|
|
|
IconButton(
|
2024-07-30 12:49:01 +00:00
|
|
|
icon: Obx(() {
|
|
|
|
return badges.Badge(
|
2024-07-09 15:06:55 +00:00
|
|
|
badgeContent: Text(
|
2024-07-30 06:49:26 +00:00
|
|
|
_editorController.attachments.length.toString(),
|
2024-07-09 15:06:55 +00:00
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
),
|
2024-07-30 06:49:26 +00:00
|
|
|
showBadge:
|
|
|
|
_editorController.attachments.isNotEmpty,
|
2024-07-09 15:06:55 +00:00
|
|
|
position: badges.BadgePosition.topEnd(
|
|
|
|
top: -12,
|
|
|
|
end: -8,
|
|
|
|
),
|
2024-07-30 12:49:01 +00:00
|
|
|
child: const Icon(Icons.file_present_rounded),
|
|
|
|
);
|
|
|
|
}),
|
2024-07-30 06:49:26 +00:00
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2024-07-30 12:49:01 +00:00
|
|
|
onPressed: () {
|
|
|
|
_editorController.editAttachment(context);
|
|
|
|
},
|
2024-07-30 06:49:26 +00:00
|
|
|
),
|
2024-07-30 18:00:03 +00:00
|
|
|
IconButton(
|
2024-08-01 03:49:28 +00:00
|
|
|
icon: Obx(() {
|
|
|
|
return badges.Badge(
|
|
|
|
badgeContent: Text(
|
|
|
|
_editorController.tags.length.toString(),
|
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
showBadge: _editorController.tags.isNotEmpty,
|
|
|
|
position: badges.BadgePosition.topEnd(
|
|
|
|
top: -12,
|
|
|
|
end: -8,
|
|
|
|
),
|
|
|
|
child: const Icon(Icons.label),
|
|
|
|
);
|
|
|
|
}),
|
2024-07-30 18:00:03 +00:00
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
onPressed: () {
|
|
|
|
_editorController.editCategoriesAndTags(context);
|
|
|
|
},
|
|
|
|
),
|
2024-08-01 07:21:43 +00:00
|
|
|
IconButton(
|
|
|
|
icon: Obx(() {
|
|
|
|
return badges.Badge(
|
|
|
|
showBadge:
|
|
|
|
_editorController.realmZone.value != null,
|
|
|
|
position: badges.BadgePosition.topEnd(
|
|
|
|
top: -4,
|
|
|
|
end: -6,
|
|
|
|
),
|
|
|
|
child: const Icon(Icons.workspaces),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
onPressed: () {
|
|
|
|
_editorController.editPublishZone(context);
|
|
|
|
},
|
|
|
|
),
|
2024-08-01 07:49:42 +00:00
|
|
|
IconButton(
|
|
|
|
icon: Obx(() {
|
|
|
|
return badges.Badge(
|
|
|
|
showBadge:
|
|
|
|
_editorController.publishedAt.value != null ||
|
|
|
|
_editorController.publishedUntil.value !=
|
|
|
|
null,
|
|
|
|
position: badges.BadgePosition.topEnd(
|
|
|
|
top: -4,
|
|
|
|
end: -6,
|
|
|
|
),
|
|
|
|
child: const Icon(Icons.schedule),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
onPressed: () {
|
|
|
|
_editorController.editPublishDate(context);
|
|
|
|
},
|
|
|
|
),
|
2024-08-01 06:46:01 +00:00
|
|
|
MarkdownToolbar(
|
|
|
|
hideImage: true,
|
|
|
|
useIncludedTextField: false,
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
iconColor: Theme.of(context).colorScheme.onSurface,
|
|
|
|
controller: _editorController.contentController,
|
|
|
|
focusNode: _contentFocusNode,
|
|
|
|
borderRadius:
|
|
|
|
const BorderRadius.all(Radius.circular(20)),
|
|
|
|
width: 40,
|
|
|
|
).paddingSymmetric(horizontal: 4),
|
2024-07-30 06:49:26 +00:00
|
|
|
],
|
|
|
|
).paddingSymmetric(horizontal: 6, vertical: 8),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
).paddingOnly(bottom: MediaQuery.of(context).padding.bottom),
|
2024-07-09 14:39:44 +00:00
|
|
|
),
|
|
|
|
],
|
2024-05-19 10:01:00 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2024-07-07 03:46:48 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
2024-08-01 06:46:01 +00:00
|
|
|
_contentFocusNode.dispose();
|
2024-07-30 06:49:26 +00:00
|
|
|
_editorController.dispose();
|
2024-07-07 03:46:48 +00:00
|
|
|
super.dispose();
|
|
|
|
}
|
2024-05-19 10:01:00 +00:00
|
|
|
}
|