diff --git a/assets/translations/en.json b/assets/translations/en.json index 8cb0235a..46847018 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -91,7 +91,7 @@ "status": "Status — Good", "bottom_sheet": { "1": "It's your personal internet address that will point to the server and other services of yours.", - "2": "{} — expires on {}" + "2": "{}" } }, "backup": { diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 855adf60..3139f007 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -91,7 +91,7 @@ "status": "Статус — в норме", "bottom_sheet": { "1": "Это ваш личный адрес в интернете, который будет указывать на сервер и другие ваши сервисы.", - "2": "{} — продлен до {}" + "2": "{}" } }, "backup": { @@ -161,6 +161,13 @@ "bottom_sheet": { "1": "Подключиться к серверу и создать пользователя можно по адресу:" } + }, + "vpn": { + "title": "VPN сервер", + "subtitle": "Закрытый VPN сервер", + "bottom_sheet": { + "1": "Создать подключиться к VPN-серверу. Движок для безопасной и масштабируемой инфраструктуры VPN" + } } }, "users": { diff --git a/ios/Podfile.lock b/ios/Podfile.lock index ff1fc217..7eefa660 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -51,7 +51,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec - local_auth: ef62030a2731330b95df7ef1331bd15f6a64b8a6 + local_auth: 25938960984c3a7f6e3253e3f8d962fdd16852bd package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68 diff --git a/lib/config/text_themes.dart b/lib/config/text_themes.dart index c84aeaed..f14d54e1 100644 --- a/lib/config/text_themes.dart +++ b/lib/config/text_themes.dart @@ -38,6 +38,13 @@ final headline4Style = defaultTextStyle.copyWith( color: BrandColors.headlineColor, ); +final headline4UnderlinedStyle = defaultTextStyle.copyWith( + fontSize: 18, + fontWeight: NamedFontWeight.medium, + color: BrandColors.headlineColor, + decoration: TextDecoration.underline, +); + final headline5Style = defaultTextStyle.copyWith( fontSize: 15, fontWeight: NamedFontWeight.medium, diff --git a/lib/logic/api_maps/api_map.dart b/lib/logic/api_maps/api_map.dart index 5f4330d4..a818e38d 100644 --- a/lib/logic/api_maps/api_map.dart +++ b/lib/logic/api_maps/api_map.dart @@ -15,13 +15,23 @@ abstract class ApiMap { if (hasLoger) { dio.interceptors.add(PrettyDioLogger()); } - dio..interceptors.add(ConsoleInterceptor()); + dio.interceptors.add(ConsoleInterceptor()); (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) { client.badCertificateCallback = (X509Certificate cert, String host, int port) => true; return client; }; + + dio.interceptors.add(InterceptorsWrapper(onError: (DioError e, handler) { + print(e.requestOptions.path); + print(e.requestOptions.data); + + print(e.message); + print(e.response); + + return handler.next(e); + })); return dio; } diff --git a/lib/logic/cubit/services/services_cubit.dart b/lib/logic/cubit/services/services_cubit.dart index 2fcf8559..5bbfcecc 100644 --- a/lib/logic/cubit/services/services_cubit.dart +++ b/lib/logic/cubit/services/services_cubit.dart @@ -14,16 +14,18 @@ class ServicesCubit extends AppConfigDependendCubit { Box box = Hive.box(BNames.servicesState); final api = ServerApi(); Future load() async { - var statuses = await api.servicesPowerCheck(); - emit( - ServicesState( - isPasswordManagerEnable: statuses[ServiceTypes.passwordManager]!, - isCloudEnable: statuses[ServiceTypes.cloud]!, - isGitEnable: statuses[ServiceTypes.git]!, - isSocialNetworkEnable: statuses[ServiceTypes.socialNetwork]!, - isVpnEnable: statuses[ServiceTypes.vpn]!, - ), - ); + if (appConfigCubit.state is AppConfigFinished) { + var statuses = await api.servicesPowerCheck(); + emit( + ServicesState( + isPasswordManagerEnable: statuses[ServiceTypes.passwordManager]!, + isCloudEnable: statuses[ServiceTypes.cloud]!, + isGitEnable: statuses[ServiceTypes.git]!, + isSocialNetworkEnable: statuses[ServiceTypes.socialNetwork]!, + isVpnEnable: statuses[ServiceTypes.vpn]!, + ), + ); + } } @override diff --git a/lib/logic/cubit/users/users_cubit.dart b/lib/logic/cubit/users/users_cubit.dart index 5d634dc4..3234a875 100644 --- a/lib/logic/cubit/users/users_cubit.dart +++ b/lib/logic/cubit/users/users_cubit.dart @@ -13,6 +13,7 @@ class UsersCubit extends Cubit { void load() async { var loadedUsers = box.values.toList(); + if (loadedUsers.isNotEmpty) { emit(UsersState(loadedUsers)); } diff --git a/lib/main.dart b/lib/main.dart index cfd595ae..028291d2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,6 +18,7 @@ import 'logic/cubit/app_settings/app_settings_cubit.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await HiveConfig.init(); + await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); Bloc.observer = SimpleBlocObserver(); Wakelock.enable(); await getItSetup(); diff --git a/lib/ui/components/brand_text/brand_text.dart b/lib/ui/components/brand_text/brand_text.dart index bd3119dc..41436cc1 100644 --- a/lib/ui/components/brand_text/brand_text.dart +++ b/lib/ui/components/brand_text/brand_text.dart @@ -13,7 +13,8 @@ enum TextType { medium, small, onboardingTitle, - buttonTitleText // risen button title text, + buttonTitleText, // risen button title text, + h4Underlined, } class BrandText extends StatelessWidget { @@ -25,6 +26,7 @@ class BrandText extends StatelessWidget { this.overflow, this.softWrap, this.textAlign, + this.maxLines, }) : super(key: key); final String? text; @@ -33,6 +35,7 @@ class BrandText extends StatelessWidget { final TextOverflow? overflow; final bool? softWrap; final TextAlign? textAlign; + final int? maxLines; factory BrandText.h1( String? text, { @@ -80,6 +83,24 @@ class BrandText extends StatelessWidget { text, type: TextType.h4, style: style, + softWrap: true, + overflow: TextOverflow.ellipsis, + maxLines: 2, + textAlign: textAlign, + ); + + factory BrandText.h4Underlined( + String? text, { + TextStyle? style, + TextAlign? textAlign, + }) => + BrandText( + text, + type: TextType.h4Underlined, + style: style, + softWrap: true, + overflow: TextOverflow.ellipsis, + maxLines: 2, textAlign: textAlign, ); @@ -148,6 +169,11 @@ class BrandText extends StatelessWidget { ? headline4Style.copyWith(color: Colors.white) : headline4Style; break; + case TextType.h4Underlined: + style = isDark + ? headline4UnderlinedStyle.copyWith(color: Colors.white) + : headline4UnderlinedStyle; + break; case TextType.h5: style = isDark ? headline5Style.copyWith(color: Colors.white) @@ -185,6 +211,7 @@ class BrandText extends StatelessWidget { return Text( text!, style: style, + maxLines: maxLines, overflow: overflow, softWrap: softWrap, textAlign: textAlign, diff --git a/lib/ui/pages/providers/providers.dart b/lib/ui/pages/providers/providers.dart index 0378a853..d158a5fb 100644 --- a/lib/ui/pages/providers/providers.dart +++ b/lib/ui/pages/providers/providers.dart @@ -28,7 +28,7 @@ class ProvidersPage extends StatefulWidget { class _ProvidersPageState extends State { @override Widget build(BuildContext context) { - var isReady = context.watch().state is AppConfigFinished; + var isReady = context.watch().state is AppConfigFinished; final cards = ProviderType.values .map( @@ -75,7 +75,7 @@ class _Card extends StatelessWidget { String? message; late String stableText; late VoidCallback onTap; - var isReady = context.watch().state is AppConfigFinished; + var isReady = context.watch().state is AppConfigFinished; AppConfigState appConfig = context.watch().state; var domainName = @@ -179,7 +179,7 @@ class _ProviderDetails extends StatelessWidget { BrandText.body1('providers.domain.bottom_sheet.1'.tr()), SizedBox(height: 10), BrandText.body1( - 'providers.domain.bottom_sheet.2'.tr(args: [domainName, 'Date'])), + 'providers.domain.bottom_sheet.2'.tr(args: [domainName])), SizedBox(height: 10), BrandText.body1('providers.domain.status'.tr()), ]; diff --git a/lib/ui/pages/services/services.dart b/lib/ui/pages/services/services.dart index 726955ee..e627a1b6 100644 --- a/lib/ui/pages/services/services.dart +++ b/lib/ui/pages/services/services.dart @@ -41,7 +41,7 @@ class ServicesPage extends StatefulWidget { class _ServicesPageState extends State { @override Widget build(BuildContext context) { - var isReady = context.watch().state is AppConfigFinished; + var isReady = context.watch().state is AppConfigFinished; return Scaffold( appBar: PreferredSize( @@ -77,7 +77,7 @@ class _Card extends StatelessWidget { final ServiceTypes serviceType; @override Widget build(BuildContext context) { - var isReady = context.watch().state is AppConfigFinished; + var isReady = context.watch().state is AppConfigFinished; var changeTab = context.read().onPress; var serviceState = context.watch().state; @@ -169,7 +169,7 @@ class _Card extends StatelessWidget { ), if (hasSwitchJob) Positioned( - bottom: 30, + bottom: 24, left: 0, right: 0, child: BackdropFilter( diff --git a/lib/ui/pages/users/fab.dart b/lib/ui/pages/users/fab.dart index 9919381f..d9a5a0ea 100644 --- a/lib/ui/pages/users/fab.dart +++ b/lib/ui/pages/users/fab.dart @@ -24,7 +24,9 @@ class _Fab extends StatelessWidget { isScrollControlled: true, backgroundColor: Colors.transparent, builder: (BuildContext context) { - return _NewUser(); + return Padding( + padding: MediaQuery.of(context).viewInsets, + child: _NewUser()); }, ); }, diff --git a/lib/ui/pages/users/user.dart b/lib/ui/pages/users/user.dart index 844082b7..314f29ec 100644 --- a/lib/ui/pages/users/user.dart +++ b/lib/ui/pages/users/user.dart @@ -1,9 +1,11 @@ part of 'users.dart'; class _User extends StatelessWidget { - const _User({Key? key, required this.user}) : super(key: key); + const _User({Key? key, required this.user, required this.rootUser}) + : super(key: key); final User user; + final bool rootUser; @override Widget build(BuildContext context) { return InkWell( @@ -29,7 +31,11 @@ class _User extends StatelessWidget { ), ), SizedBox(width: 20), - BrandText.h4(user.login), + Flexible( + child: rootUser + ? BrandText.h4Underlined(user.login) + : BrandText.h4(user.login), + ), ], ), ), diff --git a/lib/ui/pages/users/user_details.dart b/lib/ui/pages/users/user_details.dart index 8faf5a83..36116856 100644 --- a/lib/ui/pages/users/user_details.dart +++ b/lib/ui/pages/users/user_details.dart @@ -76,7 +76,9 @@ class _UserDetails extends StatelessWidget { ), onPressed: () { context.read().remove(user); - Navigator.of(context)..pop()..pop(); + Navigator.of(context) + ..pop() + ..pop(); }, ), ], @@ -115,9 +117,12 @@ class _UserDetails extends StatelessWidget { vertical: 20, horizontal: 15, ), - child: BrandText.h1( + child: AutoSizeText( user.login, + style: headline1Style, softWrap: true, + minFontSize: 9, + maxLines: 3, overflow: TextOverflow.ellipsis, )), ], diff --git a/lib/ui/pages/users/users.dart b/lib/ui/pages/users/users.dart index c0dd76cc..bc878a98 100644 --- a/lib/ui/pages/users/users.dart +++ b/lib/ui/pages/users/users.dart @@ -1,7 +1,11 @@ +import 'package:auto_size_text/auto_size_text.dart'; import 'package:cubit_form/cubit_form.dart'; import 'package:flutter/material.dart'; +import 'package:hive/hive.dart'; import 'package:selfprivacy/config/brand_colors.dart'; import 'package:selfprivacy/config/brand_theme.dart'; +import 'package:selfprivacy/config/hive_config.dart'; +import 'package:selfprivacy/config/text_themes.dart'; import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart'; import 'package:selfprivacy/logic/cubit/forms/user/user_form_cubit.dart'; import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart'; @@ -34,6 +38,11 @@ class UsersPage extends StatelessWidget { final usersCubitState = context.watch().state; var isReady = context.watch().state is AppConfigFinished; final users = usersCubitState.users; + //Todo: listen box events + User? user = Hive.box(BNames.appConfig).get(BNames.rootUser); + if (user != null) { + users.insert(0, user); + } final isEmpty = usersCubitState.isEmpty; Widget child; @@ -47,10 +56,14 @@ class UsersPage extends StatelessWidget { text: 'users.add_new_user'.tr(), ), ) - : ListView( - children: [ - ...users.map((user) => _User(user: user)).toList(), - ], + : ListView.builder( + itemCount: users.length, + itemBuilder: (BuildContext context, int index) { + return _User( + user: users[index], + rootUser: index == 0, + ); + }, ); } diff --git a/pubspec.lock b/pubspec.lock index de3775fb..01a334ba 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -28,7 +28,7 @@ packages: name: args url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.2.0" asn1lib: dependency: transitive description: @@ -43,20 +43,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.8.1" + auto_size_text: + dependency: "direct main" + description: + name: auto_size_text + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0-nullsafety.0" basic_utils: dependency: "direct main" description: name: basic_utils url: "https://pub.dartlang.org" source: hosted - version: "3.6.0" + version: "3.5.0" bloc: dependency: transitive description: name: bloc url: "https://pub.dartlang.org" source: hosted - version: "7.2.0" + version: "7.2.1" boolean_selector: dependency: transitive description: @@ -91,14 +98,14 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.1" build_runner_core: dependency: transitive description: @@ -119,7 +126,7 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.1.0" + version: "8.1.2" characters: dependency: transitive description: @@ -147,7 +154,7 @@ packages: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.3.3" clock: dependency: transitive description: @@ -175,7 +182,7 @@ packages: name: convert url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" coverage: dependency: transitive description: @@ -203,7 +210,7 @@ packages: name: cubit_form url: "https://pub.dartlang.org" source: hosted - version: "1.0.16" + version: "1.0.18" cupertino_icons: dependency: "direct main" description: @@ -217,7 +224,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.3" dio: dependency: "direct main" description: @@ -266,7 +273,7 @@ packages: name: extended_masked_text url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.3.1" fake_async: dependency: transitive description: @@ -320,7 +327,7 @@ packages: name: flutter_launcher_icons url: "https://pub.dartlang.org" source: hosted - version: "0.9.0" + version: "0.9.2" flutter_localizations: dependency: transitive description: flutter @@ -332,7 +339,7 @@ packages: name: flutter_markdown url: "https://pub.dartlang.org" source: hosted - version: "0.6.2" + version: "0.6.5" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -346,7 +353,7 @@ packages: name: flutter_secure_storage url: "https://pub.dartlang.org" source: hosted - version: "4.2.0" + version: "4.2.1" flutter_test: dependency: "direct dev" description: flutter @@ -384,7 +391,7 @@ packages: name: graphs url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.0.0" hive: dependency: "direct main" description: @@ -447,7 +454,7 @@ packages: name: io url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.3" ionicons: dependency: "direct main" description: @@ -475,14 +482,14 @@ packages: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "4.1.3" + version: "4.1.4" local_auth: dependency: "direct main" description: name: local_auth url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.1.7" logging: dependency: transitive description: @@ -580,14 +587,14 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" path_provider_platform_interface: dependency: transitive description: @@ -601,7 +608,7 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.3" pedantic: dependency: transitive description: @@ -622,21 +629,21 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.2" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" pointycastle: dependency: "direct main" description: name: pointycastle url: "https://pub.dartlang.org" source: hosted - version: "3.3.4" + version: "3.3.2" pool: dependency: transitive description: @@ -657,7 +664,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.1" + version: "4.2.3" provider: dependency: "direct main" description: @@ -706,7 +713,7 @@ packages: name: share_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" share_plus_macos: dependency: transitive description: @@ -741,21 +748,21 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.0.7" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_platform_interface: dependency: transitive description: @@ -769,21 +776,21 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shelf: dependency: transitive description: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "1.1.4" + version: "1.2.0" shelf_packages_handler: dependency: transitive description: @@ -797,7 +804,7 @@ packages: name: shelf_static url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" shelf_web_socket: dependency: transitive description: @@ -816,14 +823,14 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" source_helper: dependency: transitive description: name: source_helper url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.1" source_map_stack_trace: dependency: transitive description: @@ -935,42 +942,42 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.6" + version: "6.0.9" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.4" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" vector_math: dependency: transitive description: @@ -991,35 +998,35 @@ packages: name: wakelock url: "https://pub.dartlang.org" source: hosted - version: "0.5.2" + version: "0.5.3+3" wakelock_macos: dependency: transitive description: name: wakelock_macos url: "https://pub.dartlang.org" source: hosted - version: "0.1.0+1" + version: "0.1.0+2" wakelock_platform_interface: dependency: transitive description: name: wakelock_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "0.2.1+1" + version: "0.2.1+2" wakelock_web: dependency: transitive description: name: wakelock_web url: "https://pub.dartlang.org" source: hosted - version: "0.2.0+1" + version: "0.2.0+2" wakelock_windows: dependency: transitive description: name: wakelock_windows url: "https://pub.dartlang.org" source: hosted - version: "0.1.0" + version: "0.1.0+1" watcher: dependency: transitive description: @@ -1047,7 +1054,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.2.7" xdg_directories: dependency: transitive description: @@ -1070,5 +1077,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.13.4 <3.0.0" flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1135e637..f78160d5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,7 @@ dependencies: rsa_encrypt: ^2.0.0 ssh_key: ^0.7.0 local_auth: ^1.1.7 + auto_size_text: ^3.0.0-nullsafety.0 dev_dependencies: flutter_test: