From a2875ea9210cd4cbdf2910bf18eaa144c7c21446 Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 4 Aug 2023 21:43:33 +0700 Subject: [PATCH] TF-2064 Handle limit storage to show warning banner (cherry picked from commit 3e36cebd5cbe880f9832c62463e71979e15e1741) --- .../mailbox_dashboard_view_web.dart | 12 +-- .../data/datasource/quotas_data_source.dart | 4 +- .../quotas_data_source_impl.dart | 6 +- .../quotas/data/network/quotas_api.dart | 22 ++--- .../repository/quotas_repository_impl.dart | 4 +- .../extensions/list_quotas_extensions.dart | 16 ++++ .../quotas/domain/model/quotas_response.dart | 30 ------ .../domain/repository/quotas_repository.dart | 4 +- .../quotas/domain/state/get_quotas_state.dart | 14 ++- .../use_case/get_quotas_interactor.dart | 11 +-- .../presentation/model/quotas_state.dart | 91 ------------------- .../presentation/quotas_controller.dart | 69 ++++---------- .../quotas/presentation/quotas_view.dart | 17 ++-- .../widget/quotas_warning_banner_widget.dart | 59 ------------ .../thread/presentation/thread_view.dart | 8 +- lib/l10n/intl_messages.arb | 2 +- lib/main/localizations/app_localizations.dart | 2 +- 17 files changed, 78 insertions(+), 293 deletions(-) create mode 100644 lib/features/quotas/domain/extensions/list_quotas_extensions.dart delete mode 100644 lib/features/quotas/domain/model/quotas_response.dart delete mode 100644 lib/features/quotas/presentation/model/quotas_state.dart delete mode 100644 lib/features/quotas/presentation/widget/quotas_warning_banner_widget.dart diff --git a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart index ddab5ec3b..334e7502a 100644 --- a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart +++ b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart @@ -25,7 +25,7 @@ import 'package:tmail_ui_user/features/thread/presentation/widgets/spam_banner/s import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/top_bar_thread_selection.dart'; import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart'; import 'package:tmail_ui_user/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart'; -import 'package:tmail_ui_user/features/quotas/presentation/widget/quotas_warning_banner_widget.dart'; +import 'package:tmail_ui_user/features/quotas/presentation/widget/quotas_banner_widget.dart'; import 'package:tmail_ui_user/features/search/email/presentation/search_email_view.dart'; import 'package:tmail_ui_user/features/search/mailbox/presentation/search_mailbox_view.dart'; import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart'; @@ -118,6 +118,8 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView { ]), Expanded(child: Column(children: [ const SpamReportBannerWebWidget(), + const QuotasBannerWidget(), + _buildVacationNotificationMessage(context), Obx(() { if (controller.isEmptyTrashBannerEnabledOnWeb(context)) { return Padding( @@ -148,14 +150,6 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView { return const SizedBox.shrink(); } }), - QuotasWarningBannerWidget( - margin: EdgeInsets.only( - right: AppUtils.isDirectionRTL(context) ? 0 : 16, - left: AppUtils.isDirectionRTL(context) ? 16 : 0, - top: 8 - ), - ), - _buildVacationNotificationMessage(context), _buildListButtonQuickSearchFilter(context), _buildMarkAsMailboxReadLoading(context), Expanded(child: Obx(() { diff --git a/lib/features/quotas/data/datasource/quotas_data_source.dart b/lib/features/quotas/data/datasource/quotas_data_source.dart index e0a251649..a7b5f2422 100644 --- a/lib/features/quotas/data/datasource/quotas_data_source.dart +++ b/lib/features/quotas/data/datasource/quotas_data_source.dart @@ -1,6 +1,6 @@ import 'package:jmap_dart_client/jmap/account_id.dart'; -import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart'; +import 'package:jmap_dart_client/jmap/quotas/quota.dart'; abstract class QuotasDataSource { - Future getQuotas(AccountId accountId); + Future> getQuotas(AccountId accountId); } diff --git a/lib/features/quotas/data/datasource_impl/quotas_data_source_impl.dart b/lib/features/quotas/data/datasource_impl/quotas_data_source_impl.dart index bf01c7975..99abaaeea 100644 --- a/lib/features/quotas/data/datasource_impl/quotas_data_source_impl.dart +++ b/lib/features/quotas/data/datasource_impl/quotas_data_source_impl.dart @@ -1,17 +1,17 @@ import 'package:jmap_dart_client/jmap/account_id.dart'; +import 'package:jmap_dart_client/jmap/quotas/quota.dart'; import 'package:tmail_ui_user/features/quotas/data/datasource/quotas_data_source.dart'; import 'package:tmail_ui_user/features/quotas/data/network/quotas_api.dart'; -import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart'; import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart'; -class QuotasDataSourceImpl extends QuotasDataSource{ +class QuotasDataSourceImpl extends QuotasDataSource { final QuotasAPI _quotasAPI; final ExceptionThrower _exceptionThrower; QuotasDataSourceImpl(this._quotasAPI, this._exceptionThrower); @override - Future getQuotas(AccountId accountId) { + Future> getQuotas(AccountId accountId) { return Future.sync(() async { return await _quotasAPI.getQuotas(accountId); }).catchError(_exceptionThrower.throwException); diff --git a/lib/features/quotas/data/network/quotas_api.dart b/lib/features/quotas/data/network/quotas_api.dart index f44e3589c..935757785 100644 --- a/lib/features/quotas/data/network/quotas_api.dart +++ b/lib/features/quotas/data/network/quotas_api.dart @@ -3,36 +3,30 @@ import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/jmap_request.dart'; import 'package:jmap_dart_client/jmap/quotas/get/get_quota_method.dart'; import 'package:jmap_dart_client/jmap/quotas/get/get_quota_response.dart'; +import 'package:jmap_dart_client/jmap/quotas/quota.dart'; import 'package:tmail_ui_user/features/quotas/domain/exceptions/quotas_exception.dart'; -import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart'; class QuotasAPI { final HttpClient _httpClient; QuotasAPI(this._httpClient); - Future getQuotas(AccountId accountId) async { - final requestBuilder = - JmapRequestBuilder(_httpClient, ProcessingInvocation()); + Future> getQuotas(AccountId accountId) async { + final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation()); final getQuotaMethod = GetQuotaMethod(accountId); final getQuotaInvocation = requestBuilder.invocation(getQuotaMethod); final response = await (requestBuilder - ..usings(getQuotaMethod.requiredCapabilities)) - .build() - .execute(); + ..usings(getQuotaMethod.requiredCapabilities)) + .build() + .execute(); final getQuotaResponse = response.parse( getQuotaInvocation.methodCallId, GetQuotaResponse.deserialize, ); - if(getQuotaResponse != null) { - return QuotasResponse( - accountId: getQuotaResponse.accountId, - notFound: getQuotaResponse.notFound, - quotas: getQuotaResponse.list, - state: getQuotaResponse.state, - ); + if (getQuotaResponse?.list.isNotEmpty == true) { + return getQuotaResponse!.list; } else { throw NotFoundQuotasException(); } diff --git a/lib/features/quotas/data/repository/quotas_repository_impl.dart b/lib/features/quotas/data/repository/quotas_repository_impl.dart index 9a2636661..fcc77ed3a 100644 --- a/lib/features/quotas/data/repository/quotas_repository_impl.dart +++ b/lib/features/quotas/data/repository/quotas_repository_impl.dart @@ -1,6 +1,6 @@ import 'package:jmap_dart_client/jmap/account_id.dart'; +import 'package:jmap_dart_client/jmap/quotas/quota.dart'; import 'package:tmail_ui_user/features/quotas/data/datasource/quotas_data_source.dart'; -import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart'; import 'package:tmail_ui_user/features/quotas/domain/repository/quotas_repository.dart'; class QuotasRepositoryImpl extends QuotasRepository { @@ -9,7 +9,7 @@ class QuotasRepositoryImpl extends QuotasRepository { QuotasRepositoryImpl(this._dataSource); @override - Future getQuotas(AccountId accountId) { + Future> getQuotas(AccountId accountId) { return _dataSource.getQuotas(accountId); } } diff --git a/lib/features/quotas/domain/extensions/list_quotas_extensions.dart b/lib/features/quotas/domain/extensions/list_quotas_extensions.dart new file mode 100644 index 000000000..e6de29d54 --- /dev/null +++ b/lib/features/quotas/domain/extensions/list_quotas_extensions.dart @@ -0,0 +1,16 @@ + +import 'package:core/utils/app_logger.dart'; +import 'package:jmap_dart_client/jmap/quotas/data_types.dart'; +import 'package:jmap_dart_client/jmap/quotas/quota.dart'; + +extension ListQuotasExtensions on List { + + Quota? get octetsQuota { + try { + return firstWhere((quota) => quota.resourceType == ResourceType.octets); + } catch(e) { + logError('ListQuotasExtensions::octetsQuota: Not found octets quota'); + return null; + } + } +} \ No newline at end of file diff --git a/lib/features/quotas/domain/model/quotas_response.dart b/lib/features/quotas/domain/model/quotas_response.dart deleted file mode 100644 index 7aa01e239..000000000 --- a/lib/features/quotas/domain/model/quotas_response.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:jmap_dart_client/jmap/account_id.dart'; -import 'package:jmap_dart_client/jmap/core/id.dart'; -import 'package:jmap_dart_client/jmap/core/state.dart'; -import 'package:jmap_dart_client/jmap/quotas/quota.dart'; - -class QuotasResponse with EquatableMixin { - final AccountId accountId; - final State state; - final List quotas; - final List? notFound; - - QuotasResponse({ - required this.accountId, - required this.state, - required this.quotas, - this.notFound, - }); - - bool hasData() { - return quotas.isNotEmpty; - } - - @override - List get props => [ - quotas, - state, - notFound, - ]; -} diff --git a/lib/features/quotas/domain/repository/quotas_repository.dart b/lib/features/quotas/domain/repository/quotas_repository.dart index 9f60543f6..bc73d12f3 100644 --- a/lib/features/quotas/domain/repository/quotas_repository.dart +++ b/lib/features/quotas/domain/repository/quotas_repository.dart @@ -1,6 +1,6 @@ import 'package:jmap_dart_client/jmap/account_id.dart'; -import 'package:tmail_ui_user/features/quotas/domain/model/quotas_response.dart'; +import 'package:jmap_dart_client/jmap/quotas/quota.dart'; abstract class QuotasRepository { - Future getQuotas(AccountId accountId); + Future> getQuotas(AccountId accountId); } diff --git a/lib/features/quotas/domain/state/get_quotas_state.dart b/lib/features/quotas/domain/state/get_quotas_state.dart index 2a0399fea..d32bf15a8 100644 --- a/lib/features/quotas/domain/state/get_quotas_state.dart +++ b/lib/features/quotas/domain/state/get_quotas_state.dart @@ -1,18 +1,16 @@ -import 'package:core/core.dart'; -import 'package:jmap_dart_client/jmap/core/state.dart'; +import 'package:core/presentation/state/failure.dart'; +import 'package:core/presentation/state/success.dart'; import 'package:jmap_dart_client/jmap/quotas/quota.dart'; +class GetQuotasLoading extends LoadingState {} + class GetQuotasSuccess extends UIState { final List quotas; - final State? state; - GetQuotasSuccess(this.quotas, this.state); + GetQuotasSuccess(this.quotas); @override - List get props => [ - quotas, - state, - ]; + List get props => [quotas]; } class GetQuotasFailure extends FeatureFailure { diff --git a/lib/features/quotas/domain/use_case/get_quotas_interactor.dart b/lib/features/quotas/domain/use_case/get_quotas_interactor.dart index cc325bcfd..78cf6727e 100644 --- a/lib/features/quotas/domain/use_case/get_quotas_interactor.dart +++ b/lib/features/quotas/domain/use_case/get_quotas_interactor.dart @@ -1,6 +1,5 @@ -import 'dart:core'; - -import 'package:core/core.dart'; +import 'package:core/presentation/state/failure.dart'; +import 'package:core/presentation/state/success.dart'; import 'package:dartz/dartz.dart'; import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:tmail_ui_user/features/quotas/domain/repository/quotas_repository.dart'; @@ -13,9 +12,9 @@ class GetQuotasInteractor { Stream> execute(AccountId accountId) async* { try { - yield Right(LoadingState()); - final response = await quotasRepository.getQuotas(accountId); - yield Right(GetQuotasSuccess(response.quotas, response.state)); + yield Right(GetQuotasLoading()); + final listQuotas = await quotasRepository.getQuotas(accountId); + yield Right(GetQuotasSuccess(listQuotas)); } catch (exception) { yield Left(GetQuotasFailure(exception)); } diff --git a/lib/features/quotas/presentation/model/quotas_state.dart b/lib/features/quotas/presentation/model/quotas_state.dart deleted file mode 100644 index 237ba8dd4..000000000 --- a/lib/features/quotas/presentation/model/quotas_state.dart +++ /dev/null @@ -1,91 +0,0 @@ -import 'package:core/core.dart'; -import 'package:flutter/widgets.dart'; -import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; - -enum QuotasState { - notAvailable, - normal, - runningOutOfStorage, - runOutOfStorage; - - Color getColorProgress() { - switch(this) { - case QuotasState.notAvailable: - case QuotasState.normal: - return AppColor.primaryColor; - case QuotasState.runningOutOfStorage: - return AppColor.colorProgressQuotasWarning; - case QuotasState.runOutOfStorage: - return AppColor.colorOutOfStorageQuotasWarning; - } - } - - Color getColorQuotasFooterText() { - switch(this) { - case QuotasState.notAvailable: - case QuotasState.normal: - case QuotasState.runningOutOfStorage: - return AppColor.loginTextFieldHintColor; - case QuotasState.runOutOfStorage: - return AppColor.colorOutOfStorageQuotasWarning; - } - } - - String getQuotasFooterText(BuildContext context, num usedCapacity, num softLimitCapacity) { - switch(this) { - case QuotasState.notAvailable: - case QuotasState.normal: - case QuotasState.runningOutOfStorage: - return AppLocalizations.of(context).textQuotasUsed( - usedCapacity.toDouble(), - softLimitCapacity.toDouble(), - ); - case QuotasState.runOutOfStorage: - return AppLocalizations.of(context).textQuotasOutOfStorage; - } - } - - String getIconWarningBanner(ImagePaths imagePaths) { - switch(this) { - case QuotasState.notAvailable: - case QuotasState.normal: - case QuotasState.runningOutOfStorage: - return imagePaths.icQuotasWarning; - case QuotasState.runOutOfStorage: - return imagePaths.icQuotasOutOfStorage; - } - } - - Color getBackgroundColorWarningBanner() { - switch(this) { - case QuotasState.notAvailable: - case QuotasState.normal: - case QuotasState.runningOutOfStorage: - return AppColor.colorBackgroundQuotasWarning.withOpacity(0.12); - case QuotasState.runOutOfStorage: - return AppColor.colorOutOfStorageQuotasWarning.withOpacity(0.12); - } - } - - String getTitleWarningBanner(BuildContext context, num progress) { - switch(this) { - case QuotasState.notAvailable: - case QuotasState.normal: - case QuotasState.runningOutOfStorage: - return AppLocalizations.of(context).textQuotasRunningOutOfStorageTitle(progress.toDouble() * 100); - case QuotasState.runOutOfStorage: - return AppLocalizations.of(context).textQuotasRunOutOfStorageTitle; - } - } - - String getContentWarningBanner(BuildContext context) { - switch(this) { - case QuotasState.notAvailable: - case QuotasState.normal: - case QuotasState.runningOutOfStorage: - return AppLocalizations.of(context).textQuotasRunningOutOfStorageContent; - case QuotasState.runOutOfStorage: - return AppLocalizations.of(context).textQuotasRunOutOfStorageContent; - } - } -} \ No newline at end of file diff --git a/lib/features/quotas/presentation/quotas_controller.dart b/lib/features/quotas/presentation/quotas_controller.dart index 990006f8f..797176530 100644 --- a/lib/features/quotas/presentation/quotas_controller.dart +++ b/lib/features/quotas/presentation/quotas_controller.dart @@ -1,15 +1,15 @@ -import 'package:core/core.dart'; -import 'package:core/utils/double_convert.dart'; +import 'package:core/presentation/resources/image_paths.dart'; +import 'package:core/presentation/state/success.dart'; +import 'package:core/presentation/utils/responsive_utils.dart'; import 'package:get/get.dart'; import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart'; -import 'package:jmap_dart_client/jmap/core/session/session.dart'; -import 'package:jmap_dart_client/jmap/quotas/data_types.dart'; +import 'package:jmap_dart_client/jmap/quotas/quota.dart'; import 'package:tmail_ui_user/features/base/base_controller.dart'; import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart'; +import 'package:tmail_ui_user/features/quotas/domain/extensions/list_quotas_extensions.dart'; import 'package:tmail_ui_user/features/quotas/domain/state/get_quotas_state.dart'; import 'package:tmail_ui_user/features/quotas/domain/use_case/get_quotas_interactor.dart'; -import 'package:tmail_ui_user/features/quotas/presentation/model/quotas_state.dart'; import 'package:tmail_ui_user/main/error/capability_validator.dart'; class QuotasController extends BaseController { @@ -20,61 +20,28 @@ class QuotasController extends BaseController { final GetQuotasInteractor _getQuotasInteractor; - final usedCapacity = Rx(0); - final limitCapacity = Rx(0); - final warningLimitCapacity = Rx(0); - final quotasState = QuotasState.notAvailable.obs; - final warningProgressConstant = 0.9; - late Worker accountIdWorker; + final octetsQuota = Rxn(); - double get progressUsedCapacity => limitCapacity.value != 0 - ? (usedCapacity.value / limitCapacity.value) - : 0; - - bool get enableShowWarningQuotas => - quotasState.value != QuotasState.notAvailable && - (quotasState.value == QuotasState.runningOutOfStorage - || quotasState.value == QuotasState.runOutOfStorage); + late Worker accountIdListener; QuotasController(this._getQuotasInteractor); - void _getQuotasAction(AccountId accountId, Session session) { - try { - requireCapability(session, accountId, [CapabilityIdentifier.jmapQuota]); - consumeState(_getQuotasInteractor.execute(mailboxDashBoardController.accountId.value!)); - } catch (e) { - logError('QuotasController::_getQuotasAction():$e'); - } + void _getQuotasAction(AccountId accountId) { + consumeState(_getQuotasInteractor.execute(accountId)); } void _handleGetQuotasSuccess(GetQuotasSuccess success) { - try { - final quotas = success.quotas.firstWhere((e) => e.resourceType == ResourceType.octets); - if (quotas.used != null) { - usedCapacity.value = DoubleConvert.bytesToGigaBytes(quotas.used!.value); - } - if (quotas.limit != null) { - warningLimitCapacity.value = DoubleConvert.bytesToGigaBytes(quotas.limit!.value * warningProgressConstant); - limitCapacity.value = DoubleConvert.bytesToGigaBytes(quotas.limit!.value); - } - - if(usedCapacity.value >= limitCapacity.value) { - quotasState.value = QuotasState.runOutOfStorage; - } else if (usedCapacity.value >= warningLimitCapacity.value) { - quotasState.value = QuotasState.runningOutOfStorage; - } else { - quotasState.value = QuotasState.normal; - } - } catch (e) { - quotasState.value = QuotasState.notAvailable; - logError('QuotasController::_handleGetQuotasSuccess():[NotFoundException]: $e'); - } + octetsQuota.value = success.quotas.octetsQuota; } void _initWorker() { - accountIdWorker = ever(mailboxDashBoardController.accountId, (accountId) { - if (accountId is AccountId && mailboxDashBoardController.sessionCurrent!= null) { - _getQuotasAction(accountId, mailboxDashBoardController.sessionCurrent!); + accountIdListener = ever(mailboxDashBoardController.accountId, (accountId) { + final session = mailboxDashBoardController.sessionCurrent; + if (accountId is AccountId && + session != null && + CapabilityIdentifier.jmapQuota.isSupported(session, accountId) + ) { + _getQuotasAction(accountId); } }); } @@ -87,7 +54,7 @@ class QuotasController extends BaseController { @override void onClose() { - accountIdWorker.call(); + accountIdListener.dispose(); super.onClose(); } diff --git a/lib/features/quotas/presentation/quotas_view.dart b/lib/features/quotas/presentation/quotas_view.dart index 9fcc7528f..def5dbfaf 100644 --- a/lib/features/quotas/presentation/quotas_view.dart +++ b/lib/features/quotas/presentation/quotas_view.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; -import 'package:tmail_ui_user/features/quotas/presentation/model/quotas_state.dart'; +import 'package:tmail_ui_user/features/quotas/domain/extensions/quota_extensions.dart'; import 'package:tmail_ui_user/features/quotas/presentation/quotas_controller.dart'; import 'package:tmail_ui_user/features/quotas/presentation/styles/quotas_view_styles.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; @@ -13,7 +13,8 @@ class QuotasView extends GetWidget { @override Widget build(BuildContext context) { return Obx(() { - if (controller.quotasState.value != QuotasState.notAvailable) { + if (controller.octetsQuota.value != null && controller.octetsQuota.value!.storageAvailable) { + final octetQuota = controller.octetsQuota.value!; return LayoutBuilder(builder: (context, constraints) { return Container( padding: const EdgeInsetsDirectional.only( @@ -63,23 +64,19 @@ class QuotasView extends GetWidget { SizedBox( width: _getProgressBarMaxWith(constraints.maxWidth), child: LinearProgressIndicator( - color: controller.quotasState.value.getColorProgress(), + color: octetQuota.getQuotasStateProgressBarColor(), minHeight: QuotasViewStyles.progressBarHeight, backgroundColor: QuotasViewStyles.progressBarBackgroundColor, - value: controller.progressUsedCapacity, + value: octetQuota.usedStoragePercent, ), ), const SizedBox(height: QuotasViewStyles.space), Text( - controller.quotasState.value.getQuotasFooterText( - context, - controller.usedCapacity.value, - controller.limitCapacity.value, - ), + octetQuota.getQuotasStateTitle(context), style: TextStyle( fontSize: QuotasViewStyles.progressStateTextSize, fontWeight: QuotasViewStyles.progressStateFontWeight, - color: controller.quotasState.value.getColorQuotasFooterText(), + color: octetQuota.getQuotasStateTitleColor() ), ) ], diff --git a/lib/features/quotas/presentation/widget/quotas_warning_banner_widget.dart b/lib/features/quotas/presentation/widget/quotas_warning_banner_widget.dart deleted file mode 100644 index a87e049ea..000000000 --- a/lib/features/quotas/presentation/widget/quotas_warning_banner_widget.dart +++ /dev/null @@ -1,59 +0,0 @@ -import 'package:core/core.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:get/get.dart'; -import 'package:tmail_ui_user/features/quotas/presentation/quotas_controller.dart'; - -class QuotasWarningBannerWidget extends GetWidget { - const QuotasWarningBannerWidget({this.margin ,Key? key}) : super(key: key); - final EdgeInsets? margin; - - @override - Widget build(BuildContext context) { - return Obx( - () => controller.enableShowWarningQuotas - ? Container( - padding: const EdgeInsets.all(16), - margin: margin ?? const EdgeInsets.only(left: 12, right: 12, bottom: 12), - decoration: BoxDecoration( - color: controller.quotasState.value.getBackgroundColorWarningBanner(), - borderRadius: const BorderRadius.all(Radius.circular(10)), - ), - child: Row( - children: [ - SvgPicture.asset(controller.quotasState.value.getIconWarningBanner(controller.imagePaths)), - const SizedBox(width: 16), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - controller.quotasState.value.getTitleWarningBanner( - context, - controller.progressUsedCapacity, - ), - style: const TextStyle( - fontSize: 17, - fontWeight: FontWeight.w700, - color: AppColor.colorTitleQuotasWarning, - ), - ), - const SizedBox(height: 8), - Text( - controller.quotasState.value.getContentWarningBanner(context), - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w400, - color: AppColor.loginTextFieldHintColor, - ), - ), - ], - ), - ), - ], - ), - ) - : const SizedBox.shrink(), - ); - } -} diff --git a/lib/features/thread/presentation/thread_view.dart b/lib/features/thread/presentation/thread_view.dart index 1f61116fa..28d1de917 100644 --- a/lib/features/thread/presentation/thread_view.dart +++ b/lib/features/thread/presentation/thread_view.dart @@ -15,7 +15,7 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/mixin/filt import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart'; import 'package:tmail_ui_user/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart'; import 'package:tmail_ui_user/features/network_connection/presentation/network_connection_banner_widget.dart'; -import 'package:tmail_ui_user/features/quotas/presentation/widget/quotas_warning_banner_widget.dart'; +import 'package:tmail_ui_user/features/quotas/presentation/widget/quotas_banner_widget.dart'; import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart'; import 'package:tmail_ui_user/features/thread/domain/state/search_email_state.dart'; import 'package:tmail_ui_user/features/thread/domain/state/search_more_email_state.dart'; @@ -76,7 +76,7 @@ class ThreadView extends GetWidget }), _buildSearchBarView(context), const SpamReportBannerWidget(), - const QuotasWarningBannerWidget(), + const QuotasBannerWidget(), _buildVacationNotificationMessage(context), ], Obx(() { @@ -139,7 +139,7 @@ class ThreadView extends GetWidget padding: EdgeInsets.symmetric( horizontal: 16, vertical: _responsiveUtils.isWebNotDesktop(context) ? 8 : 0), - margin: EdgeInsets.only(bottom: PlatformInfo.isMobile ? 16 : 0), + margin: EdgeInsets.only(bottom: PlatformInfo.isMobile ? 8 : 0), child: SearchBarView(_imagePaths, hintTextSearch: AppLocalizations.of(context).search_emails, onOpenSearchViewAction: controller.goToSearchView)); @@ -503,7 +503,7 @@ class ThreadView extends GetWidget double? _getItemExtent(BuildContext context) { if (PlatformInfo.isWeb) { - return _responsiveUtils.isDesktop(context) ? 52 : 95; + return _responsiveUtils.isDesktop(context) ? 52 : 98; } else { return null; } diff --git a/lib/l10n/intl_messages.arb b/lib/l10n/intl_messages.arb index 726266517..1445faeed 100644 --- a/lib/l10n/intl_messages.arb +++ b/lib/l10n/intl_messages.arb @@ -3110,7 +3110,7 @@ "placeholders_order": [], "placeholders": {} }, - "quotaWarningBannerTitle": "You are running out of storage (99%).", + "quotaWarningBannerTitle": "You are running out of storage (90%).", "@quotaWarningBannerTitle": { "type": "text", "placeholders_order": [], diff --git a/lib/main/localizations/app_localizations.dart b/lib/main/localizations/app_localizations.dart index 210e25dae..bb52f303d 100644 --- a/lib/main/localizations/app_localizations.dart +++ b/lib/main/localizations/app_localizations.dart @@ -3215,7 +3215,7 @@ class AppLocalizations { String get quotaWarningBannerTitle { return Intl.message( - 'You are running out of storage (99%).', + 'You are running out of storage (90%).', name: 'quotaWarningBannerTitle' ); }