From 4952fbe84011db463d0bc2af55ff05300450146a Mon Sep 17 00:00:00 2001 From: Dat PHAM HOANG Date: Thu, 11 Jan 2024 01:00:50 +0700 Subject: [PATCH] [Android][Disable work manager] Update the rule for the actions in Sending queue: - editable all the time - can resend manually only when have network (cherry picked from commit c77f8de4041a53aa1a9a6c7198f2db9bd4cf0c60) --- .../domain/model/sending_email.dart | 7 +++-- .../bottom_bar_sending_queue_widget.dart | 27 +++++++------------ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/lib/features/sending_queue/domain/model/sending_email.dart b/lib/features/sending_queue/domain/model/sending_email.dart index 8fa5acaae..13f96059d 100644 --- a/lib/features/sending_queue/domain/model/sending_email.dart +++ b/lib/features/sending_queue/domain/model/sending_email.dart @@ -1,4 +1,5 @@ import 'dart:convert'; + import 'package:core/domain/extensions/datetime_extension.dart'; import 'package:core/utils/platform_info.dart'; import 'package:equatable/equatable.dart'; @@ -115,10 +116,8 @@ class SendingEmail with EquatableMixin { bool get isRunning => sendingState == SendingState.running; bool get isEditableSupported { - if (PlatformInfo.isAndroid) { - return isWaiting || isRunning || isCanceled; - } else if (PlatformInfo.isIOS) { - return isWaiting || isCanceled; + if (PlatformInfo.isMobile) { + return isWaiting || isCanceled || isError; } else { return false; } diff --git a/lib/features/sending_queue/presentation/widgets/bottom_bar_sending_queue_widget.dart b/lib/features/sending_queue/presentation/widgets/bottom_bar_sending_queue_widget.dart index 81a77425a..4f5ee1353 100644 --- a/lib/features/sending_queue/presentation/widgets/bottom_bar_sending_queue_widget.dart +++ b/lib/features/sending_queue/presentation/widgets/bottom_bar_sending_queue_widget.dart @@ -8,7 +8,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tmail_ui_user/features/base/state/button_state.dart'; import 'package:tmail_ui_user/features/sending_queue/domain/model/sending_email.dart'; -import 'package:tmail_ui_user/features/sending_queue/presentation/extensions/list_sending_email_extension.dart'; import 'package:tmail_ui_user/features/sending_queue/presentation/model/sending_email_action_type.dart'; typedef OnHandleSendingEmailActionType = void Function(SendingEmailActionType, List); @@ -49,14 +48,14 @@ class BottomBarSendingQueueWidget extends StatelessWidget { icon: _imagePaths.icEdit, borderRadius: 0, backgroundColor: Colors.transparent, - iconColor: SendingEmailActionType.edit.getButtonIconColor(_isEditable ? ButtonState.enabled : ButtonState.disabled), + iconColor: SendingEmailActionType.edit.getButtonIconColor(_canEditable ? ButtonState.enabled : ButtonState.disabled), textStyle: TextStyle( fontSize: 12, - color: SendingEmailActionType.edit.getButtonTitleColor(_isEditable ? ButtonState.enabled : ButtonState.disabled) + color: SendingEmailActionType.edit.getButtonTitleColor(_canEditable ? ButtonState.enabled : ButtonState.disabled) ), verticalDirection: _responsiveUtils.isPortraitMobile(context), onTapActionCallback: () { - if (_isEditable) { + if (_canEditable) { onHandleSendingEmailActionType?.call( SendingEmailActionType.edit, listSendingEmailSelected @@ -72,14 +71,14 @@ class BottomBarSendingQueueWidget extends StatelessWidget { icon: _imagePaths.icRefresh, borderRadius: 0, backgroundColor: Colors.transparent, - iconColor: SendingEmailActionType.resend.getButtonIconColor(_isCanResend ? ButtonState.enabled : ButtonState.disabled), + iconColor: SendingEmailActionType.resend.getButtonIconColor(_canResend ? ButtonState.enabled : ButtonState.disabled), textStyle: TextStyle( fontSize: 12, - color: SendingEmailActionType.resend.getButtonTitleColor(_isCanResend ? ButtonState.enabled : ButtonState.disabled) + color: SendingEmailActionType.resend.getButtonTitleColor(_canResend ? ButtonState.enabled : ButtonState.disabled) ), verticalDirection: _responsiveUtils.isPortraitMobile(context), onTapActionCallback: () { - if (_isCanResend) { + if (_canResend) { onHandleSendingEmailActionType?.call(SendingEmailActionType.resend, listSendingEmailSelected); } }, @@ -106,12 +105,8 @@ class BottomBarSendingQueueWidget extends StatelessWidget { ); } - bool get _isEditable { - if (PlatformInfo.isAndroid) { - return !isConnectedNetwork && - listSendingEmailSelected.length == 1 && - listSendingEmailSelected.first.isEditableSupported; - } else if (PlatformInfo.isIOS) { + bool get _canEditable { + if (PlatformInfo.isMobile) { return listSendingEmailSelected.length == 1 && listSendingEmailSelected.first.isEditableSupported; } else { @@ -119,10 +114,8 @@ class BottomBarSendingQueueWidget extends StatelessWidget { } } - bool get _isCanResend { - if (PlatformInfo.isAndroid) { - return listSendingEmailSelected.isAllSendingStateError(); - } else if (PlatformInfo.isIOS) { + bool get _canResend { + if (PlatformInfo.isMobile) { return isConnectedNetwork && listSendingEmailSelected.length == 1 && (listSendingEmailSelected.first.isWaiting || listSendingEmailSelected.first.isError);