Implement recovery method select page

Co-authored-by: Inex Code <inex.code@selfprivacy.org>
pull/90/head
NaiJi ✨ 2022-05-17 15:33:30 +03:00
parent a56af9dbec
commit ee53590ba0
7 changed files with 112 additions and 34 deletions

View File

@ -286,7 +286,16 @@
"recovering": { "recovering": {
"recovery_main_header": "Connect to an existing server", "recovery_main_header": "Connect to an existing server",
"domain_recovery_description": "Enter a server domain you want to get access for", "domain_recovery_description": "Enter a server domain you want to get access for",
"domain_recover_placeholder": "Your domain" "domain_recover_placeholder": "Your domain",
"method_select_description": "Select a recovery method:",
"method_select_other_device": "I have access on another device",
"method_select_recovery_key": "I have a recovery key",
"method_select_nothing": "I don't have any of that",
"fallback_select_description": "What exactly do you have? Pick the first available option:",
"fallback_select_token_copy": "Copy of auth token from other version of the application.",
"fallback_select_root_ssh": "Root SSH access to the server.",
"fallback_select_provider_console": "Access to the server console of my prodiver.",
"fallback_select_provider_console_hint": "For example: Hetzner."
}, },
"modals": { "modals": {
"_comment": "messages in modals", "_comment": "messages in modals",

View File

@ -284,6 +284,20 @@
"finish": "Всё инициализировано.", "finish": "Всё инициализировано.",
"checks": "Проверок выполнено: \n{} / {}" "checks": "Проверок выполнено: \n{} / {}"
}, },
"recovering": {
"recovery_main_header": "Подключиться к существующему серверу",
"domain_recovery_description": "Введите домен, по которому вы хотите получить доступ к серверу:",
"domain_recover_placeholder": "Домен",
"method_select_description": "Выберите способ входа:",
"method_select_other_device": "У меня есть доступ на другом устройстве",
"method_select_recovery_key": "У меня есть ключ восстановления",
"method_select_nothing": "У меня ничего из этого нет",
"fallback_select_description": "Что у вас из этого есть? Выберите первое, что подходит:",
"fallback_select_token_copy": "Копия токена авторизации из другой версии приложения.",
"fallback_select_root_ssh": "Root доступ к серверу по SSH.",
"fallback_select_provider_console": "Доступ к консоли хостинга.",
"fallback_select_provider_console_hint": "Например, Hetzner."
},
"modals": { "modals": {
"_comment": "messages in modals", "_comment": "messages in modals",
"1": "Сервер с таким именем уже существует", "1": "Сервер с таким именем уже существует",

View File

@ -39,8 +39,13 @@ abstract class AppThemeFactory {
); );
} }
final accentColor = await SystemAccentColor(fallbackColor) final accentColor = await SystemAccentColor(fallbackColor);
..load();
try {
await accentColor.load();
} on MissingPluginException catch (e) {
print("_createAppTheme: ${e.message}");
}
final fallbackColorScheme = ColorScheme.fromSeed( final fallbackColorScheme = ColorScheme.fromSeed(
seedColor: accentColor.accent, seedColor: accentColor.accent,

View File

@ -67,12 +67,12 @@ class _OutlinedCard extends StatelessWidget {
return Card( return Card(
elevation: 0.0, elevation: 0.0,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.all(Radius.circular(12)),
side: BorderSide( side: BorderSide(
color: Colors.grey.withOpacity(0.2), color: Theme.of(context).colorScheme.outline,
width: 1,
), ),
), ),
clipBehavior: Clip.antiAlias,
child: child, child: child,
); );
} }

View File

@ -17,7 +17,7 @@ import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
import 'package:selfprivacy/ui/components/brand_timer/brand_timer.dart'; 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_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 +104,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

@ -15,33 +15,35 @@ class RecoveryDomain extends StatelessWidget {
return BlocProvider( return BlocProvider(
create: (context) => create: (context) =>
RecoveryDomainFormCubit(appConfig, FieldCubitFactory(context)), RecoveryDomainFormCubit(appConfig, FieldCubitFactory(context)),
child: Builder(builder: (context) { child: Builder(
var formCubitState = context.watch<RecoveryDomainFormCubit>().state; builder: (context) {
var formCubitState = context.watch<RecoveryDomainFormCubit>().state;
return BrandHeroScreen( return BrandHeroScreen(
children: [ heroTitle: "recovering.recovery_main_header".tr(),
CubitFormTextField( heroSubtitle: "recovering.domain_recovery_description".tr(),
formFieldCubit: hasBackButton: true,
context.read<RecoveryDomainFormCubit>().serverDomainField, hasFlashButton: false,
decoration: InputDecoration( children: [
border: OutlineInputBorder(), CubitFormTextField(
labelText: "recovering.domain_recover_placeholder".tr(), formFieldCubit:
context.read<RecoveryDomainFormCubit>().serverDomainField,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "recovering.domain_recover_placeholder".tr(),
),
), ),
), SizedBox(height: 16),
SizedBox(height: 16), FilledButton(
FilledButton( title: "more.continue".tr(),
title: "more.continue".tr(), onPressed: formCubitState.isSubmitting
onPressed: formCubitState.isSubmitting ? null
? null : () => context.read<RecoveryDomainFormCubit>().trySubmit(),
: () => context.read<RecoveryDomainFormCubit>().trySubmit(), )
) ],
], );
heroTitle: "recovering.recovery_main_header".tr(), },
heroSubtitle: "recovering.domain_recovery_description".tr(), ),
hasBackButton: true,
hasFlashButton: false,
);
}),
); );
} }
} }

View File

@ -0,0 +1,48 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
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/utils/route_transitions/basic.dart';
import 'package:selfprivacy/ui/pages/rootRoute.dart';
class RecoveryMethodSelect extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BrandHeroScreen(
heroTitle: "recovering.recovery_main_header".tr(),
heroSubtitle: "recovering.method_select_description".tr(),
hasBackButton: true,
hasFlashButton: false,
children: [
BrandCards.outlined(
child: ListTile(
title: Text(
"recovering.method_select_other_device".tr(),
style: Theme.of(context).textTheme.titleMedium,
),
leading: Icon(Icons.offline_share_outlined),
onTap: () => Navigator.of(context).push(materialRoute(RootPage())),
),
),
SizedBox(height: 16),
BrandCards.outlined(
child: ListTile(
title: Text(
"recovering.method_select_recovery_key".tr(),
style: Theme.of(context).textTheme.titleMedium,
),
leading: Icon(Icons.password_outlined),
onTap: () => Navigator.of(context).push(materialRoute(RootPage())),
),
),
SizedBox(height: 16),
BrandButton.text(
title: "recovering.method_select_nothing".tr(),
onPressed: () =>
Navigator.of(context).push(materialRoute(RootPage())),
)
],
);
}
}