TF-4045 Add storage information in settings
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/storage/storage_controller.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/use_case/get_quotas_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/presentation/quotas_interactor_bindings.dart';
|
||||
|
||||
class StorageBindings extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
QuotasInteractorBindings().dependencies();
|
||||
Get.lazyPut(() => StorageController(Get.find<GetQuotasInteractor>()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/quota.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/extensions/list_quotas_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/state/get_quotas_state.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/use_case/get_quotas_interactor.dart';
|
||||
|
||||
class StorageController extends BaseController {
|
||||
final dashBoardController = Get.find<ManageAccountDashBoardController>();
|
||||
|
||||
final GetQuotasInteractor _getQuotasInteractor;
|
||||
|
||||
final octetsQuota = Rxn<Quota>();
|
||||
|
||||
StorageController(this._getQuotasInteractor);
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
final accountId = dashBoardController.accountId.value;
|
||||
if(accountId != null) {
|
||||
_getQuotasAction(accountId);
|
||||
} else {
|
||||
consumeState(
|
||||
Stream.value(
|
||||
Left(GetQuotasFailure(NotFoundAccountIdException())),
|
||||
),
|
||||
);
|
||||
}
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
void _getQuotasAction(AccountId accountId) {
|
||||
consumeState(_getQuotasInteractor.execute(accountId));
|
||||
}
|
||||
|
||||
void _handleGetQuotasSuccess(GetQuotasSuccess success) {
|
||||
octetsQuota.value = success.quotas.octetsQuota;
|
||||
}
|
||||
|
||||
void onUpgradeStorage() {
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void handleSuccessViewState(Success success) {
|
||||
if (success is GetQuotasSuccess) {
|
||||
_handleGetQuotasSuccess(success);
|
||||
} else {
|
||||
super.handleSuccessViewState(success);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void handleFailureViewState(Failure failure) {
|
||||
if (failure is GetQuotasFailure) {
|
||||
octetsQuota.value = null;
|
||||
} else {
|
||||
super.handleFailureViewState(failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import 'package:core/presentation/utils/theme_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/base/setting_detail_view_builder.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/settings_utils.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/storage/storage_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/storage/widgets/storage_progress_bar_widget.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/storage/widgets/upgrade_storage_widget.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/widgets/setting_explanation_widget.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/widgets/setting_header_widget.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/extensions/quota_extensions.dart';
|
||||
|
||||
class StorageView extends GetWidget<StorageController> {
|
||||
const StorageView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final responsiveUtils = controller.responsiveUtils;
|
||||
final isMobile = responsiveUtils.isMobile(context);
|
||||
final isDesktop = responsiveUtils.isDesktop(context);
|
||||
final isWebDesktop = responsiveUtils.isWebDesktop(context);
|
||||
|
||||
return SettingDetailViewBuilder(
|
||||
responsiveUtils: responsiveUtils,
|
||||
child: Container(
|
||||
color: SettingsUtils.getContentBackgroundColor(
|
||||
context,
|
||||
responsiveUtils,
|
||||
),
|
||||
decoration: SettingsUtils.getBoxDecorationForContent(
|
||||
context,
|
||||
responsiveUtils,
|
||||
),
|
||||
width: double.infinity,
|
||||
padding: isDesktop
|
||||
? const EdgeInsets.symmetric(vertical: 30, horizontal: 22)
|
||||
: null,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (isWebDesktop)
|
||||
SettingHeaderWidget(
|
||||
menuItem: AccountMenuItem.storage,
|
||||
textStyle: ThemeUtils.textStyleInter600().copyWith(
|
||||
color: Colors.black.withValues(alpha: 0.9),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
)
|
||||
else
|
||||
const SettingExplanationWidget(
|
||||
menuItem: AccountMenuItem.storage,
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: 16,
|
||||
end: 16,
|
||||
bottom: 16,
|
||||
),
|
||||
isCenter: true,
|
||||
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,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
EdgeInsetsGeometry _getPadding({
|
||||
bool isMobile = false,
|
||||
bool isDesktop = false,
|
||||
}) {
|
||||
if (isMobile) {
|
||||
return const EdgeInsetsDirectional.only(top: 31, start: 24, end: 24);
|
||||
} else if (isDesktop) {
|
||||
return const EdgeInsetsDirectional.only(top: 37, start: 15);
|
||||
} else {
|
||||
return const EdgeInsetsDirectional.only(top: 31, start: 32, end: 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/utils/theme_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:jmap_dart_client/jmap/quotas/quota.dart';
|
||||
import 'package:tmail_ui_user/features/quotas/domain/extensions/quota_extensions.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class StorageProgressBarWidget extends StatelessWidget {
|
||||
final ImagePaths imagePaths;
|
||||
final Quota quota;
|
||||
final bool isMobile;
|
||||
|
||||
const StorageProgressBarWidget({
|
||||
super.key,
|
||||
required this.imagePaths,
|
||||
required this.quota,
|
||||
this.isMobile = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appLocalizations = AppLocalizations.of(context);
|
||||
|
||||
final logoStorageWidget = Container(
|
||||
width: 64,
|
||||
height: 64,
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColor.lightGrayF6FAFF,
|
||||
borderRadius: BorderRadius.all(Radius.circular(100)),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: SvgPicture.asset(
|
||||
imagePaths.icCloud,
|
||||
width: 30.72,
|
||||
height: 30.72,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
);
|
||||
|
||||
final infoStorageWidgets = <Widget>[
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
quota.usedStorageAsString,
|
||||
style: ThemeUtils.textStyleInter600().copyWith(
|
||||
color: AppColor.m3SurfaceBackground,
|
||||
fontSize: 18.13,
|
||||
height: 22.66 / 18.13,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
),
|
||||
child: Text(
|
||||
appLocalizations.storageUsedMessage(
|
||||
quota.hardLimitStorageAsString,
|
||||
),
|
||||
style: ThemeUtils.textStyleInter500().copyWith(
|
||||
color: AppColor.m3Tertiary20,
|
||||
fontSize: 9.06,
|
||||
height: 13.6 / 9.06,
|
||||
letterSpacing: 0.08,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
appLocalizations.storageAvailableMessage(
|
||||
quota.quotaAvailableStorageAsString,
|
||||
),
|
||||
style: ThemeUtils.textStyleInter600().copyWith(
|
||||
color: AppColor.m3Tertiary20,
|
||||
fontSize: 9.06,
|
||||
height: 13.6 / 9.06,
|
||||
letterSpacing: 0.08,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.only(top: 5),
|
||||
width: double.infinity,
|
||||
child: LinearProgressIndicator(
|
||||
color: quota.getQuotasStateProgressBarColor(
|
||||
fromSetting: true,
|
||||
),
|
||||
minHeight: 4.53,
|
||||
backgroundColor: AppColor.lightGrayF7F6F9,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(13.03),
|
||||
),
|
||||
value: quota.usedStoragePercent,
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
return Container(
|
||||
width: isMobile ? double.infinity : 439,
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: isMobile
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
logoStorageWidget,
|
||||
const SizedBox(height: 8),
|
||||
...infoStorageWidgets,
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
children: [
|
||||
logoStorageWidget,
|
||||
const SizedBox(width: 24),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: infoStorageWidgets,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/utils/theme_utils.dart';
|
||||
import 'package:core/presentation/views/dialog/confirm_dialog_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class UpgradeStorageWidget extends StatelessWidget {
|
||||
final ImagePaths imagePaths;
|
||||
final bool isMobile;
|
||||
final VoidCallback onUpgradeStorageAction;
|
||||
|
||||
const UpgradeStorageWidget({
|
||||
super.key,
|
||||
required this.imagePaths,
|
||||
required this.onUpgradeStorageAction,
|
||||
this.isMobile = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appLocalizations = AppLocalizations.of(context);
|
||||
return SizedBox(
|
||||
width: isMobile ? double.infinity : 439,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
constraints: const BoxConstraints(minWidth: 179),
|
||||
height: 48,
|
||||
child: ConfirmDialogButton(
|
||||
label: appLocalizations.upgradeStorage,
|
||||
backgroundColor: AppColor.primaryMain,
|
||||
textColor: Colors.white,
|
||||
onTapAction: onUpgradeStorageAction,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user