TF-4045 Remove storage information in left menu when it’s less than 80% of the total capacity

This commit is contained in:
dab246
2025-10-01 16:40:27 +07:00
committed by Dat H. Pham
parent 06783298bc
commit 2cc727c209
3 changed files with 45 additions and 44 deletions
@@ -59,32 +59,37 @@ class StorageView extends GetWidget<StorageController> {
textAlign: TextAlign.center,
),
Expanded(
child: Padding(
padding: _getPadding(isMobile: isMobile, isDesktop: isDesktop),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Obx(() {
final octetsQuota = controller.octetsQuota.value;
if (octetsQuota != null && octetsQuota.storageAvailable) {
return StorageProgressBarWidget(
imagePaths: controller.imagePaths,
quota: octetsQuota,
isMobile: isMobile,
);
} else {
return const SizedBox.shrink();
}
}),
UpgradeStorageWidget(
imagePaths: controller.imagePaths,
isMobile: isMobile,
onUpgradeStorageAction: controller.onUpgradeStorage,
)
],
),
),
child: Obx(() {
final octetsQuota = controller.octetsQuota.value;
if (octetsQuota != null && octetsQuota.storageAvailable) {
return SingleChildScrollView(
child: Padding(
padding: _getPadding(
isMobile: isMobile,
isDesktop: isDesktop,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
StorageProgressBarWidget(
imagePaths: controller.imagePaths,
quota: octetsQuota,
isMobile: isMobile,
),
UpgradeStorageWidget(
imagePaths: controller.imagePaths,
isMobile: isMobile,
onUpgradeStorageAction: controller.onUpgradeStorage,
)
],
),
),
);
} else {
return const SizedBox.shrink();
}
}),
),
],
),
@@ -15,9 +15,7 @@ extension QuotasExtensions on Quota {
String get hardLimitStorageAsString => presentationHardLimit != null ? filesize(presentationHardLimit!.value) : '';
String get quotaAvailableStorageAsString {
if (used != null &&
presentationHardLimit != null &&
presentationHardLimit!.value > used!.value) {
if (storageAvailable && presentationHardLimit!.value > used!.value) {
return filesize(presentationHardLimit!.value - used!.value);
}
return '0 B';
@@ -25,14 +23,14 @@ extension QuotasExtensions on Quota {
bool get isWarnLimitReached {
if (used != null && warnLimit != null) {
return used!.value >= warnLimit!.value * 0.9;
return used!.value >= warnLimit!.value;
} else {
return false;
}
}
bool get isHardLimitReached {
if (used != null && presentationHardLimit != null) {
if (storageAvailable) {
return used!.value >= presentationHardLimit!.value;
} else {
return false;
@@ -40,8 +38,8 @@ extension QuotasExtensions on Quota {
}
double get usedStoragePercent {
if (used != null && hardLimit != null && hardLimit!.value > 0) {
return used!.value / hardLimit!.value;
if (storageAvailable && presentationHardLimit!.value > 0) {
return used!.value / presentationHardLimit!.value;
} else {
return 0;
}
@@ -51,6 +49,14 @@ extension QuotasExtensions on Quota {
bool get storageAvailable => used != null && presentationHardLimit != null;
bool get isStorageUsageIndicatorAppear {
if (storageAvailable) {
return used!.value <= presentationHardLimit!.value * 0.8;
} else {
return false;
}
}
String getQuotasStateTitle(BuildContext context) {
if (isHardLimitReached) {
return '${AppLocalizations.of(context).textQuotasOutOfStorage}'
@@ -87,14 +93,4 @@ extension QuotasExtensions on Quota {
return '';
}
}
Color getQuotaBannerMessageColor() {
if (isHardLimitReached) {
return AppColor.colorQuotaError;
} else if (isWarnLimitReached) {
return AppColor.colorQuotaWarning;
} else {
return Colors.black;
}
}
}
@@ -20,7 +20,7 @@ class QuotasView extends GetWidget<QuotasController> {
final octetQuota = controller.octetsQuota.value;
bool isDesktop = controller.responsiveUtils.isDesktop(context);
if (octetQuota != null && octetQuota.storageAvailable) {
if (octetQuota != null && octetQuota.isStorageUsageIndicatorAppear) {
return Container(
padding: isDesktop
? const EdgeInsetsDirectional.only(