2022-05-17 12:33:30 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2022-05-26 01:02:06 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2022-05-19 14:26:57 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2023-03-27 17:02:44 +00:00
|
|
|
import 'package:selfprivacy/ui/components/buttons/brand_button.dart';
|
2023-04-05 10:33:53 +00:00
|
|
|
import 'package:selfprivacy/ui/components/cards/outlined_card.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
2022-05-19 14:26:57 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/setup/recovering/recover_by_old_token.dart';
|
2022-05-17 12:33:30 +00:00
|
|
|
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
|
|
|
|
|
|
|
class RecoveryMethodSelect extends StatelessWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const RecoveryMethodSelect({super.key});
|
2022-05-24 18:55:39 +00:00
|
|
|
|
2022-05-17 12:33:30 +00:00
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget build(final BuildContext context) => BrandHeroScreen(
|
2022-05-26 01:02:06 +00:00
|
|
|
heroTitle: 'recovering.recovery_main_header'.tr(),
|
2022-06-05 22:40:34 +00:00
|
|
|
heroSubtitle: 'recovering.method_select_description'.tr(),
|
2022-05-26 01:02:06 +00:00
|
|
|
hasBackButton: true,
|
|
|
|
hasFlashButton: false,
|
2023-04-04 14:31:35 +00:00
|
|
|
ignoreBreakpoints: true,
|
2022-06-09 21:13:06 +00:00
|
|
|
onBackButtonPressed:
|
|
|
|
context.read<ServerInstallationCubit>().revertRecoveryStep,
|
2022-05-26 01:02:06 +00:00
|
|
|
children: [
|
2022-09-15 16:57:26 +00:00
|
|
|
OutlinedCard(
|
2022-05-26 01:02:06 +00:00
|
|
|
child: ListTile(
|
|
|
|
title: Text(
|
2022-06-05 22:40:34 +00:00
|
|
|
'recovering.method_select_other_device'.tr(),
|
2022-05-26 01:02:06 +00:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
leading: const Icon(Icons.offline_share_outlined),
|
|
|
|
onTap: () => context
|
|
|
|
.read<ServerInstallationCubit>()
|
|
|
|
.selectRecoveryMethod(ServerRecoveryMethods.newDeviceKey),
|
2022-05-19 14:26:57 +00:00
|
|
|
),
|
|
|
|
),
|
2022-05-26 01:02:06 +00:00
|
|
|
const SizedBox(height: 16),
|
2022-09-15 16:57:26 +00:00
|
|
|
OutlinedCard(
|
2022-05-26 01:02:06 +00:00
|
|
|
child: ListTile(
|
|
|
|
title: Text(
|
2022-06-05 22:40:34 +00:00
|
|
|
'recovering.method_select_recovery_key'.tr(),
|
2022-05-26 01:02:06 +00:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
leading: const Icon(Icons.password_outlined),
|
|
|
|
onTap: () => context
|
|
|
|
.read<ServerInstallationCubit>()
|
|
|
|
.selectRecoveryMethod(ServerRecoveryMethods.recoveryKey),
|
2022-05-19 14:26:57 +00:00
|
|
|
),
|
|
|
|
),
|
2022-05-26 01:02:06 +00:00
|
|
|
const SizedBox(height: 16),
|
2022-06-05 22:40:34 +00:00
|
|
|
BrandButton.text(
|
|
|
|
title: 'recovering.method_select_nothing'.tr(),
|
|
|
|
onPressed: () => Navigator.of(context)
|
|
|
|
.push(materialRoute(const RecoveryFallbackMethodSelect())),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
class RecoveryFallbackMethodSelect extends StatelessWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const RecoveryFallbackMethodSelect({super.key});
|
2022-06-05 22:40:34 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(final BuildContext context) =>
|
|
|
|
BlocListener<ServerInstallationCubit, ServerInstallationState>(
|
|
|
|
listener: (final context, final state) {
|
|
|
|
if (state is ServerInstallationRecovery &&
|
|
|
|
state.recoveryCapabilities ==
|
|
|
|
ServerRecoveryCapabilities.loginTokens &&
|
|
|
|
state.currentStep != RecoveryStep.selecting) {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: BrandHeroScreen(
|
|
|
|
heroTitle: 'recovering.recovery_main_header'.tr(),
|
|
|
|
heroSubtitle: 'recovering.fallback_select_description'.tr(),
|
|
|
|
hasBackButton: true,
|
|
|
|
hasFlashButton: false,
|
2023-04-04 14:31:35 +00:00
|
|
|
ignoreBreakpoints: true,
|
2022-06-05 22:40:34 +00:00
|
|
|
children: [
|
2022-09-15 16:57:26 +00:00
|
|
|
OutlinedCard(
|
2022-06-05 22:40:34 +00:00
|
|
|
child: ListTile(
|
|
|
|
title: Text(
|
|
|
|
'recovering.fallback_select_token_copy'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
leading: const Icon(Icons.vpn_key),
|
|
|
|
onTap: () => Navigator.of(context).push(
|
|
|
|
materialRoute(
|
|
|
|
const RecoverByOldTokenInstruction(
|
|
|
|
instructionFilename: 'how_fallback_old',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-05-26 01:02:06 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
2022-09-15 16:57:26 +00:00
|
|
|
OutlinedCard(
|
2022-06-05 22:40:34 +00:00
|
|
|
child: ListTile(
|
|
|
|
title: Text(
|
|
|
|
'recovering.fallback_select_root_ssh'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
leading: const Icon(Icons.terminal),
|
|
|
|
onTap: () => Navigator.of(context).push(
|
|
|
|
materialRoute(
|
|
|
|
const RecoverByOldTokenInstruction(
|
|
|
|
instructionFilename: 'how_fallback_ssh',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-05-26 01:02:06 +00:00
|
|
|
),
|
2022-05-19 14:26:57 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
const SizedBox(height: 16),
|
2022-09-15 16:57:26 +00:00
|
|
|
OutlinedCard(
|
2022-06-05 22:40:34 +00:00
|
|
|
child: ListTile(
|
|
|
|
title: Text(
|
|
|
|
'recovering.fallback_select_provider_console'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
'recovering.fallback_select_provider_console_hint'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
|
|
|
leading: const Icon(Icons.web),
|
|
|
|
onTap: () => Navigator.of(context).push(
|
|
|
|
materialRoute(
|
|
|
|
const RecoverByOldTokenInstruction(
|
|
|
|
instructionFilename: 'how_fallback_terminal',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2022-05-19 14:26:57 +00:00
|
|
|
}
|