TF-1793 Add spam mailbox to canDeletePermanently condition

(cherry picked from commit 242122dcb187c1032208de4a756b250bb5335087)
This commit is contained in:
hieubt
2023-10-24 08:36:22 +07:00
committed by Dat H. Pham
parent 6f471deec5
commit 73a8919f18
5 changed files with 18 additions and 13 deletions
@@ -117,17 +117,17 @@ class EmailViewAppBarWidget extends StatelessWidget {
iconSize: EmailViewAppBarWidgetStyles.deleteButtonIconSize, iconSize: EmailViewAppBarWidgetStyles.deleteButtonIconSize,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
padding: EmailViewAppBarWidgetStyles.buttonPadding, padding: EmailViewAppBarWidgetStyles.buttonPadding,
iconColor: mailboxContain?.isTrash == false iconColor: canDeletePermanently
? EmailViewAppBarWidgetStyles.emptyTrashButtonColor ? EmailViewAppBarWidgetStyles.deletePermanentButtonColor
: EmailViewAppBarWidgetStyles.deletePermanentButtonColor, : EmailViewAppBarWidgetStyles.emptyTrashButtonColor,
tooltipMessage: mailboxContain?.isTrash == false tooltipMessage: canDeletePermanently
? AppLocalizations.of(context).move_to_trash ? AppLocalizations.of(context).delete_permanently
: AppLocalizations.of(context).delete_permanently, : AppLocalizations.of(context).move_to_trash,
onTapActionCallback: () { onTapActionCallback: () {
if (mailboxContain?.isTrash == false) { if (canDeletePermanently) {
onEmailActionClick?.call(presentationEmail, EmailActionType.moveToTrash);
} else {
onEmailActionClick?.call(presentationEmail, EmailActionType.deletePermanently); onEmailActionClick?.call(presentationEmail, EmailActionType.deletePermanently);
} else {
onEmailActionClick?.call(presentationEmail, EmailActionType.moveToTrash);
} }
} }
), ),
@@ -165,4 +165,8 @@ class EmailViewAppBarWidget extends StatelessWidget {
isSearchActivated; isSearchActivated;
} }
} }
bool get canDeletePermanently {
return mailboxContain?.isTrash == true || mailboxContain?.isSpam == true;
}
} }
@@ -152,5 +152,5 @@ class SelectionWebAppBarThreadWidget extends StatelessWidget {
); );
} }
bool get _deletePermanentlyValid => mailboxSelected?.isTrash == true || mailboxSelected?.isDrafts == true; bool get _deletePermanentlyValid => mailboxSelected?.isTrash == true || mailboxSelected?.isDrafts == true || mailboxSelected?.isSpam == true;
} }
@@ -164,7 +164,7 @@ class BottomBarThreadSelectionWidget extends StatelessWidget{
} }
bool get canDeletePermanently { bool get canDeletePermanently {
return _currentMailbox?.isTrash == true || _currentMailbox?.isDrafts == true; return _currentMailbox?.isTrash == true || _currentMailbox?.isDrafts == true || _currentMailbox?.isSpam == true;
} }
bool _verticalDirection(BuildContext context) { bool _verticalDirection(BuildContext context) {
@@ -477,7 +477,7 @@ class EmailTileBuilder with BaseEmailItemTile {
} }
bool get canDeletePermanently { bool get canDeletePermanently {
return mailboxContain?.isTrash == true || mailboxContain?.isDrafts == true; return mailboxContain?.isTrash == true || mailboxContain?.isDrafts == true || mailboxContain?.isSpam == true;
} }
Widget _buildDateTimeForDesktopScreen() { Widget _buildDateTimeForDesktopScreen() {
@@ -27,7 +27,8 @@ extension ListPresentationEmailExtension on List<PresentationEmail> {
.whereType<PresentationMailbox>() .whereType<PresentationMailbox>()
.toList(); .toList();
final stateDelete = listMailboxContain.every((mailbox) => mailbox.isTrash) || final stateDelete = listMailboxContain.every((mailbox) => mailbox.isTrash) ||
listMailboxContain.every((mailbox) => mailbox.isDrafts); listMailboxContain.every((mailbox) => mailbox.isDrafts) ||
listMailboxContain.every((mailbox) => mailbox.isSpam);
return stateDelete; return stateDelete;
} }