2023-07-02 15:24:07 +00:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2024-01-29 13:54:09 +00:00
|
|
|
import 'package:selfprivacy/logic/bloc/backups/backups_bloc.dart';
|
2023-07-02 15:24:07 +00:00
|
|
|
import 'package:selfprivacy/logic/models/backup.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/service.dart';
|
|
|
|
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
2024-11-26 12:14:49 +00:00
|
|
|
import 'package:selfprivacy/ui/molecules/list_items/snapshot_item.dart';
|
2023-07-02 15:24:07 +00:00
|
|
|
|
|
|
|
@RoutePage()
|
|
|
|
class BackupsListPage extends StatelessWidget {
|
|
|
|
const BackupsListPage({
|
|
|
|
required this.service,
|
|
|
|
super.key,
|
|
|
|
});
|
|
|
|
|
|
|
|
final Service? service;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
// If the service is null, get all backups from state. If not null, call the
|
|
|
|
// serviceBackups(serviceId) on the backups state.
|
|
|
|
final List<Backup> backups = service == null
|
2024-01-29 13:54:09 +00:00
|
|
|
? context.watch<BackupsBloc>().state.backups
|
|
|
|
: context.watch<BackupsBloc>().state.serviceBackups(service!.id);
|
2023-07-02 15:24:07 +00:00
|
|
|
final bool preventActions =
|
2024-01-29 13:54:09 +00:00
|
|
|
context.watch<BackupsBloc>().state.preventActions;
|
2023-07-02 15:24:07 +00:00
|
|
|
return BrandHeroScreen(
|
|
|
|
heroTitle: 'backup.snapshots_title'.tr(),
|
2023-11-20 15:46:03 +00:00
|
|
|
hasFlashButton: true,
|
2023-07-02 15:24:07 +00:00
|
|
|
children: [
|
|
|
|
if (backups.isEmpty)
|
|
|
|
Center(
|
|
|
|
child: Text(
|
|
|
|
'backup.no_backups'.tr(),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
else
|
2023-11-06 13:15:38 +00:00
|
|
|
...backups.map(
|
2024-11-26 12:14:49 +00:00
|
|
|
(final Backup backup) => SnapshotItem(
|
|
|
|
backup: backup,
|
|
|
|
preventActions: preventActions,
|
|
|
|
),
|
2023-11-06 13:15:38 +00:00
|
|
|
),
|
2023-07-02 15:24:07 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|