58a576adeb
TF-3643 Thread Detail cache email with thread id TF-3643 Thread Detail view thread detail TF-3643 Thread Detail [Part 2 fixup] remove ThreadDetailController dependency from MailboxDashboardController TF-3643 Thread Detail [Part 2 fixup] remove EmailSupervisorController dependency from ThreadDetailController TF-3643 Thread Detail [Part 2 fixup] move isSearchRunning check into ThreadDetailController TF-3643 Thread Detail [Part 2 fixup] ensure GetEmailsByIdsInteractor performance TF-3643 Thread Detail [Part 2 fixup] unit test loadMoreThreadDetailEmails TF-3643 Thread Detail [Part 2 fixup] unit test getEmailIdsToLoad TF-3643 Thread Detail [Part 2 fixup] optimize ThreadDetailBinding bindingsDataSource TF-3643 Thread Detail [Part 2 fixup] optimize getThreadDetailLoadingView TF-3643 Thread Detail [Part 2 fixup] readd unique ValueKey for HtmlContentViewerOnWebWidget TF-3643 Thread Detail [Part 2 fixup] unit test initializeThreadDetailEmails TF-3643 Thread Detail [Part 3 fixup] Update private action button methods TF-3643 Thread Detail [Part 4 fixup] Collapsed email preview 65 characters max TF-3643 Thread Detail [Part 4 fixup] Remove personal scripts TF-3643 Thread Detail move EmailInThreadStatus into PresentationEmail TF-3643 Thread Detail refactor toggle collapse expand TF-3643 Thread Detail EmailViewAppBarWidget required parameters TF-3643 Thread Detail tap avatar toggle expansion TF-3643 Thread Detail fix cannot open single email TF-3643 Thread Detail fix open thread first time blank view TF-3643 Thread Detail fix thread detail UI TF-3643 Thread Detail fix round bottom view TF-3643 Thread Detail fix round bottom view TF-3643 Thread Detail bottom actions depend on current expanded email TF-3643 Thread Detail hide next previous actions TF-3643 Thread Detail fix load more show initial loading view TF-3643 Thread Detail fix cannot view single email TF-3643 Thread Detail fix bottom place holder not aligned TF-3643 Thread Detail fix back to search view TF-3643 Thread Detail fix display 65 character preview collapsed email TF-3643 Thread Detail fix search not work TF-3643 Thread Detail fix bottom place holder UI TF-3643 Thread Detail fix expand view TF-3643 Thread Detail jump to top of last email view TF-3643 Thread Detail remove toMe condition of filtering thread TF-3643 Thread Detail fix sort thread detail TF-3643 Thread Detail fix assert not work in release TF-3643 Thread Detail add load more test case <20 TF-3643 Thread Detail remove the use of currentThreadId TF-3643 Thread Detail remove the use of selectedEmail in SingleEmailController TF-3643 Thread Detail fix unit test SingleEmailController calendar TF-3643 Thread Detail disable 2 way scroll control TF-3643 Thread Detail allow thread to load sent email incase thread only contains 1 email TF-3643 Thread Detail disable single email page view TF-3643 Thread Detail update emailsNotLoadedCount name TF-3643 Thread Detail remove collapsed email char limit TF-3643 Thread Detail fix CI TF-3643 Thread Detail unit test handleGetEmailIdsByThreadIdSuccess TF-3643 Thread Detail make _currentEmailId private TF-3643 Thread Detail fix search click users TF-3643 Thread Detail fix scroll jump TF-3643 Thread Detail fix scroll jump TF-3643 Thread Detail fix web back action TF-3643 Thread Detail round bottom actions TF-3643 Thread Detail fix tablet large empty email TF-3643 Thread Detail fix email subject selectable TF-3643 Thread Detail fix email single view with top divider TF-3643 Thread Detail fix email cache threadId missing TF-3643 Thread Detail fix filter sent email in thread details TF-3643 Thread Detail fix select text TF-3643 Thread Detail fix subject alignment TF-3643 Thread Detail fix subject alignment TF-3643 Thread Detail fix tablet large empty email TF-3643 Thread Detail add nullcheck for _jumpScrollViewToTopOfEmail TF-3643 Thread Detail decouple ThreadDetailController from SingleEmailController TF-3643 Thread Detail combine emailIds to emailIdsPresentation TF-3643 Thread Detail remove currentEmailLoaded obx listener of SingleEmailController TF-3643 Thread Detail replace threadAction with an email ui action TF-3643 Thread Detail fix top and bottom bar delay displaying TF-3643 Thread Detail update ReplyForwardBottomBarAction to PerformEmailActionInThreadDetailAction TF-3643 Thread Detail use getOwnEmailAddress in ThreadDetailAppBar TF-3643 Thread Detail add TextOverflow.ellipsis to EmailSubjectWidget TF-3643 Thread Detail fix round border threadDetailLoadingView
179 lines
7.7 KiB
Dart
179 lines
7.7 KiB
Dart
import 'package:core/presentation/action/action_callback_define.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/utils/platform_info.dart';
|
|
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';
|
|
import 'package:tmail_ui_user/features/email/presentation/widgets/draggable_attachment_item_widget.dart';
|
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
|
|
|
class EmailAttachmentsWidget extends StatelessWidget {
|
|
|
|
final List<Attachment> attachments;
|
|
final OnDragAttachmentStarted? onDragStarted;
|
|
final OnDragAttachmentEnd? onDragEnd;
|
|
final OnDownloadAttachmentFileAction? downloadAttachmentAction;
|
|
final OnViewAttachmentFileAction? viewAttachmentAction;
|
|
final ResponsiveUtils responsiveUtils;
|
|
final ImagePaths imagePaths;
|
|
final OnTapActionCallback? onTapShowAllAttachmentFile;
|
|
final bool showDownloadAllAttachmentsButton;
|
|
final OnTapActionCallback? onTapDownloadAllButton;
|
|
final String? singleEmailControllerTag;
|
|
|
|
const EmailAttachmentsWidget({
|
|
super.key,
|
|
required this.attachments,
|
|
required this.responsiveUtils,
|
|
required this.imagePaths,
|
|
this.onDragStarted,
|
|
this.onDragEnd,
|
|
this.downloadAttachmentAction,
|
|
this.viewAttachmentAction,
|
|
this.onTapShowAllAttachmentFile,
|
|
this.showDownloadAllAttachmentsButton = false,
|
|
this.onTapDownloadAllButton,
|
|
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,
|
|
);
|
|
int hideItemsCount = attachments.length - attachmentDisplayed.length;
|
|
if (hideItemsCount > 999) {
|
|
hideItemsCount = 999;
|
|
}
|
|
return Padding(
|
|
padding: EmailAttachmentsStyles.padding,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
AttachmentsInfo(
|
|
imagePaths: imagePaths,
|
|
numberOfAttachments: attachments.length,
|
|
totalSizeInfo: filesize(attachments.totalSize, 1),
|
|
responsiveUtils: responsiveUtils,
|
|
onTapShowAllAttachmentFile: onTapShowAllAttachmentFile,
|
|
downloadAllEnabled: showDownloadAllAttachmentsButton,
|
|
onTapDownloadAllButton: onTapDownloadAllButton,
|
|
),
|
|
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: EmailAttachmentsStyles.marginHeader),
|
|
if (responsiveUtils.isMobile(context))
|
|
Row(
|
|
children: [
|
|
if (hideItemsCount > 0)
|
|
_buildMoreAttachmentButton(
|
|
context,
|
|
hideItemsCount,
|
|
padding: EmailAttachmentsStyles.mobileButtonPadding,
|
|
margin: EmailAttachmentsStyles.mobileMoreButtonMargin,
|
|
),
|
|
const Spacer(),
|
|
if (showDownloadAllAttachmentsButton)
|
|
TMailButtonWidget(
|
|
text: AppLocalizations.of(context).downloadAll,
|
|
icon: imagePaths.icDownloadAll,
|
|
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,
|
|
mainAxisSize: MainAxisSize.min,
|
|
flexibleText: true,
|
|
onTapActionCallback: onTapDownloadAllButton,
|
|
),
|
|
]
|
|
),
|
|
],
|
|
),
|
|
);
|
|
});
|
|
}
|
|
}
|