TF-4045 Remove storage information in left menu when it’s less than 80% of the total capacity
This commit is contained in:
@@ -59,32 +59,37 @@ class StorageView extends GetWidget<StorageController> {
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Obx(() {
|
||||||
padding: _getPadding(isMobile: isMobile, isDesktop: isDesktop),
|
final octetsQuota = controller.octetsQuota.value;
|
||||||
child: Column(
|
if (octetsQuota != null && octetsQuota.storageAvailable) {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
return SingleChildScrollView(
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Padding(
|
||||||
children: [
|
padding: _getPadding(
|
||||||
Obx(() {
|
isMobile: isMobile,
|
||||||
final octetsQuota = controller.octetsQuota.value;
|
isDesktop: isDesktop,
|
||||||
if (octetsQuota != null && octetsQuota.storageAvailable) {
|
),
|
||||||
return StorageProgressBarWidget(
|
child: Column(
|
||||||
imagePaths: controller.imagePaths,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
quota: octetsQuota,
|
mainAxisSize: MainAxisSize.min,
|
||||||
isMobile: isMobile,
|
children: [
|
||||||
);
|
StorageProgressBarWidget(
|
||||||
} else {
|
imagePaths: controller.imagePaths,
|
||||||
return const SizedBox.shrink();
|
quota: octetsQuota,
|
||||||
}
|
isMobile: isMobile,
|
||||||
}),
|
),
|
||||||
UpgradeStorageWidget(
|
UpgradeStorageWidget(
|
||||||
imagePaths: controller.imagePaths,
|
imagePaths: controller.imagePaths,
|
||||||
isMobile: isMobile,
|
isMobile: isMobile,
|
||||||
onUpgradeStorageAction: controller.onUpgradeStorage,
|
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 hardLimitStorageAsString => presentationHardLimit != null ? filesize(presentationHardLimit!.value) : '';
|
||||||
|
|
||||||
String get quotaAvailableStorageAsString {
|
String get quotaAvailableStorageAsString {
|
||||||
if (used != null &&
|
if (storageAvailable && presentationHardLimit!.value > used!.value) {
|
||||||
presentationHardLimit != null &&
|
|
||||||
presentationHardLimit!.value > used!.value) {
|
|
||||||
return filesize(presentationHardLimit!.value - used!.value);
|
return filesize(presentationHardLimit!.value - used!.value);
|
||||||
}
|
}
|
||||||
return '0 B';
|
return '0 B';
|
||||||
@@ -25,14 +23,14 @@ extension QuotasExtensions on Quota {
|
|||||||
|
|
||||||
bool get isWarnLimitReached {
|
bool get isWarnLimitReached {
|
||||||
if (used != null && warnLimit != null) {
|
if (used != null && warnLimit != null) {
|
||||||
return used!.value >= warnLimit!.value * 0.9;
|
return used!.value >= warnLimit!.value;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isHardLimitReached {
|
bool get isHardLimitReached {
|
||||||
if (used != null && presentationHardLimit != null) {
|
if (storageAvailable) {
|
||||||
return used!.value >= presentationHardLimit!.value;
|
return used!.value >= presentationHardLimit!.value;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -40,8 +38,8 @@ extension QuotasExtensions on Quota {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double get usedStoragePercent {
|
double get usedStoragePercent {
|
||||||
if (used != null && hardLimit != null && hardLimit!.value > 0) {
|
if (storageAvailable && presentationHardLimit!.value > 0) {
|
||||||
return used!.value / hardLimit!.value;
|
return used!.value / presentationHardLimit!.value;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -51,6 +49,14 @@ extension QuotasExtensions on Quota {
|
|||||||
|
|
||||||
bool get storageAvailable => used != null && presentationHardLimit != null;
|
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) {
|
String getQuotasStateTitle(BuildContext context) {
|
||||||
if (isHardLimitReached) {
|
if (isHardLimitReached) {
|
||||||
return '${AppLocalizations.of(context).textQuotasOutOfStorage}'
|
return '${AppLocalizations.of(context).textQuotasOutOfStorage}'
|
||||||
@@ -87,14 +93,4 @@ extension QuotasExtensions on Quota {
|
|||||||
return '';
|
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;
|
final octetQuota = controller.octetsQuota.value;
|
||||||
bool isDesktop = controller.responsiveUtils.isDesktop(context);
|
bool isDesktop = controller.responsiveUtils.isDesktop(context);
|
||||||
|
|
||||||
if (octetQuota != null && octetQuota.storageAvailable) {
|
if (octetQuota != null && octetQuota.isStorageUsageIndicatorAppear) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: isDesktop
|
padding: isDesktop
|
||||||
? const EdgeInsetsDirectional.only(
|
? const EdgeInsetsDirectional.only(
|
||||||
|
|||||||
Reference in New Issue
Block a user