From 76cf08830b53917a6b40e7780bb6bbd05156f2b3 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 7 Dec 2024 23:40:26 +0800 Subject: [PATCH] :bug: Fix unable to repost --- lib/controllers/post_write_controller.dart | 2 +- lib/screens/album.dart | 2 +- lib/widgets/attachment/attachment_list.dart | 2 +- ...hment_detail.dart => attachment_zoom.dart} | 0 lib/widgets/chat/chat_message_input.dart | 49 ++++++++----------- lib/widgets/markdown_content.dart | 2 +- lib/widgets/post/post_media_pending_list.dart | 2 +- 7 files changed, 25 insertions(+), 34 deletions(-) rename lib/widgets/attachment/{attachment_detail.dart => attachment_zoom.dart} (100%) diff --git a/lib/controllers/post_write_controller.dart b/lib/controllers/post_write_controller.dart index 90d1b8b..ae8fa98 100644 --- a/lib/controllers/post_write_controller.dart +++ b/lib/controllers/post_write_controller.dart @@ -220,7 +220,7 @@ class PostWriteController extends ChangeNotifier { if (reposting != null) { final post = await pt.getPost(reposting); - replyingPost = post; + repostingPost = post; } } catch (err) { if (!context.mounted) return; diff --git a/lib/screens/album.dart b/lib/screens/album.dart index 0484c83..58afe18 100644 --- a/lib/screens/album.dart +++ b/lib/screens/album.dart @@ -7,7 +7,7 @@ import 'package:styled_widget/styled_widget.dart'; import 'package:surface/providers/sn_network.dart'; import 'package:surface/types/attachment.dart'; import 'package:surface/widgets/app_bar_leading.dart'; -import 'package:surface/widgets/attachment/attachment_detail.dart'; +import 'package:surface/widgets/attachment/attachment_zoom.dart'; import 'package:surface/widgets/attachment/attachment_item.dart'; import 'package:surface/widgets/dialog.dart'; import 'package:uuid/uuid.dart'; diff --git a/lib/widgets/attachment/attachment_list.dart b/lib/widgets/attachment/attachment_list.dart index 14cf6b5..eeddebc 100644 --- a/lib/widgets/attachment/attachment_list.dart +++ b/lib/widgets/attachment/attachment_list.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; import 'package:responsive_framework/responsive_framework.dart'; import 'package:surface/types/attachment.dart'; -import 'package:surface/widgets/attachment/attachment_detail.dart'; +import 'package:surface/widgets/attachment/attachment_zoom.dart'; import 'package:surface/widgets/attachment/attachment_item.dart'; import 'package:uuid/uuid.dart'; diff --git a/lib/widgets/attachment/attachment_detail.dart b/lib/widgets/attachment/attachment_zoom.dart similarity index 100% rename from lib/widgets/attachment/attachment_detail.dart rename to lib/widgets/attachment/attachment_zoom.dart diff --git a/lib/widgets/chat/chat_message_input.dart b/lib/widgets/chat/chat_message_input.dart index c8fc447..e7a17f1 100644 --- a/lib/widgets/chat/chat_message_input.dart +++ b/lib/widgets/chat/chat_message_input.dart @@ -16,6 +16,7 @@ import 'package:surface/widgets/post/post_media_pending_list.dart'; class ChatMessageInput extends StatefulWidget { final ChatMessageController controller; + const ChatMessageInput({super.key, required this.controller}); @override @@ -74,9 +75,7 @@ class ChatMessageInputState extends State { media.name, 'interactive', null, - mimetype: media.raw != null && media.type == PostWriteMediaType.image - ? 'image/png' - : null, + mimetype: media.raw != null && media.type == PostWriteMediaType.image ? 'image/png' : null, ); final item = await attach.chunkedUploadParts( @@ -110,10 +109,7 @@ class ChatMessageInputState extends State { widget.controller.sendMessage( 'messages.new', _contentController.text, - attachments: _attachments - .where((e) => e.attachment != null) - .map((e) => e.attachment!.rid) - .toList(), + attachments: _attachments.where((e) => e.attachment != null).map((e) => e.attachment!.rid).toList(), relatedId: _editingMessage?.id, quoteId: _replyingMessage?.id, editingMessage: _editingMessage, @@ -167,15 +163,12 @@ class ChatMessageInputState extends State { TweenAnimationBuilder( tween: Tween(begin: 0, end: _progress), duration: Duration(milliseconds: 300), - builder: (context, value, _) => - LinearProgressIndicator(value: value, minHeight: 2), + builder: (context, value, _) => LinearProgressIndicator(value: value, minHeight: 2), ) else if (_isBusy) const LinearProgressIndicator(value: null, minHeight: 2), Padding( - padding: _attachments.isNotEmpty - ? const EdgeInsets.only(top: 8) - : EdgeInsets.zero, + padding: _attachments.isNotEmpty ? const EdgeInsets.only(top: 8) : EdgeInsets.zero, child: PostMediaPendingList( attachments: _attachments, isBusy: _isBusy, @@ -187,18 +180,18 @@ class ChatMessageInputState extends State { }, onUpdateBusy: (state) => setState(() => _isBusy = state), ), - ).height(_attachments.isNotEmpty ? 80 + 8 : 0, animate: true).animate( - const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut), + ) + .height(_attachments.isNotEmpty ? 80 + 8 : 0, animate: true) + .animate(const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut), SingleChildScrollView( physics: const NeverScrollableScrollPhysics(), child: Padding( - padding: _replyingMessage != null - ? const EdgeInsets.only(top: 8) - : EdgeInsets.zero, + padding: _replyingMessage != null ? const EdgeInsets.only(top: 8) : EdgeInsets.zero, child: _replyingMessage != null ? MaterialBanner( padding: const EdgeInsets.only(left: 16.0), leading: const Icon(Symbols.reply), + backgroundColor: Colors.transparent, content: SingleChildScrollView( physics: const NeverScrollableScrollPhysics(), child: Column( @@ -223,18 +216,18 @@ class ChatMessageInputState extends State { ) : const SizedBox.shrink(), ), - ).height(_replyingMessage != null ? 54 + 8 : 0, animate: true).animate( - const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut), + ) + .height(_replyingMessage != null ? 54 + 8 : 0, animate: true) + .animate(const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut), SingleChildScrollView( physics: const NeverScrollableScrollPhysics(), child: Padding( - padding: _editingMessage != null - ? const EdgeInsets.only(top: 8) - : EdgeInsets.zero, + padding: _editingMessage != null ? const EdgeInsets.only(top: 8) : EdgeInsets.zero, child: _editingMessage != null ? MaterialBanner( padding: const EdgeInsets.only(left: 16.0), leading: const Icon(Symbols.edit), + backgroundColor: Colors.transparent, content: SingleChildScrollView( physics: const NeverScrollableScrollPhysics(), child: Column( @@ -259,8 +252,9 @@ class ChatMessageInputState extends State { ) : const SizedBox.shrink(), ), - ).height(_editingMessage != null ? 54 + 8 : 0, animate: true).animate( - const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut), + ) + .height(_editingMessage != null ? 54 + 8 : 0, animate: true) + .animate(const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut), SizedBox( height: 56, child: Row( @@ -271,13 +265,10 @@ class ChatMessageInputState extends State { controller: _contentController, decoration: InputDecoration( isCollapsed: true, - hintText: 'fieldChatMessage'.tr(args: [ - widget.controller.channel?.name ?? 'loading'.tr() - ]), + hintText: 'fieldChatMessage'.tr(args: [widget.controller.channel?.name ?? 'loading'.tr()]), border: InputBorder.none, ), - onTapOutside: (_) => - FocusManager.instance.primaryFocus?.unfocus(), + onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), onSubmitted: (_) { if (_isBusy) return; _sendMessage(); diff --git a/lib/widgets/markdown_content.dart b/lib/widgets/markdown_content.dart index 497b4ea..558dd01 100644 --- a/lib/widgets/markdown_content.dart +++ b/lib/widgets/markdown_content.dart @@ -15,7 +15,7 @@ import 'package:url_launcher/url_launcher_string.dart'; import 'package:path/path.dart'; import 'package:uuid/uuid.dart'; -import 'attachment/attachment_detail.dart'; +import 'attachment/attachment_zoom.dart'; class MarkdownTextContent extends StatelessWidget { final String content; diff --git a/lib/widgets/post/post_media_pending_list.dart b/lib/widgets/post/post_media_pending_list.dart index 42e0abb..8681ae0 100644 --- a/lib/widgets/post/post_media_pending_list.dart +++ b/lib/widgets/post/post_media_pending_list.dart @@ -13,7 +13,7 @@ import 'package:provider/provider.dart'; import 'package:styled_widget/styled_widget.dart'; import 'package:surface/controllers/post_write_controller.dart'; import 'package:surface/providers/sn_network.dart'; -import 'package:surface/widgets/attachment/attachment_detail.dart'; +import 'package:surface/widgets/attachment/attachment_zoom.dart'; import 'package:surface/widgets/dialog.dart'; class PostMediaPendingList extends StatelessWidget {