2024-11-10 10:37:34 +00:00
|
|
|
import 'package:dio/dio.dart';
|
2024-11-10 04:41:56 +00:00
|
|
|
import 'package:dropdown_button2/dropdown_button2.dart';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/gestures.dart';
|
2024-11-09 17:34:58 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-11-10 04:41:56 +00:00
|
|
|
import 'package:gap/gap.dart';
|
|
|
|
import 'package:go_router/go_router.dart';
|
2024-11-10 08:41:11 +00:00
|
|
|
import 'package:image_picker/image_picker.dart';
|
2024-11-10 04:41:56 +00:00
|
|
|
import 'package:material_symbols_icons/symbols.dart';
|
|
|
|
import 'package:styled_widget/styled_widget.dart';
|
2024-11-10 08:41:11 +00:00
|
|
|
import 'package:surface/providers/sn_attachment.dart';
|
2024-11-10 04:41:56 +00:00
|
|
|
import 'package:surface/providers/sn_network.dart';
|
2024-11-10 08:41:11 +00:00
|
|
|
import 'package:surface/types/attachment.dart';
|
2024-11-10 04:41:56 +00:00
|
|
|
import 'package:surface/types/post.dart';
|
|
|
|
import 'package:surface/widgets/account/account_image.dart';
|
2024-11-10 10:37:34 +00:00
|
|
|
import 'package:surface/widgets/loading_indicator.dart';
|
2024-11-10 04:41:56 +00:00
|
|
|
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
2024-11-10 10:37:34 +00:00
|
|
|
import 'package:surface/widgets/post/post_item.dart';
|
2024-11-10 08:41:11 +00:00
|
|
|
import 'package:surface/widgets/post/post_media_pending_list.dart';
|
2024-11-10 04:41:56 +00:00
|
|
|
import 'package:surface/widgets/post/post_meta_editor.dart';
|
2024-11-10 08:41:11 +00:00
|
|
|
import 'package:surface/widgets/dialog.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2024-11-09 17:34:58 +00:00
|
|
|
|
2024-11-10 04:41:56 +00:00
|
|
|
class PostEditorScreen extends StatefulWidget {
|
|
|
|
final String mode;
|
2024-11-10 10:37:34 +00:00
|
|
|
final int? postEditId;
|
|
|
|
final int? postReplyId;
|
|
|
|
final int? postRepostId;
|
|
|
|
const PostEditorScreen({
|
|
|
|
super.key,
|
|
|
|
required this.mode,
|
|
|
|
required this.postEditId,
|
|
|
|
required this.postReplyId,
|
|
|
|
required this.postRepostId,
|
|
|
|
});
|
2024-11-10 04:41:56 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<PostEditorScreen> createState() => _PostEditorScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PostEditorScreenState extends State<PostEditorScreen> {
|
|
|
|
static const Map<String, String> _kTitleMap = {
|
|
|
|
'stories': 'writePostTypeStory',
|
|
|
|
'articles': 'writePostTypeArticle',
|
|
|
|
};
|
|
|
|
|
|
|
|
bool _isBusy = false;
|
2024-11-10 10:37:34 +00:00
|
|
|
bool _isLoading = false;
|
2024-11-10 04:41:56 +00:00
|
|
|
|
|
|
|
SnPublisher? _publisher;
|
|
|
|
List<SnPublisher>? _publishers;
|
|
|
|
|
2024-11-10 08:41:11 +00:00
|
|
|
final List<XFile> _selectedMedia = List.empty(growable: true);
|
|
|
|
final List<SnAttachment> _attachments = List.empty(growable: true);
|
|
|
|
|
2024-11-10 10:37:34 +00:00
|
|
|
Future<void> _fetchPublishers() async {
|
2024-11-10 04:41:56 +00:00
|
|
|
final sn = context.read<SnNetworkProvider>();
|
|
|
|
final resp = await sn.client.get('/cgi/co/publishers');
|
|
|
|
_publishers = List<SnPublisher>.from(
|
|
|
|
resp.data?.map((e) => SnPublisher.fromJson(e)) ?? [],
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
_publisher = _publishers?.first;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-11-10 10:37:34 +00:00
|
|
|
SnPost? _editingOg;
|
|
|
|
SnPost? _replyingTo;
|
|
|
|
SnPost? _repostingTo;
|
|
|
|
|
|
|
|
Future<void> _fetchRelatedPost() async {
|
|
|
|
final sn = context.read<SnNetworkProvider>();
|
|
|
|
final attach = context.read<SnAttachmentProvider>();
|
|
|
|
|
|
|
|
try {
|
|
|
|
setState(() => _isLoading = true);
|
|
|
|
|
|
|
|
if (widget.postEditId != null) {
|
|
|
|
final resp = await sn.client.get('/cgi/co/posts/${widget.postEditId}');
|
|
|
|
final post = SnPost.fromJson(resp.data);
|
|
|
|
final attachments = await attach
|
|
|
|
.getMultiple(post.body['attachments']?.cast<String>() ?? []);
|
|
|
|
_title = post.body['title'];
|
|
|
|
_description = post.body['description'];
|
|
|
|
_contentController.text = post.body['content'] ?? '';
|
|
|
|
_attachments.addAll(attachments);
|
|
|
|
|
|
|
|
_editingOg = post.copyWith(
|
|
|
|
preload: SnPostPreload(
|
|
|
|
attachments: attachments,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget.postReplyId != null) {
|
|
|
|
final resp = await sn.client.get('/cgi/co/posts/${widget.postReplyId}');
|
|
|
|
final post = SnPost.fromJson(resp.data);
|
|
|
|
_replyingTo = post.copyWith(
|
|
|
|
preload: SnPostPreload(
|
|
|
|
attachments: await attach
|
|
|
|
.getMultiple(post.body['attachments']?.cast<String>() ?? []),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget.postRepostId != null) {
|
|
|
|
final resp =
|
|
|
|
await sn.client.get('/cgi/co/posts/${widget.postRepostId}');
|
|
|
|
final post = SnPost.fromJson(resp.data);
|
|
|
|
_repostingTo = post.copyWith(
|
|
|
|
preload: SnPostPreload(
|
|
|
|
attachments: await attach
|
|
|
|
.getMultiple(post.body['attachments']?.cast<String>() ?? []),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
context.showErrorDialog(err);
|
|
|
|
} finally {
|
|
|
|
setState(() => _isLoading = false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-10 04:41:56 +00:00
|
|
|
String? _title;
|
|
|
|
String? _description;
|
|
|
|
|
|
|
|
final TextEditingController _contentController = TextEditingController();
|
|
|
|
|
2024-11-10 08:41:11 +00:00
|
|
|
double? _progress;
|
|
|
|
|
2024-11-10 08:52:24 +00:00
|
|
|
static const kAttachmentProgressWeight = 0.9;
|
|
|
|
static const kPostingProgressWeight = 0.1;
|
|
|
|
|
2024-11-10 04:41:56 +00:00
|
|
|
void _performAction() async {
|
|
|
|
if (_isBusy || _publisher == null) return;
|
|
|
|
|
|
|
|
final sn = context.read<SnNetworkProvider>();
|
2024-11-10 08:41:11 +00:00
|
|
|
final attach = context.read<SnAttachmentProvider>();
|
2024-11-10 04:41:56 +00:00
|
|
|
|
2024-11-10 08:52:24 +00:00
|
|
|
setState(() {
|
|
|
|
_progress = 0;
|
|
|
|
_isBusy = true;
|
|
|
|
});
|
2024-11-10 04:41:56 +00:00
|
|
|
|
2024-11-10 08:41:11 +00:00
|
|
|
// Uploading attachments
|
|
|
|
try {
|
2024-11-10 08:52:24 +00:00
|
|
|
for (int i = 0; i < _selectedMedia.length; i++) {
|
|
|
|
final media = _selectedMedia[i];
|
2024-11-10 08:41:11 +00:00
|
|
|
final place = await attach.chunkedUploadInitialize(
|
|
|
|
await media.length(),
|
|
|
|
media.name,
|
|
|
|
'interactive',
|
|
|
|
null,
|
|
|
|
);
|
2024-11-10 08:52:24 +00:00
|
|
|
|
|
|
|
final item = await attach.chunkedUploadParts(
|
|
|
|
media,
|
|
|
|
place.$1,
|
|
|
|
place.$2,
|
|
|
|
onProgress: (progress) {
|
|
|
|
// Calculate overall progress for attachments
|
|
|
|
setState(() {
|
|
|
|
_progress = ((i + progress) / _selectedMedia.length) *
|
|
|
|
kAttachmentProgressWeight;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2024-11-10 08:41:11 +00:00
|
|
|
_attachments.add(item);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
2024-11-10 08:52:24 +00:00
|
|
|
if (!mounted) return;
|
2024-11-10 08:41:11 +00:00
|
|
|
context.showErrorDialog(err);
|
2024-11-10 08:52:24 +00:00
|
|
|
setState(() => _isBusy = false);
|
2024-11-10 08:41:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-11-10 08:52:24 +00:00
|
|
|
setState(() => _progress = kAttachmentProgressWeight);
|
|
|
|
|
|
|
|
// Posting the content
|
2024-11-10 04:41:56 +00:00
|
|
|
try {
|
2024-11-10 08:52:24 +00:00
|
|
|
final baseProgressVal = _progress!;
|
2024-11-10 10:37:34 +00:00
|
|
|
await sn.client.request(
|
|
|
|
[
|
|
|
|
'/cgi/co/${widget.mode}',
|
|
|
|
if (widget.postEditId != null) '${widget.postEditId}',
|
|
|
|
].join('/'),
|
|
|
|
data: {
|
|
|
|
'publisher': _publisher!.id,
|
|
|
|
'content': _contentController.value.text,
|
|
|
|
'title': _title,
|
|
|
|
'description': _description,
|
|
|
|
'attachments': _attachments.map((e) => e.rid).toList(),
|
2024-11-10 12:07:26 +00:00
|
|
|
if (_replyingTo != null) 'reply_to': _replyingTo!.id,
|
|
|
|
if (_repostingTo != null) 'repost_to': _repostingTo!.id,
|
2024-11-10 10:37:34 +00:00
|
|
|
},
|
|
|
|
onSendProgress: (count, total) {
|
|
|
|
setState(() {
|
|
|
|
_progress = baseProgressVal +
|
|
|
|
(count / total) * (kPostingProgressWeight / 2);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onReceiveProgress: (count, total) {
|
|
|
|
setState(() {
|
|
|
|
_progress = baseProgressVal +
|
|
|
|
(kPostingProgressWeight / 2) +
|
|
|
|
(count / total) * (kPostingProgressWeight / 2);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
options: Options(
|
|
|
|
method: widget.postEditId != null ? 'PUT' : 'POST',
|
|
|
|
),
|
|
|
|
);
|
2024-11-10 08:52:24 +00:00
|
|
|
if (!mounted) return;
|
2024-11-10 04:41:56 +00:00
|
|
|
Navigator.pop(context, true);
|
|
|
|
} catch (err) {
|
2024-11-10 08:52:24 +00:00
|
|
|
if (!mounted) return;
|
2024-11-10 04:41:56 +00:00
|
|
|
context.showErrorDialog(err);
|
|
|
|
} finally {
|
|
|
|
setState(() => _isBusy = false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _updateMeta() {
|
|
|
|
showModalBottomSheet<PostMetaResult?>(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => PostMetaEditor(
|
|
|
|
initialTitle: _title,
|
|
|
|
initialDescription: _description,
|
|
|
|
),
|
|
|
|
useRootNavigator: true,
|
|
|
|
).then((value) {
|
|
|
|
if (value is PostMetaResult) {
|
|
|
|
_title = value.title;
|
|
|
|
_description = value.description;
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-11-10 08:41:11 +00:00
|
|
|
final _imagePicker = ImagePicker();
|
|
|
|
|
|
|
|
void _selectMedia() async {
|
|
|
|
final result = await _imagePicker.pickMultipleMedia();
|
|
|
|
if (result.isEmpty) return;
|
|
|
|
_selectedMedia.addAll(result);
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
2024-11-10 04:41:56 +00:00
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_contentController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
if (!_kTitleMap.keys.contains(widget.mode)) {
|
|
|
|
context.showErrorDialog('Unknown post type');
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
2024-11-10 10:37:34 +00:00
|
|
|
_fetchRelatedPost();
|
2024-11-10 04:41:56 +00:00
|
|
|
_fetchPublishers();
|
|
|
|
}
|
2024-11-09 17:34:58 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-11-10 04:41:56 +00:00
|
|
|
return AppScaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
leading: BackButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
flexibleSpace: Column(
|
|
|
|
children: [
|
|
|
|
Text(_title ?? 'Untitled')
|
|
|
|
.textStyle(Theme.of(context).textTheme.titleLarge!)
|
|
|
|
.textColor(Colors.white),
|
|
|
|
Text(_kTitleMap[widget.mode]!)
|
|
|
|
.tr()
|
|
|
|
.textColor(Colors.white.withAlpha((255 * 0.9).round())),
|
|
|
|
],
|
|
|
|
).padding(top: MediaQuery.of(context).padding.top),
|
|
|
|
actions: [
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Symbols.tune),
|
|
|
|
onPressed: _isBusy ? null : _updateMeta,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
DropdownButtonHideUnderline(
|
|
|
|
child: DropdownButton2<SnPublisher>(
|
|
|
|
isExpanded: true,
|
|
|
|
hint: Text(
|
|
|
|
'fieldPostPublisher',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Theme.of(context).hintColor,
|
|
|
|
),
|
|
|
|
).tr(),
|
|
|
|
items: <DropdownMenuItem<SnPublisher>>[
|
|
|
|
...(_publishers?.map(
|
|
|
|
(item) => DropdownMenuItem<SnPublisher>(
|
2024-11-10 10:37:34 +00:00
|
|
|
enabled: _editingOg == null,
|
2024-11-10 04:41:56 +00:00
|
|
|
value: item,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
AccountImage(content: item.avatar, radius: 16),
|
|
|
|
const Gap(8),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(item.nick).textStyle(
|
|
|
|
Theme.of(context).textTheme.bodyMedium!),
|
|
|
|
Text('@${item.name}')
|
|
|
|
.textStyle(Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.bodySmall!)
|
|
|
|
.fontSize(12),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
) ??
|
|
|
|
[]),
|
|
|
|
DropdownMenuItem<SnPublisher>(
|
|
|
|
value: null,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
CircleAvatar(
|
|
|
|
radius: 16,
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
foregroundColor:
|
|
|
|
Theme.of(context).colorScheme.onSurface,
|
|
|
|
child: const Icon(Symbols.add),
|
|
|
|
),
|
|
|
|
const Gap(8),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text('publishersNew').tr().textStyle(
|
|
|
|
Theme.of(context).textTheme.bodyMedium!),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
value: _publisher,
|
|
|
|
onChanged: (SnPublisher? value) {
|
|
|
|
if (value == null) {
|
|
|
|
GoRouter.of(context)
|
|
|
|
.pushNamed('accountPublisherNew')
|
|
|
|
.then((value) {
|
|
|
|
if (value == true) {
|
|
|
|
_publisher = null;
|
|
|
|
_publishers = null;
|
|
|
|
_fetchPublishers();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setState(() {
|
|
|
|
_publisher = value;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
buttonStyleData: const ButtonStyleData(
|
|
|
|
padding: EdgeInsets.only(right: 16),
|
|
|
|
height: 48,
|
|
|
|
),
|
|
|
|
menuItemStyleData: const MenuItemStyleData(
|
|
|
|
height: 48,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const Divider(height: 1),
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
2024-11-10 12:07:26 +00:00
|
|
|
padding: EdgeInsets.only(bottom: 8),
|
2024-11-10 04:41:56 +00:00
|
|
|
child: Column(
|
|
|
|
children: [
|
2024-11-10 12:07:26 +00:00
|
|
|
// Replying Notice
|
|
|
|
if (_replyingTo != null)
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Theme(
|
|
|
|
data: Theme.of(context).copyWith(
|
|
|
|
dividerColor: Colors.transparent,
|
|
|
|
),
|
|
|
|
child: ExpansionTile(
|
|
|
|
minTileHeight: 48,
|
|
|
|
leading: const Icon(Symbols.reply).padding(left: 4),
|
|
|
|
title: Text('postReplyingNotice')
|
|
|
|
.fontSize(15)
|
|
|
|
.tr(args: ['@${_replyingTo!.publisher.name}']),
|
|
|
|
children: <Widget>[PostItem(data: _replyingTo!)],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const Divider(height: 1),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
// Reposting Notice
|
|
|
|
if (_repostingTo != null)
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Theme(
|
|
|
|
data: Theme.of(context).copyWith(
|
|
|
|
dividerColor: Colors.transparent,
|
|
|
|
),
|
|
|
|
child: ExpansionTile(
|
|
|
|
minTileHeight: 48,
|
|
|
|
leading:
|
|
|
|
const Icon(Symbols.forward).padding(left: 4),
|
|
|
|
title: Text('postRepostingNotice')
|
|
|
|
.fontSize(15)
|
|
|
|
.tr(args: ['@${_repostingTo!.publisher.name}']),
|
|
|
|
children: <Widget>[PostItem(data: _repostingTo!)],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const Divider(height: 1),
|
|
|
|
],
|
|
|
|
),
|
2024-11-10 10:37:34 +00:00
|
|
|
// Editing Notice
|
|
|
|
if (_editingOg != null)
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Theme(
|
2024-11-10 12:07:26 +00:00
|
|
|
data: Theme.of(context).copyWith(
|
|
|
|
dividerColor: Colors.transparent,
|
|
|
|
),
|
2024-11-10 10:37:34 +00:00
|
|
|
child: ExpansionTile(
|
|
|
|
minTileHeight: 48,
|
|
|
|
leading:
|
|
|
|
const Icon(Symbols.edit_note).padding(left: 4),
|
|
|
|
title: Text('postEditingNotice')
|
|
|
|
.fontSize(15)
|
|
|
|
.tr(args: ['@${_editingOg!.publisher.name}']),
|
2024-11-10 12:07:26 +00:00
|
|
|
children: <Widget>[PostItem(data: _editingOg!)],
|
2024-11-10 10:37:34 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const Divider(height: 1),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
// Content Input Area
|
2024-11-10 04:41:56 +00:00
|
|
|
TextField(
|
|
|
|
controller: _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(),
|
|
|
|
)
|
2024-11-10 12:07:26 +00:00
|
|
|
].expand((ele) => [ele, const Gap(8)]).toList()
|
|
|
|
..removeLast(),
|
2024-11-10 04:41:56 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-11-10 08:41:11 +00:00
|
|
|
if (_selectedMedia.isNotEmpty)
|
|
|
|
PostMediaPendingList(
|
|
|
|
data: _selectedMedia,
|
|
|
|
onRemove: (idx) {
|
|
|
|
setState(() {
|
|
|
|
_selectedMedia.removeAt(idx);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
).padding(bottom: 8),
|
2024-11-10 04:41:56 +00:00
|
|
|
Material(
|
|
|
|
elevation: 2,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2024-11-10 12:07:26 +00:00
|
|
|
LoadingIndicator(isActive: _isLoading),
|
2024-11-10 09:21:57 +00:00
|
|
|
if (_isBusy && _progress != null)
|
|
|
|
TweenAnimationBuilder<double>(
|
|
|
|
tween: Tween(begin: 0, end: 1),
|
|
|
|
duration: Duration(milliseconds: 300),
|
|
|
|
builder: (context, value, _) =>
|
|
|
|
LinearProgressIndicator(value: value, minHeight: 2),
|
|
|
|
)
|
|
|
|
else if (_isBusy)
|
|
|
|
const LinearProgressIndicator(value: null, minHeight: 2),
|
2024-11-10 04:41:56 +00:00
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: ScrollConfiguration(
|
|
|
|
behavior: _PostEditorActionScrollBehavior(),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
IconButton(
|
2024-11-10 08:41:11 +00:00
|
|
|
onPressed: _isBusy ? null : _selectMedia,
|
2024-11-10 04:41:56 +00:00
|
|
|
icon: Icon(
|
|
|
|
Symbols.add_photo_alternate,
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TextButton.icon(
|
|
|
|
onPressed: (_isBusy || _publisher == null)
|
|
|
|
? null
|
|
|
|
: _performAction,
|
|
|
|
icon: const Icon(Symbols.send),
|
|
|
|
label: Text('postPublish').tr(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
).padding(horizontal: 16),
|
|
|
|
],
|
|
|
|
).padding(
|
|
|
|
bottom: MediaQuery.of(context).padding.bottom,
|
|
|
|
top: 4,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2024-11-09 17:34:58 +00:00
|
|
|
}
|
|
|
|
}
|
2024-11-10 04:41:56 +00:00
|
|
|
|
|
|
|
class _PostEditorActionScrollBehavior extends MaterialScrollBehavior {
|
|
|
|
@override
|
|
|
|
Set<PointerDeviceKind> get dragDevices => {
|
|
|
|
PointerDeviceKind.touch,
|
|
|
|
PointerDeviceKind.mouse,
|
|
|
|
};
|
|
|
|
}
|