diff --git a/lib/features/manage_account/presentation/storage/storage_controller.dart b/lib/features/manage_account/presentation/storage/storage_controller.dart index 9cc690669..0a6911ec5 100644 --- a/lib/features/manage_account/presentation/storage/storage_controller.dart +++ b/lib/features/manage_account/presentation/storage/storage_controller.dart @@ -16,6 +16,22 @@ class StorageController extends BaseController with SaaSPremiumMixin { return isPremiumAvailable(accountId: accountId, session: session); } + bool validateUserHasIsAlreadyHighestSubscription() { + final accountId = dashBoardController.accountId.value; + final session = dashBoardController.sessionCurrent; + + if (accountId == null || session == null) { + return false; + } + + return isAlreadyHighestSubscription(accountId: accountId, session: session); + } + + bool get isUpgradeStorageIsDisabled { + return !validatePremiumIsAvailable() || + validateUserHasIsAlreadyHighestSubscription(); + } + void onUpgradeStorage() { dashBoardController.paywallController?.navigateToPaywall(); } diff --git a/lib/features/manage_account/presentation/storage/storage_view.dart b/lib/features/manage_account/presentation/storage/storage_view.dart index e7c1a692a..dd88032f2 100644 --- a/lib/features/manage_account/presentation/storage/storage_view.dart +++ b/lib/features/manage_account/presentation/storage/storage_view.dart @@ -83,19 +83,16 @@ class StorageView extends GetWidget with AppLoaderMixin { quota: octetsQuota, isMobile: isMobile, ), - Obx(() { - if (controller.validatePremiumIsAvailable() && - PlatformInfo.isWeb) { - return UpgradeStorageWidget( - imagePaths: controller.imagePaths, - isMobile: isMobile, - onUpgradeStorageAction: - controller.onUpgradeStorage, - ); - } else { - return const SizedBox.shrink(); - } - }) + UpgradeStorageWidget( + imagePaths: controller.imagePaths, + isMobile: isMobile, + isPremiumAvailable: PlatformInfo.isWeb && + !controller.isUpgradeStorageIsDisabled, + isQuotaExceeds90Percent: + octetsQuota.allowedDisplayToQuotaBanner, + onUpgradeStorageAction: + controller.onUpgradeStorage, + ), ], ), ), diff --git a/lib/features/manage_account/presentation/storage/widgets/upgrade_storage_widget.dart b/lib/features/manage_account/presentation/storage/widgets/upgrade_storage_widget.dart index 18f66e78e..4f4bd965f 100644 --- a/lib/features/manage_account/presentation/storage/widgets/upgrade_storage_widget.dart +++ b/lib/features/manage_account/presentation/storage/widgets/upgrade_storage_widget.dart @@ -9,6 +9,8 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; class UpgradeStorageWidget extends StatelessWidget { final ImagePaths imagePaths; final bool isMobile; + final bool isPremiumAvailable; + final bool isQuotaExceeds90Percent; final VoidCallback onUpgradeStorageAction; const UpgradeStorageWidget({ @@ -16,6 +18,8 @@ class UpgradeStorageWidget extends StatelessWidget { required this.imagePaths, required this.onUpgradeStorageAction, this.isMobile = false, + this.isPremiumAvailable = false, + this.isQuotaExceeds90Percent = false, }); @override @@ -27,40 +31,44 @@ class UpgradeStorageWidget extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset( - imagePaths.icWarning, - width: 16, - height: 16, - fit: BoxFit.fill, - ), - const SizedBox(width: 7), - Expanded( - child: Text( - appLocalizations.storageIsAlmostFullMessage, - style: ThemeUtils.textStyleInter600().copyWith( - color: AppColor.m3Neutral40, - fontSize: 12, - height: 16 / 12, - letterSpacing: 0.4, + if (isQuotaExceeds90Percent) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.asset( + imagePaths.icWarning, + width: 16, + height: 16, + fit: BoxFit.fill, + ), + const SizedBox(width: 7), + Expanded( + child: Text( + appLocalizations.storageIsAlmostFullMessage, + style: ThemeUtils.textStyleInter600().copyWith( + color: AppColor.m3Neutral40, + fontSize: 12, + height: 16 / 12, + letterSpacing: 0.4, + ), ), ), - ), - ], - ), - const SizedBox(height: 16), - Container( - constraints: const BoxConstraints(minWidth: 179), - height: 48, - child: ConfirmDialogButton( - label: appLocalizations.upgradeStorage, - backgroundColor: AppColor.primaryMain, - textColor: Colors.white, - onTapAction: onUpgradeStorageAction, + ], + ), + if (isPremiumAvailable) + Container( + constraints: const BoxConstraints(minWidth: 179), + margin: isQuotaExceeds90Percent + ? const EdgeInsetsDirectional.only(start: 16) + : null, + height: 48, + child: ConfirmDialogButton( + label: appLocalizations.upgradeStorage, + backgroundColor: AppColor.primaryMain, + textColor: Colors.white, + onTapAction: onUpgradeStorageAction, + ), ), - ), ], ), );