TF-1014: add covert bytes to gb and edit UI
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import 'dart:ui';
|
||||
|
||||
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:
|
||||
@@ -22,6 +22,7 @@ enum QuotasState {
|
||||
|
||||
Color getColorQuotasFooterText() {
|
||||
switch(this) {
|
||||
case QuotasState.notAvailable:
|
||||
case QuotasState.normal:
|
||||
case QuotasState.runningOutOfStorage:
|
||||
return AppColor.loginTextFieldHintColor;
|
||||
@@ -32,6 +33,7 @@ enum QuotasState {
|
||||
|
||||
String getQuotasFooterText(BuildContext context, num usedCapacity, num softLimitCapacity) {
|
||||
switch(this) {
|
||||
case QuotasState.notAvailable:
|
||||
case QuotasState.normal:
|
||||
case QuotasState.runningOutOfStorage:
|
||||
return AppLocalizations.of(context).textQuotasUsed(
|
||||
@@ -45,6 +47,7 @@ enum QuotasState {
|
||||
|
||||
String getIconWarningBanner(ImagePaths imagePaths) {
|
||||
switch(this) {
|
||||
case QuotasState.notAvailable:
|
||||
case QuotasState.normal:
|
||||
case QuotasState.runningOutOfStorage:
|
||||
return imagePaths.icQuotasWarning;
|
||||
@@ -55,6 +58,7 @@ enum QuotasState {
|
||||
|
||||
Color getBackgroundColorWarningBanner() {
|
||||
switch(this) {
|
||||
case QuotasState.notAvailable:
|
||||
case QuotasState.normal:
|
||||
case QuotasState.runningOutOfStorage:
|
||||
return AppColor.colorBackgroundQuotasWarning.withOpacity(0.12);
|
||||
@@ -65,6 +69,7 @@ enum QuotasState {
|
||||
|
||||
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);
|
||||
@@ -75,6 +80,7 @@ enum QuotasState {
|
||||
|
||||
String getContentWarningBanner(BuildContext context) {
|
||||
switch(this) {
|
||||
case QuotasState.notAvailable:
|
||||
case QuotasState.normal:
|
||||
case QuotasState.runningOutOfStorage:
|
||||
return AppLocalizations.of(context).textQuotasRunningOutOfStorageContent;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/utils/double_convert.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';
|
||||
@@ -17,8 +18,7 @@ class QuotasController extends BaseController {
|
||||
final usedCapacity = Rx<num>(0);
|
||||
final limitCapacity = Rx<num>(0);
|
||||
final warningLimitCapacity = Rx<num>(0);
|
||||
final enableShowQuotas = false.obs;
|
||||
final quotasState = QuotasState.normal.obs;
|
||||
final quotasState = QuotasState.notAvailable.obs;
|
||||
final warningProgressConstant = 0.9;
|
||||
late Worker accountIdWorker;
|
||||
|
||||
@@ -27,7 +27,7 @@ class QuotasController extends BaseController {
|
||||
: 0;
|
||||
|
||||
bool get enableShowWarningQuotas =>
|
||||
enableShowQuotas.isTrue &&
|
||||
quotasState.value != QuotasState.notAvailable &&
|
||||
(quotasState.value == QuotasState.runningOutOfStorage
|
||||
|| quotasState.value == QuotasState.runOutOfStorage);
|
||||
|
||||
@@ -36,14 +36,6 @@ class QuotasController extends BaseController {
|
||||
|
||||
QuotasController(this._getQuotasInteractor);
|
||||
|
||||
void _initWorker() {
|
||||
accountIdWorker = ever(mailboxDashBoardController.accountId, (accountId) {
|
||||
if (accountId is AccountId && mailboxDashBoardController.sessionCurrent!= null) {
|
||||
_getQuotasAction(accountId, mailboxDashBoardController.sessionCurrent!);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _getQuotasAction(AccountId accountId, Session session) {
|
||||
try {
|
||||
requireCapability(session, accountId, [CapabilityIdentifier.jmapQuota]);
|
||||
@@ -72,9 +64,9 @@ class QuotasController extends BaseController {
|
||||
void _handleGetQuotasSuccess(GetQuotasSuccess success) {
|
||||
try {
|
||||
final quotas = success.quotas.firstWhere((e) => e.resourceType == ResourceType.octets);
|
||||
usedCapacity.value = quotas.used.value;
|
||||
warningLimitCapacity.value = quotas.limit.value * warningProgressConstant;
|
||||
limitCapacity.value = quotas.limit.value;
|
||||
usedCapacity.value = DoubleConvert.bytesToGigaBytes(quotas.used.value);
|
||||
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) {
|
||||
@@ -82,13 +74,24 @@ class QuotasController extends BaseController {
|
||||
} else {
|
||||
quotasState.value = QuotasState.normal;
|
||||
}
|
||||
enableShowQuotas.value = true;
|
||||
} catch (e) {
|
||||
enableShowQuotas.value = false;
|
||||
quotasState.value = QuotasState.notAvailable;
|
||||
logError('QuotasController::_handleGetQuotasSuccess():[NotFoundException]: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void covertBytesToGB() {
|
||||
|
||||
}
|
||||
|
||||
void _initWorker() {
|
||||
accountIdWorker = ever(mailboxDashBoardController.accountId, (accountId) {
|
||||
if (accountId is AccountId && mailboxDashBoardController.sessionCurrent!= null) {
|
||||
_getQuotasAction(accountId, mailboxDashBoardController.sessionCurrent!);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
_initWorker();
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import 'package:tmail_ui_user/features/quotas/domain/use_case/get_quotas_interac
|
||||
import 'package:tmail_ui_user/features/quotas/presentation/quotas_controller.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||
|
||||
class QuotasBindings extends BaseBindings {
|
||||
class QuotasControllerBindings extends BaseBindings {
|
||||
@override
|
||||
void bindingsController() {
|
||||
Get.put(QuotasController(Get.find<GetQuotasInteractor>()));
|
||||
@@ -17,7 +17,7 @@ class QuotasBindings extends BaseBindings {
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<QuotasDataSource>(() => Get.find<QuotasDataSourceImpl>());
|
||||
Get.lazyPut<QuotasDataSource>(() => (Get.find<QuotasDataSourceImpl>()));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -2,6 +2,7 @@ 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/model/quotas_state.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/presentation/quotas_controller.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
@@ -11,7 +12,7 @@ class QuotasFooterWidget extends GetWidget<QuotasController> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(
|
||||
() => controller.enableShowQuotas.value
|
||||
() => controller.quotasState.value != QuotasState.notAvailable
|
||||
? Container(
|
||||
color: AppColor.colorBgDesktop,
|
||||
padding: padding ?? const EdgeInsets.all(24),
|
||||
|
||||
Reference in New Issue
Block a user