feat(backups): Show how much space a service uses on backup

- Resolve: #434
pull/500/head
NaiJi ✨ 2024-04-16 23:38:24 +04:00
parent c179a109fd
commit 4ad43ff1fd
1 changed files with 19 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:selfprivacy/logic/bloc/backups/backups_bloc.dart';
import 'package:selfprivacy/logic/bloc/server_jobs/server_jobs_bloc.dart';
import 'package:selfprivacy/logic/bloc/volumes/volumes_bloc.dart';
import 'package:selfprivacy/logic/models/json/server_job.dart';
import 'package:selfprivacy/logic/models/service.dart';
@ -103,6 +104,23 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
...widget.services.map(
(final Service service) {
final bool busy = busyServices.contains(service.id);
String description;
if (busy) {
description = 'backup.service_busy'.tr();
} else {
description = service.backupDescription;
description += '\n';
description += 'service_page.uses'.tr(
namedArgs: {
'usage': service.storageUsage.used.toString(),
'volume': context
.read<VolumesBloc>()
.state
.getVolume(service.storageUsage.volume ?? '')
.displayName,
},
);
}
return CheckboxListTile.adaptive(
onChanged: !busy
? (final bool? value) {
@ -123,7 +141,7 @@ class _CreateBackupsModalState extends State<CreateBackupsModal> {
service.displayName,
),
subtitle: Text(
busy ? 'backup.service_busy'.tr() : service.backupDescription,
description,
),
secondary: SvgPicture.string(
service.svgIcon,