mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-03-31 18:56:21 +00:00
parent
447ee39cbd
commit
afc552353a
2 changed files with 33 additions and 8 deletions
|
@ -221,7 +221,8 @@
|
|||
},
|
||||
"backup": {
|
||||
"card_title": "Backup",
|
||||
"card_subtitle": "Manage your backups",
|
||||
"card_subtitle": "{backupsPeriod} · Last backup: {lastBackups}",
|
||||
"card_subtitle_never": "Never",
|
||||
"description": "Will save your day in case of incident: hackers attack, server deletion, etc.",
|
||||
"reupload_key": "Force reupload key",
|
||||
"reuploaded_key": "Key reuploaded",
|
||||
|
|
|
@ -15,6 +15,7 @@ import 'package:selfprivacy/ui/molecules/cards/server_outdated_card.dart';
|
|||
import 'package:selfprivacy/ui/organisms/headers/brand_header.dart';
|
||||
import 'package:selfprivacy/ui/router/router.dart';
|
||||
import 'package:selfprivacy/utils/breakpoints.dart';
|
||||
import 'package:selfprivacy/utils/extensions/duration.dart';
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
|
||||
GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
@ -32,7 +33,9 @@ class _ProvidersPageState extends State<ProvidersPage> {
|
|||
Widget build(final BuildContext context) {
|
||||
final bool isReady = context.watch<ServerInstallationCubit>().state
|
||||
is ServerInstallationFinished;
|
||||
final BackupsState backupsState = context.watch<BackupsBloc>().state;
|
||||
final backupsState = context.watch<BackupsBloc>().state;
|
||||
_backupsCardSubtitle(backupsState);
|
||||
|
||||
final DnsRecordsStatus dnsStatus =
|
||||
context.watch<DnsRecordsCubit>().state.dnsState;
|
||||
|
||||
|
@ -127,12 +130,7 @@ class _ProvidersPageState extends State<ProvidersPage> {
|
|||
: StateType.uninitialized,
|
||||
icon: BrandIcons.save,
|
||||
title: 'backup.card_title'.tr(),
|
||||
subtitle: backupsState is BackupsInitialized
|
||||
? 'backup.card_subtitle'.tr()
|
||||
: backupsState is BackupsLoading ||
|
||||
backupsState is BackupsInitial
|
||||
? 'basis.loading'.tr()
|
||||
: '',
|
||||
subtitle: _backupsCardSubtitle(backupsState),
|
||||
onTap: isClickable()
|
||||
? () => context.pushRoute(const BackupDetailsRoute())
|
||||
: null,
|
||||
|
@ -142,4 +140,30 @@ class _ProvidersPageState extends State<ProvidersPage> {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _backupsCardSubtitle(final BackupsState backupsState) {
|
||||
if (backupsState is BackupsInitialized) {
|
||||
final period = backupsState.autobackupPeriod;
|
||||
final backups = backupsState.backups;
|
||||
return 'backup.card_subtitle'.tr(
|
||||
namedArgs: {
|
||||
'backupsPeriod': (period != null)
|
||||
? 'backup.autobackup_period_every'.tr(
|
||||
namedArgs: {
|
||||
'period': period.toPrettyString(context.locale),
|
||||
},
|
||||
)
|
||||
: 'backup.card_subtitle_never'.tr(),
|
||||
'lastBackups': backups.isNotEmpty
|
||||
? DateFormat('yyyy-MM-dd H:m').format(backups.first.time)
|
||||
: 'backup.card_subtitle_never'.tr(),
|
||||
},
|
||||
);
|
||||
} else if (backupsState is BackupsLoading ||
|
||||
backupsState is BackupsInitial) {
|
||||
return 'basis.loading'.tr();
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue