From af73f90508e7cab37f3adeb11443e13f4ddf103d Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 9 Jun 2023 16:30:48 +0700 Subject: [PATCH] TF-1915 Add Refresh To Pull for SendingQueueView (cherry picked from commit a3c1e891bbd002b116d39ac1e28a4f4b8ba4b4e1) --- .../presentation/sending_queue_controller.dart | 6 +++--- .../presentation/sending_queue_view.dart | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/features/sending_queue/presentation/sending_queue_controller.dart b/lib/features/sending_queue/presentation/sending_queue_controller.dart index 0a75e8461..4bdc74880 100644 --- a/lib/features/sending_queue/presentation/sending_queue_controller.dart +++ b/lib/features/sending_queue/presentation/sending_queue_controller.dart @@ -60,7 +60,7 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi final workState = WorkerState.values.firstWhereOrNull((state) => state.name == event); log('SendingQueueController::_handleSendingQueueEvent():workState: $workState'); if (workState != null) { - _refreshSendingQueue(needToReopen: true); + refreshSendingQueue(needToReopen: true); } } } @@ -87,7 +87,7 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi bool get isConnectedNetwork => _networkConnectionController?.isNetworkConnectionAvailable() == true; - void _refreshSendingQueue({bool needToReopen = false}) { + void refreshSendingQueue({bool needToReopen = false}) { dashboardController!.getAllSendingEmails(needToReopen: needToReopen); } @@ -178,7 +178,7 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi AppLocalizations.of(currentContext!).messageHaveBeenDeletedSuccessfully ); - _refreshSendingQueue(); + refreshSendingQueue(); } } diff --git a/lib/features/sending_queue/presentation/sending_queue_view.dart b/lib/features/sending_queue/presentation/sending_queue_view.dart index f84acd67c..f03cc6e55 100644 --- a/lib/features/sending_queue/presentation/sending_queue_view.dart +++ b/lib/features/sending_queue/presentation/sending_queue_view.dart @@ -1,6 +1,7 @@ import 'package:core/presentation/extensions/color_extension.dart'; import 'package:flutter/material.dart'; +import 'package:model/mailbox/select_mode.dart'; import 'package:tmail_ui_user/features/base/mixin/app_loader_mixin.dart'; import 'package:tmail_ui_user/features/base/widget/compose_floating_button.dart'; import 'package:tmail_ui_user/features/email/presentation/model/composer_arguments.dart'; @@ -59,11 +60,25 @@ class SendingQueueView extends GetWidget with AppLoaderM } Widget _buildListSendingEmails(BuildContext context) { + return Obx(() { + if (controller.selectionState.value == SelectMode.INACTIVE) { + return RefreshIndicator( + color: AppColor.primaryColor, + onRefresh: () async => controller.refreshSendingQueue(needToReopen: true), + child: _buildListViewItemSendingEmails()); + } else { + return _buildListViewItemSendingEmails(); + } + }); + } + + Widget _buildListViewItemSendingEmails() { return Obx(() { final listSendingEmails = controller.dashboardController!.listSendingEmails; if (listSendingEmails.isNotEmpty) { return ListView.builder( controller: controller.listSendingEmailController, + physics: const AlwaysScrollableScrollPhysics(), // Trigger Refresh To pull itemCount: listSendingEmails.length, itemBuilder: (context, index) { return SendingEmailTileWidget(