From b2a5d57a1dfa8c87a46246a8ea4e722ffe92214b Mon Sep 17 00:00:00 2001 From: NaiJi Date: Sun, 20 Nov 2022 14:48:08 +0400 Subject: [PATCH] feat(initializing): Add description and back button to server type step --- assets/translations/en.json | 2 ++ assets/translations/ru.json | 4 +++- .../setup/initializing/initializing.dart | 5 ++++ .../initializing/server_type_picker.dart | 23 +++++++++++++++++-- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index 908ef5e1..18e70c5b 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -273,6 +273,8 @@ "place_where_data": "A place where your data and SelfPrivacy services will reside:", "how": "How to obtain API token", "provider_bad_key_error": "Provider API key is invalid", + "choose_location_type": "Choose your server location and type:", + "back_to_locations": "Go back to available locations!", "no_locations_found": "No available locations found. Make sure your account is accessible.", "no_server_types_found": "No available server types found. Make sure your account is accessible and try to change your server location.", "cloudflare_bad_key_error": "Cloudflare API key is invalid", diff --git a/assets/translations/ru.json b/assets/translations/ru.json index ee056a3d..7352bf59 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -271,7 +271,9 @@ "connect_to_server": "Подключите сервер", "place_where_data": "Здесь будут жить ваши данные и SelfPrivacy-сервисы:", "how": "Как получить API Token", - "provider_bad_key_error": "API ключ провайдера неверен", + "provider_bad_key_error": "Provider API key is invalid", + "choose_location_type": "Выберите локацию и тип вашего сервера:", + "back_to_locations": "Назад к доступным локациям!", "no_locations_found": "Не найдено локаций. Убедитесь, что ваш аккаунт доступен.", "no_server_types_found": "Не удалось получить список серверов. Убедитесь, что ваш аккаунт доступен и попытайтесь сменить локацию сервера.", "cloudflare_bad_key_error": "Cloudflare API ключ неверен", diff --git a/lib/ui/pages/setup/initializing/initializing.dart b/lib/ui/pages/setup/initializing/initializing.dart index c56928a9..29fcd6f0 100644 --- a/lib/ui/pages/setup/initializing/initializing.dart +++ b/lib/ui/pages/setup/initializing/initializing.dart @@ -82,6 +82,11 @@ class InitializingPage extends StatelessWidget { activeIndex: cubit.state.porgressBar, ), ), + if (cubit.state.porgressBar == + ServerSetupProgress.serverProviderFilled.index) + BrandText.h2( + 'initializing.choose_location_type'.tr(), + ), _addCard( AnimatedSwitcher( duration: const Duration(milliseconds: 300), diff --git a/lib/ui/pages/setup/initializing/server_type_picker.dart b/lib/ui/pages/setup/initializing/server_type_picker.dart index a6757571..04b3bd5f 100644 --- a/lib/ui/pages/setup/initializing/server_type_picker.dart +++ b/lib/ui/pages/setup/initializing/server_type_picker.dart @@ -4,6 +4,7 @@ import 'package:selfprivacy/config/brand_theme.dart'; import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart'; import 'package:selfprivacy/logic/models/server_provider_location.dart'; import 'package:selfprivacy/logic/models/server_type.dart'; +import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; class ServerTypePicker extends StatefulWidget { const ServerTypePicker({ @@ -21,7 +22,7 @@ class _ServerTypePickerState extends State { ServerProviderLocation? serverProviderLocation; ServerType? serverType; - void setServerProviderLocation(final ServerProviderLocation location) { + void setServerProviderLocation(final ServerProviderLocation? location) { setState(() { serverProviderLocation = location; }); @@ -39,6 +40,9 @@ class _ServerTypePickerState extends State { return SelectTypePage( location: serverProviderLocation!, serverInstallationCubit: widget.serverInstallationCubit, + backToLocationPickingCallback: () { + setServerProviderLocation(null); + }, ); } } @@ -102,6 +106,7 @@ class SelectLocationPage extends StatelessWidget { class SelectTypePage extends StatelessWidget { const SelectTypePage({ + required this.backToLocationPickingCallback, required this.location, required this.serverInstallationCubit, super.key, @@ -109,6 +114,7 @@ class SelectTypePage extends StatelessWidget { final ServerProviderLocation location; final ServerInstallationCubit serverInstallationCubit; + final Function backToLocationPickingCallback; @override Widget build(final BuildContext context) => FutureBuilder( @@ -119,7 +125,20 @@ class SelectTypePage extends StatelessWidget { ) { if (snapshot.hasData) { if ((snapshot.data as List).isEmpty) { - return Text('initializing.no_server_types_found'.tr()); + return Column( + children: [ + Text( + 'initializing.no_server_types_found'.tr(), + ), + const SizedBox(height: 10), + BrandButton.rised( + onPressed: () { + backToLocationPickingCallback(); + }, + text: 'initializing.back_to_locations'.tr(), + ), + ], + ); } return ListView( padding: paddingH15V0,