2022-09-16 09:08:31 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
2023-03-27 17:02:44 +00:00
|
|
|
import 'package:selfprivacy/ui/components/buttons/brand_button.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
2022-09-16 09:08:31 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_linear_indicator/brand_linear_indicator.dart';
|
|
|
|
import 'package:selfprivacy/ui/pages/root_route.dart';
|
|
|
|
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
|
|
|
|
|
|
|
class MigrationProcessPage extends StatefulWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const MigrationProcessPage({super.key});
|
2022-09-16 09:08:31 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<MigrationProcessPage> createState() => _MigrationProcessPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MigrationProcessPageState extends State<MigrationProcessPage> {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(final BuildContext context) {
|
2022-09-18 14:05:41 +00:00
|
|
|
ServerJob? job;
|
|
|
|
String? subtitle = '';
|
|
|
|
double value = 0.0;
|
|
|
|
List<Widget> children = [];
|
|
|
|
|
2022-09-16 09:08:31 +00:00
|
|
|
final serverJobsState = context.watch<ServerJobsCubit>().state;
|
2022-09-18 14:05:41 +00:00
|
|
|
if (serverJobsState.migrationJobUid != null) {
|
|
|
|
job = context.read<ServerJobsCubit>().getServerJobByUid(
|
|
|
|
serverJobsState.migrationJobUid!,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (job == null) {
|
|
|
|
subtitle = 'basis.loading'.tr();
|
|
|
|
} else {
|
|
|
|
value = job.progress == null ? 0.0 : job.progress! / 100;
|
|
|
|
subtitle = job.statusText;
|
|
|
|
children = [
|
|
|
|
...children,
|
2022-09-16 09:08:31 +00:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
if (job.finishedAt != null)
|
|
|
|
Text(
|
|
|
|
job.result!,
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
if (job.finishedAt != null) const SizedBox(height: 16),
|
|
|
|
if (job.finishedAt != null)
|
2023-02-05 13:24:37 +00:00
|
|
|
BrandButton.filled(
|
|
|
|
child: Text('storage.migration_done'.tr()),
|
2022-09-16 09:08:31 +00:00
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
materialRoute(const RootPage()),
|
|
|
|
(final predicate) => false,
|
|
|
|
);
|
|
|
|
},
|
2022-09-18 14:05:41 +00:00
|
|
|
),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
return BrandHeroScreen(
|
|
|
|
hasBackButton: false,
|
2022-10-03 23:32:35 +00:00
|
|
|
heroTitle: 'storage.migration_process'.tr(),
|
2022-09-18 14:05:41 +00:00
|
|
|
heroSubtitle: subtitle,
|
|
|
|
children: [
|
|
|
|
BrandLinearIndicator(
|
|
|
|
value: value,
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.surfaceVariant,
|
|
|
|
height: 4.0,
|
|
|
|
),
|
|
|
|
...children,
|
2022-09-16 09:08:31 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|