TF-1915 Updating correctly state sending email when work manager running
(cherry picked from commit 60b5683cddc2f8c026935528002c736f74018798)
This commit is contained in:
@@ -5,73 +5,98 @@ import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
enum SendingState {
|
||||
ready,
|
||||
delivering,
|
||||
error;
|
||||
waiting,
|
||||
running,
|
||||
error,
|
||||
success;
|
||||
|
||||
String getTitle(BuildContext context) {
|
||||
switch(this) {
|
||||
case SendingState.delivering:
|
||||
case SendingState.waiting:
|
||||
case SendingState.running:
|
||||
return AppLocalizations.of(context).delivering;
|
||||
case SendingState.error:
|
||||
return AppLocalizations.of(context).error;
|
||||
case SendingState.ready:
|
||||
case SendingState.success:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
String getIcon(ImagePaths imagePaths) {
|
||||
switch(this) {
|
||||
case SendingState.delivering:
|
||||
case SendingState.waiting:
|
||||
case SendingState.running:
|
||||
return imagePaths.icDelivering;
|
||||
case SendingState.error:
|
||||
return imagePaths.icError;
|
||||
case SendingState.ready:
|
||||
case SendingState.success:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
String getAvatarGroup(ImagePaths imagePaths) {
|
||||
switch(this) {
|
||||
case SendingState.delivering:
|
||||
case SendingState.running:
|
||||
return imagePaths.icAvatarGroupDelivering;
|
||||
case SendingState.waiting:
|
||||
case SendingState.error:
|
||||
return imagePaths.icAvatarGroup;
|
||||
case SendingState.ready:
|
||||
case SendingState.success:
|
||||
return imagePaths.icAvatarGroup;
|
||||
}
|
||||
}
|
||||
|
||||
String getAvatarPersonal(ImagePaths imagePaths) {
|
||||
switch(this) {
|
||||
case SendingState.delivering:
|
||||
case SendingState.running:
|
||||
return imagePaths.icAvatarPersonalDelivering;
|
||||
case SendingState.waiting:
|
||||
case SendingState.error:
|
||||
return imagePaths.icAvatarPersonal;
|
||||
case SendingState.ready:
|
||||
case SendingState.success:
|
||||
return imagePaths.icAvatarPersonal;
|
||||
}
|
||||
}
|
||||
|
||||
Color getTitleColor() {
|
||||
switch(this) {
|
||||
case SendingState.delivering:
|
||||
case SendingState.waiting:
|
||||
case SendingState.running:
|
||||
case SendingState.success:
|
||||
return AppColor.colorTitleSendingItem;
|
||||
case SendingState.error:
|
||||
return AppColor.colorErrorState;
|
||||
case SendingState.ready:
|
||||
return Colors.transparent;
|
||||
}
|
||||
}
|
||||
|
||||
Color getBackgroundColor() {
|
||||
switch(this) {
|
||||
case SendingState.delivering:
|
||||
case SendingState.waiting:
|
||||
case SendingState.running:
|
||||
case SendingState.success:
|
||||
return AppColor.colorBackgroundDeliveringState;
|
||||
case SendingState.error:
|
||||
return AppColor.colorBackgroundErrorState;
|
||||
case SendingState.ready:
|
||||
return Colors.transparent;
|
||||
}
|
||||
}
|
||||
|
||||
Color getTitleSendingEmailItemColor() {
|
||||
switch(this) {
|
||||
case SendingState.running:
|
||||
return AppColor.colorDeliveringState;
|
||||
case SendingState.waiting:
|
||||
case SendingState.error:
|
||||
case SendingState.success:
|
||||
return Colors.black;
|
||||
}
|
||||
}
|
||||
|
||||
Color getSubTitleSendingEmailItemColor() {
|
||||
switch(this) {
|
||||
case SendingState.running:
|
||||
return AppColor.colorDeliveringState;
|
||||
case SendingState.waiting:
|
||||
case SendingState.error:
|
||||
case SendingState.success:
|
||||
return AppColor.colorTitleSendingItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,11 @@ import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:model/extensions/list_email_content_extension.dart';
|
||||
import 'package:model/extensions/session_extension.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:model/oidc/token_oidc.dart';
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart';
|
||||
import 'package:tmail_ui_user/features/caching/utils/cache_utils.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/send_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/usecases/send_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/delete_sending_email_state.dart';
|
||||
@@ -24,7 +25,6 @@ import 'package:tmail_ui_user/features/offline_mode/bindings/sending_email_inter
|
||||
import 'package:tmail_ui_user/features/offline_mode/exceptions/workmanager_exception.dart';
|
||||
import 'package:tmail_ui_user/features/offline_mode/model/sending_state.dart';
|
||||
import 'package:tmail_ui_user/features/offline_mode/observer/work_observer.dart';
|
||||
import 'package:tmail_ui_user/features/offline_mode/scheduler/worker_state.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/notification/local_notification_config.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/notification/local_notification_manager.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/domain/extensions/sending_email_extension.dart';
|
||||
@@ -68,6 +68,7 @@ class SendingEmailObserver extends WorkObserver {
|
||||
_completer = completer;
|
||||
_sendingEmail = SendingEmail.fromJson(inputData);
|
||||
log('SendingEmailObserver::observe():_sendingEmail: $_sendingEmail');
|
||||
_updatingSendingStateToMainUI();
|
||||
_getAuthenticatedAccount();
|
||||
}
|
||||
|
||||
@@ -90,10 +91,7 @@ class SendingEmailObserver extends WorkObserver {
|
||||
@override
|
||||
void handleFailureViewState(Failure failure) {
|
||||
log('SendingEmailObserver::_handleFailureViewState(): $failure');
|
||||
if (failure is SendEmailFailure) {
|
||||
_updateStoredSendingEmail(SendingState.error);
|
||||
} else if (failure is DeleteSendingEmailFailure) {
|
||||
_showLocalNotification();
|
||||
if (failure is SendEmailFailure || failure is DeleteSendingEmailFailure) {
|
||||
_updateStoredSendingEmail(SendingState.error);
|
||||
} else if (failure is GetAuthenticatedAccountFailure ||
|
||||
failure is NoAuthenticatedAccountFailure ||
|
||||
@@ -101,7 +99,7 @@ class SendingEmailObserver extends WorkObserver {
|
||||
failure is GetStoredTokenOidcFailure ||
|
||||
failure is GetCredentialFailure ||
|
||||
failure is UpdateSendingEmailFailure) {
|
||||
_invokeCompleteWorkManager();
|
||||
_handleTaskFailureInWorkManager();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +124,7 @@ class SendingEmailObserver extends WorkObserver {
|
||||
@override
|
||||
void handleOnError(Object? error, StackTrace stackTrace) {
|
||||
super.handleOnError(error, stackTrace);
|
||||
_invokeCompleteWorkManager();
|
||||
_handleTaskFailureInWorkManager();
|
||||
}
|
||||
|
||||
Future<void> _getInteractorBindings() async {
|
||||
@@ -141,7 +139,24 @@ class SendingEmailObserver extends WorkObserver {
|
||||
_updateSendingEmailInteractor = getBinding<UpdateSendingEmailInteractor>();
|
||||
} catch (e) {
|
||||
logError('SendingEmailObserver::_getInteractorBindings(): ${e.toString()}');
|
||||
_invokeCompleteWorkManager();
|
||||
_handleTaskFailureInWorkManager();
|
||||
}
|
||||
}
|
||||
|
||||
void _updatingSendingStateToMainUI({String? sendingId, SendingState? sendingState}) {
|
||||
final eventAction = _generateEventAction(
|
||||
sendingId ?? _sendingEmail!.sendingId,
|
||||
sendingState ?? _sendingEmail!.sendingState
|
||||
);
|
||||
log('SendingEmailObserver::_updatingSendingStateToMainUI():eventAction: $eventAction');
|
||||
_sendingQueueIsolateManager?.addEvent(eventAction);
|
||||
}
|
||||
|
||||
void _getAuthenticatedAccount() {
|
||||
if (_getAuthenticatedAccountInteractor != null) {
|
||||
consumeState(_getAuthenticatedAccountInteractor!.execute());
|
||||
} else {
|
||||
_handleTaskFailureInWorkManager();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,15 +164,7 @@ class SendingEmailObserver extends WorkObserver {
|
||||
if (_getSessionInteractor != null) {
|
||||
consumeState(_getSessionInteractor!.execute());
|
||||
} else {
|
||||
_invokeCompleteWorkManager();
|
||||
}
|
||||
}
|
||||
|
||||
void _getAuthenticatedAccount() {
|
||||
if (_getAuthenticatedAccountInteractor != null) {
|
||||
consumeState(_getAuthenticatedAccountInteractor!.execute());
|
||||
} else {
|
||||
_invokeCompleteWorkManager();
|
||||
_handleTaskFailureInWorkManager();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,14 +175,14 @@ class SendingEmailObserver extends WorkObserver {
|
||||
if (apiUrl.isNotEmpty) {
|
||||
_dynamicUrlInterceptors?.changeBaseUrl(apiUrl);
|
||||
|
||||
_updateStoredSendingEmail(SendingState.delivering);
|
||||
_updateStoredSendingEmail(SendingState.running);
|
||||
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 2000),
|
||||
_sendEmailAction
|
||||
);
|
||||
} else {
|
||||
_invokeCompleteWorkManager();
|
||||
_handleTaskFailureInWorkManager();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,16 +197,15 @@ class SendingEmailObserver extends WorkObserver {
|
||||
}
|
||||
|
||||
void _sendEmailAction() {
|
||||
final mailboxRequestNotNull = _sendingEmail?.mailboxNameRequest != null && _sendingEmail?.creationIdRequest != null;
|
||||
|
||||
if (_sendEmailInteractor != null && _isDataParameterNotNull) {
|
||||
final mailboxRequest = _sendingEmail!.mailboxNameRequest != null && _sendingEmail!.creationIdRequest != null
|
||||
? CreateNewMailboxRequest(_sendingEmail!.creationIdRequest!, _sendingEmail!.mailboxNameRequest!)
|
||||
: null;
|
||||
consumeState(_sendEmailInteractor!.execute(
|
||||
_currentSession!,
|
||||
_currentAccountId!,
|
||||
_sendingEmail!.toEmailRequest(),
|
||||
mailboxRequest: mailboxRequestNotNull
|
||||
? CreateNewMailboxRequest(_sendingEmail!.creationIdRequest!, _sendingEmail!.mailboxNameRequest!)
|
||||
: null
|
||||
mailboxRequest: mailboxRequest
|
||||
));
|
||||
} else {
|
||||
_updateStoredSendingEmail(SendingState.error);
|
||||
@@ -217,6 +223,7 @@ class SendingEmailObserver extends WorkObserver {
|
||||
}
|
||||
|
||||
void _handleSendEmailSuccess(SendEmailSuccess success) {
|
||||
_showLocalNotification();
|
||||
_deleteSendingEmailAction();
|
||||
}
|
||||
|
||||
@@ -235,16 +242,8 @@ class SendingEmailObserver extends WorkObserver {
|
||||
}
|
||||
}
|
||||
|
||||
void _handleDeleteSendingEmailSuccess() async {
|
||||
_showLocalNotification();
|
||||
_sendingQueueIsolateManager?.addEvent(WorkerState.success.name);
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 1000),
|
||||
() {
|
||||
_completer?.complete(true);
|
||||
_completer = null;
|
||||
}
|
||||
);
|
||||
void _handleDeleteSendingEmailSuccess() {
|
||||
_handleTaskSuccessInWorkManager();
|
||||
}
|
||||
|
||||
void _showLocalNotification() {
|
||||
@@ -259,7 +258,7 @@ class SendingEmailObserver extends WorkObserver {
|
||||
bool get _isDataParameterNotNull => _currentSession != null && _currentAccountId != null && _sendingEmail != null;
|
||||
|
||||
void _updateStoredSendingEmail(SendingState newState) {
|
||||
log('SendingEmailObserver::_updateStoredSendingEmail():');
|
||||
log('SendingEmailObserver::_updateStoredSendingEmail():newState: $newState');
|
||||
if (_updateSendingEmailInteractor != null && _isDataParameterNotNull) {
|
||||
consumeState(_updateSendingEmailInteractor!.execute(
|
||||
_currentAccountId!,
|
||||
@@ -268,34 +267,43 @@ class SendingEmailObserver extends WorkObserver {
|
||||
needToReopen: true
|
||||
));
|
||||
} else {
|
||||
_invokeCompleteWorkManager();
|
||||
_handleTaskFailureInWorkManager();
|
||||
}
|
||||
}
|
||||
|
||||
void _handleUpdateStoredSendingEmailSuccess(UpdateSendingEmailSuccess success) {
|
||||
log('SendingEmailObserver::_handleUpdateStoredSendingEmailSuccess():sendingState: ${success.newSendingEmail.sendingState}');
|
||||
switch (success.newSendingEmail.sendingState) {
|
||||
case SendingState.ready:
|
||||
break;
|
||||
case SendingState.delivering:
|
||||
_sendingQueueIsolateManager?.addEvent(WorkerState.pending.name);
|
||||
break;
|
||||
case SendingState.error:
|
||||
_invokeCompleteWorkManager();
|
||||
break;
|
||||
}
|
||||
_updatingSendingStateToMainUI(
|
||||
sendingState: success.newSendingEmail.sendingState,
|
||||
sendingId: success.newSendingEmail.sendingId);
|
||||
}
|
||||
|
||||
void _invokeCompleteWorkManager() async {
|
||||
log('SendingEmailObserver::_invokeCompleteWorkManager():');
|
||||
_sendingEmail = null;
|
||||
_sendingQueueIsolateManager?.addEvent(WorkerState.failed.name);
|
||||
void _handleTaskFailureInWorkManager() async {
|
||||
log('SendingEmailObserver::_handleTaskFailureInWorkManager():');
|
||||
_updatingSendingStateToMainUI(sendingState: SendingState.error);
|
||||
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 1000),
|
||||
() {
|
||||
_completer?.completeError(CannotCompleteTaskInWorkManagerException());
|
||||
_sendingEmail = null;
|
||||
_completer = null;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void _handleTaskSuccessInWorkManager() async {
|
||||
log('SendingEmailObserver::_handleTaskSuccessInWorkManager():');
|
||||
_updatingSendingStateToMainUI(sendingState: SendingState.success);
|
||||
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 1000),
|
||||
() {
|
||||
_completer?.complete(true);
|
||||
_sendingEmail = null;
|
||||
_completer = null;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
String _generateEventAction(String sendingId, SendingState sendingState) => TupleKey(sendingId, sendingState.name).toString();
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
enum WorkerState {
|
||||
pending,
|
||||
success,
|
||||
failed;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class SendingEmail with EquatableMixin {
|
||||
this.mailboxNameRequest,
|
||||
this.creationIdRequest,
|
||||
this.selectMode = SelectMode.INACTIVE,
|
||||
this.sendingState = SendingState.ready
|
||||
this.sendingState = SendingState.waiting
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -99,9 +99,7 @@ class SendingEmail with EquatableMixin {
|
||||
|
||||
bool get isSelected => selectMode == SelectMode.ACTIVE;
|
||||
|
||||
bool get isDelivering => sendingState == SendingState.delivering;
|
||||
|
||||
bool get isReady => sendingState == SendingState.ready;
|
||||
bool get isWaiting => sendingState == SendingState.waiting;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/domain/usecases/delete_multiple_sending_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/domain/usecases/update_sending_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/presentation/sending_queue_controller.dart';
|
||||
|
||||
class SendingQueueBindings extends Bindings {
|
||||
@@ -11,6 +12,9 @@ class SendingQueueBindings extends Bindings {
|
||||
}
|
||||
|
||||
void _bindingsController() {
|
||||
Get.put(SendingQueueController(Get.find<DeleteMultipleSendingEmailInteractor>()));
|
||||
Get.put(SendingQueueController(
|
||||
Get.find<DeleteMultipleSendingEmailInteractor>(),
|
||||
Get.find<UpdateSendingEmailInteractor>(),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,4 @@ extension ListSendingEmailExtension on List<SendingEmail> {
|
||||
bool isAllUnSelected() => every((sendingEmail) => !sendingEmail.isSelected);
|
||||
|
||||
List<SendingEmail> listSelected() => where((sendingEmail) => sendingEmail.isSelected).toList();
|
||||
|
||||
bool isAllNotReadySendingState() => every((sendingEmail) => !sendingEmail.isReady);
|
||||
|
||||
bool isAllNotDeliveringSendingState() => every((sendingEmail) => !sendingEmail.isDelivering);
|
||||
}
|
||||
@@ -13,11 +13,14 @@ import 'package:model/extensions/list_email_content_extension.dart';
|
||||
import 'package:model/mailbox/select_mode.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/base/mixin/message_dialog_action_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/caching/utils/cache_utils.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/model/composer_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/network_status_handle/presentation/network_connnection_controller.dart';
|
||||
import 'package:tmail_ui_user/features/offline_mode/scheduler/worker_state.dart';
|
||||
import 'package:tmail_ui_user/features/offline_mode/model/sending_state.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/domain/model/sending_email.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/domain/state/update_sending_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/domain/usecases/update_sending_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/presentation/utils/sending_queue_isolate_manager.dart';
|
||||
import 'package:tmail_ui_user/features/offline_mode/controller/work_scheduler_controller.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/domain/state/delete_multiple_sending_email_state.dart';
|
||||
@@ -30,6 +33,7 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
class SendingQueueController extends BaseController with MessageDialogActionMixin {
|
||||
|
||||
final DeleteMultipleSendingEmailInteractor _deleteMultipleSendingEmailInteractor;
|
||||
final UpdateSendingEmailInteractor _updateSendingEmailInteractor;
|
||||
|
||||
final dashboardController = getBinding<MailboxDashBoardController>();
|
||||
final _networkConnectionController = getBinding<NetworkConnectionController>();
|
||||
@@ -41,7 +45,10 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
||||
|
||||
final selectionState = Rx<SelectMode>(SelectMode.INACTIVE);
|
||||
|
||||
SendingQueueController(this._deleteMultipleSendingEmailInteractor);
|
||||
SendingQueueController(
|
||||
this._deleteMultipleSendingEmailInteractor,
|
||||
this._updateSendingEmailInteractor,
|
||||
);
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -56,12 +63,36 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
||||
|
||||
void _handleSendingQueueEvent(Object? event) {
|
||||
log('SendingQueueController::_handleSendingQueueEvent():event: $event');
|
||||
if (event is String) {
|
||||
final workState = WorkerState.values.firstWhereOrNull((state) => state.name == event);
|
||||
log('SendingQueueController::_handleSendingQueueEvent():workState: $workState');
|
||||
if (workState != null) {
|
||||
refreshSendingQueue(needToReopen: true);
|
||||
try {
|
||||
if (event is String) {
|
||||
final tupleKey = TupleKey.fromString(event);
|
||||
final sendingId = tupleKey.parts[0];
|
||||
final sendingState = SendingState.values.firstWhereOrNull((state) => state.name == tupleKey.parts[1]);
|
||||
log('SendingQueueController::_handleSendingQueueEvent():sendingId: $sendingId | sendingState: $sendingState');
|
||||
|
||||
if (sendingState != null) {
|
||||
switch(sendingState) {
|
||||
case SendingState.waiting:
|
||||
_handleSendingStateRunningEvent(sendingId);
|
||||
break;
|
||||
case SendingState.running:
|
||||
case SendingState.success:
|
||||
case SendingState.error:
|
||||
refreshSendingQueue(needToReopen: true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logError('SendingQueueController::_handleSendingQueueEvent(): EXCEPTION: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void _handleSendingStateRunningEvent(String sendingId) {
|
||||
log('SendingQueueController::_handleSendingStateRunningEvent():sendingId: $sendingId');
|
||||
final matchedSendingEmail = dashboardController!.listSendingEmails.firstWhereOrNull((sendingEmail) => sendingEmail.sendingId == sendingId);
|
||||
if (matchedSendingEmail != null) {
|
||||
_updateSendingEmailAction(matchedSendingEmail);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,12 +231,27 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
||||
selectionState.value = SelectMode.INACTIVE;
|
||||
}
|
||||
|
||||
void _updateSendingEmailAction(SendingEmail newSendingEmail) {
|
||||
final accountId = dashboardController!.accountId.value;
|
||||
final session = dashboardController!.sessionCurrent;
|
||||
if (accountId != null && session != null) {
|
||||
consumeState(_updateSendingEmailInteractor.execute(
|
||||
accountId,
|
||||
session.username,
|
||||
newSendingEmail,
|
||||
needToReopen: true
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void handleSuccessViewState(Success success) {
|
||||
super.handleSuccessViewState(success);
|
||||
if (success is DeleteMultipleSendingEmailAllSuccess ||
|
||||
success is DeleteMultipleSendingEmailHasSomeSuccess) {
|
||||
_handleDeleteSendingEmailSuccess();
|
||||
} else if (success is UpdateSendingEmailSuccess) {
|
||||
refreshSendingQueue(needToReopen: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
||||
}),
|
||||
const Divider(color: AppColor.colorDividerComposer, height: 1),
|
||||
Obx(() {
|
||||
if (!controller.dashboardController!.listSendingEmails.isAllNotReadySendingState()) {
|
||||
if (!controller.isConnectedNetwork) {
|
||||
return const BannerMessageSendingQueueWidget();
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
@@ -87,7 +87,7 @@ class SendingQueueView extends GetWidget<SendingQueueController> with AppLoaderM
|
||||
onLongPressAction: controller.handleOnLongPressAction,
|
||||
onSelectLeadingAction: controller.toggleSelectionSendingEmail,
|
||||
onTapAction: (actionType, sendingEmail) {
|
||||
if (!controller.isConnectedNetwork && sendingEmail.isReady) {
|
||||
if (!controller.isConnectedNetwork && sendingEmail.isWaiting) {
|
||||
controller.handleSendingEmailActionType(context, actionType, [sendingEmail]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/domain/model/sending_email.dart';
|
||||
|
||||
class SendingQueueUtils {
|
||||
|
||||
@@ -29,11 +28,11 @@ class SendingQueueUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static EdgeInsets getPaddingDividerListViewByResponsiveSize(double width, SendingEmail sendingEmail) {
|
||||
static EdgeInsets getPaddingDividerListViewByResponsiveSize(double width) {
|
||||
if (ResponsiveUtils.isMatchedMobileWidth(width)) {
|
||||
return EdgeInsets.only(left: 84, right: 8, top: sendingEmail.isReady ? 0 : 8);
|
||||
return const EdgeInsets.only(left: 84, right: 8, top: 8);
|
||||
} else {
|
||||
return EdgeInsets.only(left: 100, right: 24, top: sendingEmail.isReady ? 0 : 8);
|
||||
return const EdgeInsets.only(left: 100, right: 24, top: 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-11
@@ -6,7 +6,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<SendingEmail>);
|
||||
@@ -54,15 +53,11 @@ class BottomBarSendingQueueWidget extends StatelessWidget {
|
||||
).build()),
|
||||
Expanded(child: (ButtonBuilder(imagePaths.icDeleteComposer)
|
||||
..key(Key(SendingEmailActionType.delete.getButtonKey()))
|
||||
..iconColor(SendingEmailActionType.delete.getButtonIconColor(_isCanBeDeleted ? ButtonState.enabled : ButtonState.disabled))
|
||||
..iconColor(SendingEmailActionType.delete.getButtonIconColor(ButtonState.enabled))
|
||||
..padding(const EdgeInsets.all(8))
|
||||
..radiusSplash(8)
|
||||
..textStyle(TextStyle(fontSize: 12, color: SendingEmailActionType.delete.getButtonTitleColor(_isCanBeDeleted ? ButtonState.enabled : ButtonState.disabled)))
|
||||
..onPressActionClick(() {
|
||||
if (_isCanBeDeleted) {
|
||||
onHandleSendingEmailActionType?.call(SendingEmailActionType.delete, listSendingEmailSelected);
|
||||
}
|
||||
})
|
||||
..textStyle(TextStyle(fontSize: 12, color: SendingEmailActionType.delete.getButtonTitleColor(ButtonState.enabled)))
|
||||
..onPressActionClick(() => onHandleSendingEmailActionType?.call(SendingEmailActionType.delete, listSendingEmailSelected))
|
||||
..text(SendingEmailActionType.delete.getButtonTitle(context), isVertical: true)
|
||||
).build())
|
||||
],
|
||||
@@ -72,7 +67,5 @@ class BottomBarSendingQueueWidget extends StatelessWidget {
|
||||
|
||||
bool get _isEditable => !isConnectedNetwork &&
|
||||
listSendingEmailSelected.length == 1 &&
|
||||
listSendingEmailSelected.first.isReady;
|
||||
|
||||
bool get _isCanBeDeleted => listSendingEmailSelected.isAllNotDeliveringSendingState();
|
||||
listSendingEmailSelected.first.isWaiting;
|
||||
}
|
||||
@@ -97,9 +97,7 @@ class SendingEmailTileWidget extends StatelessWidget {
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: sendingEmail.isDelivering
|
||||
? AppColor.colorDeliveringState
|
||||
: Colors.black,
|
||||
color: sendingEmail.sendingState.getTitleSendingEmailItemColor(),
|
||||
fontWeight: FontWeight.w600
|
||||
)
|
||||
)),
|
||||
@@ -122,14 +120,12 @@ class SendingEmailTileWidget extends StatelessWidget {
|
||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: sendingEmail.isDelivering
|
||||
? AppColor.colorDeliveringState
|
||||
: Colors.black,
|
||||
color: sendingEmail.sendingState.getTitleSendingEmailItemColor(),
|
||||
fontWeight: FontWeight.normal
|
||||
)
|
||||
)
|
||||
),
|
||||
if (!sendingEmail.isReady && !ResponsiveUtils.isMatchedMobileWidth(constraints.maxWidth))
|
||||
if (!ResponsiveUtils.isMatchedMobileWidth(constraints.maxWidth))
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 8),
|
||||
width: 120,
|
||||
@@ -153,13 +149,11 @@ class SendingEmailTileWidget extends StatelessWidget {
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: sendingEmail.isDelivering
|
||||
? AppColor.colorDeliveringState
|
||||
: AppColor.colorTitleSendingItem,
|
||||
color: sendingEmail.sendingState.getSubTitleSendingEmailItemColor(),
|
||||
fontWeight: FontWeight.normal
|
||||
)
|
||||
),
|
||||
if (!sendingEmail.isReady && ResponsiveUtils.isMatchedMobileWidth(constraints.maxWidth))
|
||||
if (ResponsiveUtils.isMatchedMobileWidth(constraints.maxWidth))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: SendingStateWidget(sendingState: sendingEmail.sendingState))
|
||||
@@ -168,7 +162,7 @@ class SendingEmailTileWidget extends StatelessWidget {
|
||||
]),
|
||||
),
|
||||
Padding(
|
||||
padding: SendingQueueUtils.getPaddingDividerListViewByResponsiveSize(constraints.maxWidth, sendingEmail),
|
||||
padding: SendingQueueUtils.getPaddingDividerListViewByResponsiveSize(constraints.maxWidth),
|
||||
child: const Divider(
|
||||
color: AppColor.lineItemListColor,
|
||||
height: 1,
|
||||
|
||||
Reference in New Issue
Block a user