TF-3002 [WEB] Apply new design for SearchFilterButton
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/email_receive_time_type.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/email_sort_order_type.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/search_email_filter.dart';
|
||||
@@ -11,7 +12,9 @@ enum QuickSearchFilter {
|
||||
hasAttachment,
|
||||
last7Days,
|
||||
fromMe,
|
||||
sortBy;
|
||||
sortBy,
|
||||
dateTime,
|
||||
from;
|
||||
|
||||
String getName(BuildContext context) {
|
||||
switch(this) {
|
||||
@@ -23,6 +26,12 @@ enum QuickSearchFilter {
|
||||
return AppLocalizations.of(context).fromMe;
|
||||
case QuickSearchFilter.sortBy:
|
||||
return AppLocalizations.of(context).sortBy;
|
||||
case QuickSearchFilter.dateTime:
|
||||
return AppLocalizations.of(context).allTime;
|
||||
case QuickSearchFilter.from:
|
||||
return AppLocalizations.of(context).from_email_address_prefix;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,74 +41,109 @@ enum QuickSearchFilter {
|
||||
EmailSortOrderType? sortOrderType,
|
||||
DateTime? startDate,
|
||||
DateTime? endDate,
|
||||
Set<String>? listAddressOfFrom,
|
||||
UserName? userName
|
||||
}) {
|
||||
switch(this) {
|
||||
case QuickSearchFilter.hasAttachment:
|
||||
return AppLocalizations.of(context).hasAttachment;
|
||||
case QuickSearchFilter.last7Days:
|
||||
return receiveTimeType?.getTitle(context, startDate: startDate, endDate: endDate)
|
||||
?? AppLocalizations.of(context).allTime;
|
||||
return AppLocalizations.of(context).last7Days;
|
||||
case QuickSearchFilter.fromMe:
|
||||
return AppLocalizations.of(context).fromMe;
|
||||
case QuickSearchFilter.sortBy:
|
||||
return sortOrderType?.getTitle(context)
|
||||
?? AppLocalizations.of(context).mostRecent;
|
||||
case QuickSearchFilter.dateTime:
|
||||
return receiveTimeType?.getTitle(
|
||||
context,
|
||||
startDate: startDate,
|
||||
endDate: endDate
|
||||
) ?? AppLocalizations.of(context).allTime;
|
||||
case QuickSearchFilter.from:
|
||||
if (listAddressOfFrom?.length != 1) {
|
||||
return AppLocalizations.of(context).from_email_address_prefix;
|
||||
}
|
||||
|
||||
if (userName?.value.isNotEmpty == true && listAddressOfFrom?.first == userName?.value) {
|
||||
return AppLocalizations.of(context).fromMe;
|
||||
} else {
|
||||
return '${AppLocalizations.of(context).from_email_address_prefix} ${listAddressOfFrom?.first}';
|
||||
}
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
String getIcon(ImagePaths imagePaths, {required bool isFilterSelected}) {
|
||||
if (isFilterSelected) {
|
||||
return imagePaths.icSelectedSB;
|
||||
} else {
|
||||
switch(this) {
|
||||
case QuickSearchFilter.hasAttachment:
|
||||
return imagePaths.icAttachmentSB;
|
||||
case QuickSearchFilter.last7Days:
|
||||
return imagePaths.icCalendarSB;
|
||||
case QuickSearchFilter.fromMe:
|
||||
return imagePaths.icUserSB;
|
||||
case QuickSearchFilter.sortBy:
|
||||
return imagePaths.icFilterSB;
|
||||
}
|
||||
String getIcon(ImagePaths imagePaths, {bool isSelected = false}) {
|
||||
switch(this) {
|
||||
case QuickSearchFilter.hasAttachment:
|
||||
return isSelected ? imagePaths.icSelectedSB : imagePaths.icAttachmentSB;
|
||||
case QuickSearchFilter.last7Days:
|
||||
return isSelected ? imagePaths.icSelectedSB : imagePaths.icCalendarSB;
|
||||
case QuickSearchFilter.fromMe:
|
||||
return isSelected ? imagePaths.icSelectedSB : imagePaths.icUserSB;
|
||||
case QuickSearchFilter.sortBy:
|
||||
return imagePaths.icFilterSB;
|
||||
case QuickSearchFilter.dateTime:
|
||||
return imagePaths.icCalendarSB;
|
||||
case QuickSearchFilter.from:
|
||||
return imagePaths.icUserSB;
|
||||
}
|
||||
}
|
||||
|
||||
Color getBackgroundColor({required bool isFilterSelected}) {
|
||||
Color getBackgroundColor({bool isFilterSelected = false}) {
|
||||
if (isFilterSelected) {
|
||||
return AppColor.colorItemEmailSelectedDesktop;
|
||||
return AppColor.primaryColor.withOpacity(0.06);
|
||||
} else {
|
||||
return AppColor.colorButtonHeaderThread;
|
||||
return AppColor.colorSearchFilterButton;
|
||||
}
|
||||
}
|
||||
|
||||
TextStyle getTextStyle({required bool isFilterSelected}) {
|
||||
Color getSuggestionBackgroundColor({bool isFilterSelected = false}) {
|
||||
if (isFilterSelected) {
|
||||
return const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColor.colorTextButton);
|
||||
return AppColor.primaryColor.withOpacity(0.06);
|
||||
} else {
|
||||
return const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: AppColor.colorTextButtonHeaderThread);
|
||||
return AppColor.colorSuggestionSearchFilterButton.withOpacity(0.6);
|
||||
}
|
||||
}
|
||||
|
||||
Color getIconColor({bool isSelected = false}) {
|
||||
if (isSelected) {
|
||||
return AppColor.primaryColor;
|
||||
} else {
|
||||
return AppColor.colorTextBody;
|
||||
}
|
||||
}
|
||||
|
||||
bool isApplied(List<QuickSearchFilter> listFilter) => listFilter.contains(this);
|
||||
|
||||
bool isSelected(SearchEmailFilter filter) {
|
||||
bool isSelected(
|
||||
BuildContext context,
|
||||
SearchEmailFilter searchFilter,
|
||||
EmailSortOrderType sortOrderType
|
||||
) {
|
||||
switch (this) {
|
||||
case QuickSearchFilter.hasAttachment:
|
||||
return filter.hasAttachment == true;
|
||||
return searchFilter.hasAttachment;
|
||||
case QuickSearchFilter.last7Days:
|
||||
return true;
|
||||
case QuickSearchFilter.fromMe:
|
||||
return filter.from.length == 1;
|
||||
return searchFilter.from.length == 1;
|
||||
case QuickSearchFilter.sortBy:
|
||||
return true;
|
||||
return sortOrderType != EmailSortOrderType.mostRecent;
|
||||
case QuickSearchFilter.dateTime:
|
||||
return searchFilter.emailReceiveTimeType != EmailReceiveTimeType.allTime;
|
||||
case QuickSearchFilter.from:
|
||||
return searchFilter.from.isNotEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
bool isTapOpenPopupMenu() => this == QuickSearchFilter.last7Days || this == QuickSearchFilter.sortBy;
|
||||
bool isOnTapWithPositionActionSupported() =>
|
||||
this == QuickSearchFilter.dateTime || this == QuickSearchFilter.sortBy;
|
||||
|
||||
bool isArrowDownIconSupported() =>
|
||||
this == QuickSearchFilter.dateTime ||
|
||||
this == QuickSearchFilter.from ||
|
||||
this == QuickSearchFilter.sortBy;
|
||||
}
|
||||
Reference in New Issue
Block a user