TF-4075 Change attachments location

(cherry picked from commit ab23dac45d9dcf7c5e057f8e16974b3ed8205771)
This commit is contained in:
dab246
2025-10-06 19:17:25 +07:00
committed by Dat H. Pham
parent 993b05fbc2
commit 6bbebd8e67
31 changed files with 540 additions and 486 deletions
@@ -52,79 +52,40 @@ class AttachmentsInfo extends StatelessWidget {
style: ThemeUtils.textStyleInter400.copyWith(
fontSize: 15,
height: 20 / 15,
letterSpacing: -0.24,
color: AppColor.gray99A2AD,
),
);
if (responsiveUtils.isMobile(context)) {
return Row(
children: [
iconAttachment,
Expanded(
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 8, end: 3),
child: titleHeaderAttachment,
),
return Row(
children: [
iconAttachment,
Expanded(
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 8, end: 3),
child: titleHeaderAttachment,
),
if (displayShowAll && numberOfAttachments > 3)
_buildShowAllButton(context),
],
);
} else {
return Row(
children: [
iconAttachment,
Expanded(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 8, end: 3),
child: titleHeaderAttachment,
),
),
if (displayShowAll && numberOfAttachments > 4)
_buildShowAllButton(context),
],
),
if (onTapDownloadAllButton != null)
TMailButtonWidget(
text: AppLocalizations.of(context).archiveAndDownload,
icon: imagePaths.icDownloadAll,
iconSize: 20,
iconColor: AppColor.steelGrayA540,
iconAlignment: TextDirection.rtl,
backgroundColor: Colors.transparent,
borderRadius: 5,
mainAxisSize: MainAxisSize.min,
flexibleText: true,
maxLines: 1,
maxWidth: 300,
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 5),
textStyle: ThemeUtils.textStyleBodyBody1().copyWith(
color: AppColor.steelGray400,
),
onTapActionCallback: onTapDownloadAllButton,
),
if (onTapDownloadAllButton != null)
TMailButtonWidget(
text: AppLocalizations.of(context).archiveAndDownload,
icon: imagePaths.icDownloadAll,
iconSize: 20,
iconColor: AppColor.steelGrayA540,
iconAlignment: TextDirection.rtl,
backgroundColor: Colors.transparent,
borderRadius: 5,
mainAxisSize: MainAxisSize.min,
flexibleText: true,
maxLines: 1,
maxWidth: 300,
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 5),
textStyle: ThemeUtils.textStyleBodyBody1().copyWith(
color: AppColor.steelGray400,
),
onTapActionCallback: onTapDownloadAllButton,
),
],
);
}
}
Widget _buildShowAllButton(BuildContext context) {
return TMailButtonWidget.fromText(
text: AppLocalizations.of(context).showAll,
backgroundColor: Colors.transparent,
textStyle: ThemeUtils.textStyleBodyBody1().copyWith(
color: AppColor.steelGray400,
),
borderRadius: 5,
maxLines: 1,
maxWidth: 120,
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 5),
onTapActionCallback: onTapShowAllAttachmentFile,
],
);
}
}
@@ -1,10 +1,10 @@
import 'package:core/presentation/action/action_callback_define.dart';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/button/tmail_button_widget.dart';
import 'package:core/presentation/views/dialog/confirm_dialog_button.dart';
import 'package:core/utils/app_logger.dart';
import 'package:core/utils/platform_info.dart';
import 'package:filesize/filesize.dart';
import 'package:flutter/material.dart';
import 'package:model/email/attachment.dart';
@@ -41,7 +41,7 @@ class EmailAttachmentsWidget extends StatelessWidget {
this.viewAttachmentAction,
this.onTapShowAllAttachmentFile,
this.showDownloadAllAttachmentsButton = false,
this.isDisplayAllAttachments = true,
this.isDisplayAllAttachments = false,
this.onTapDownloadAllButton,
this.singleEmailControllerTag,
});
@@ -68,20 +68,17 @@ class EmailAttachmentsWidget extends StatelessWidget {
final hiddenItemsCount = attachmentRecord.hiddenItemsCount;
return Padding(
padding: const EdgeInsetsDirectional.only(top: 12, bottom: 24),
padding: const EdgeInsetsDirectional.only(
start: 16,
end: 16,
bottom: 24,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
attachmentHeader,
Padding(
padding: const EdgeInsetsDirectional.symmetric(horizontal: 12),
child: attachmentHeader,
),
Padding(
padding: const EdgeInsetsDirectional.only(
start: 12,
end: 12,
top: 4,
),
padding: const EdgeInsetsDirectional.only(top: 4),
child: Column(
children: displayedAttachments.map((attachment) {
return AttachmentItemWidget(
@@ -95,189 +92,106 @@ class EmailAttachmentsWidget extends StatelessWidget {
}).toList(),
),
),
const SizedBox(height: 12),
if (hiddenItemsCount > 0 && showDownloadAllAttachmentsButton)
Padding(
padding: const EdgeInsetsDirectional.symmetric(horizontal: 8),
child: Row(
children: [
TMailButtonWidget.fromText(
text: AppLocalizations.of(context).moreAttachments(
hiddenItemsCount,
),
backgroundColor: Colors.transparent,
borderRadius: 5,
maxWidth: 120,
maxLines: 1,
textStyle: ThemeUtils.textStyleM3TitleSmall,
padding: const EdgeInsets.symmetric(
vertical: 3,
horizontal: 5,
),
onTapActionCallback: onTapShowAllAttachmentFile,
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: TMailButtonWidget(
text: AppLocalizations
.of(context)
.archiveAndDownload,
icon: imagePaths.icDownloadAll,
iconSize: 20,
iconColor: AppColor.steelGrayA540,
iconAlignment: TextDirection.rtl,
backgroundColor: Colors.transparent,
borderRadius: 5,
mainAxisSize: MainAxisSize.min,
maxLines: 1,
flexibleText: true,
padding: const EdgeInsets.symmetric(
vertical: 3,
horizontal: 5,
),
textStyle: ThemeUtils.textStyleBodyBody1()
.copyWith(color: AppColor.steelGray400),
onTapActionCallback: onTapDownloadAllButton,
),
),
],
),
),
],
),
)
else if (hiddenItemsCount > 0)
TMailButtonWidget.fromText(
text: AppLocalizations.of(context).moreAttachments(
hiddenItemsCount,
),
backgroundColor: Colors.transparent,
borderRadius: 5,
maxLines: 1,
textStyle: ThemeUtils.textStyleM3TitleSmall,
padding: const EdgeInsets.symmetric(
vertical: 3,
horizontal: 5,
),
margin: const EdgeInsetsDirectional.symmetric(horizontal: 8),
onTapActionCallback: onTapShowAllAttachmentFile,
)
else if (showDownloadAllAttachmentsButton)
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Flexible(
child: TMailButtonWidget(
text: AppLocalizations.of(context).archiveAndDownload,
icon: imagePaths.icDownloadAll,
iconSize: 20,
iconColor: AppColor.steelGrayA540,
iconAlignment: TextDirection.rtl,
backgroundColor: Colors.transparent,
borderRadius: 5,
mainAxisSize: MainAxisSize.min,
maxLines: 1,
flexibleText: true,
padding: const EdgeInsets.symmetric(
vertical: 3,
horizontal: 5,
),
margin: const EdgeInsetsDirectional.symmetric(
horizontal: 8,
),
textStyle: ThemeUtils.textStyleBodyBody1().copyWith(
color: AppColor.steelGray400,
),
onTapActionCallback: onTapDownloadAllButton,
),
),
],
const SizedBox(height: 8),
if (hiddenItemsCount > 0)
SizedBox(
height: 36,
width: double.infinity,
child: ConfirmDialogButton(
label: AppLocalizations.of(context).moreAttachments(
hiddenItemsCount,
),
backgroundColor: Theme.of(context).colorScheme.outline.withValues(
alpha: 0.08,
),
textStyle: ThemeUtils.textStyleM3TitleSmall,
radius: 5,
onTapAction: onTapShowAllAttachmentFile,
),
),
],
),
);
} else {
return Padding(
padding: const EdgeInsetsDirectional.only(
start: 16,
end: 16,
top: 16,
bottom: 28,
start: 8,
end: 8,
top: 12,
bottom: 16,
),
child: LayoutBuilder(
builder: (context, constraints) {
final attachmentRecord = _getDisplayedAndHiddenAttachment(
context,
constraints.maxWidth,
);
final displayedAttachments = attachmentRecord.displayedAttachments;
final hiddenItemsCount = attachmentRecord.hiddenItemsCount;
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsetsDirectional.symmetric(horizontal: 12),
child: attachmentHeader,
),
Padding(
padding: const EdgeInsetsDirectional.only(
start: 12,
end: 12,
top: 12,
),
child: LayoutBuilder(
builder: (context, constraints) {
final attachmentRecord = _getDisplayedAndHiddenAttachment(
context,
constraints.maxWidth,
);
final displayedAttachments = attachmentRecord.displayedAttachments;
final hiddenItemsCount = attachmentRecord.hiddenItemsCount;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsetsDirectional.symmetric(horizontal: 12),
child: attachmentHeader,
),
Padding(
padding: const EdgeInsetsDirectional.only(
start: 12,
end: 12,
top: 12,
),
child: Wrap(
spacing: 8,
runSpacing: isDisplayAllAttachments ? 8 : 0,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
...displayedAttachments.map((attachment) {
if (responsiveUtils.isDesktop(context)) {
return DraggableAttachmentItemWidget(
attachment: attachment,
imagePaths: imagePaths,
width: EmailUtils.desktopItemMaxWidth,
onDragStarted: onDragStarted,
onDragEnd: onDragEnd,
downloadAttachmentAction: downloadAttachmentAction,
viewAttachmentAction: viewAttachmentAction,
singleEmailControllerTag: singleEmailControllerTag,
);
} else {
return AttachmentItemWidget(
attachment: attachment,
imagePaths: imagePaths,
width: EmailUtils.desktopItemMaxWidth,
downloadAttachmentAction: downloadAttachmentAction,
viewAttachmentAction: viewAttachmentAction,
singleEmailControllerTag: singleEmailControllerTag,
);
}
}).toList(),
if (hiddenItemsCount > 0)
TMailButtonWidget.fromText(
text: '+ $hiddenItemsCount',
backgroundColor: Colors.transparent,
borderRadius: 5,
maxWidth: EmailUtils.desktopMoreButtonMaxWidth,
maxLines: 1,
textStyle: ThemeUtils.textStyleM3TitleSmall,
padding: const EdgeInsets.symmetric(
vertical: 3,
horizontal: 5,
return Wrap(
spacing: EmailUtils.attachmentItemSpacing,
runSpacing: isDisplayAllAttachments
? EmailUtils.attachmentItemSpacing
: 0,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
...displayedAttachments.map((attachment) {
if (PlatformInfo.isWeb &&
responsiveUtils.isDesktop(context)) {
return DraggableAttachmentItemWidget(
attachment: attachment,
imagePaths: imagePaths,
width: EmailUtils.desktopItemMaxWidth,
onDragStarted: onDragStarted,
onDragEnd: onDragEnd,
downloadAttachmentAction: downloadAttachmentAction,
viewAttachmentAction: viewAttachmentAction,
singleEmailControllerTag: singleEmailControllerTag,
);
} else {
return AttachmentItemWidget(
attachment: attachment,
imagePaths: imagePaths,
width: EmailUtils.desktopItemMaxWidth,
downloadAttachmentAction: downloadAttachmentAction,
viewAttachmentAction: viewAttachmentAction,
singleEmailControllerTag: singleEmailControllerTag,
);
}
}).toList(),
if (hiddenItemsCount > 0)
SizedBox(
height: 36,
child: ConfirmDialogButton(
label: '+$hiddenItemsCount',
backgroundColor: Theme.of(context).colorScheme.outline.withValues(
alpha: 0.08,
),
textStyle: ThemeUtils.textStyleM3TitleSmall,
radius: 5,
onTapAction: onTapShowAllAttachmentFile,
),
),
onTapActionCallback: onTapShowAllAttachmentFile,
),
],
),
),
],
);
}
],
);
}
),
),
],
),
);
}
@@ -182,6 +182,7 @@ class _EmailReceiverWidgetState extends State<EmailReceiverWidget> {
fontSize: 15
),
backgroundColor: Colors.transparent,
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 5),
onTapActionCallback: () => setState(() => _isDisplayAll = false),
)
]