TF-1915 Add Refresh To Pull for SendingQueueView

(cherry picked from commit a3c1e891bbd002b116d39ac1e28a4f4b8ba4b4e1)
This commit is contained in:
dab246
2023-06-09 16:30:48 +07:00
committed by Dat Vu
parent 3ed868c35d
commit af73f90508
2 changed files with 18 additions and 3 deletions
@@ -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();
}
}
@@ -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<SendingQueueController> 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(