Show UpgradeStorageWidget only when premium is available or quota exceeds 90%
This commit is contained in:
@@ -68,6 +68,10 @@ class StorageView extends GetWidget<StorageController> with AppLoaderMixin {
|
|||||||
.value;
|
.value;
|
||||||
|
|
||||||
if (octetsQuota != null && octetsQuota.storageAvailable) {
|
if (octetsQuota != null && octetsQuota.storageAvailable) {
|
||||||
|
final isPremiumAvailable = PlatformInfo.isWeb &&
|
||||||
|
!controller.isUpgradeStorageIsDisabled;
|
||||||
|
final isQuotaExceeds90Percent = octetsQuota.allowedDisplayToQuotaBanner;
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: _getPadding(
|
padding: _getPadding(
|
||||||
@@ -83,16 +87,15 @@ class StorageView extends GetWidget<StorageController> with AppLoaderMixin {
|
|||||||
quota: octetsQuota,
|
quota: octetsQuota,
|
||||||
isMobile: isMobile,
|
isMobile: isMobile,
|
||||||
),
|
),
|
||||||
UpgradeStorageWidget(
|
if (isPremiumAvailable || isQuotaExceeds90Percent)
|
||||||
imagePaths: controller.imagePaths,
|
UpgradeStorageWidget(
|
||||||
isMobile: isMobile,
|
imagePaths: controller.imagePaths,
|
||||||
isPremiumAvailable: PlatformInfo.isWeb &&
|
isMobile: isMobile,
|
||||||
!controller.isUpgradeStorageIsDisabled,
|
isPremiumAvailable: isPremiumAvailable,
|
||||||
isQuotaExceeds90Percent:
|
isQuotaExceeds90Percent: isQuotaExceeds90Percent,
|
||||||
octetsQuota.allowedDisplayToQuotaBanner,
|
onUpgradeStorageAction:
|
||||||
onUpgradeStorageAction:
|
controller.onUpgradeStorage,
|
||||||
controller.onUpgradeStorage,
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
+64
-44
@@ -25,51 +25,71 @@ class UpgradeStorageWidget extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final appLocalizations = AppLocalizations.of(context);
|
final appLocalizations = AppLocalizations.of(context);
|
||||||
return SizedBox(
|
|
||||||
width: isMobile ? double.infinity : 439,
|
final widgets = [
|
||||||
child: Column(
|
if (isQuotaExceeds90Percent) _buildWarning(context, appLocalizations),
|
||||||
mainAxisSize: MainAxisSize.min,
|
if (isPremiumAvailable) _buildUpgradeButton(appLocalizations),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
];
|
||||||
children: [
|
|
||||||
if (isQuotaExceeds90Percent)
|
if (widgets.isEmpty) return const SizedBox.shrink();
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
final body = widgets.length == 1
|
||||||
children: [
|
? widgets.first
|
||||||
SvgPicture.asset(
|
: Column(
|
||||||
imagePaths.icWarning,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
width: 16,
|
mainAxisSize: MainAxisSize.min,
|
||||||
height: 16,
|
children: widgets,
|
||||||
fit: BoxFit.fill,
|
);
|
||||||
),
|
|
||||||
const SizedBox(width: 7),
|
return isQuotaExceeds90Percent
|
||||||
Expanded(
|
? SizedBox(
|
||||||
child: Text(
|
width: isMobile ? double.infinity : 439,
|
||||||
appLocalizations.storageIsAlmostFullMessage,
|
child: body,
|
||||||
style: ThemeUtils.textStyleInter600().copyWith(
|
)
|
||||||
color: AppColor.m3Neutral40,
|
: body;
|
||||||
fontSize: 12,
|
}
|
||||||
height: 16 / 12,
|
|
||||||
letterSpacing: 0.4,
|
Widget _buildWarning(
|
||||||
),
|
BuildContext context,
|
||||||
),
|
AppLocalizations appLocalizations,
|
||||||
),
|
) {
|
||||||
],
|
return 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 (isPremiumAvailable)
|
),
|
||||||
Container(
|
),
|
||||||
constraints: const BoxConstraints(minWidth: 179),
|
],
|
||||||
margin: isQuotaExceeds90Percent
|
);
|
||||||
? const EdgeInsetsDirectional.only(start: 16)
|
}
|
||||||
: null,
|
|
||||||
height: 48,
|
Widget _buildUpgradeButton(AppLocalizations appLocalizations) {
|
||||||
child: ConfirmDialogButton(
|
return Container(
|
||||||
label: appLocalizations.upgradeStorage,
|
margin: isQuotaExceeds90Percent
|
||||||
backgroundColor: AppColor.primaryMain,
|
? const EdgeInsetsDirectional.only(top: 16)
|
||||||
textColor: Colors.white,
|
: null,
|
||||||
onTapAction: onUpgradeStorageAction,
|
height: 48,
|
||||||
),
|
constraints: const BoxConstraints(minWidth: 179),
|
||||||
),
|
child: ConfirmDialogButton(
|
||||||
],
|
label: appLocalizations.upgradeStorage,
|
||||||
|
backgroundColor: AppColor.primaryMain,
|
||||||
|
textColor: Colors.white,
|
||||||
|
onTapAction: onUpgradeStorageAction,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user