TF-381 Apply new UI for list emails
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/caching/state_cache_client.dart';
|
||||
@@ -43,15 +42,10 @@ class ThreadBindings extends BaseBindings {
|
||||
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => ScrollController());
|
||||
Get.put(ThreadController(
|
||||
Get.find<ResponsiveUtils>(),
|
||||
Get.find<GetEmailsInMailboxInteractor>(),
|
||||
Get.find<RefreshAllEmailsInMailboxInteractor>(),
|
||||
Get.find<ScrollController>(),
|
||||
Get.find<MarkAsMultipleEmailReadInteractor>(),
|
||||
Get.find<AppToast>(),
|
||||
Get.find<ImagePaths>(),
|
||||
Get.find<MoveMultipleEmailToMailboxInteractor>(),
|
||||
Get.find<MarkAsStarEmailInteractor>(),
|
||||
Get.find<MarkAsStarMultipleEmailInteractor>(),
|
||||
|
||||
@@ -55,13 +55,13 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
class ThreadController extends BaseController {
|
||||
|
||||
final mailboxDashBoardController = Get.find<MailboxDashBoardController>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _appToast = Get.find<AppToast>();
|
||||
|
||||
final GetEmailsInMailboxInteractor _getEmailsInMailboxInteractor;
|
||||
final RefreshAllEmailsInMailboxInteractor _refreshAllEmailsInMailboxInteractor;
|
||||
final MarkAsMultipleEmailReadInteractor _markAsMultipleEmailReadInteractor;
|
||||
final AppToast _appToast;
|
||||
final ResponsiveUtils responsiveUtils;
|
||||
final ImagePaths _imagePaths;
|
||||
final ScrollController listEmailController;
|
||||
final MoveMultipleEmailToMailboxInteractor _moveMultipleEmailToMailboxInteractor;
|
||||
final MarkAsStarEmailInteractor _markAsStarEmailInteractor;
|
||||
final MarkAsStarMultipleEmailInteractor _markAsStarMultipleEmailInteractor;
|
||||
@@ -81,6 +81,7 @@ class ThreadController extends BaseController {
|
||||
get isLoadingMore => _isLoadingMore;
|
||||
MailboxId? _currentMailboxId;
|
||||
jmap.State? _currentEmailState;
|
||||
final ScrollController listEmailController = ScrollController();
|
||||
|
||||
SearchQuery? get searchQuery => mailboxDashBoardController.searchQuery;
|
||||
|
||||
@@ -91,13 +92,9 @@ class ThreadController extends BaseController {
|
||||
AccountId? get _accountId => mailboxDashBoardController.accountId.value;
|
||||
|
||||
ThreadController(
|
||||
this.responsiveUtils,
|
||||
this._getEmailsInMailboxInteractor,
|
||||
this._refreshAllEmailsInMailboxInteractor,
|
||||
this.listEmailController,
|
||||
this._markAsMultipleEmailReadInteractor,
|
||||
this._appToast,
|
||||
this._imagePaths,
|
||||
this._moveMultipleEmailToMailboxInteractor,
|
||||
this._markAsStarEmailInteractor,
|
||||
this._markAsStarMultipleEmailInteractor,
|
||||
@@ -360,7 +357,7 @@ class ThreadController extends BaseController {
|
||||
|
||||
void previewEmail(BuildContext context, PresentationEmail presentationEmailSelected) {
|
||||
mailboxDashBoardController.setSelectedEmail(presentationEmailSelected);
|
||||
if (responsiveUtils.isDesktop(context) || responsiveUtils.isTabletLarge(context)) {
|
||||
if (_responsiveUtils.isDesktop(context) || _responsiveUtils.isTabletLarge(context)) {
|
||||
mailboxDashBoardController.dispatchRoute(AppRoutes.EMAIL);
|
||||
} else {
|
||||
goToEmail(context);
|
||||
|
||||
@@ -12,14 +12,13 @@ import 'package:tmail_ui_user/features/thread/presentation/widgets/bottom_bar_th
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/email_tile_builder.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/filter_message_cupertino_action_sheet_action_builder.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/search_app_bar_widget.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/search_bar_thread_view_widget.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/suggestion_box_widget.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class ThreadView extends GetWidget<ThreadController> {
|
||||
|
||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final imagePaths = Get.find<ImagePaths>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -27,63 +26,72 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: _responsiveUtils.isDesktop(context) ? AppColor.colorBgDesktop : Colors.white,
|
||||
body: SafeArea(
|
||||
right: responsiveUtils.isMobileDevice(context) && responsiveUtils.isLandscape(context),
|
||||
left: responsiveUtils.isMobileDevice(context) && responsiveUtils.isLandscape(context),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.zero,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
right: _responsiveUtils.isMobileDevice(context) && _responsiveUtils.isLandscape(context),
|
||||
left: _responsiveUtils.isMobileDevice(context) && _responsiveUtils.isLandscape(context),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildAppBarThread(context),
|
||||
Obx(() => !controller.isSearchActive()
|
||||
? (SearchBarThreadViewWidget(imagePaths)
|
||||
..hintTextSearch(AppLocalizations.of(context).hint_search_emails)
|
||||
..addOnOpenSearchViewAction(() => controller.enableSearch(context)))
|
||||
.build()
|
||||
: SizedBox.shrink()),
|
||||
Expanded(child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.zero,
|
||||
if (_responsiveUtils.isDesktop(context))
|
||||
Container(
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildStatusResultSearch(context),
|
||||
_buildLoadingView(),
|
||||
Expanded(child: _buildListEmail(context)),
|
||||
_buildLoadingViewLoadMore()
|
||||
]
|
||||
)
|
||||
),
|
||||
_buildSuggestionBox(context)
|
||||
],
|
||||
)),
|
||||
padding: EdgeInsets.only(right: 10, top: 16, bottom: 10),
|
||||
child: _buildHeader(context)),
|
||||
Obx(() => controller.isSearchActive()
|
||||
? _buildSearchForm(context)
|
||||
: _responsiveUtils.isDesktop(context) ? SizedBox.shrink() : _buildAppBarNormal(context)),
|
||||
Obx(() => !controller.isSearchActive() && !_responsiveUtils.isDesktop(context)
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(left: 16, right: 16, bottom: 10),
|
||||
child: (SearchBarView(_imagePaths)
|
||||
..hintTextSearch(AppLocalizations.of(context).hint_search_emails)
|
||||
..addOnOpenSearchViewAction(() => controller.enableSearch(context)))
|
||||
.build())
|
||||
: SizedBox.shrink()),
|
||||
Expanded(child: Container(
|
||||
color: AppColor.colorBgDesktop,
|
||||
margin: _responsiveUtils.isDesktop(context) ? EdgeInsets.all(16) : EdgeInsets.zero,
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: _responsiveUtils.isDesktop(context) ? BorderRadius.circular(20) : null,
|
||||
border: _responsiveUtils.isDesktop(context) ? Border.all(color: AppColor.colorBorderBodyThread, width: 1) : null,
|
||||
color: Colors.white),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildStatusResultSearch(context),
|
||||
_buildLoadingView(),
|
||||
Expanded(child: _buildListEmail(context)),
|
||||
_buildLoadingViewLoadMore(),
|
||||
]
|
||||
)
|
||||
),
|
||||
_buildSuggestionBox(context)
|
||||
],
|
||||
))
|
||||
),
|
||||
Obx(() => controller.isSelectionEnabled()
|
||||
? Column(children: [
|
||||
Divider(color: AppColor.lineItemListColor, height: 1, thickness: 0.2),
|
||||
_buildOptionSelectionBottomBar(context)
|
||||
])
|
||||
: SizedBox.shrink()),
|
||||
? Column(children: [
|
||||
Divider(color: AppColor.lineItemListColor, height: 1, thickness: 0.2),
|
||||
_buildOptionSelectionBottomBar(context)
|
||||
])
|
||||
: SizedBox.shrink()),
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
floatingActionButton: Obx(() => !controller.isSearchActive() && !controller.isSelectionEnabled()
|
||||
? Container(
|
||||
padding: EdgeInsets.only(bottom: controller.isSelectionEnabled()
|
||||
? 80
|
||||
: responsiveUtils.isMobileDevice(context) ? 0 : 16),
|
||||
: _responsiveUtils.isMobileDevice(context) ? 0 : 16),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: ScrollingFloatingButtonAnimated(
|
||||
icon: SvgPicture.asset(imagePaths.icCompose, width: 20, height: 20, fit: BoxFit.fill),
|
||||
icon: SvgPicture.asset(_imagePaths.icCompose, width: 20, height: 20, fit: BoxFit.fill),
|
||||
text: Padding(
|
||||
padding: EdgeInsets.only(right: 10),
|
||||
child: Text(
|
||||
@@ -101,15 +109,82 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppBarThread(BuildContext context) {
|
||||
return Obx(() {
|
||||
return Stack(
|
||||
children: [
|
||||
if (!controller.isSearchActive()) _buildAppBarNormal(context),
|
||||
if (controller.isSearchActive()) _buildSearchForm(context),
|
||||
],
|
||||
);
|
||||
});
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
return Row(children: [
|
||||
(ButtonBuilder(_imagePaths.icRefresh)
|
||||
..key(Key('button_reload_thread'))
|
||||
..decoration(BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppColor.colorButtonHeaderThread))
|
||||
..paddingIcon(EdgeInsets.zero)
|
||||
..size(16)
|
||||
..radiusSplash(10)
|
||||
..padding(EdgeInsets.symmetric(horizontal: 8, vertical: 8))
|
||||
..onPressActionClick(() => controller.refreshAllEmail()))
|
||||
.build(),
|
||||
SizedBox(width: 16),
|
||||
(ButtonBuilder(_imagePaths.icSelectAll)
|
||||
..key(Key('button_select_all'))
|
||||
..decoration(BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppColor.colorButtonHeaderThread))
|
||||
..paddingIcon(EdgeInsets.only(right: 8))
|
||||
..size(16)
|
||||
..radiusSplash(10)
|
||||
..padding(EdgeInsets.symmetric(horizontal: 12, vertical: 8))
|
||||
..textStyle(TextStyle(fontSize: 12, color: AppColor.colorTextButtonHeaderThread))
|
||||
..onPressActionClick(() => controller.enableSelectionEmail())
|
||||
..text(AppLocalizations.of(context).select_all, isVertical: false))
|
||||
.build(),
|
||||
SizedBox(width: 16),
|
||||
(ButtonBuilder(_imagePaths.icMarkAllAsRead)
|
||||
..key(Key('button_mark_all_as_read'))
|
||||
..decoration(BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppColor.colorButtonHeaderThread))
|
||||
..paddingIcon(EdgeInsets.only(right: 8))
|
||||
..size(16)
|
||||
..padding(EdgeInsets.symmetric(horizontal: 12, vertical: 8))
|
||||
..radiusSplash(10)
|
||||
..textStyle(TextStyle(fontSize: 12, color: AppColor.colorTextButtonHeaderThread))
|
||||
..onPressActionClick(() => {})
|
||||
..text(AppLocalizations.of(context).mark_all_as_read, isVertical: false))
|
||||
.build(),
|
||||
SizedBox(width: 16),
|
||||
(ButtonBuilder(_imagePaths.icFilterWeb)
|
||||
..key(Key('button_filter_messages'))
|
||||
..context(context)
|
||||
..decoration(BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppColor.colorButtonHeaderThread))
|
||||
..paddingIcon(EdgeInsets.only(right: 8))
|
||||
..size(16)
|
||||
..padding(EdgeInsets.symmetric(horizontal: 12, vertical: 8))
|
||||
..radiusSplash(10)
|
||||
..textStyle(TextStyle(fontSize: 12, color: AppColor.colorTextButtonHeaderThread))
|
||||
..addIconAction(Padding(
|
||||
padding: EdgeInsets.only(left: 8),
|
||||
child: SvgPicture.asset(_imagePaths.icArrowDown, fit: BoxFit.fill)))
|
||||
..addOnPressActionWithPositionClick((position) =>
|
||||
controller.openFilterMessagesForTablet(
|
||||
context,
|
||||
position,
|
||||
_popupMenuEmailActionTile(context, controller.filterMessageOption.value)))
|
||||
..text(AppLocalizations.of(context).filter_messages, isVertical: false))
|
||||
.build(),
|
||||
SizedBox(width: 16),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 16),
|
||||
child: (SearchBarView(_imagePaths)
|
||||
..hintTextSearch(AppLocalizations.of(context).search_emails)
|
||||
..maxSizeWidth(240)
|
||||
..addOnOpenSearchViewAction(() => controller.enableSearch(context)))
|
||||
.build()),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 16),
|
||||
child: (AvatarBuilder()
|
||||
..text(controller.mailboxDashBoardController.userProfile.value?.getAvatarText() ?? '')
|
||||
..backgroundColor(Colors.white)
|
||||
..textColor(Colors.black)
|
||||
..addBoxShadows([BoxShadow(
|
||||
color: AppColor.colorShadowBgContentEmail,
|
||||
spreadRadius: 1, blurRadius: 1, offset: Offset(0, 0.5))])
|
||||
..size(48))
|
||||
.build()),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildOptionSelectionBottomBar(BuildContext context) {
|
||||
@@ -117,8 +192,8 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
padding: EdgeInsets.all(10),
|
||||
child: (BottomBarThreadSelectionWidget(
|
||||
context,
|
||||
imagePaths,
|
||||
responsiveUtils,
|
||||
_imagePaths,
|
||||
_responsiveUtils,
|
||||
controller.getListEmailSelected())
|
||||
..addOnPressEmailSelectionActionClick((actionType, selectionEmail) =>
|
||||
controller.pressEmailSelectionAction(context, actionType, selectionEmail)))
|
||||
@@ -127,7 +202,7 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
|
||||
Widget _buildSearchForm(BuildContext context) {
|
||||
return (SearchAppBarWidget(
|
||||
imagePaths,
|
||||
_imagePaths,
|
||||
controller.searchQuery,
|
||||
controller.mailboxDashBoardController.searchFocus,
|
||||
controller.mailboxDashBoardController.searchInputController,
|
||||
@@ -145,8 +220,8 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
Widget _buildAppBarNormal(BuildContext context) {
|
||||
return (AppBarThreadWidgetBuilder(
|
||||
context,
|
||||
imagePaths,
|
||||
responsiveUtils,
|
||||
_imagePaths,
|
||||
_responsiveUtils,
|
||||
controller.mailboxDashBoardController.selectedMailbox.value,
|
||||
controller.getListEmailSelected(),
|
||||
controller.currentSelectMode.value,
|
||||
@@ -154,7 +229,7 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
..addOpenListMailboxActionClick(() => controller.openMailboxLeftMenu())
|
||||
..addOnEditThreadAction(() => controller.enableSelectionEmail())
|
||||
..addOnFilterEmailAction((filterMessageOption, position) =>
|
||||
responsiveUtils.isMobileDevice(context)
|
||||
_responsiveUtils.isMobileDevice(context)
|
||||
? controller.openFilterMessagesCupertinoActionSheet(
|
||||
context,
|
||||
_filterMessagesCupertinoActionTile(context, filterMessageOption),
|
||||
@@ -187,17 +262,17 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
Widget _filterMessageWithAttachmentsAction(BuildContext context, FilterMessageOption optionCurrent) {
|
||||
return (FilterMessageCupertinoActionSheetActionBuilder(
|
||||
Key('filter_attachment_action'),
|
||||
SvgPicture.asset(imagePaths.icAttachment, width: 28, height: 28, fit: BoxFit.fill, color: AppColor.colorTextButton),
|
||||
SvgPicture.asset(_imagePaths.icAttachment, width: 28, height: 28, fit: BoxFit.fill, color: AppColor.colorTextButton),
|
||||
AppLocalizations.of(context).with_attachments,
|
||||
FilterMessageOption.attachments,
|
||||
optionCurrent: optionCurrent,
|
||||
iconLeftPadding: responsiveUtils.isMobile(context)
|
||||
iconLeftPadding: _responsiveUtils.isMobile(context)
|
||||
? EdgeInsets.only(left: 12, right: 16)
|
||||
: EdgeInsets.only(right: 12),
|
||||
iconRightPadding: responsiveUtils.isMobile(context)
|
||||
iconRightPadding: _responsiveUtils.isMobile(context)
|
||||
? EdgeInsets.only(right: 12)
|
||||
: EdgeInsets.zero,
|
||||
actionSelected: SvgPicture.asset(imagePaths.icFilterSelected, fit: BoxFit.fill))
|
||||
actionSelected: SvgPicture.asset(_imagePaths.icFilterSelected, fit: BoxFit.fill))
|
||||
..onActionClick((option) => controller.filterMessagesAction(context, option)))
|
||||
.build();
|
||||
}
|
||||
@@ -205,17 +280,17 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
Widget _filterMessagesUnreadAction(BuildContext context, FilterMessageOption optionCurrent) {
|
||||
return (FilterMessageCupertinoActionSheetActionBuilder(
|
||||
Key('filter_unread_action'),
|
||||
SvgPicture.asset(imagePaths.icUnread, width: 28, height: 28, fit: BoxFit.fill),
|
||||
SvgPicture.asset(_imagePaths.icUnread, width: 28, height: 28, fit: BoxFit.fill),
|
||||
AppLocalizations.of(context).unread,
|
||||
FilterMessageOption.unread,
|
||||
optionCurrent: optionCurrent,
|
||||
iconLeftPadding: responsiveUtils.isMobile(context)
|
||||
iconLeftPadding: _responsiveUtils.isMobile(context)
|
||||
? EdgeInsets.only(left: 12, right: 16)
|
||||
: EdgeInsets.only(right: 12),
|
||||
iconRightPadding: responsiveUtils.isMobile(context)
|
||||
iconRightPadding: _responsiveUtils.isMobile(context)
|
||||
? EdgeInsets.only(right: 12)
|
||||
: EdgeInsets.zero,
|
||||
actionSelected: SvgPicture.asset(imagePaths.icFilterSelected, fit: BoxFit.fill))
|
||||
actionSelected: SvgPicture.asset(_imagePaths.icFilterSelected, fit: BoxFit.fill))
|
||||
..onActionClick((option) => controller.filterMessagesAction(context, option)))
|
||||
.build();
|
||||
}
|
||||
@@ -223,17 +298,17 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
Widget _filterMessageStarredAction(BuildContext context, FilterMessageOption optionCurrent) {
|
||||
return (FilterMessageCupertinoActionSheetActionBuilder(
|
||||
Key('filter_starred_action'),
|
||||
SvgPicture.asset(imagePaths.icStar, width: 28, height: 28, fit: BoxFit.fill),
|
||||
SvgPicture.asset(_imagePaths.icStar, width: 28, height: 28, fit: BoxFit.fill),
|
||||
AppLocalizations.of(context).starred,
|
||||
FilterMessageOption.starred,
|
||||
optionCurrent: optionCurrent,
|
||||
iconLeftPadding: responsiveUtils.isMobile(context)
|
||||
iconLeftPadding: _responsiveUtils.isMobile(context)
|
||||
? EdgeInsets.only(left: 12, right: 16)
|
||||
: EdgeInsets.only(right: 12),
|
||||
iconRightPadding: responsiveUtils.isMobile(context)
|
||||
iconRightPadding: _responsiveUtils.isMobile(context)
|
||||
? EdgeInsets.only(right: 12)
|
||||
: EdgeInsets.zero,
|
||||
actionSelected: SvgPicture.asset(imagePaths.icFilterSelected, fit: BoxFit.fill))
|
||||
actionSelected: SvgPicture.asset(_imagePaths.icFilterSelected, fit: BoxFit.fill))
|
||||
..onActionClick((option) => controller.filterMessagesAction(context, option)))
|
||||
.build();
|
||||
}
|
||||
@@ -254,55 +329,46 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
(success) {
|
||||
if (controller.isSearchActive()) {
|
||||
return success is SearchingState
|
||||
? Center(child: Padding(
|
||||
padding: EdgeInsets.only(top: 16, bottom: 16),
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator(color: AppColor.primaryColor))))
|
||||
? Padding(padding: EdgeInsets.only(top: 16), child: _loadingWidget)
|
||||
: SizedBox.shrink();
|
||||
} else {
|
||||
return success is LoadingState
|
||||
? Center(child: Padding(
|
||||
padding: EdgeInsets.only(top: 16, bottom: 16),
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator(color: AppColor.primaryColor))))
|
||||
: SizedBox.shrink();
|
||||
? Padding(padding: EdgeInsets.only(top: 16), child: _loadingWidget)
|
||||
: SizedBox.shrink();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
Widget get _loadingWidget {
|
||||
return Center(child: Padding(
|
||||
padding: EdgeInsets.zero,
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CupertinoActivityIndicator(color: AppColor.colorTextButton))));
|
||||
}
|
||||
|
||||
Widget _buildLoadingViewLoadMore() {
|
||||
return Obx(() => controller.viewState.value.fold(
|
||||
(failure) => SizedBox.shrink(),
|
||||
(success) {
|
||||
if (controller.isSearchActive()) {
|
||||
return success is SearchingMoreState
|
||||
? Center(child: Padding(
|
||||
padding: EdgeInsets.only(top: 16, bottom: 16),
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator(color: AppColor.primaryColor))))
|
||||
: SizedBox.shrink();
|
||||
? Padding(padding: EdgeInsets.only(bottom: 16), child: _loadingWidget)
|
||||
: SizedBox.shrink();
|
||||
} else {
|
||||
return success is LoadingMoreState
|
||||
? Center(child: Padding(
|
||||
padding: EdgeInsets.only(top: 16, bottom: 16),
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator(color: AppColor.primaryColor))))
|
||||
: SizedBox.shrink();
|
||||
? Padding(padding: EdgeInsets.only(bottom: 16), child: _loadingWidget)
|
||||
: SizedBox.shrink();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
Widget _buildListEmail(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.zero,
|
||||
margin: _responsiveUtils.isDesktop(context)
|
||||
? EdgeInsets.only(top: 16, bottom: 16)
|
||||
: EdgeInsets.zero,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
alignment: Alignment.center,
|
||||
@@ -364,12 +430,10 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
child: ListView.builder(
|
||||
controller: controller.listEmailController,
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
padding: EdgeInsets.only(top: 16),
|
||||
key: Key('presentation_email_list'),
|
||||
itemCount: listPresentationEmail.length,
|
||||
itemBuilder: (context, index) => Obx(() => (EmailTileBuilder(
|
||||
context,
|
||||
imagePaths,
|
||||
listPresentationEmail[index],
|
||||
controller.mailboxDashBoardController.selectedMailbox.value?.role,
|
||||
controller.currentSelectMode.value,
|
||||
@@ -382,7 +446,8 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
controller.previewEmail(context, selectedEmail);
|
||||
}
|
||||
})
|
||||
..onSelectEmailAction((selectedEmail) => controller.selectEmail(context, selectedEmail)))
|
||||
..onSelectEmailAction((selectedEmail) => controller.selectEmail(context, selectedEmail))
|
||||
..addOnMarkAsStarActionClick((selectedEmail) => controller.markAsStarEmail(selectedEmail)))
|
||||
.build()),
|
||||
)
|
||||
);
|
||||
@@ -394,7 +459,7 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
(success) => !(success is LoadingState) && !(success is SearchingState)
|
||||
? (BackgroundWidgetBuilder(context)
|
||||
..key(Key('empty_email_background'))
|
||||
..image(SvgPicture.asset(imagePaths.icEmptyImageDefault, width: 120, height: 120, fit: BoxFit.fill))
|
||||
..image(SvgPicture.asset(_imagePaths.icEmptyImageDefault, width: 120, height: 120, fit: BoxFit.fill))
|
||||
..text(controller.isSearchActive()
|
||||
? AppLocalizations.of(context).no_emails_matching_your_search
|
||||
: AppLocalizations.of(context).no_emails))
|
||||
@@ -407,7 +472,7 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
return Obx(() => controller.mailboxDashBoardController.suggestionSearch.isNotEmpty
|
||||
? (SuggestionBoxWidget(
|
||||
context,
|
||||
imagePaths,
|
||||
_imagePaths,
|
||||
controller.mailboxDashBoardController.suggestionSearch)
|
||||
..addOnSelectedSuggestion((suggestion) =>
|
||||
controller.mailboxDashBoardController.searchEmail(context, suggestion)))
|
||||
@@ -423,8 +488,12 @@ class ThreadView extends GetWidget<ThreadController> {
|
||||
? Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.zero,
|
||||
color: AppColor.bgStatusResultSearch,
|
||||
padding: EdgeInsets.symmetric(vertical: 12, horizontal: 24),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: _responsiveUtils.isDesktop(context)
|
||||
? BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20))
|
||||
: null,
|
||||
color: AppColor.bgStatusResultSearch),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).results,
|
||||
style: TextStyle(color: AppColor.baseTextColor, fontSize: 14, fontWeight: FontWeight.w500),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -8,13 +9,17 @@ import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/model/search_status.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
typedef OnOpenEmailActionClick = void Function(PresentationEmail selectedEmail);
|
||||
typedef OnSelectEmailActionClick = void Function(PresentationEmail selectedEmail);
|
||||
typedef OnMarkAsStarActionClick = void Function(PresentationEmail selectedEmail);
|
||||
|
||||
class EmailTileBuilder {
|
||||
|
||||
final ImagePaths _imagePaths;
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
final PresentationEmail _presentationEmail;
|
||||
final BuildContext _context;
|
||||
final SelectMode _selectModeAll;
|
||||
@@ -24,10 +29,10 @@ class EmailTileBuilder {
|
||||
|
||||
OnOpenEmailActionClick? _onOpenEmailActionClick;
|
||||
OnSelectEmailActionClick? _onSelectEmailActionClick;
|
||||
OnMarkAsStarActionClick? _onMarkAsStarActionClick;
|
||||
|
||||
EmailTileBuilder(
|
||||
this._context,
|
||||
this._imagePaths,
|
||||
this._presentationEmail,
|
||||
this._mailboxRole,
|
||||
this._selectModeAll,
|
||||
@@ -43,126 +48,124 @@ class EmailTileBuilder {
|
||||
_onSelectEmailActionClick = onSelectEmailActionClick;
|
||||
}
|
||||
|
||||
void addOnMarkAsStarActionClick(OnMarkAsStarActionClick onMarkAsStarActionClick) {
|
||||
_onMarkAsStarActionClick = onMarkAsStarActionClick;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
return Theme(
|
||||
data: ThemeData(
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent),
|
||||
child: Container(
|
||||
key: Key('thread_tile'),
|
||||
margin: EdgeInsets.zero,
|
||||
key: Key('thread_tile'),
|
||||
data: ThemeData(splashColor: Colors.transparent, highlightColor: Colors.transparent),
|
||||
child: ResponsiveWidget(
|
||||
responsiveUtils: _responsiveUtils,
|
||||
mobile: _buildListTile(),
|
||||
desktop: _buildListTileForDesktop(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildListTile() {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.only(bottom: 10, left: 20, right: 6),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
color: Colors.white),
|
||||
child: MediaQuery(
|
||||
data: MediaQueryData(padding: EdgeInsets.zero),
|
||||
child: Column(children: [
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => {
|
||||
if (_onOpenEmailActionClick != null) {
|
||||
_onOpenEmailActionClick!(_presentationEmail)
|
||||
}
|
||||
},
|
||||
onLongPress: () => {
|
||||
if (_onSelectEmailActionClick != null) {
|
||||
_onSelectEmailActionClick!(_presentationEmail)
|
||||
}
|
||||
},
|
||||
leading: Transform(
|
||||
transform: Matrix4.translationValues(-5.0, 0.0, 0.0),
|
||||
child: _buildAvatarIcon()),
|
||||
title: Transform(
|
||||
transform: Matrix4.translationValues(-8.0, 0.0, 0.0),
|
||||
child: Row(
|
||||
children: [
|
||||
if (_presentationEmail.isUnReadEmail())
|
||||
Padding(
|
||||
child: Column(children: [
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => _onOpenEmailActionClick?.call(_presentationEmail),
|
||||
onLongPress: () => _onSelectEmailActionClick!.call(_presentationEmail),
|
||||
leading: Transform(
|
||||
transform: Matrix4.translationValues(-5.0, 0.0, 0.0),
|
||||
child: _buildAvatarIcon()),
|
||||
title: Transform(
|
||||
transform: Matrix4.translationValues(-8.0, 0.0, 0.0),
|
||||
child: Row(
|
||||
children: [
|
||||
if (_presentationEmail.isUnReadEmail())
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 5),
|
||||
child: SvgPicture.asset(_imagePaths.icUnreadStatus, width: 9, height: 9, fit: BoxFit.fill)),
|
||||
Expanded(
|
||||
child: _searchStatus == SearchStatus.ACTIVE && _searchQuery != null && _searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_getInformationSender(),
|
||||
'${_searchQuery!.value}',
|
||||
TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
|
||||
TextStyle(fontSize: 15, color: AppColor.colorNameEmail, backgroundColor: AppColor.bgWordSearch, fontWeight: FontWeight.w600)).build()
|
||||
: Text(
|
||||
_getInformationSender(),
|
||||
maxLines: 1,
|
||||
overflow:TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600))
|
||||
),
|
||||
if (_presentationEmail.hasAttachment == true)
|
||||
Padding(
|
||||
Expanded(
|
||||
child: _searchStatus == SearchStatus.ACTIVE && _searchQuery != null && _searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_getInformationSender(),
|
||||
'${_searchQuery!.value}',
|
||||
TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
|
||||
TextStyle(fontSize: 15, color: AppColor.colorNameEmail, backgroundColor: AppColor.bgWordSearch, fontWeight: FontWeight.w600)).build()
|
||||
: Text(
|
||||
_getInformationSender(),
|
||||
maxLines: 1,
|
||||
overflow:TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600))
|
||||
),
|
||||
if (_presentationEmail.hasAttachment == true)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 8),
|
||||
child: (ButtonBuilder(_imagePaths.icAttachment)
|
||||
..paddingIcon(EdgeInsets.zero)
|
||||
..size(16))
|
||||
.build()),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 4, left: 8),
|
||||
child: Text(
|
||||
'${_presentationEmail.getReceivedAt(Localizations.localeOf(_context).toLanguageTag())}',
|
||||
maxLines: 1,
|
||||
overflow:TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 13, color: AppColor.colorContentEmail))),
|
||||
(ButtonBuilder(_imagePaths.icChevron)
|
||||
..paddingIcon(EdgeInsets.zero)
|
||||
..size(16))
|
||||
..paddingIcon(EdgeInsets.zero)
|
||||
..size(16))
|
||||
.build()),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 4, left: 8),
|
||||
child: Text(
|
||||
'${_presentationEmail.getReceivedAt(Localizations.localeOf(_context).toLanguageTag())}',
|
||||
maxLines: 1,
|
||||
overflow:TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 13, color: AppColor.colorContentEmail))),
|
||||
(ButtonBuilder(_imagePaths.icChevron)
|
||||
..paddingIcon(EdgeInsets.zero)
|
||||
..size(16))
|
||||
.build(),
|
||||
],
|
||||
)
|
||||
),
|
||||
subtitle: Transform(
|
||||
transform: Matrix4.translationValues(-8.0, 8.0, 0.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.zero,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE && _searchQuery != null && _searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
'${_presentationEmail.getEmailTitle()}',
|
||||
'${_searchQuery!.value}',
|
||||
TextStyle(fontSize: 13, color: AppColor.colorNameEmail),
|
||||
TextStyle(fontSize: 13, backgroundColor: AppColor.bgWordSearch, color: AppColor.colorNameEmail)).build()
|
||||
: Text(
|
||||
'${_presentationEmail.getEmailTitle()}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 13, color: AppColor.colorNameEmail))
|
||||
],
|
||||
)
|
||||
),
|
||||
subtitle: Transform(
|
||||
transform: Matrix4.translationValues(-8.0, 8.0, 0.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.zero,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE && _searchQuery != null && _searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
'${_presentationEmail.getEmailTitle()}',
|
||||
'${_searchQuery!.value}',
|
||||
TextStyle(fontSize: 13, color: AppColor.colorNameEmail),
|
||||
TextStyle(fontSize: 13, backgroundColor: AppColor.bgWordSearch, color: AppColor.colorNameEmail)).build()
|
||||
: Text(
|
||||
'${_presentationEmail.getEmailTitle()}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 13, color: AppColor.colorNameEmail))
|
||||
),
|
||||
if (_searchStatus == SearchStatus.ACTIVE && _presentationEmail.mailboxName.isNotEmpty)
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 8),
|
||||
padding: EdgeInsets.only(left: 8, right: 8, top: 3, bottom: 3),
|
||||
constraints: BoxConstraints(maxWidth: 100),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: AppColor.backgroundCounterMailboxColor),
|
||||
child: Text(
|
||||
'${_presentationEmail.mailboxName}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 10, color: AppColor.mailboxTextColor, fontWeight: FontWeight.bold),
|
||||
)
|
||||
),
|
||||
if (_searchStatus == SearchStatus.ACTIVE && _presentationEmail.mailboxName.isNotEmpty)
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 8),
|
||||
padding: EdgeInsets.only(left: 8, right: 8, top: 3, bottom: 3),
|
||||
constraints: BoxConstraints(maxWidth: 100),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: AppColor.backgroundCounterMailboxColor),
|
||||
child: Text(
|
||||
'${_presentationEmail.mailboxName}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 10, color: AppColor.mailboxTextColor, fontWeight: FontWeight.bold),
|
||||
)
|
||||
),
|
||||
if (_presentationEmail.isFlaggedEmail() )
|
||||
(ButtonBuilder(_imagePaths.icStar)
|
||||
..paddingIcon(EdgeInsets.zero)
|
||||
..size(15))
|
||||
.build(),
|
||||
],
|
||||
)),
|
||||
Padding(
|
||||
if (_presentationEmail.isFlaggedEmail() )
|
||||
(ButtonBuilder(_imagePaths.icStar)
|
||||
..paddingIcon(EdgeInsets.zero)
|
||||
..size(15))
|
||||
.build(),
|
||||
],
|
||||
)),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 8),
|
||||
child: Row(children: [
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE && _searchQuery != null && _searchQuery!.value.isNotEmpty
|
||||
@@ -178,27 +181,124 @@ class EmailTileBuilder {
|
||||
style: TextStyle(fontSize: 13, color: AppColor.colorContentEmail))
|
||||
),
|
||||
]))
|
||||
],
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
Padding(
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 12, right: 12),
|
||||
child: Divider(color: AppColor.lineItemListColor, height: 1, thickness: 0.2)),
|
||||
]),
|
||||
)
|
||||
)
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAvatarIcon() {
|
||||
Widget _buildListTileForDesktop() {
|
||||
return InkWell(
|
||||
onTap: () => _onOpenEmailActionClick?.call(_presentationEmail),
|
||||
onLongPress: () => _onSelectEmailActionClick?.call(_presentationEmail),
|
||||
child: Column(children: [
|
||||
Row(children: [
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 16, right: 16),
|
||||
alignment: Alignment.center,
|
||||
child: _presentationEmail.isUnReadEmail()
|
||||
? SvgPicture.asset(_imagePaths.icUnreadStatus, width: 9, height: 9, fit: BoxFit.fill)
|
||||
: SizedBox(width: 9)),
|
||||
buildIconWeb(
|
||||
icon: SvgPicture.asset(
|
||||
_presentationEmail.isFlaggedEmail() ? _imagePaths.icStar : _imagePaths.icUnStar,
|
||||
width: 20,
|
||||
height: 20,
|
||||
fit: BoxFit.fill),
|
||||
tooltip: _presentationEmail.isFlaggedEmail() ? AppLocalizations.of(_context).starred : AppLocalizations.of(_context).not_starred,
|
||||
onTap: () => _onMarkAsStarActionClick?.call(_presentationEmail)),
|
||||
SizedBox(width: 8),
|
||||
_buildAvatarIcon(
|
||||
iconSize: 32,
|
||||
iconSizeSelect: 32,
|
||||
textStyle: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white),
|
||||
paddingIconSelect: EdgeInsets.all(5)),
|
||||
SizedBox(width: 10),
|
||||
Container(width: 180, child: _isSearchEnabled
|
||||
? RichTextBuilder(
|
||||
_getInformationSender(),
|
||||
'${_searchQuery!.value}',
|
||||
TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
|
||||
TextStyle(fontSize: 15, color: AppColor.colorNameEmail, backgroundColor: AppColor.bgWordSearch, fontWeight: FontWeight.w600)).build()
|
||||
: Text('${_getInformationSender()}',
|
||||
maxLines: 1,
|
||||
overflow: kIsWeb ? null : TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600)),
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
Container(width: 150, child: _isSearchEnabled
|
||||
? RichTextBuilder(
|
||||
'${_presentationEmail.getEmailTitle()}',
|
||||
'${_searchQuery!.value}',
|
||||
TextStyle(fontSize: 13, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
|
||||
TextStyle(fontSize: 13, backgroundColor: AppColor.bgWordSearch, color: AppColor.colorNameEmail)).build()
|
||||
: Text('${_presentationEmail.getEmailTitle()}',
|
||||
maxLines: 1,
|
||||
overflow: kIsWeb ? null : TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 13, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600))
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Expanded(flex: 3, child: _isSearchEnabled
|
||||
? RichTextBuilder(
|
||||
'${_presentationEmail.getPartialContent()}',
|
||||
'${_searchQuery!.value}',
|
||||
TextStyle(fontSize: 13, color: AppColor.colorContentEmail, fontWeight: FontWeight.normal),
|
||||
TextStyle(fontSize: 13, color: AppColor.colorContentEmail, backgroundColor: AppColor.bgWordSearch)).build()
|
||||
: Text('${_presentationEmail.getPartialContent()}',
|
||||
maxLines: 1,
|
||||
overflow: kIsWeb ? null : TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 13, color: AppColor.colorContentEmail, fontWeight: FontWeight.normal))
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
if (_searchStatus == SearchStatus.ACTIVE && _presentationEmail.mailboxName.isNotEmpty)
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 8),
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
constraints: BoxConstraints(maxWidth: 100),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppColor.backgroundCounterMailboxColor),
|
||||
child: Text('${_presentationEmail.mailboxName}',
|
||||
maxLines: 1,
|
||||
overflow: kIsWeb ? null: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 10, color: AppColor.mailboxTextColor, fontWeight: FontWeight.bold),
|
||||
)
|
||||
),
|
||||
if (_presentationEmail.hasAttachment == true)
|
||||
Padding(padding: EdgeInsets.only(left: 8),
|
||||
child: (ButtonBuilder(_imagePaths.icAttachment)
|
||||
..paddingIcon(EdgeInsets.zero)
|
||||
..size(16))
|
||||
.build()),
|
||||
Padding(padding: EdgeInsets.only(right: 20, left: 8),
|
||||
child: Text('${_presentationEmail.getReceivedAt(Localizations.localeOf(_context).toLanguageTag())}',
|
||||
maxLines: 1,
|
||||
overflow: kIsWeb ? null: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 13, color: AppColor.colorContentEmail))),
|
||||
]),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 10, bottom: 10, left: 70),
|
||||
child: Divider(color: AppColor.lineItemListColor, height: 1, thickness: 0.2)),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAvatarIcon({
|
||||
double? iconSize,
|
||||
double? iconSizeSelect,
|
||||
EdgeInsets? paddingIconSelect,
|
||||
TextStyle? textStyle
|
||||
}) {
|
||||
if (_selectModeAll == SelectMode.ACTIVE) {
|
||||
return AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 600),
|
||||
transitionBuilder: _transitionBuilder,
|
||||
child: (IconBuilder(_presentationEmail.selectMode == SelectMode.ACTIVE ? _imagePaths.icSelected : _imagePaths.icUnSelected)
|
||||
..padding(EdgeInsets.all(14))
|
||||
..size(GetPlatform.isWeb ? 48 : 56)
|
||||
..padding(paddingIconSelect ?? EdgeInsets.all(14))
|
||||
..size(iconSize ?? (GetPlatform.isWeb ? 48 : 56))
|
||||
..addOnTapActionClick(() {
|
||||
if (_selectModeAll == SelectMode.ACTIVE && _onSelectEmailActionClick != null) {
|
||||
_onSelectEmailActionClick!(_presentationEmail);
|
||||
@@ -208,8 +308,9 @@ class EmailTileBuilder {
|
||||
} else {
|
||||
return (AvatarBuilder()
|
||||
..text('${_presentationEmail.getAvatarText()}')
|
||||
..size(GetPlatform.isWeb ? 48 : 56)
|
||||
..size(iconSize ?? (GetPlatform.isWeb ? 48 : 56))
|
||||
..textColor(Colors.white)
|
||||
..addTextStyle(textStyle)
|
||||
..avatarColor(_presentationEmail.avatarColors))
|
||||
.build();
|
||||
}
|
||||
@@ -240,4 +341,6 @@ class EmailTileBuilder {
|
||||
}
|
||||
return '${_presentationEmail.getSenderName()}';
|
||||
}
|
||||
|
||||
bool get _isSearchEnabled => _searchStatus == SearchStatus.ACTIVE && _searchQuery != null && _searchQuery!.value.isNotEmpty;
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
typedef OnOpenSearchViewAction = Function();
|
||||
|
||||
class SearchBarThreadViewWidget {
|
||||
OnOpenSearchViewAction? _onOpenSearchViewAction;
|
||||
|
||||
final ImagePaths _imagePaths;
|
||||
|
||||
double? _heightSearchBar;
|
||||
EdgeInsets? _padding;
|
||||
EdgeInsets? _margin;
|
||||
String? _hintTextSearch;
|
||||
|
||||
SearchBarThreadViewWidget(this._imagePaths);
|
||||
|
||||
void addOnOpenSearchViewAction(OnOpenSearchViewAction onOpenSearchViewAction) {
|
||||
_onOpenSearchViewAction = onOpenSearchViewAction;
|
||||
}
|
||||
|
||||
void setHeightSearchBar(double heightSearchBar) {
|
||||
_heightSearchBar = heightSearchBar;
|
||||
}
|
||||
|
||||
void addPadding(EdgeInsets padding) {
|
||||
_padding = padding;
|
||||
}
|
||||
|
||||
void addMargin(EdgeInsets margin) {
|
||||
_margin = margin;
|
||||
}
|
||||
|
||||
void hintTextSearch(String text) {
|
||||
_hintTextSearch = text;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
return GestureDetector(
|
||||
onTap: () => _onOpenSearchViewAction?.call(),
|
||||
child: Container(
|
||||
key: Key('search_bar_widget'),
|
||||
alignment: Alignment.topCenter,
|
||||
height: _heightSearchBar ?? 40,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: AppColor.colorBgSearchBar),
|
||||
padding: _padding ?? EdgeInsets.zero,
|
||||
margin: _margin ?? EdgeInsets.only(left: 16, right: 16, bottom: 10),
|
||||
child: MediaQuery(
|
||||
data: MediaQueryData(padding: EdgeInsets.zero),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
_buildSearchButton(),
|
||||
Expanded(child: Text(
|
||||
_hintTextSearch ?? '',
|
||||
maxLines: 1,
|
||||
style: TextStyle(fontSize: 17, color: AppColor.colorHintSearchBar)))
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSearchButton() {
|
||||
return Material(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.transparent,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 2),
|
||||
child: IconButton(
|
||||
icon: SvgPicture.asset(_imagePaths.icSearchBar, width: 18, height: 18, fit: BoxFit.fill),
|
||||
onPressed: () => _onOpenSearchViewAction?.call()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user