TF-3548 Handle exceeded quota (#3557)
This commit is contained in:
@@ -45,7 +45,8 @@ extension QuotasExtensions on Quota {
|
|||||||
|
|
||||||
String getQuotasStateTitle(BuildContext context) {
|
String getQuotasStateTitle(BuildContext context) {
|
||||||
if (isHardLimitReached) {
|
if (isHardLimitReached) {
|
||||||
return AppLocalizations.of(context).textQuotasOutOfStorage;
|
return '${AppLocalizations.of(context).textQuotasOutOfStorage}'
|
||||||
|
'\n${AppLocalizations.of(context).quotaStateLabel(usedStorageAsString, hardLimitStorageAsString)}';
|
||||||
} else {
|
} else {
|
||||||
return AppLocalizations.of(context).quotaStateLabel(usedStorageAsString, hardLimitStorageAsString);
|
return AppLocalizations.of(context).quotaStateLabel(usedStorageAsString, hardLimitStorageAsString);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,12 @@ class QuotasController extends BaseController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reloadQuota() {
|
||||||
|
if (mailboxDashBoardController.accountId.value == null) return;
|
||||||
|
|
||||||
|
_getQuotasAction(mailboxDashBoardController.accountId.value!);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
_initWorker();
|
_initWorker();
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:tmail_ui_user/features/quotas/domain/extensions/quota_extensions.dart';
|
import 'package:tmail_ui_user/features/quotas/domain/extensions/quota_extensions.dart';
|
||||||
|
import 'package:tmail_ui_user/features/quotas/domain/state/get_quotas_state.dart';
|
||||||
import 'package:tmail_ui_user/features/quotas/presentation/quotas_controller.dart';
|
import 'package:tmail_ui_user/features/quotas/presentation/quotas_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/quotas/presentation/styles/quotas_view_styles.dart';
|
import 'package:tmail_ui_user/features/quotas/presentation/styles/quotas_view_styles.dart';
|
||||||
|
import 'package:tmail_ui_user/features/quotas/presentation/widget/quota_reload_button.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
class QuotasView extends GetWidget<QuotasController> {
|
class QuotasView extends GetWidget<QuotasController> {
|
||||||
@@ -48,7 +50,7 @@ class QuotasView extends GetWidget<QuotasController> {
|
|||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
),
|
),
|
||||||
const SizedBox(width: QuotasViewStyles.iconPadding),
|
const SizedBox(width: QuotasViewStyles.iconPadding),
|
||||||
Expanded(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context).storageQuotas,
|
AppLocalizations.of(context).storageQuotas,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -59,7 +61,20 @@ class QuotasView extends GetWidget<QuotasController> {
|
|||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
const SizedBox(width: QuotasViewStyles.iconPadding),
|
||||||
|
Obx(() {
|
||||||
|
final isLoading = controller.viewState.value.fold(
|
||||||
|
(failure) => false,
|
||||||
|
(success) => success is GetQuotasLoading,
|
||||||
|
);
|
||||||
|
|
||||||
|
return QuotaReloadButton(
|
||||||
|
icon: controller.imagePaths.icRefresh,
|
||||||
|
isLoading: isLoading,
|
||||||
|
onTap: controller.reloadQuota,
|
||||||
|
);
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: QuotasViewStyles.space),
|
const SizedBox(height: QuotasViewStyles.space),
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class QuotaReloadButton extends StatefulWidget {
|
||||||
|
const QuotaReloadButton({
|
||||||
|
super.key,
|
||||||
|
required this.icon,
|
||||||
|
required this.isLoading,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String icon;
|
||||||
|
final bool isLoading;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<QuotaReloadButton> createState() => _QuotaReloadButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuotaReloadButtonState extends State<QuotaReloadButton> with SingleTickerProviderStateMixin {
|
||||||
|
late final AnimationController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
controller = AnimationController(vsync: this, duration: const Duration(seconds: 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant QuotaReloadButton oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (oldWidget.isLoading != widget.isLoading) {
|
||||||
|
if (widget.isLoading) {
|
||||||
|
controller.repeat();
|
||||||
|
} else {
|
||||||
|
controller.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return RotationTransition(
|
||||||
|
turns: Tween(begin: 0.0, end: 1.0).animate(controller),
|
||||||
|
child: TMailButtonWidget.fromIcon(
|
||||||
|
icon: widget.icon,
|
||||||
|
iconColor: AppColor.steelGray400,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
iconSize: 20,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
onTapActionCallback: () {
|
||||||
|
if (widget.isLoading) return;
|
||||||
|
|
||||||
|
widget.onTap();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user