Add recovery token pages

master^2
NaiJi ✨ 2022-05-18 02:18:26 +03:00
parent bf79fb1adf
commit 20f6e8156c
6 changed files with 121 additions and 20 deletions

View File

@ -0,0 +1,25 @@
import 'dart:async';
import 'package:cubit_form/cubit_form.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
class RecoveryDeviceFormCubit extends FormCubit {
RecoveryDeviceFormCubit(
this.initializingCubit, final FieldCubitFactory fieldFactory) {
tokenField = fieldFactory.createServerDomainField();
super.addFields([tokenField]);
}
@override
FutureOr<void> onSubmit() async {
// initializingCubit.setDomain(ServerDomain(
// domainName: serverDomainField.state.value,
// provider: DnsProvider.Unknown,
// zoneId: ""));
}
final ServerInstallationCubit initializingCubit;
late final FieldCubit<String> tokenField;
}

View File

@ -18,6 +18,7 @@ import 'package:selfprivacy/ui/components/brand_timer/brand_timer.dart';
import 'package:selfprivacy/ui/components/progress_bar/progress_bar.dart'; import 'package:selfprivacy/ui/components/progress_bar/progress_bar.dart';
import 'package:selfprivacy/ui/pages/rootRoute.dart'; import 'package:selfprivacy/ui/pages/rootRoute.dart';
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_domain.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recovery_domain.dart';
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_method_select.dart';
import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart';
class InitializingPage extends StatelessWidget { class InitializingPage extends StatelessWidget {
@ -104,8 +105,8 @@ class InitializingPage extends StatelessWidget {
child: BrandButton.text( child: BrandButton.text(
title: 'basis.connect_to_existing'.tr(), title: 'basis.connect_to_existing'.tr(),
onPressed: () { onPressed: () {
Navigator.of(context) Navigator.of(context).push(
.push(materialRoute(RecoveryDomain())); materialRoute(RecoveryMethodSelect()));
}, },
), ),
) )

View File

@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart'; import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart';
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
import 'package:selfprivacy/ui/pages/rootRoute.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recovery_method_device_2.dart';
import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart';
class RecoveryMethodDevice1 extends StatelessWidget { class RecoveryMethodDevice1 extends StatelessWidget {
@ -16,8 +16,8 @@ class RecoveryMethodDevice1 extends StatelessWidget {
children: [ children: [
FilledButton( FilledButton(
title: "recovering.method_device_button".tr(), title: "recovering.method_device_button".tr(),
onPressed: () => onPressed: () => Navigator.of(context)
Navigator.of(context).push(materialRoute(RootPage())), .push(materialRoute(RecoveryMethodDevice2())),
) )
], ],
); );

View File

@ -1,25 +1,49 @@
import 'package:cubit_form/cubit_form.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.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';
import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart'; import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart';
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
import 'package:selfprivacy/utils/route_transitions/basic.dart';
import 'package:selfprivacy/ui/pages/rootRoute.dart';
class RecoveryMethodDevice2 extends StatelessWidget { class RecoveryMethodDevice2 extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BrandHeroScreen( var appConfig = context.watch<ServerInstallationCubit>();
heroTitle: "recovering.recovery_main_header".tr(),
heroSubtitle: "recovering.method_device_input_description".tr(), return BlocProvider(
hasBackButton: true, create: (context) =>
hasFlashButton: false, RecoveryDeviceFormCubit(appConfig, FieldCubitFactory(context)),
children: [ child: Builder(
FilledButton( builder: (context) {
title: "recovering.method_device_button".tr(), var formCubitState = context.watch<RecoveryDeviceFormCubit>().state;
onPressed: () =>
Navigator.of(context).push(materialRoute(RootPage())), return BrandHeroScreen(
) heroTitle: "recovering.recovery_main_header".tr(),
], heroSubtitle: "recovering.method_device_input_description".tr(),
hasBackButton: true,
hasFlashButton: false,
children: [
CubitFormTextField(
formFieldCubit:
context.read<RecoveryDeviceFormCubit>().tokenField,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "recovering.method_device_input_placeholder".tr(),
),
),
SizedBox(height: 16),
FilledButton(
title: "more.continue".tr(),
onPressed: formCubitState.isSubmitting
? null
: () => context.read<RecoveryDeviceFormCubit>().trySubmit(),
)
],
);
},
),
); );
} }
} }

View File

@ -5,6 +5,7 @@ import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_fallback_select.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recovery_fallback_select.dart';
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_method_device_1.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recovery_method_device_1.dart';
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_method_token.dart';
import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart';
import 'package:selfprivacy/ui/pages/rootRoute.dart'; import 'package:selfprivacy/ui/pages/rootRoute.dart';
@ -36,7 +37,8 @@ class RecoveryMethodSelect extends StatelessWidget {
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleMedium,
), ),
leading: Icon(Icons.password_outlined), leading: Icon(Icons.password_outlined),
onTap: () => Navigator.of(context).push(materialRoute(RootPage())), onTap: () => Navigator.of(context)
.push(materialRoute(RecoveryMethodToken())),
), ),
), ),
SizedBox(height: 16), SizedBox(height: 16),

View File

@ -0,0 +1,49 @@
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';
import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart';
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
class RecoveryMethodToken extends StatelessWidget {
@override
Widget build(BuildContext context) {
var appConfig = context.watch<ServerInstallationCubit>();
return BlocProvider(
create: (context) =>
RecoveryDeviceFormCubit(appConfig, FieldCubitFactory(context)),
child: Builder(
builder: (context) {
var formCubitState = context.watch<RecoveryDeviceFormCubit>().state;
return BrandHeroScreen(
heroTitle: "recovering.recovery_main_header".tr(),
heroSubtitle: "recovering.method_recovery_input_description".tr(),
hasBackButton: true,
hasFlashButton: false,
children: [
CubitFormTextField(
formFieldCubit:
context.read<RecoveryDeviceFormCubit>().tokenField,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "recovering.method_device_input_placeholder".tr(),
),
),
SizedBox(height: 16),
FilledButton(
title: "more.continue".tr(),
onPressed: formCubitState.isSubmitting
? null
: () => context.read<RecoveryDeviceFormCubit>().trySubmit(),
)
],
);
},
),
);
}
}