TF-2925 Write widget test for thread view
This commit is contained in:
@@ -440,7 +440,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
|
||||
void _getAllEmailSuccess(GetAllEmailSuccess success) {
|
||||
if (success.currentMailboxId != selectedMailboxId) {
|
||||
log('ThreadController::_getAllEmailSuccess: GetAllForMailboxEd = ${success.currentMailboxId?.asString} | SELECTED_MAILBOX_ID = ${selectedMailboxId?.asString} | SELECTED_MAILBOX_NAME = ${selectedMailbox?.name?.name}');
|
||||
log('ThreadController::_getAllEmailSuccess: GetAllForMailboxId = ${success.currentMailboxId?.asString} | SELECTED_MAILBOX_ID = ${selectedMailboxId?.asString} | SELECTED_MAILBOX_NAME = ${selectedMailbox?.name?.name}');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -933,8 +933,6 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
}
|
||||
}
|
||||
|
||||
bool isSelectionEnabled() => mailboxDashBoardController.isSelectionEnabled();
|
||||
|
||||
void pressEmailSelectionAction(BuildContext context, EmailActionType actionType, List<PresentationEmail> selectionEmail) {
|
||||
switch(actionType) {
|
||||
case EmailActionType.markAsRead:
|
||||
|
||||
@@ -248,13 +248,21 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
|
||||
Widget _buildListButtonSelectionForMobile(BuildContext context) {
|
||||
return Obx(() {
|
||||
if ((PlatformInfo.isMobile || (PlatformInfo.isWeb && controller.isSelectionEnabled()
|
||||
&& controller.isSearchActive && !controller.responsiveUtils.isDesktop(context)))
|
||||
&& controller.mailboxDashBoardController.emailsInCurrentMailbox.listEmailSelected.isNotEmpty) {
|
||||
final listEmailSelected = controller.mailboxDashBoardController.emailsInCurrentMailbox.listEmailSelected;
|
||||
final currentSelectMode = controller.mailboxDashBoardController.currentSelectMode.value;
|
||||
final isSearchEmailRunning = controller.searchController.simpleSearchIsActivated.isTrue
|
||||
|| controller.searchController.advancedSearchIsActivated.isTrue;
|
||||
|
||||
if (_validateDisplayBottomBarSelection(
|
||||
context: context,
|
||||
listEmailSelected: listEmailSelected,
|
||||
isSearchEmailRunning: isSearchEmailRunning,
|
||||
currentSelectMode: currentSelectMode
|
||||
)) {
|
||||
return BottomBarThreadSelectionWidget(
|
||||
controller.imagePaths,
|
||||
controller.responsiveUtils,
|
||||
controller.mailboxDashBoardController.emailsInCurrentMailbox.listEmailSelected,
|
||||
listEmailSelected,
|
||||
controller.mailboxDashBoardController.selectedMailbox.value,
|
||||
onPressEmailSelectionActionClick: (actionType, selectionEmail) =>
|
||||
controller.pressEmailSelectionAction(
|
||||
@@ -269,6 +277,28 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
});
|
||||
}
|
||||
|
||||
bool _validateDisplayBottomBarSelection({
|
||||
required BuildContext context,
|
||||
required List<PresentationEmail> listEmailSelected,
|
||||
required bool isSearchEmailRunning,
|
||||
required SelectMode currentSelectMode,
|
||||
}) {
|
||||
if (PlatformInfo.isMobile && listEmailSelected.isNotEmpty) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PlatformInfo.isWeb
|
||||
&& currentSelectMode == SelectMode.ACTIVE
|
||||
&& isSearchEmailRunning
|
||||
&& !controller.responsiveUtils.isDesktop(context)
|
||||
&& listEmailSelected.isNotEmpty
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Widget _buildFloatingButtonCompose(BuildContext context) {
|
||||
if (controller.responsiveUtils.isWebDesktop(context)) {
|
||||
return const SizedBox.shrink();
|
||||
@@ -394,7 +424,7 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
if (index == listPresentationEmail.length + 1) {
|
||||
return _buildLoadMoreProgressBar(controller.loadingMoreStatus.value);
|
||||
}
|
||||
return _buildEmailItem(
|
||||
return _buildEmailItem(
|
||||
context,
|
||||
listPresentationEmail[index]);
|
||||
}),
|
||||
@@ -487,6 +517,7 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
final selectModeAll = controller.mailboxDashBoardController.currentSelectMode.value;
|
||||
|
||||
return EmailTileBuilder(
|
||||
key: Key('email_tile_builder_${presentationEmail.id?.asString}'),
|
||||
presentationEmail: presentationEmail,
|
||||
selectAllMode: selectModeAll,
|
||||
isShowingEmailContent: isShowingEmailContent,
|
||||
@@ -571,6 +602,7 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
: null,
|
||||
confirmDismiss: (direction) => controller.swipeEmailAction(context, presentationEmail, direction),
|
||||
child: EmailTileBuilder(
|
||||
key: Key('email_tile_builder_${presentationEmail.id?.asString}'),
|
||||
presentationEmail: presentationEmail,
|
||||
selectAllMode: selectModeAll,
|
||||
isShowingEmailContent: isShowingEmailContent,
|
||||
@@ -656,24 +688,24 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
return Obx(() => controller.viewState.value.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) {
|
||||
if (success is! GetAllEmailLoading && success is! SearchingState) {
|
||||
if (success is GetAllEmailSuccess
|
||||
&& success.currentMailboxId != controller.selectedMailboxId) {
|
||||
return const SizedBox.shrink();
|
||||
} else {
|
||||
return EmptyEmailsWidget(
|
||||
key: const Key('empty_thread_view'),
|
||||
title: _getMessageEmptyEmail(context),
|
||||
iconSVG: controller.imagePaths.icEmptyEmail,
|
||||
subTitle: _getSubMessageEmptyEmail(context),
|
||||
onCreateFiltersActionCallback: controller.isNewFolderCreated
|
||||
? controller.goToCreateEmailRuleView
|
||||
: null,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (success is GetAllEmailLoading || success is SearchingState) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
if (success is GetAllEmailSuccess
|
||||
&& success.currentMailboxId != controller.selectedMailboxId) {
|
||||
return const SizedBox.shrink();
|
||||
} else {
|
||||
return EmptyEmailsWidget(
|
||||
key: const Key('empty_thread_view'),
|
||||
title: _getMessageEmptyEmail(context),
|
||||
iconSVG: controller.imagePaths.icEmptyEmail,
|
||||
subTitle: _getSubMessageEmptyEmail(context),
|
||||
onCreateFiltersActionCallback: controller.isNewFolderCreated
|
||||
? controller.goToCreateEmailRuleView
|
||||
: null,
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
+3
-1
@@ -2,6 +2,7 @@ import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/utils/direction_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/model/spam_report_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/spam_report_controller.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/styles/spam_banner/spam_report_banner_button_styles.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/styles/spam_banner/spam_report_banner_label_styles.dart';
|
||||
@@ -18,7 +19,8 @@ class SpamReportBannerWebWidget extends StatelessWidget {
|
||||
final spamReportController = Get.find<SpamReportController>();
|
||||
final imagePaths = Get.find<ImagePaths>();
|
||||
return Obx(() {
|
||||
if (!spamReportController.enableSpamReport || spamReportController.notShowSpamReportBanner) {
|
||||
if (spamReportController.spamReportState.value == SpamReportState.disabled
|
||||
|| spamReportController.presentationSpamMailbox.value == null) {
|
||||
return const SizedBox(
|
||||
height: 8,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/model/spam_report_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/spam_report_controller.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/styles/spam_banner/spam_report_banner_button_styles.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/styles/spam_banner/spam_report_banner_styles.dart';
|
||||
@@ -19,9 +20,9 @@ class SpamReportBannerWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
|
||||
return Obx(() {
|
||||
if (!spamReportController.enableSpamReport || spamReportController.notShowSpamReportBanner) {
|
||||
if (spamReportController.spamReportState.value == SpamReportState.disabled
|
||||
|| spamReportController.presentationSpamMailbox.value == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return Container(
|
||||
|
||||
Reference in New Issue
Block a user