selfprivacy.org.app/lib/ui/pages/setup/recovering/recover_by_recovery_key.dart

59 lines
2.2 KiB
Dart
Raw Normal View History

2022-05-18 02:18:26 +03:00
import 'package:cubit_form/cubit_form.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
import 'package:selfprivacy/logic/cubit/forms/setup/recovering/recovery_device_form_cubit.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
2022-05-24 21:55:39 +03:00
import 'package:selfprivacy/ui/components/brand_button/filled_button.dart';
2022-05-18 02:18:26 +03:00
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
class RecoverByRecoveryKey extends StatelessWidget {
const RecoverByRecoveryKey({final super.key});
2022-05-24 21:55:39 +03:00
2022-05-18 02:18:26 +03:00
@override
2022-06-05 22:36:32 +03:00
Widget build(final BuildContext context) {
final ServerInstallationCubit appConfig =
context.watch<ServerInstallationCubit>();
2022-05-18 02:18:26 +03:00
return BlocProvider(
2022-06-05 22:36:32 +03:00
create: (final context) => RecoveryDeviceFormCubit(
appConfig,
FieldCubitFactory(context),
ServerRecoveryMethods.recoveryKey,
),
2022-05-18 02:18:26 +03:00
child: Builder(
2022-06-05 22:36:32 +03:00
builder: (final context) {
final FormCubitState formCubitState =
context.watch<RecoveryDeviceFormCubit>().state;
2022-05-18 02:18:26 +03:00
return BrandHeroScreen(
2022-05-24 21:55:39 +03:00
heroTitle: 'recovering.recovery_main_header'.tr(),
heroSubtitle: 'recovering.method_recovery_input_description'.tr(),
2022-05-18 02:18:26 +03:00
hasBackButton: true,
hasFlashButton: false,
2022-06-10 00:13:06 +03:00
onBackButtonPressed:
context.read<ServerInstallationCubit>().revertRecoveryStep,
2022-05-18 02:18:26 +03:00
children: [
CubitFormTextField(
formFieldCubit:
context.read<RecoveryDeviceFormCubit>().tokenField,
decoration: InputDecoration(
2022-05-24 21:55:39 +03:00
border: const OutlineInputBorder(),
labelText: 'recovering.method_device_input_placeholder'.tr(),
2022-05-18 02:18:26 +03:00
),
),
2022-05-24 21:55:39 +03:00
const SizedBox(height: 16),
2022-05-18 02:18:26 +03:00
FilledButton(
title: 'basis.continue'.tr(),
2022-05-18 02:18:26 +03:00
onPressed: formCubitState.isSubmitting
? null
: () => context.read<RecoveryDeviceFormCubit>().trySubmit(),
)
],
);
},
),
);
}
}