From 1d734b15e55101e218dbb86d2643424182bc6b00 Mon Sep 17 00:00:00 2001 From: lucien144 Date: Fri, 27 Sep 2024 12:00:52 +0200 Subject: [PATCH] feat: #453 for mails --- lib/components/mail_list_item.dart | 118 +++++++++++++++-------------- 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/lib/components/mail_list_item.dart b/lib/components/mail_list_item.dart index d93477f..32e64e4 100644 --- a/lib/components/mail_list_item.dart +++ b/lib/components/mail_list_item.dart @@ -32,15 +32,14 @@ class MailListItem extends ConsumerStatefulWidget { } class _MailListItemState extends ConsumerState { - void showMailContext() { showCupertinoModalBottomSheet( context: context, builder: (BuildContext context) => PostContextMenu( - parentContext: context, - item: widget.mail, - flagPostCallback: (mailId) => MainRepository().settings.blockMail(mailId), - )); + parentContext: context, + item: widget.mail, + flagPostCallback: (mailId) => MainRepository().settings.blockMail(mailId), + )); } @override @@ -50,61 +49,64 @@ class _MailListItemState extends ConsumerState { return Visibility( visible: !isDeleted, - child: GestureDetector( - onLongPress: showMailContext, - child: ContentBoxLayout( - isHighlighted: widget.mail.isNew, - isPreview: widget.isPreview == true, - content: widget.mail.content, - topLeftWidget: PostAvatar(widget.mail.direction == MailDirection.from ? widget.mail.participant : MainRepository().credentials!.nickname, - description: - '→ ${widget.mail.direction == MailDirection.to ? widget.mail.participant : MainRepository().credentials!.nickname}, ${Helpers.absoluteTime(widget.mail.time)} ~${Helpers.relativeTime(widget.mail.time)}'), - topRightWidget: Row( - children: [ - Visibility( - visible: widget.mail.isOutgoing && widget.mail.isUnread, - child: Icon( - MdiIcons.emailMarkAsUnread, - color: colors.text.withOpacity(0.38), - ), - ), - SizedBox( - width: 4, - ), - GestureFeedback( - child: Icon(Icons.more_vert, color: colors.text.withOpacity(0.38)), - onTap: showMailContext, - ), - ], + child: ContentBoxLayout( + isHighlighted: widget.mail.isNew, + isPreview: widget.isPreview == true, + content: widget.mail.content, + topLeftWidget: Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onLongPress: showMailContext, + child: PostAvatar(widget.mail.direction == MailDirection.from ? widget.mail.participant : MainRepository().credentials!.nickname, + description: + '→ ${widget.mail.direction == MailDirection.to ? widget.mail.participant : MainRepository().credentials!.nickname}, ${Helpers.absoluteTime(widget.mail.time)} ~${Helpers.relativeTime(widget.mail.time)}'), ), - bottomWidget: widget.isPreview == true - ? null - : Row(mainAxisAlignment: MainAxisAlignment.end, children: [ - GestureDetector( - behavior: HitTestBehavior.opaque, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [IconReply(), Text('Odpovědět', style: TextStyle(color: colors.text.withOpacity(0.38), fontSize: 14))], - ), - onTap: () => Navigator.of(context, rootNavigator: true).pushNamed('/new-message', - arguments: NewMessageSettings( - onSubmit: (String? inputField, String message, List> attachments) async { - if (inputField == null) { - return false; - } - var response = await ApiController().sendMail(inputField, message, attachments: attachments); - return response.isOk; - }, - onClose: this.widget.onUpdate!, - inputFieldPlaceholder: widget.mail.participant, - hasInputField: true, - replyWidget: MailListItem( - widget.mail, - isPreview: true, - ))), - ) - ]), ), + topRightWidget: Row( + children: [ + Visibility( + visible: widget.mail.isOutgoing && widget.mail.isUnread, + child: Icon( + MdiIcons.emailMarkAsUnread, + color: colors.text.withOpacity(0.38), + ), + ), + SizedBox( + width: 4, + ), + GestureFeedback( + child: Icon(Icons.more_vert, color: colors.text.withOpacity(0.38)), + onTap: showMailContext, + ), + ], + ), + bottomWidget: widget.isPreview == true + ? null + : Row(mainAxisAlignment: MainAxisAlignment.end, children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [IconReply(), Text('Odpovědět', style: TextStyle(color: colors.text.withOpacity(0.38), fontSize: 14))], + ), + onTap: () => Navigator.of(context, rootNavigator: true).pushNamed('/new-message', + arguments: NewMessageSettings( + onSubmit: (String? inputField, String message, List> attachments) async { + if (inputField == null) { + return false; + } + var response = await ApiController().sendMail(inputField, message, attachments: attachments); + return response.isOk; + }, + onClose: this.widget.onUpdate!, + inputFieldPlaceholder: widget.mail.participant, + hasInputField: true, + replyWidget: MailListItem( + widget.mail, + isPreview: true, + ))), + ) + ]), ), ); }