Change order of attachment and mail body on mobile
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
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/container/tmail_container_widget.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:extended_text/extended_text.dart';
|
||||
import 'package:filesize/filesize.dart';
|
||||
@@ -10,7 +12,6 @@ import 'package:get/get.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/controller/single_email_controller.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/extensions/attachment_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/attachment/attachment_item_widget_style.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||
|
||||
typedef OnDownloadAttachmentFileAction = void Function(Attachment attachment);
|
||||
@@ -19,16 +20,17 @@ typedef OnViewAttachmentFileAction = void Function(Attachment attachment);
|
||||
class AttachmentItemWidget extends StatelessWidget {
|
||||
|
||||
final Attachment attachment;
|
||||
final ImagePaths imagePaths;
|
||||
final double? width;
|
||||
final OnDownloadAttachmentFileAction? downloadAttachmentAction;
|
||||
final OnViewAttachmentFileAction? viewAttachmentAction;
|
||||
final String? singleEmailControllerTag;
|
||||
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
AttachmentItemWidget({
|
||||
const AttachmentItemWidget({
|
||||
Key? key,
|
||||
required this.attachment,
|
||||
required this.imagePaths,
|
||||
this.width,
|
||||
this.downloadAttachmentAction,
|
||||
this.viewAttachmentAction,
|
||||
this.singleEmailControllerTag,
|
||||
@@ -36,91 +38,105 @@ class AttachmentItemWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(
|
||||
() {
|
||||
final controller = Get.find<SingleEmailController>(tag: singleEmailControllerTag);
|
||||
final attachmentsViewState = controller.attachmentsViewState;
|
||||
bool isLoading = false;
|
||||
if (attachment.blobId != null) {
|
||||
isLoading = !EmailUtils.checkingIfAttachmentActionIsEnabled(
|
||||
return Obx(() {
|
||||
final controller = Get.find<SingleEmailController>(tag: singleEmailControllerTag);
|
||||
final attachmentsViewState = controller.attachmentsViewState;
|
||||
bool isLoading = false;
|
||||
if (attachment.blobId != null) {
|
||||
isLoading = !EmailUtils.checkingIfAttachmentActionIsEnabled(
|
||||
attachmentsViewState[attachment.blobId!]);
|
||||
}
|
||||
}
|
||||
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: isLoading ? null : () => (viewAttachmentAction ?? downloadAttachmentAction)?.call(attachment),
|
||||
customBorder: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(AttachmentItemWidgetStyle.radius))
|
||||
),
|
||||
child: Container(
|
||||
padding: AttachmentItemWidgetStyle.contentPadding,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(AttachmentItemWidgetStyle.radius)),
|
||||
border: Border.all(color: AttachmentItemWidgetStyle.borderColor),
|
||||
),
|
||||
width: AttachmentItemWidgetStyle.getMaxWidthItem(
|
||||
platformIsMobile: PlatformInfo.isMobile,
|
||||
responsiveIsMobile: _responsiveUtils.isMobile(context),
|
||||
responsiveIsTablet: _responsiveUtils.isTablet(context),
|
||||
responsiveIsTabletLarge: _responsiveUtils.isTabletLarge(context),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
isLoading
|
||||
? const SizedBox(
|
||||
width: AttachmentItemWidgetStyle.iconSize,
|
||||
height: AttachmentItemWidgetStyle.iconSize,
|
||||
child: CircularProgressIndicator(strokeWidth: 2))
|
||||
: SvgPicture.asset(attachment.getIcon(_imagePaths),
|
||||
width: AttachmentItemWidgetStyle.iconSize,
|
||||
height: AttachmentItemWidgetStyle.iconSize,
|
||||
fit: BoxFit.fill
|
||||
),
|
||||
const SizedBox(width: AttachmentItemWidgetStyle.space),
|
||||
Expanded(
|
||||
child: PlatformInfo.isCanvasKit
|
||||
? ExtendedText(
|
||||
(attachment.name ?? ''),
|
||||
maxLines: 1,
|
||||
overflowWidget: TextOverflowWidget(
|
||||
position: TextOverflowPosition.middle,
|
||||
clearType: TextOverflowClearType.clipRect,
|
||||
child: Text(
|
||||
"...",
|
||||
style: AttachmentItemWidgetStyle.dotsLabelTextStyle,
|
||||
),
|
||||
),
|
||||
style: AttachmentItemWidgetStyle.labelTextStyle,
|
||||
)
|
||||
: Text(
|
||||
(attachment.name ?? ''),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AttachmentItemWidgetStyle.labelTextStyle,
|
||||
)
|
||||
),
|
||||
const SizedBox(width: AttachmentItemWidgetStyle.space),
|
||||
Text(
|
||||
filesize(attachment.size?.value),
|
||||
maxLines: 1,
|
||||
style: AttachmentItemWidgetStyle.sizeLabelTextStyle,
|
||||
),
|
||||
TMailButtonWidget.fromIcon(
|
||||
icon: _imagePaths.icDownloadAttachment,
|
||||
backgroundColor: Colors.transparent,
|
||||
padding: const EdgeInsets.all(5),
|
||||
iconSize: AttachmentItemWidgetStyle.downloadIconSize,
|
||||
onTapActionCallback: isLoading
|
||||
? null
|
||||
: () => downloadAttachmentAction?.call(attachment)
|
||||
)
|
||||
]
|
||||
)
|
||||
const loadingIndicator = SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
);
|
||||
|
||||
final attachmentIcon = SvgPicture.asset(
|
||||
attachment.getIcon(imagePaths),
|
||||
width: 20,
|
||||
height: 20,
|
||||
fit: BoxFit.fill,
|
||||
);
|
||||
|
||||
final attachmentTitleWithMiddleDots = ExtendedText(
|
||||
attachment.generateFileName(),
|
||||
maxLines: 1,
|
||||
overflowWidget: TextOverflowWidget(
|
||||
position: TextOverflowPosition.middle,
|
||||
clearType: TextOverflowClearType.clipRect,
|
||||
child: Text(
|
||||
"...",
|
||||
style: ThemeUtils.textStyleM3LabelLarge(
|
||||
color: AppColor.m3SurfaceBackground,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
),
|
||||
style: ThemeUtils.textStyleM3LabelLarge(
|
||||
color: AppColor.m3SurfaceBackground,
|
||||
),
|
||||
);
|
||||
|
||||
final attachmentTitleWithEndDots = Text(
|
||||
attachment.generateFileName(),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: ThemeUtils.textStyleM3LabelLarge(
|
||||
color: AppColor.m3SurfaceBackground,
|
||||
),
|
||||
);
|
||||
|
||||
final bodyItemWidget = Row(
|
||||
children: [
|
||||
isLoading ? loadingIndicator : attachmentIcon,
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: PlatformInfo.isCanvasKit
|
||||
? attachmentTitleWithMiddleDots
|
||||
: attachmentTitleWithEndDots,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
filesize(attachment.size?.value),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: ThemeUtils.textStyleM3LabelSmall,
|
||||
),
|
||||
),
|
||||
TMailButtonWidget.fromIcon(
|
||||
icon: imagePaths.icFileDownload,
|
||||
backgroundColor: Colors.transparent,
|
||||
padding: const EdgeInsets.all(5),
|
||||
iconColor: AppColor.steelGrayA540,
|
||||
iconSize: 20,
|
||||
onTapActionCallback:
|
||||
isLoading ? null : () => _onTapDownloadAction(attachment),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
return TMailContainerWidget(
|
||||
height: 36,
|
||||
borderRadius: 8,
|
||||
border: Border.all(color: AppColor.m3Tertiary70),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
backgroundColor: Colors.transparent,
|
||||
width: width,
|
||||
margin: const EdgeInsets.only(top: 8),
|
||||
onTapActionCallback:
|
||||
isLoading ? null : () => _onViewOrDownloadAction(attachment),
|
||||
child: bodyItemWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void _onTapDownloadAction(Attachment attachment) {
|
||||
downloadAttachmentAction?.call(attachment);
|
||||
}
|
||||
|
||||
void _onViewOrDownloadAction(Attachment attachment) {
|
||||
(viewAttachmentAction ?? downloadAttachmentAction)?.call(attachment);
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,8 @@ 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/utils/platform_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/email_attachments_styles.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class AttachmentsInfo extends StatelessWidget {
|
||||
@@ -17,7 +15,6 @@ class AttachmentsInfo extends StatelessWidget {
|
||||
required this.totalSizeInfo,
|
||||
required this.responsiveUtils,
|
||||
this.onTapShowAllAttachmentFile,
|
||||
this.downloadAllEnabled = false,
|
||||
this.onTapDownloadAllButton,
|
||||
});
|
||||
|
||||
@@ -26,75 +23,97 @@ class AttachmentsInfo extends StatelessWidget {
|
||||
final String totalSizeInfo;
|
||||
final ResponsiveUtils responsiveUtils;
|
||||
final VoidCallback? onTapShowAllAttachmentFile;
|
||||
final bool downloadAllEnabled;
|
||||
final VoidCallback? onTapDownloadAllButton;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> attachmentsAmountAndSize = [
|
||||
SvgPicture.asset(
|
||||
imagePaths.icAttachment,
|
||||
width: EmailAttachmentsStyles.headerIconSize,
|
||||
height: EmailAttachmentsStyles.headerIconSize,
|
||||
colorFilter: EmailAttachmentsStyles.headerIconColor.asFilter(),
|
||||
fit: BoxFit.fill
|
||||
),
|
||||
const SizedBox(width: EmailAttachmentsStyles.headerSpace),
|
||||
Text(
|
||||
AppLocalizations.of(context).titleHeaderAttachment(
|
||||
numberOfAttachments,
|
||||
totalSizeInfo,
|
||||
),
|
||||
style: ThemeUtils.defaultTextStyleInterFont.copyWith(
|
||||
fontSize: EmailAttachmentsStyles.headerTextSize,
|
||||
fontWeight: EmailAttachmentsStyles.headerFontWeight,
|
||||
color: EmailAttachmentsStyles.headerTextColor
|
||||
)
|
||||
),
|
||||
];
|
||||
|
||||
final showAllAttachments = (numberOfAttachments > 2)
|
||||
? TMailButtonWidget(
|
||||
text: AppLocalizations.of(context).showAll,
|
||||
backgroundColor: Colors.transparent,
|
||||
borderRadius: EmailAttachmentsStyles.buttonBorderRadius,
|
||||
padding: EmailAttachmentsStyles.buttonPadding,
|
||||
textStyle: ThemeUtils.defaultTextStyleInterFont.copyWith(
|
||||
fontSize: EmailAttachmentsStyles.buttonTextSize,
|
||||
color: EmailAttachmentsStyles.buttonTextColor,
|
||||
fontWeight: EmailAttachmentsStyles.buttonFontWeight
|
||||
),
|
||||
onTapActionCallback: onTapShowAllAttachmentFile,
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
|
||||
List<Widget> downloadAllAttachments = downloadAllEnabled && !responsiveUtils.isMobile(context)
|
||||
? [
|
||||
const Spacer(),
|
||||
TMailButtonWidget(
|
||||
text: AppLocalizations.of(context).downloadAll,
|
||||
icon: imagePaths.icDownloadAll,
|
||||
iconAlignment: TextDirection.rtl,
|
||||
backgroundColor: Colors.transparent,
|
||||
borderRadius: EmailAttachmentsStyles.buttonBorderRadius,
|
||||
padding: EmailAttachmentsStyles.buttonPadding,
|
||||
textStyle: ThemeUtils.defaultTextStyleInterFont.copyWith(
|
||||
fontSize: EmailAttachmentsStyles.buttonTextSize,
|
||||
color: EmailAttachmentsStyles.buttonTextColor,
|
||||
fontWeight: EmailAttachmentsStyles.buttonFontWeight
|
||||
),
|
||||
onTapActionCallback: onTapDownloadAllButton,
|
||||
),
|
||||
]
|
||||
: const [];
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
...attachmentsAmountAndSize,
|
||||
if (!PlatformInfo.isWeb) const Spacer(),
|
||||
showAllAttachments,
|
||||
...downloadAllAttachments,
|
||||
],
|
||||
final iconAttachment = SvgPicture.asset(
|
||||
imagePaths.icAttachment,
|
||||
width: 14,
|
||||
height: 14,
|
||||
colorFilter: AppColor.gray959DAD.asFilter(),
|
||||
fit: BoxFit.fill,
|
||||
);
|
||||
|
||||
final titleHeaderAttachment = Text(
|
||||
AppLocalizations.of(context).titleHeaderAttachment(
|
||||
numberOfAttachments,
|
||||
totalSizeInfo,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: ThemeUtils.textStyleInter400.copyWith(
|
||||
fontSize: 15,
|
||||
height: 20 / 15,
|
||||
color: AppColor.gray99A2AD,
|
||||
),
|
||||
);
|
||||
|
||||
final showAllButton = 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,
|
||||
);
|
||||
|
||||
if (responsiveUtils.isMobile(context)) {
|
||||
return Row(
|
||||
children: [
|
||||
iconAttachment,
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 8, end: 3),
|
||||
child: titleHeaderAttachment,
|
||||
),
|
||||
),
|
||||
if (numberOfAttachments > 3) showAllButton,
|
||||
],
|
||||
);
|
||||
} 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 (numberOfAttachments > 4) showAllButton,
|
||||
],
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_item_widget.dart';
|
||||
@@ -10,6 +11,7 @@ typedef OnDragAttachmentEnd = Function(DraggableDetails details);
|
||||
class DraggableAttachmentItemWidget extends StatelessWidget{
|
||||
|
||||
final Attachment attachment;
|
||||
final ImagePaths imagePaths;
|
||||
final OnDragAttachmentStarted? onDragStarted;
|
||||
final OnDragAttachmentEnd? onDragEnd;
|
||||
final OnDownloadAttachmentFileAction? downloadAttachmentAction;
|
||||
@@ -19,6 +21,7 @@ class DraggableAttachmentItemWidget extends StatelessWidget{
|
||||
const DraggableAttachmentItemWidget({
|
||||
Key? key,
|
||||
required this.attachment,
|
||||
required this.imagePaths,
|
||||
this.onDragStarted,
|
||||
this.onDragEnd,
|
||||
this.downloadAttachmentAction,
|
||||
@@ -35,6 +38,7 @@ class DraggableAttachmentItemWidget extends StatelessWidget{
|
||||
onDragEnd: onDragEnd,
|
||||
child: AttachmentItemWidget(
|
||||
attachment: attachment,
|
||||
imagePaths: imagePaths,
|
||||
downloadAttachmentAction: downloadAttachmentAction,
|
||||
viewAttachmentAction: viewAttachmentAction,
|
||||
singleEmailControllerTag: singleEmailControllerTag,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
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';
|
||||
@@ -8,7 +9,6 @@ import 'package:filesize/filesize.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:model/extensions/list_attachment_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/email_attachments_styles.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachment_item_widget.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/attachments_info.dart';
|
||||
@@ -44,135 +44,225 @@ class EmailAttachmentsWidget extends StatelessWidget {
|
||||
this.singleEmailControllerTag,
|
||||
});
|
||||
|
||||
Widget _buildMoreAttachmentButton(
|
||||
BuildContext context,
|
||||
int hideItemsCount, {
|
||||
EdgeInsetsGeometry? padding,
|
||||
EdgeInsetsGeometry? margin,
|
||||
}) {
|
||||
return TMailButtonWidget(
|
||||
text: AppLocalizations.of(context).moreAttachments(hideItemsCount),
|
||||
backgroundColor: Colors.transparent,
|
||||
borderRadius: EmailAttachmentsStyles.buttonBorderRadius,
|
||||
padding: padding,
|
||||
maxWidth: EmailAttachmentsStyles.buttonMoreMaxWidth,
|
||||
margin: margin,
|
||||
textStyle: ThemeUtils.defaultTextStyleInterFont.copyWith(
|
||||
fontSize: EmailAttachmentsStyles.buttonMoreAttachmentsTextSize,
|
||||
color: EmailAttachmentsStyles.buttonMoreAttachmentsTextColor,
|
||||
fontWeight: EmailAttachmentsStyles.buttonMoreAttachmentsFontWeight,
|
||||
),
|
||||
maxLines: 1,
|
||||
onTapActionCallback: onTapShowAllAttachmentFile,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
final attachmentDisplayed = EmailUtils.getAttachmentDisplayed(
|
||||
context: context,
|
||||
maxWidth: constraints.maxWidth
|
||||
- EmailAttachmentsStyles.padding.horizontal
|
||||
- EmailAttachmentsStyles.listSpace * 2,
|
||||
platformIsMobile: PlatformInfo.isMobile,
|
||||
attachments: attachments,
|
||||
responsiveUtils: responsiveUtils,
|
||||
final attachmentRecord = _getDisplayedAndHiddenAttachment(
|
||||
context,
|
||||
constraints.maxWidth,
|
||||
);
|
||||
int hideItemsCount = attachments.length - attachmentDisplayed.length;
|
||||
if (hideItemsCount > 999) {
|
||||
hideItemsCount = 999;
|
||||
}
|
||||
return Padding(
|
||||
padding: EmailAttachmentsStyles.padding,
|
||||
child: Column(
|
||||
|
||||
final attachmentHeader = AttachmentsInfo(
|
||||
imagePaths: imagePaths,
|
||||
numberOfAttachments: attachments.length,
|
||||
totalSizeInfo: filesize(attachments.totalSize, 1),
|
||||
responsiveUtils: responsiveUtils,
|
||||
onTapShowAllAttachmentFile: onTapShowAllAttachmentFile,
|
||||
onTapDownloadAllButton: showDownloadAllAttachmentsButton
|
||||
? onTapDownloadAllButton
|
||||
: null,
|
||||
);
|
||||
|
||||
late Widget attachmentWidget;
|
||||
|
||||
if (responsiveUtils.isMobile(context)) {
|
||||
attachmentWidget = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AttachmentsInfo(
|
||||
imagePaths: imagePaths,
|
||||
numberOfAttachments: attachments.length,
|
||||
totalSizeInfo: filesize(attachments.totalSize, 1),
|
||||
responsiveUtils: responsiveUtils,
|
||||
onTapShowAllAttachmentFile: onTapShowAllAttachmentFile,
|
||||
downloadAllEnabled: showDownloadAllAttachmentsButton,
|
||||
onTapDownloadAllButton: onTapDownloadAllButton,
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(horizontal: 12),
|
||||
child: attachmentHeader,
|
||||
),
|
||||
const SizedBox(height: EmailAttachmentsStyles.marginHeader),
|
||||
Row(
|
||||
crossAxisAlignment: responsiveUtils.isMobile(context)
|
||||
? CrossAxisAlignment.end
|
||||
: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Wrap(
|
||||
spacing: EmailAttachmentsStyles.listSpace,
|
||||
runSpacing: EmailAttachmentsStyles.listSpace,
|
||||
children: attachmentDisplayed.map((attachment) {
|
||||
if (PlatformInfo.isWeb) {
|
||||
return DraggableAttachmentItemWidget(
|
||||
attachment: attachment,
|
||||
onDragStarted: onDragStarted,
|
||||
onDragEnd: onDragEnd,
|
||||
downloadAttachmentAction: downloadAttachmentAction,
|
||||
viewAttachmentAction: viewAttachmentAction,
|
||||
singleEmailControllerTag: singleEmailControllerTag,
|
||||
);
|
||||
} else {
|
||||
return AttachmentItemWidget(
|
||||
attachment: attachment,
|
||||
downloadAttachmentAction: downloadAttachmentAction,
|
||||
viewAttachmentAction: viewAttachmentAction,
|
||||
singleEmailControllerTag: singleEmailControllerTag,
|
||||
);
|
||||
}
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
if (hideItemsCount > 0 && !responsiveUtils.isMobile(context))
|
||||
_buildMoreAttachmentButton(
|
||||
context,
|
||||
hideItemsCount,
|
||||
padding: EmailAttachmentsStyles.buttonPadding,
|
||||
margin: EmailAttachmentsStyles.moreButtonMargin,
|
||||
),
|
||||
]
|
||||
const SizedBox(height: 4),
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(horizontal: 12),
|
||||
child: Column(
|
||||
children: attachmentRecord.displayedAttachments.map((attachment) {
|
||||
return AttachmentItemWidget(
|
||||
attachment: attachment,
|
||||
imagePaths: imagePaths,
|
||||
downloadAttachmentAction: downloadAttachmentAction,
|
||||
viewAttachmentAction: viewAttachmentAction,
|
||||
singleEmailControllerTag: singleEmailControllerTag,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: EmailAttachmentsStyles.marginHeader),
|
||||
if (responsiveUtils.isMobile(context))
|
||||
Row(
|
||||
children: [
|
||||
if (hideItemsCount > 0)
|
||||
_buildMoreAttachmentButton(
|
||||
context,
|
||||
hideItemsCount,
|
||||
padding: EmailAttachmentsStyles.mobileButtonPadding,
|
||||
margin: EmailAttachmentsStyles.mobileMoreButtonMargin,
|
||||
const SizedBox(height: 12),
|
||||
if (attachmentRecord.hiddenItemsCount > 0 &&
|
||||
showDownloadAllAttachmentsButton)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(horizontal: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
TMailButtonWidget.fromText(
|
||||
text: AppLocalizations.of(context).moreAttachments(
|
||||
attachmentRecord.hiddenItemsCount,
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
borderRadius: 5,
|
||||
maxWidth: 120,
|
||||
maxLines: 1,
|
||||
textStyle: ThemeUtils.textStyleM3TitleSmall,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 3,
|
||||
horizontal: 5,
|
||||
),
|
||||
onTapActionCallback: onTapShowAllAttachmentFile,
|
||||
),
|
||||
const Spacer(),
|
||||
if (showDownloadAllAttachmentsButton)
|
||||
TMailButtonWidget(
|
||||
text: AppLocalizations.of(context).downloadAll,
|
||||
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 (attachmentRecord.hiddenItemsCount > 0)
|
||||
TMailButtonWidget.fromText(
|
||||
text: AppLocalizations.of(context).moreAttachments(
|
||||
attachmentRecord.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: EmailAttachmentsStyles.buttonBorderRadius,
|
||||
padding: EmailAttachmentsStyles.mobileButtonPadding,
|
||||
textStyle: ThemeUtils.defaultTextStyleInterFont.copyWith(
|
||||
fontSize: EmailAttachmentsStyles.buttonTextSize,
|
||||
color: EmailAttachmentsStyles.buttonTextColor,
|
||||
fontWeight: EmailAttachmentsStyles.buttonFontWeight
|
||||
),
|
||||
maxWidth: EmailAttachmentsStyles.buttonDownloadAllMaxWidth,
|
||||
maxLines: 1,
|
||||
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,
|
||||
),
|
||||
]
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
attachmentWidget = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(horizontal: 12),
|
||||
child: attachmentHeader,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(horizontal: 12),
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: attachmentRecord.displayedAttachments.map((attachment) {
|
||||
if (responsiveUtils.isDesktop(context)) {
|
||||
return DraggableAttachmentItemWidget(
|
||||
attachment: attachment,
|
||||
imagePaths: imagePaths,
|
||||
onDragStarted: onDragStarted,
|
||||
onDragEnd: onDragEnd,
|
||||
downloadAttachmentAction: downloadAttachmentAction,
|
||||
viewAttachmentAction: viewAttachmentAction,
|
||||
singleEmailControllerTag: singleEmailControllerTag,
|
||||
);
|
||||
} else {
|
||||
return AttachmentItemWidget(
|
||||
attachment: attachment,
|
||||
imagePaths: imagePaths,
|
||||
width: 260,
|
||||
downloadAttachmentAction: downloadAttachmentAction,
|
||||
viewAttachmentAction: viewAttachmentAction,
|
||||
singleEmailControllerTag: singleEmailControllerTag,
|
||||
);
|
||||
}
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 12, bottom: 24),
|
||||
child: attachmentWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
({List<Attachment> displayedAttachments, int hiddenItemsCount})
|
||||
_getDisplayedAndHiddenAttachment(BuildContext context, double maxWidth) {
|
||||
const itemSpace = 8.0;
|
||||
const itemHorizontalPadding = 24;
|
||||
final maxWidthDesktop = maxWidth - itemHorizontalPadding - itemSpace * 2;
|
||||
|
||||
final displayedAttachments = EmailUtils.getAttachmentDisplayed(
|
||||
context: context,
|
||||
maxWidth: maxWidthDesktop,
|
||||
platformIsMobile: PlatformInfo.isMobile,
|
||||
attachments: attachments,
|
||||
responsiveUtils: responsiveUtils,
|
||||
);
|
||||
|
||||
int hiddenItemsCount = attachments.length - displayedAttachments.length;
|
||||
if (hiddenItemsCount > 999) {
|
||||
hiddenItemsCount = 999;
|
||||
} else if (hiddenItemsCount < 0) {
|
||||
hiddenItemsCount = 0;
|
||||
}
|
||||
|
||||
return (
|
||||
displayedAttachments: displayedAttachments,
|
||||
hiddenItemsCount: hiddenItemsCount,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -147,7 +147,7 @@ class InformationSenderAndReceiverBuilder extends StatelessWidget {
|
||||
padding: const EdgeInsetsDirectional.only(start: 16),
|
||||
child: SvgPicture.asset(
|
||||
imagePaths.icAttachment,
|
||||
colorFilter: AppColor.colorAttachmentIcon.asFilter(),
|
||||
colorFilter: AppColor.steelGray200.asFilter(),
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
@@ -215,7 +215,7 @@ class InformationSenderAndReceiverBuilder extends StatelessWidget {
|
||||
padding: const EdgeInsetsDirectional.only(end: 8),
|
||||
child: SvgPicture.asset(
|
||||
imagePaths.icAttachment,
|
||||
colorFilter: AppColor.colorAttachmentIcon.asFilter(),
|
||||
colorFilter: AppColor.steelGray200.asFilter(),
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user