From 14acfdec6b2a8d13fc236de1b924c06ab21c12b2 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Tue, 24 May 2022 21:55:39 +0300 Subject: [PATCH] Linting --- analysis_options.yaml | 2 +- lib/config/bloc_observer.dart | 4 +- lib/config/brand_colors.dart | 2 +- lib/config/brand_theme.dart | 20 +- lib/config/hive_config.dart | 2 +- lib/config/localization.dart | 4 +- lib/config/text_themes.dart | 6 +- lib/logic/api_maps/api_map.dart | 8 +- lib/logic/api_maps/backblaze.dart | 7 +- lib/logic/api_maps/cloudflare.dart | 3 +- lib/logic/api_maps/hetzner.dart | 53 +- lib/logic/api_maps/server.dart | 61 +- lib/logic/common_enum/common_enum.dart | 2 +- .../authentication_dependend_cubit.dart | 2 +- .../app_settings/app_settings_cubit.dart | 2 +- lib/logic/cubit/backups/backups_cubit.dart | 28 +- lib/logic/cubit/backups/backups_state.dart | 2 +- .../cubit/dns_records/dns_records_cubit.dart | 12 +- .../cubit/dns_records/dns_records_state.dart | 2 +- .../forms/factories/field_cubit_factory.dart | 4 +- .../initializing/cloudflare_form_cubit.dart | 7 +- .../setup/initializing/domain_cloudflare.dart | 2 +- .../initializing/hetzner_form_cubit.dart | 2 +- .../recovery_domain_form_cubit.dart | 2 +- .../cubit/forms/user/ssh_form_cubit.dart | 2 +- .../cubit/forms/validations/validations.dart | 2 +- .../hetzner_metrics_cubit.dart | 5 +- .../hetzner_metrics_repository.dart | 14 +- .../hetzner_metrics_state.dart | 6 +- .../cubit/providers/providers_cubit.dart | 2 +- .../recovery_key/recovery_key_cubit.dart | 2 +- .../recovery_key/recovery_key_state.dart | 8 +- .../server_detailed_info_cubit.dart | 2 +- .../server_detailed_info_repository.dart | 8 +- .../server_detailed_info_state.dart | 2 +- .../server_installation_cubit.dart | 96 +- .../server_installation_repository.dart | 28 +- .../server_installation_state.dart | 24 +- lib/logic/cubit/services/services_cubit.dart | 2 +- lib/logic/cubit/services/services_state.dart | 4 +- lib/logic/cubit/users/users_cubit.dart | 9 +- lib/logic/get_it/api_config.dart | 2 +- lib/logic/get_it/console.dart | 2 +- lib/logic/models/hive/backblaze_bucket.dart | 2 +- .../models/hive/backblaze_credential.dart | 4 +- lib/logic/models/hive/server_details.dart | 7 +- lib/logic/models/hive/server_details.g.dart | 12 +- lib/logic/models/hive/server_domain.dart | 6 +- lib/logic/models/hive/server_domain.g.dart | 12 +- lib/logic/models/hive/user.dart | 5 +- lib/logic/models/job.dart | 4 +- lib/logic/models/json/api_token.dart | 5 +- lib/logic/models/json/api_token.g.dart | 2 +- .../models/json/auto_upgrade_settings.dart | 2 +- .../models/json/recovery_token_status.dart | 2 +- lib/logic/models/message.dart | 2 +- lib/main.dart | 4 +- lib/theming/factory/app_theme_factory.dart | 6 +- .../action_button/action_button.dart | 2 +- .../brand_bottom_sheet.dart | 4 +- .../components/brand_button/brand_button.dart | 4 +- .../{FilledButton.dart => filled_button.dart} | 2 +- .../components/brand_cards/brand_cards.dart | 16 +- .../components/brand_header/brand_header.dart | 30 +- .../brand_hero_screen/brand_hero_screen.dart | 12 +- .../components/brand_icons/brand_icons.dart | 2 +- .../components/brand_loader/brand_loader.dart | 4 +- .../components/brand_radio/brand_radio.dart | 6 +- .../brand_radio_tile/brand_radio_tile.dart | 4 +- .../brand_span_button/brand_span_button.dart | 2 +- .../brand_tab_bar/brand_tab_bar.dart | 2 +- .../components/brand_timer/brand_timer.dart | 8 +- .../dots_indicator/dots_indicator.dart | 2 +- lib/ui/components/error/error.dart | 2 +- .../icon_status_mask/icon_status_mask.dart | 6 +- .../components/jobs_content/jobs_content.dart | 16 +- .../not_ready_card/not_ready_card.dart | 6 +- lib/ui/components/one_page/one_page.dart | 6 +- .../components/pre_styled_buttons/close.dart | 2 +- .../components/pre_styled_buttons/flash.dart | 8 +- .../{flashFab.dart => flash_fab.dart} | 8 +- .../pre_styled_buttons.dart | 2 +- .../components/progress_bar/progress_bar.dart | 26 +- .../components/switch_block/switch_bloc.dart | 6 +- lib/ui/helpers/modals.dart | 2 +- .../pages/backup_details/backup_details.dart | 24 +- lib/ui/pages/dns_details/dns_details.dart | 18 +- lib/ui/pages/more/about/about.dart | 8 +- .../pages/more/app_settings/app_setting.dart | 45 +- lib/ui/pages/more/console/console.dart | 8 +- lib/ui/pages/more/info/info.dart | 6 +- lib/ui/pages/more/more.dart | 20 +- lib/ui/pages/onboarding/onboarding.dart | 16 +- lib/ui/pages/providers/providers.dart | 20 +- .../pages/{rootRoute.dart => root_route.dart} | 6 +- lib/ui/pages/server_details/chart.dart | 36 +- lib/ui/pages/server_details/cpu_chart.dart | 8 +- lib/ui/pages/server_details/header.dart | 12 +- .../pages/server_details/network_charts.dart | 8 +- .../server_details/server_details_screen.dart | 18 +- .../pages/server_details/server_settings.dart | 42 +- lib/ui/pages/server_details/text_details.dart | 22 +- .../pages/server_details/time_zone/lang.dart | 858 +++++++++--------- .../server_details/time_zone/time_zone.dart | 26 +- lib/ui/pages/services/services.dart | 58 +- lib/ui/pages/setup/initializing.dart | 136 +-- .../recovering/recover_by_new_device_key.dart | 28 +- .../recovering/recover_by_old_token.dart | 27 +- .../recovering/recover_by_recovery_key.dart | 16 +- .../recovery_confirm_backblaze.dart | 20 +- .../recovery_confirm_cloudflare.dart | 12 +- .../recovering/recovery_confirm_server.dart | 43 +- .../recovery_hentzner_connected.dart | 22 +- .../recovering/recovery_method_select.dart | 50 +- .../setup/recovering/recovery_routing.dart | 57 +- lib/ui/pages/ssh_keys/new_ssh_key.dart | 12 +- lib/ui/pages/ssh_keys/ssh_keys.dart | 10 +- lib/ui/pages/users/empty.dart | 10 +- lib/ui/pages/users/fab.dart | 6 +- lib/ui/pages/users/new_user.dart | 16 +- lib/ui/pages/users/user.dart | 5 +- lib/ui/pages/users/user_details.dart | 36 +- lib/ui/pages/users/users.dart | 8 +- lib/utils/color_utils.dart | 2 +- lib/utils/extensions/duration.dart | 4 +- lib/utils/extensions/text_extensions.dart | 26 +- lib/utils/route_transitions/slide_bottom.dart | 4 +- lib/utils/route_transitions/slide_right.dart | 2 +- pubspec.lock | 2 +- pubspec.yaml | 1 + test/widget_test.dart | 10 +- 131 files changed, 1289 insertions(+), 1259 deletions(-) rename lib/ui/components/brand_button/{FilledButton.dart => filled_button.dart} (100%) rename lib/ui/components/pre_styled_buttons/{flashFab.dart => flash_fab.dart} (92%) rename lib/ui/pages/{rootRoute.dart => root_route.dart} (92%) diff --git a/analysis_options.yaml b/analysis_options.yaml index 1caa1fad..39d63410 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -22,7 +22,7 @@ linter: # `// ignore_for_file: name_of_lint` syntax on the line or in the file # producing the lint. rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule + avoid_print: false # Uncomment to disable the `avoid_print` rule prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule # Additional information about this file can be found at diff --git a/lib/config/bloc_observer.dart b/lib/config/bloc_observer.dart index e54b399b..c53f5961 100644 --- a/lib/config/bloc_observer.dart +++ b/lib/config/bloc_observer.dart @@ -8,7 +8,7 @@ class SimpleBlocObserver extends BlocObserver { SimpleBlocObserver(); @override - void onError(BlocBase cubit, Object error, StackTrace stackTrace) { + void onError(BlocBase bloc, Object error, StackTrace stackTrace) { final navigator = getIt.get().navigator!; navigator.push( @@ -19,6 +19,6 @@ class SimpleBlocObserver extends BlocObserver { ), ), ); - super.onError(cubit, error, stackTrace); + super.onError(bloc, error, stackTrace); } } diff --git a/lib/config/brand_colors.dart b/lib/config/brand_colors.dart index c68d6dd8..a06b8895 100644 --- a/lib/config/brand_colors.dart +++ b/lib/config/brand_colors.dart @@ -10,7 +10,7 @@ class BrandColors { static const Color gray3 = Color(0xFFFAFAFA); static const Color gray4 = Color(0xFFDDDDDD); static const Color gray5 = Color(0xFFEDEEF1); - static Color gray6 = Color(0xFF181818).withOpacity(0.7); + static Color gray6 = const Color(0xFF181818).withOpacity(0.7); static const Color grey7 = Color(0xFFABABAB); static const Color red1 = Color(0xFFFA0E0E); diff --git a/lib/config/brand_theme.dart b/lib/config/brand_theme.dart index 8ebc54ee..5837748b 100644 --- a/lib/config/brand_theme.dart +++ b/lib/config/brand_theme.dart @@ -9,7 +9,7 @@ final lightTheme = ThemeData( fontFamily: 'Inter', brightness: Brightness.light, scaffoldBackgroundColor: BrandColors.scaffoldBackground, - inputDecorationTheme: InputDecorationTheme( + inputDecorationTheme: const InputDecorationTheme( border: InputBorder.none, contentPadding: EdgeInsets.all(16), enabledBorder: OutlineInputBorder( @@ -39,7 +39,7 @@ final lightTheme = ThemeData( color: BrandColors.red1, ), ), - listTileTheme: ListTileThemeData( + listTileTheme: const ListTileThemeData( minLeadingWidth: 24.0, ), textTheme: TextTheme( @@ -48,25 +48,25 @@ final lightTheme = ThemeData( headline3: headline3Style, headline4: headline4Style, bodyText1: body1Style, - subtitle1: TextStyle(fontSize: 15, height: 1.6), // text input style + subtitle1: const TextStyle(fontSize: 15, height: 1.6), // text input style ), ); var darkTheme = lightTheme.copyWith( brightness: Brightness.dark, - scaffoldBackgroundColor: Color(0xFF202120), - iconTheme: IconThemeData(color: BrandColors.gray3), + scaffoldBackgroundColor: const Color(0xFF202120), + iconTheme: const IconThemeData(color: BrandColors.gray3), cardColor: BrandColors.gray1, - dialogBackgroundColor: Color(0xFF202120), + dialogBackgroundColor: const Color(0xFF202120), textTheme: TextTheme( headline1: headline1Style.copyWith(color: BrandColors.white), headline2: headline2Style.copyWith(color: BrandColors.white), headline3: headline3Style.copyWith(color: BrandColors.white), headline4: headline4Style.copyWith(color: BrandColors.white), bodyText1: body1Style.copyWith(color: BrandColors.white), - subtitle1: TextStyle(fontSize: 15, height: 1.6), // text input style + subtitle1: const TextStyle(fontSize: 15, height: 1.6), // text input style ), - inputDecorationTheme: InputDecorationTheme( + inputDecorationTheme: const InputDecorationTheme( labelStyle: TextStyle(color: BrandColors.white), hintStyle: TextStyle(color: BrandColors.white), border: OutlineInputBorder( @@ -82,6 +82,6 @@ var darkTheme = lightTheme.copyWith( ), ); -final paddingH15V30 = EdgeInsets.symmetric(horizontal: 15, vertical: 30); +const paddingH15V30 = EdgeInsets.symmetric(horizontal: 15, vertical: 30); -final paddingH15V0 = EdgeInsets.symmetric(horizontal: 15); +const paddingH15V0 = EdgeInsets.symmetric(horizontal: 15); diff --git a/lib/config/hive_config.dart b/lib/config/hive_config.dart index 360c5e55..28748a98 100644 --- a/lib/config/hive_config.dart +++ b/lib/config/hive_config.dart @@ -41,7 +41,7 @@ class HiveConfig { } static Future getEncryptedKey(String encKey) async { - final secureStorage = FlutterSecureStorage(); + const secureStorage = FlutterSecureStorage(); var hasEncryptionKey = await secureStorage.containsKey(key: encKey); if (!hasEncryptionKey) { var key = Hive.generateSecureKey(); diff --git a/lib/config/localization.dart b/lib/config/localization.dart index 09d5ac07..9fe2dc20 100644 --- a/lib/config/localization.dart +++ b/lib/config/localization.dart @@ -11,9 +11,9 @@ class Localization extends StatelessWidget { @override Widget build(BuildContext context) { return EasyLocalization( - supportedLocales: [Locale('ru'), Locale('en')], + supportedLocales: const [Locale('ru'), Locale('en')], path: 'assets/translations', - fallbackLocale: Locale('en'), + fallbackLocale: const Locale('en'), saveLocale: false, useOnlyLangCode: true, child: child!, diff --git a/lib/config/text_themes.dart b/lib/config/text_themes.dart index f14d54e1..8e775783 100644 --- a/lib/config/text_themes.dart +++ b/lib/config/text_themes.dart @@ -3,7 +3,7 @@ import 'package:selfprivacy/utils/named_font_weight.dart'; import 'brand_colors.dart'; -final defaultTextStyle = TextStyle( +const defaultTextStyle = TextStyle( fontSize: 15, color: BrandColors.textColor1, ); @@ -51,7 +51,7 @@ final headline5Style = defaultTextStyle.copyWith( color: BrandColors.headlineColor.withOpacity(0.8), ); -final body1Style = defaultTextStyle; +const body1Style = defaultTextStyle; final body2Style = defaultTextStyle.copyWith( color: BrandColors.textColor2, ); @@ -69,7 +69,7 @@ final smallStyle = defaultTextStyle.copyWith(fontSize: 11, height: 1.45); final linkStyle = defaultTextStyle.copyWith(color: BrandColors.blue); -final progressTextStyleLight = TextStyle( +const progressTextStyleLight = TextStyle( fontSize: 11, color: BrandColors.textColor1, height: 1.7, diff --git a/lib/logic/api_maps/api_map.dart b/lib/logic/api_maps/api_map.dart index 5e07d838..a00757fe 100644 --- a/lib/logic/api_maps/api_map.dart +++ b/lib/logic/api_maps/api_map.dart @@ -56,7 +56,7 @@ class ConsoleInterceptor extends InterceptorsWrapper { @override Future onRequest( RequestOptions options, - RequestInterceptorHandler requestInterceptorHandler, + RequestInterceptorHandler handler, ) async { addMessage( Message( @@ -64,13 +64,13 @@ class ConsoleInterceptor extends InterceptorsWrapper { 'request-uri: ${options.uri}\nheaders: ${options.headers}\ndata: ${options.data}', ), ); - return super.onRequest(options, requestInterceptorHandler); + return super.onRequest(options, handler); } @override Future onResponse( Response response, - ResponseInterceptorHandler requestInterceptorHandler, + ResponseInterceptorHandler handler, ) async { addMessage( Message( @@ -80,7 +80,7 @@ class ConsoleInterceptor extends InterceptorsWrapper { ); return super.onResponse( response, - requestInterceptorHandler, + handler, ); } diff --git a/lib/logic/api_maps/backblaze.dart b/lib/logic/api_maps/backblaze.dart index 678ec333..abf460ea 100644 --- a/lib/logic/api_maps/backblaze.dart +++ b/lib/logic/api_maps/backblaze.dart @@ -23,6 +23,7 @@ class BackblazeApplicationKey { class BackblazeApi extends ApiMap { BackblazeApi({this.hasLogger = false, this.isWithToken = true}); + @override BaseOptions get options { var options = BaseOptions(baseUrl: rootAddress); if (isWithToken) { @@ -97,9 +98,9 @@ class BackblazeApi extends ApiMap { 'bucketType': 'allPrivate', 'lifecycleRules': [ { - "daysFromHidingToDeleting": 30, - "daysFromUploadingToHiding": null, - "fileNamePrefix": "" + 'daysFromHidingToDeleting': 30, + 'daysFromUploadingToHiding': null, + 'fileNamePrefix': '' } ], }, diff --git a/lib/logic/api_maps/cloudflare.dart b/lib/logic/api_maps/cloudflare.dart index 9b950546..8fc4aa1c 100644 --- a/lib/logic/api_maps/cloudflare.dart +++ b/lib/logic/api_maps/cloudflare.dart @@ -25,6 +25,7 @@ class CloudflareApi extends ApiMap { this.customToken, }); + @override BaseOptions get options { var options = BaseOptions(baseUrl: rootAddress); if (isWithToken) { @@ -164,7 +165,7 @@ class CloudflareApi extends ApiMap { await Future.wait(allCreateFutures); } on DioError catch (e) { print(e.message); - throw e; + rethrow; } finally { close(client); } diff --git a/lib/logic/api_maps/hetzner.dart b/lib/logic/api_maps/hetzner.dart index cbcacf80..aa1d19b6 100644 --- a/lib/logic/api_maps/hetzner.dart +++ b/lib/logic/api_maps/hetzner.dart @@ -10,11 +10,14 @@ import 'package:selfprivacy/logic/models/hive/user.dart'; import 'package:selfprivacy/utils/password_generator.dart'; class HetznerApi extends ApiMap { + @override bool hasLogger; + @override bool isWithToken; HetznerApi({this.hasLogger = false, this.isWithToken = true}); + @override BaseOptions get options { var options = BaseOptions(baseUrl: rootAddress); if (isWithToken) { @@ -60,12 +63,12 @@ class HetznerApi extends ApiMap { Response dbCreateResponse = await client.post( '/volumes', data: { - "size": 10, - "name": StringGenerators.dbStorageName(), - "labels": {"labelkey": "value"}, - "location": "fsn1", - "automount": false, - "format": "ext4" + 'size': 10, + 'name': StringGenerators.dbStorageName(), + 'labels': {'labelkey': 'value'}, + 'location': 'fsn1', + 'automount': false, + 'format': 'ext4' }, ); var dbId = dbCreateResponse.data['volume']['id']; @@ -93,7 +96,7 @@ class HetznerApi extends ApiMap { final base64Password = base64.encode(utf8.encode(rootUser.password ?? 'PASS')); - print("hostname: $hostname"); + print('hostname: $hostname'); /// add ssh key when you need it: e.g. "ssh_keys":["kherel"] /// check the branch name, it could be "development" or "master". @@ -103,18 +106,18 @@ class HetznerApi extends ApiMap { print(userdataString); final data = { - "name": hostname, - "server_type": "cx11", - "start_after_create": false, - "image": "ubuntu-20.04", - "volumes": [dbId], - "networks": [], - "user_data": userdataString, - "labels": {}, - "automount": true, - "location": "fsn1" + 'name': hostname, + 'server_type': 'cx11', + 'start_after_create': false, + 'image': 'ubuntu-20.04', + 'volumes': [dbId], + 'networks': [], + 'user_data': userdataString, + 'labels': {}, + 'automount': true, + 'location': 'fsn1' }; - print("Decoded data: $data"); + print('Decoded data: $data'); Response serverCreateResponse = await client.post( '/servers', @@ -129,7 +132,7 @@ class HetznerApi extends ApiMap { createTime: DateTime.now(), volume: dataBase, apiToken: apiToken, - provider: ServerProvider.Hetzner, + provider: ServerProvider.hetzner, ); } @@ -166,7 +169,7 @@ class HetznerApi extends ApiMap { for (var volumeId in volumes) { await client.post('/volumes/$volumeId/actions/detach'); } - await Future.delayed(Duration(seconds: 10)); + await Future.delayed(const Duration(seconds: 10)); for (var volumeId in volumes) { laterFutures.add(client.delete('/volumes/$volumeId')); @@ -203,9 +206,9 @@ class HetznerApi extends ApiMap { var client = await getClient(); Map queryParameters = { - "start": start.toUtc().toIso8601String(), - "end": end.toUtc().toIso8601String(), - "type": type + 'start': start.toUtc().toIso8601String(), + 'end': end.toUtc().toIso8601String(), + 'type': type }; var res = await client.get( '/servers/${hetznerServer!.id}/metrics', @@ -243,8 +246,8 @@ class HetznerApi extends ApiMap { await client.post( '/servers/${hetznerServer!.id}/actions/change_dns_ptr', data: { - "ip": ip4, - "dns_ptr": domainName, + 'ip': ip4, + 'dns_ptr': domainName, }, ); close(client); diff --git a/lib/logic/api_maps/server.dart b/lib/logic/api_maps/server.dart index d29dffa9..b58aff55 100644 --- a/lib/logic/api_maps/server.dart +++ b/lib/logic/api_maps/server.dart @@ -44,6 +44,7 @@ class ServerApi extends ApiMap { this.overrideDomain, this.customToken}); + @override BaseOptions get options { var options = BaseOptions(); @@ -73,7 +74,7 @@ class ServerApi extends ApiMap { Response response; var client = await getClient(); - String? apiVersion = null; + String? apiVersion; try { response = await client.get('/api/version'); @@ -82,8 +83,8 @@ class ServerApi extends ApiMap { print(e.message); } finally { close(client); - return apiVersion; } + return apiVersion; } Future isHttpServerWorking() async { @@ -98,8 +99,8 @@ class ServerApi extends ApiMap { print(e.message); } finally { close(client); - return res; } + return res; } Future> createUser(User user) async { @@ -227,7 +228,7 @@ class ServerApi extends ApiMap { try { response = await client.put( '/services/ssh/key/send', - data: {"public_key": ssh}, + data: {'public_key': ssh}, ); } on DioError catch (e) { print(e.message); @@ -293,7 +294,7 @@ class ServerApi extends ApiMap { try { response = await client.delete( '/services/ssh/keys/${user.login}', - data: {"public_key": sshKey}, + data: {'public_key': sshKey}, ); } on DioError catch (e) { print(e.message); @@ -331,10 +332,11 @@ class ServerApi extends ApiMap { res = false; } finally { close(client); - return res; } + return res; } + @override String get rootAddress => throw UnimplementedError('not used in with implementation'); @@ -351,8 +353,8 @@ class ServerApi extends ApiMap { res = false; } finally { close(client); - return res; } + return res; } Future switchService(ServiceTypes type, bool needToTurnOn) async { @@ -433,8 +435,8 @@ class ServerApi extends ApiMap { print(e); } finally { close(client); - return backups; } + return backups; } Future getBackupStatus() async { @@ -453,8 +455,8 @@ class ServerApi extends ApiMap { print(e.message); } finally { close(client); - return status; } + return status; } Future forceBackupListReload() async { @@ -496,8 +498,8 @@ class ServerApi extends ApiMap { print(e.message); } finally { close(client); - return result; } + return result; } Future reboot() async { @@ -514,8 +516,8 @@ class ServerApi extends ApiMap { print(e.message); } finally { close(client); - return result; } + return result; } Future upgrade() async { @@ -532,13 +534,13 @@ class ServerApi extends ApiMap { print(e.message); } finally { close(client); - return result; } + return result; } Future getAutoUpgradeSettings() async { Response response; - AutoUpgradeSettings settings = AutoUpgradeSettings( + AutoUpgradeSettings settings = const AutoUpgradeSettings( enable: false, allowReboot: false, ); @@ -553,8 +555,8 @@ class ServerApi extends ApiMap { print(e.message); } finally { close(client); - return settings; } + return settings; } Future updateAutoUpgradeSettings(AutoUpgradeSettings settings) async { @@ -616,7 +618,7 @@ class ServerApi extends ApiMap { } if (response.statusCode != HttpStatus.ok) { - return ""; + return ''; } final base64toString = utf8.fuse(base64); @@ -639,7 +641,7 @@ class ServerApi extends ApiMap { return ApiResponse( errorMessage: e.message, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, - data: RecoveryKeyStatus(exists: false, valid: false)); + data: const RecoveryKeyStatus(exists: false, valid: false)); } finally { close(client); } @@ -677,7 +679,7 @@ class ServerApi extends ApiMap { return ApiResponse( errorMessage: e.message, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, - data: ""); + data: ''); } finally { close(client); } @@ -686,7 +688,7 @@ class ServerApi extends ApiMap { return ApiResponse( statusCode: code, - data: response.data != null ? response.data["token"] : ''); + data: response.data != null ? response.data['token'] : ''); } Future> useRecoveryToken(DeviceToken token) async { @@ -706,7 +708,7 @@ class ServerApi extends ApiMap { return ApiResponse( errorMessage: e.message, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, - data: ""); + data: ''); } finally { client.close(); } @@ -715,7 +717,7 @@ class ServerApi extends ApiMap { return ApiResponse( statusCode: code, - data: response.data != null ? response.data["token"] : ''); + data: response.data != null ? response.data['token'] : ''); } Future> authorizeDevice(DeviceToken token) async { @@ -735,16 +737,14 @@ class ServerApi extends ApiMap { return ApiResponse( errorMessage: e.message, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, - data: ""); + data: ''); } finally { client.close(); } final int code = response.statusCode ?? HttpStatus.internalServerError; - return ApiResponse( - statusCode: code, - data: response.data["token"] != null ? response.data["token"] : ''); + return ApiResponse(statusCode: code, data: response.data['token'] ?? ''); } Future> createDeviceToken() async { @@ -758,7 +758,7 @@ class ServerApi extends ApiMap { return ApiResponse( errorMessage: e.message, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, - data: ""); + data: ''); } finally { client.close(); } @@ -767,7 +767,7 @@ class ServerApi extends ApiMap { return ApiResponse( statusCode: code, - data: response.data != null ? response.data["token"] : ''); + data: response.data != null ? response.data['token'] : ''); } Future> deleteDeviceToken() async { @@ -781,15 +781,14 @@ class ServerApi extends ApiMap { return ApiResponse( errorMessage: e.message, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, - data: ""); + data: ''); } finally { client.close(); } final int code = response.statusCode ?? HttpStatus.internalServerError; - return ApiResponse( - statusCode: code, data: response.data != null ? response.data : ''); + return ApiResponse(statusCode: code, data: response.data ?? ''); } Future>> getApiTokens() async { @@ -828,7 +827,7 @@ class ServerApi extends ApiMap { return ApiResponse( errorMessage: e.message, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, - data: ""); + data: ''); } finally { client.close(); } @@ -837,7 +836,7 @@ class ServerApi extends ApiMap { return ApiResponse( statusCode: code, - data: response.data != null ? response.data["token"] : ''); + data: response.data != null ? response.data['token'] : ''); } Future> deleteApiToken(String device) async { diff --git a/lib/logic/common_enum/common_enum.dart b/lib/logic/common_enum/common_enum.dart index 41fe6528..edaaf567 100644 --- a/lib/logic/common_enum/common_enum.dart +++ b/lib/logic/common_enum/common_enum.dart @@ -131,5 +131,5 @@ extension ServiceTypesExt on ServiceTypes { } } - String get txt => this.toString().split('.')[1]; + String get txt => toString().split('.')[1]; } diff --git a/lib/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart b/lib/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart index 217cb15c..080fd684 100644 --- a/lib/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart +++ b/lib/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:bloc/bloc.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; diff --git a/lib/logic/cubit/app_settings/app_settings_cubit.dart b/lib/logic/cubit/app_settings/app_settings_cubit.dart index a4a2d0f7..bafc1d96 100644 --- a/lib/logic/cubit/app_settings/app_settings_cubit.dart +++ b/lib/logic/cubit/app_settings/app_settings_cubit.dart @@ -1,4 +1,4 @@ -import 'package:bloc/bloc.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:hive/hive.dart'; import 'package:selfprivacy/config/hive_config.dart'; diff --git a/lib/logic/cubit/backups/backups_cubit.dart b/lib/logic/cubit/backups/backups_cubit.dart index 47ad4796..45e24717 100644 --- a/lib/logic/cubit/backups/backups_cubit.dart +++ b/lib/logic/cubit/backups/backups_cubit.dart @@ -5,7 +5,6 @@ import 'package:selfprivacy/config/get_it_config.dart'; import 'package:selfprivacy/logic/api_maps/backblaze.dart'; import 'package:selfprivacy/logic/api_maps/server.dart'; import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart'; -import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart'; import 'package:selfprivacy/logic/models/json/backup.dart'; @@ -13,16 +12,18 @@ part 'backups_state.dart'; class BackupsCubit extends ServerInstallationDependendCubit { BackupsCubit(ServerInstallationCubit serverInstallationCubit) - : super(serverInstallationCubit, BackupsState(preventActions: true)); + : super( + serverInstallationCubit, const BackupsState(preventActions: true)); final api = ServerApi(); final backblaze = BackblazeApi(); + @override Future load() async { if (serverInstallationCubit.state is ServerInstallationFinished) { final bucket = getIt().backblazeBucket; if (bucket == null) { - emit(BackupsState( + emit(const BackupsState( isInitialized: false, preventActions: false, refreshing: false)); } else { final status = await api.getBackupStatus(); @@ -30,7 +31,7 @@ class BackupsCubit extends ServerInstallationDependendCubit { case BackupStatusEnum.noKey: case BackupStatusEnum.notInitialized: emit(BackupsState( - backups: [], + backups: const [], isInitialized: true, preventActions: false, progress: 0, @@ -40,12 +41,12 @@ class BackupsCubit extends ServerInstallationDependendCubit { break; case BackupStatusEnum.initializing: emit(BackupsState( - backups: [], + backups: const [], isInitialized: true, preventActions: false, progress: 0, status: status.status, - refreshTimer: Duration(seconds: 10), + refreshTimer: const Duration(seconds: 10), refreshing: false, )); break; @@ -72,12 +73,12 @@ class BackupsCubit extends ServerInstallationDependendCubit { progress: status.progress, status: status.status, error: status.errorMessage ?? '', - refreshTimer: Duration(seconds: 5), + refreshTimer: const Duration(seconds: 5), refreshing: false, )); break; default: - emit(BackupsState()); + emit(const BackupsState()); } Timer(state.refreshTimer, () => updateBackups(useTimer: true)); } @@ -126,11 +127,11 @@ class BackupsCubit extends ServerInstallationDependendCubit { switch (status) { case BackupStatusEnum.backingUp: case BackupStatusEnum.restoring: - return Duration(seconds: 5); + return const Duration(seconds: 5); case BackupStatusEnum.initializing: - return Duration(seconds: 10); + return const Duration(seconds: 10); default: - return Duration(seconds: 60); + return const Duration(seconds: 60); } } @@ -146,8 +147,9 @@ class BackupsCubit extends ServerInstallationDependendCubit { refreshTimer: refreshTimeFromState(status.status), refreshing: false, )); - if (useTimer) + if (useTimer) { Timer(state.refreshTimer, () => updateBackups(useTimer: true)); + } } Future forceUpdateBackups() async { @@ -173,6 +175,6 @@ class BackupsCubit extends ServerInstallationDependendCubit { @override void clear() async { - emit(BackupsState()); + emit(const BackupsState()); } } diff --git a/lib/logic/cubit/backups/backups_state.dart b/lib/logic/cubit/backups/backups_state.dart index 3d618a75..3f0e2c3f 100644 --- a/lib/logic/cubit/backups/backups_state.dart +++ b/lib/logic/cubit/backups/backups_state.dart @@ -7,7 +7,7 @@ class BackupsState extends ServerInstallationDependendState { this.progress = 0.0, this.status = BackupStatusEnum.noKey, this.preventActions = true, - this.error = "", + this.error = '', this.refreshTimer = const Duration(seconds: 60), this.refreshing = true, }); diff --git a/lib/logic/cubit/dns_records/dns_records_cubit.dart b/lib/logic/cubit/dns_records/dns_records_cubit.dart index 88ad9ba0..9d9bdf8e 100644 --- a/lib/logic/cubit/dns_records/dns_records_cubit.dart +++ b/lib/logic/cubit/dns_records/dns_records_cubit.dart @@ -1,6 +1,5 @@ import 'package:cubit_form/cubit_form.dart'; import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart'; -import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/models/hive/server_domain.dart'; import 'package:selfprivacy/logic/models/json/dns_records.dart'; @@ -13,16 +12,17 @@ class DnsRecordsCubit extends ServerInstallationDependendCubit { DnsRecordsCubit(ServerInstallationCubit serverInstallationCubit) : super(serverInstallationCubit, - DnsRecordsState(dnsState: DnsRecordsStatus.refreshing)); + const DnsRecordsState(dnsState: DnsRecordsStatus.refreshing)); final api = ServerApi(); final cloudflare = CloudflareApi(); + @override Future load() async { emit(DnsRecordsState( dnsState: DnsRecordsStatus.refreshing, dnsRecords: _getDesiredDnsRecords( - serverInstallationCubit.state.serverDomain?.domainName, "", ""))); + serverInstallationCubit.state.serverDomain?.domainName, '', ''))); print('Loading DNS status'); if (serverInstallationCubit.state is ServerInstallationFinished) { final ServerDomain? domain = serverInstallationCubit.state.serverDomain; @@ -75,7 +75,7 @@ class DnsRecordsCubit : DnsRecordsStatus.good, )); } else { - emit(DnsRecordsState()); + emit(const DnsRecordsState()); } } } @@ -88,7 +88,7 @@ class DnsRecordsCubit @override Future clear() async { - emit(DnsRecordsState(dnsState: DnsRecordsStatus.error)); + emit(const DnsRecordsState(dnsState: DnsRecordsStatus.error)); } Future refresh() async { @@ -104,7 +104,7 @@ class DnsRecordsCubit await cloudflare.removeSimilarRecords(cloudFlareDomain: domain!); await cloudflare.createMultipleDnsRecords( cloudFlareDomain: domain, ip4: ipAddress); - await cloudflare.setDkim(dkimPublicKey ?? "", domain); + await cloudflare.setDkim(dkimPublicKey ?? '', domain); await load(); } diff --git a/lib/logic/cubit/dns_records/dns_records_state.dart b/lib/logic/cubit/dns_records/dns_records_state.dart index 7055d698..59c266b7 100644 --- a/lib/logic/cubit/dns_records/dns_records_state.dart +++ b/lib/logic/cubit/dns_records/dns_records_state.dart @@ -42,7 +42,7 @@ class DnsRecordsState extends ServerInstallationDependendState { class DesiredDnsRecord { const DesiredDnsRecord({ required this.name, - this.type = "A", + this.type = 'A', required this.content, this.description = '', this.category = DnsRecordsCategory.services, diff --git a/lib/logic/cubit/forms/factories/field_cubit_factory.dart b/lib/logic/cubit/forms/factories/field_cubit_factory.dart index a86f6445..86f3b70b 100644 --- a/lib/logic/cubit/forms/factories/field_cubit_factory.dart +++ b/lib/logic/cubit/forms/factories/field_cubit_factory.dart @@ -16,7 +16,7 @@ class FieldCubitFactory { /// - Must not be a reserved root login /// - Must be unique FieldCubit createUserLoginField() { - final userAllowedRegExp = RegExp(r"^[a-z_][a-z0-9_]+$"); + final userAllowedRegExp = RegExp(r'^[a-z_][a-z0-9_]+$'); const userMaxLength = 31; return FieldCubit( initalValue: '', @@ -40,7 +40,7 @@ class FieldCubitFactory { /// - Must fail on the regural expression of invalid matches: [\n\r\s]+ /// - Must not be empty FieldCubit createUserPasswordField() { - var passwordForbiddenRegExp = RegExp(r"[\n\r\s]+"); + var passwordForbiddenRegExp = RegExp(r'[\n\r\s]+'); return FieldCubit( initalValue: '', validations: [ diff --git a/lib/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart b/lib/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart index c6dea6c5..fd700633 100644 --- a/lib/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart +++ b/lib/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart @@ -8,7 +8,7 @@ import 'package:selfprivacy/logic/cubit/forms/validations/validations.dart'; class CloudFlareFormCubit extends FormCubit { CloudFlareFormCubit(this.initializingCubit) { - var regExp = RegExp(r"\s+|[!$%^&*()@+|~=`{}\[\]:<>?,.\/]"); + var regExp = RegExp(r'\s+|[!$%^&*()@+|~=`{}\[\]:<>?,.\/]'); apiKey = FieldCubit( initalValue: '', validations: [ @@ -48,9 +48,4 @@ class CloudFlareFormCubit extends FormCubit { } return true; } - - @override - Future close() async { - return super.close(); - } } diff --git a/lib/logic/cubit/forms/setup/initializing/domain_cloudflare.dart b/lib/logic/cubit/forms/setup/initializing/domain_cloudflare.dart index fe595927..bf9e1eb0 100644 --- a/lib/logic/cubit/forms/setup/initializing/domain_cloudflare.dart +++ b/lib/logic/cubit/forms/setup/initializing/domain_cloudflare.dart @@ -39,7 +39,7 @@ class DomainSetupCubit extends Cubit { var domain = ServerDomain( domainName: domainName, zoneId: zoneId, - provider: DnsProvider.Cloudflare, + provider: DnsProvider.cloudflare, ); serverInstallationCubit.setDomain(domain); diff --git a/lib/logic/cubit/forms/setup/initializing/hetzner_form_cubit.dart b/lib/logic/cubit/forms/setup/initializing/hetzner_form_cubit.dart index 0ac97e84..0d343191 100644 --- a/lib/logic/cubit/forms/setup/initializing/hetzner_form_cubit.dart +++ b/lib/logic/cubit/forms/setup/initializing/hetzner_form_cubit.dart @@ -8,7 +8,7 @@ import 'package:selfprivacy/logic/cubit/forms/validations/validations.dart'; class HetznerFormCubit extends FormCubit { HetznerFormCubit(this.serverInstallationCubit) { - var regExp = RegExp(r"\s+|[-!$%^&*()@+|~=`{}\[\]:<>?,.\/]"); + var regExp = RegExp(r'\s+|[-!$%^&*()@+|~=`{}\[\]:<>?,.\/]'); apiKey = FieldCubit( initalValue: '', validations: [ diff --git a/lib/logic/cubit/forms/setup/recovering/recovery_domain_form_cubit.dart b/lib/logic/cubit/forms/setup/recovering/recovery_domain_form_cubit.dart index c67f3bee..0064cae8 100644 --- a/lib/logic/cubit/forms/setup/recovering/recovery_domain_form_cubit.dart +++ b/lib/logic/cubit/forms/setup/recovering/recovery_domain_form_cubit.dart @@ -34,7 +34,7 @@ class RecoveryDomainFormCubit extends FormCubit { final bool domainValid = await api.getApiVersion() != null; if (!domainValid) { - serverDomainField.setError("recovering.domain_recover_error".tr()); + serverDomainField.setError('recovering.domain_recover_error'.tr()); } return domainValid; diff --git a/lib/logic/cubit/forms/user/ssh_form_cubit.dart b/lib/logic/cubit/forms/user/ssh_form_cubit.dart index 47bf2994..bebbbcd5 100644 --- a/lib/logic/cubit/forms/user/ssh_form_cubit.dart +++ b/lib/logic/cubit/forms/user/ssh_form_cubit.dart @@ -12,7 +12,7 @@ class SshFormCubit extends FormCubit { required this.user, }) { var keyRegExp = RegExp( - r"^(ssh-rsa AAAAB3NzaC1yc2|ssh-ed25519 AAAAC3NzaC1lZDI1NTE5)[0-9A-Za-z+/]+[=]{0,3}( .*)?$"); + r'^(ssh-rsa AAAAB3NzaC1yc2|ssh-ed25519 AAAAC3NzaC1lZDI1NTE5)[0-9A-Za-z+/]+[=]{0,3}( .*)?$'); key = FieldCubit( initalValue: '', diff --git a/lib/logic/cubit/forms/validations/validations.dart b/lib/logic/cubit/forms/validations/validations.dart index 91a8f75c..b7d054d0 100644 --- a/lib/logic/cubit/forms/validations/validations.dart +++ b/lib/logic/cubit/forms/validations/validations.dart @@ -8,7 +8,7 @@ abstract class LengthStringValidation extends ValidationModel { @override String? check(String value) { var length = value.length; - var errorMessage = this.errorMassage.replaceAll("[]", length.toString()); + var errorMessage = errorMassage.replaceAll('[]', length.toString()); return test(value) ? errorMessage : null; } } diff --git a/lib/logic/cubit/hetzner_metrics/hetzner_metrics_cubit.dart b/lib/logic/cubit/hetzner_metrics/hetzner_metrics_cubit.dart index 3795c828..d16b13b0 100644 --- a/lib/logic/cubit/hetzner_metrics/hetzner_metrics_cubit.dart +++ b/lib/logic/cubit/hetzner_metrics/hetzner_metrics_cubit.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:bloc/bloc.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:selfprivacy/logic/common_enum/common_enum.dart'; import 'package:selfprivacy/logic/models/hetzner_metrics.dart'; @@ -10,12 +10,13 @@ import 'hetzner_metrics_repository.dart'; part 'hetzner_metrics_state.dart'; class HetznerMetricsCubit extends Cubit { - HetznerMetricsCubit() : super(HetznerMetricsLoading(Period.day)); + HetznerMetricsCubit() : super(const HetznerMetricsLoading(Period.day)); final repository = HetznerMetricsRepository(); Timer? timer; + @override close() { closeTimer(); return super.close(); diff --git a/lib/logic/cubit/hetzner_metrics/hetzner_metrics_repository.dart b/lib/logic/cubit/hetzner_metrics/hetzner_metrics_repository.dart index 11ce2bc1..fe601cc6 100644 --- a/lib/logic/cubit/hetzner_metrics/hetzner_metrics_repository.dart +++ b/lib/logic/cubit/hetzner_metrics/hetzner_metrics_repository.dart @@ -11,13 +11,13 @@ class HetznerMetricsRepository { switch (period) { case Period.hour: - start = end.subtract(Duration(hours: 1)); + start = end.subtract(const Duration(hours: 1)); break; case Period.day: - start = end.subtract(Duration(days: 1)); + start = end.subtract(const Duration(days: 1)); break; case Period.month: - start = end.subtract(Duration(days: 15)); + start = end.subtract(const Duration(days: 15)); break; } @@ -28,14 +28,14 @@ class HetznerMetricsRepository { api.getMetrics(start, end, 'network'), ]); - var cpuMetricsData = results[0]["metrics"]; - var networkMetricsData = results[1]["metrics"]; + var cpuMetricsData = results[0]['metrics']; + var networkMetricsData = results[1]['metrics']; return HetznerMetricsLoaded( period: period, start: start, end: end, - stepInSeconds: cpuMetricsData["step"], + stepInSeconds: cpuMetricsData['step'], cpu: timeSeriesSerializer(cpuMetricsData, 'cpu'), ppsIn: timeSeriesSerializer(networkMetricsData, 'network.0.pps.in'), ppsOut: timeSeriesSerializer(networkMetricsData, 'network.0.pps.out'), @@ -51,6 +51,6 @@ class HetznerMetricsRepository { List timeSeriesSerializer( Map json, String type) { - List list = json["time_series"][type]["values"]; + List list = json['time_series'][type]['values']; return list.map((el) => TimeSeriesData(el[0], double.parse(el[1]))).toList(); } diff --git a/lib/logic/cubit/hetzner_metrics/hetzner_metrics_state.dart b/lib/logic/cubit/hetzner_metrics/hetzner_metrics_state.dart index bbd3f7d1..b6204db9 100644 --- a/lib/logic/cubit/hetzner_metrics/hetzner_metrics_state.dart +++ b/lib/logic/cubit/hetzner_metrics/hetzner_metrics_state.dart @@ -7,7 +7,8 @@ abstract class HetznerMetricsState extends Equatable { } class HetznerMetricsLoading extends HetznerMetricsState { - HetznerMetricsLoading(this.period); + const HetznerMetricsLoading(this.period); + @override final Period period; @override @@ -15,7 +16,7 @@ class HetznerMetricsLoading extends HetznerMetricsState { } class HetznerMetricsLoaded extends HetznerMetricsState { - HetznerMetricsLoaded({ + const HetznerMetricsLoaded({ required this.period, required this.start, required this.end, @@ -27,6 +28,7 @@ class HetznerMetricsLoaded extends HetznerMetricsState { required this.bandwidthOut, }); + @override final Period period; final DateTime start; final DateTime end; diff --git a/lib/logic/cubit/providers/providers_cubit.dart b/lib/logic/cubit/providers/providers_cubit.dart index 5f92e225..5d48ecda 100644 --- a/lib/logic/cubit/providers/providers_cubit.dart +++ b/lib/logic/cubit/providers/providers_cubit.dart @@ -1,4 +1,4 @@ -import 'package:bloc/bloc.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:selfprivacy/logic/models/provider.dart'; import 'package:selfprivacy/logic/models/state_types.dart'; diff --git a/lib/logic/cubit/recovery_key/recovery_key_cubit.dart b/lib/logic/cubit/recovery_key/recovery_key_cubit.dart index eec3bfb1..6092a03d 100644 --- a/lib/logic/cubit/recovery_key/recovery_key_cubit.dart +++ b/lib/logic/cubit/recovery_key/recovery_key_cubit.dart @@ -7,7 +7,7 @@ part 'recovery_key_state.dart'; class RecoveryKeyCubit extends ServerInstallationDependendCubit { RecoveryKeyCubit(ServerInstallationCubit serverInstallationCubit) - : super(serverInstallationCubit, RecoveryKeyState.initial()); + : super(serverInstallationCubit, const RecoveryKeyState.initial()); final api = ServerApi(); diff --git a/lib/logic/cubit/recovery_key/recovery_key_state.dart b/lib/logic/cubit/recovery_key/recovery_key_state.dart index 60e86ecf..c88a9138 100644 --- a/lib/logic/cubit/recovery_key/recovery_key_state.dart +++ b/lib/logic/cubit/recovery_key/recovery_key_state.dart @@ -7,12 +7,12 @@ enum LoadingStatus { error, } - class RecoveryKeyState extends ServerInstallationDependendState { const RecoveryKeyState(this._status, this.loadingStatus); - RecoveryKeyState.initial() - : this(RecoveryKeyStatus(exists: false, valid: false), LoadingStatus.refreshing); + const RecoveryKeyState.initial() + : this(const RecoveryKeyStatus(exists: false, valid: false), + LoadingStatus.refreshing); final RecoveryKeyStatus _status; final LoadingStatus loadingStatus; @@ -30,7 +30,7 @@ class RecoveryKeyState extends ServerInstallationDependendState { LoadingStatus? loadingStatus, }) { return RecoveryKeyState( - status ?? this._status, + status ?? _status, loadingStatus ?? this.loadingStatus, ); } diff --git a/lib/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart b/lib/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart index 86b44be7..dea0081a 100644 --- a/lib/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart +++ b/lib/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart @@ -1,4 +1,4 @@ -import 'package:bloc/bloc.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:selfprivacy/config/get_it_config.dart'; import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_repository.dart'; diff --git a/lib/logic/cubit/server_detailed_info/server_detailed_info_repository.dart b/lib/logic/cubit/server_detailed_info/server_detailed_info_repository.dart index ee407da5..842fa527 100644 --- a/lib/logic/cubit/server_detailed_info/server_detailed_info_repository.dart +++ b/lib/logic/cubit/server_detailed_info/server_detailed_info_repository.dart @@ -8,9 +8,9 @@ class ServerDetailsRepository { var hetznerAPi = HetznerApi(); var selfprivacyServer = ServerApi(); - Future<_ServerDetailsRepositoryDto> load() async { + Future load() async { print('load'); - return _ServerDetailsRepositoryDto( + return ServerDetailsRepositoryDto( autoUpgradeSettings: await selfprivacyServer.getAutoUpgradeSettings(), hetznerServerInfo: await hetznerAPi.getInfo(), serverTimezone: await selfprivacyServer.getServerTimezone(), @@ -18,14 +18,14 @@ class ServerDetailsRepository { } } -class _ServerDetailsRepositoryDto { +class ServerDetailsRepositoryDto { final HetznerServerInfo hetznerServerInfo; final TimeZoneSettings serverTimezone; final AutoUpgradeSettings autoUpgradeSettings; - _ServerDetailsRepositoryDto({ + ServerDetailsRepositoryDto({ required this.hetznerServerInfo, required this.serverTimezone, required this.autoUpgradeSettings, diff --git a/lib/logic/cubit/server_detailed_info/server_detailed_info_state.dart b/lib/logic/cubit/server_detailed_info/server_detailed_info_state.dart index b4524751..034d2a47 100644 --- a/lib/logic/cubit/server_detailed_info/server_detailed_info_state.dart +++ b/lib/logic/cubit/server_detailed_info/server_detailed_info_state.dart @@ -23,7 +23,7 @@ class Loaded extends ServerDetailsState { final AutoUpgradeSettings autoUpgradeSettings; final DateTime checkTime; - Loaded({ + const Loaded({ required this.serverInfo, required this.serverTimezone, required this.autoUpgradeSettings, diff --git a/lib/logic/cubit/server_installation/server_installation_cubit.dart b/lib/logic/cubit/server_installation/server_installation_cubit.dart index 579269e7..311f41e1 100644 --- a/lib/logic/cubit/server_installation/server_installation_cubit.dart +++ b/lib/logic/cubit/server_installation/server_installation_cubit.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:bloc/bloc.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:equatable/equatable.dart'; import 'package:selfprivacy/config/get_it_config.dart'; @@ -17,7 +17,7 @@ export 'package:provider/provider.dart'; part '../server_installation/server_installation_state.dart'; class ServerInstallationCubit extends Cubit { - ServerInstallationCubit() : super(ServerInstallationEmpty()); + ServerInstallationCubit() : super(const ServerInstallationEmpty()); final repository = ServerInstallationRepository(); @@ -54,7 +54,7 @@ class ServerInstallationCubit extends Cubit { if (state is ServerInstallationRecovery) { emit((state as ServerInstallationRecovery).copyWith( hetznerKey: hetznerKey, - currentStep: RecoveryStep.ServerSelection, + currentStep: RecoveryStep.serverSelection, )); return; } @@ -104,12 +104,12 @@ class ServerInstallationCubit extends Cubit { } void createServerAndSetDnsRecords() async { - ServerInstallationNotFinished _stateCopy = + ServerInstallationNotFinished stateCopy = state as ServerInstallationNotFinished; - var onCancel = () => emit( + onCancel() => emit( (state as ServerInstallationNotFinished).copyWith(isLoading: false)); - var onSuccess = (ServerHostingDetails serverDetails) async { + onSuccess(ServerHostingDetails serverDetails) async { await repository.createDnsRecords( serverDetails.ip4, state.serverDomain!, @@ -120,8 +120,8 @@ class ServerInstallationCubit extends Cubit { isLoading: false, serverDetails: serverDetails, )); - runDelayed(startServerIfDnsIsOkay, Duration(seconds: 30), null); - }; + runDelayed(startServerIfDnsIsOkay, const Duration(seconds: 30), null); + } try { emit((state as ServerInstallationNotFinished).copyWith(isLoading: true)); @@ -134,7 +134,7 @@ class ServerInstallationCubit extends Cubit { onSuccess: onSuccess, ); } catch (e) { - emit(_stateCopy); + emit(stateCopy); } } @@ -163,7 +163,8 @@ class ServerInstallationCubit extends Cubit { serverDetails: server, ), ); - runDelayed(resetServerIfServerIsOkay, Duration(seconds: 60), dataState); + runDelayed( + resetServerIfServerIsOkay, const Duration(seconds: 60), dataState); } else { emit( dataState.copyWith( @@ -171,7 +172,8 @@ class ServerInstallationCubit extends Cubit { dnsMatches: matches, ), ); - runDelayed(startServerIfDnsIsOkay, Duration(seconds: 30), dataState); + runDelayed( + startServerIfDnsIsOkay, const Duration(seconds: 30), dataState); } } @@ -183,7 +185,7 @@ class ServerInstallationCubit extends Cubit { var isServerWorking = await repository.isHttpServerWorking(); if (isServerWorking) { - var pauseDuration = Duration(seconds: 30); + var pauseDuration = const Duration(seconds: 30); emit(TimerState( dataState: dataState, timerStart: DateTime.now(), @@ -202,10 +204,11 @@ class ServerInstallationCubit extends Cubit { isLoading: false, ), ); - runDelayed(finishCheckIfServerIsOkay, Duration(seconds: 60), dataState); + runDelayed( + finishCheckIfServerIsOkay, const Duration(seconds: 60), dataState); }); } else { - runDelayed(oneMoreReset, Duration(seconds: 60), dataState); + runDelayed(oneMoreReset, const Duration(seconds: 60), dataState); } } @@ -219,7 +222,7 @@ class ServerInstallationCubit extends Cubit { var isServerWorking = await repository.isHttpServerWorking(); if (isServerWorking) { - var pauseDuration = Duration(seconds: 30); + var pauseDuration = const Duration(seconds: 30); emit(TimerState( dataState: dataState, timerStart: DateTime.now(), @@ -238,10 +241,11 @@ class ServerInstallationCubit extends Cubit { isLoading: false, ), ); - runDelayed(oneMoreReset, Duration(seconds: 60), dataState); + runDelayed(oneMoreReset, const Duration(seconds: 60), dataState); }); } else { - runDelayed(resetServerIfServerIsOkay, Duration(seconds: 60), dataState); + runDelayed( + resetServerIfServerIsOkay, const Duration(seconds: 60), dataState); } } @@ -260,7 +264,8 @@ class ServerInstallationCubit extends Cubit { emit(dataState.finish()); } else { - runDelayed(finishCheckIfServerIsOkay, Duration(seconds: 60), dataState); + runDelayed( + finishCheckIfServerIsOkay, const Duration(seconds: 60), dataState); } } @@ -280,7 +285,7 @@ class ServerInstallationCubit extends Cubit { void submitDomainForAccessRecovery(String domain) async { var serverDomain = ServerDomain( domainName: domain, - provider: DnsProvider.Unknown, + provider: DnsProvider.unknown, zoneId: '', ); final recoveryCapabilities = @@ -291,12 +296,12 @@ class ServerInstallationCubit extends Cubit { emit(ServerInstallationRecovery( serverDomain: serverDomain, recoveryCapabilities: recoveryCapabilities, - currentStep: RecoveryStep.Selecting, + currentStep: RecoveryStep.selecting, )); } void tryToRecover(String token, ServerRecoveryMethods method) async { - final dataState = this.state as ServerInstallationRecovery; + final dataState = state as ServerInstallationRecovery; final serverDomain = dataState.serverDomain; if (serverDomain == null) { return; @@ -324,7 +329,7 @@ class ServerInstallationCubit extends Cubit { await repository.saveServerDetails(serverDetails); emit(dataState.copyWith( serverDetails: serverDetails, - currentStep: RecoveryStep.HetznerToken, + currentStep: RecoveryStep.hetznerToken, )); } on ServerAuthorizationException { getIt() @@ -338,23 +343,23 @@ class ServerInstallationCubit extends Cubit { } void revertRecoveryStep() { - final dataState = this.state as ServerInstallationRecovery; + final dataState = state as ServerInstallationRecovery; switch (dataState.currentStep) { - case RecoveryStep.Selecting: + case RecoveryStep.selecting: repository.deleteDomain(); - emit(ServerInstallationEmpty()); + emit(const ServerInstallationEmpty()); break; - case RecoveryStep.RecoveryKey: - case RecoveryStep.NewDeviceKey: - case RecoveryStep.OldToken: + case RecoveryStep.recoveryKey: + case RecoveryStep.newDeviceKey: + case RecoveryStep.oldToken: emit(dataState.copyWith( - currentStep: RecoveryStep.Selecting, + currentStep: RecoveryStep.selecting, )); break; - case RecoveryStep.ServerSelection: + case RecoveryStep.serverSelection: repository.deleteHetznerKey(); emit(dataState.copyWith( - currentStep: RecoveryStep.HetznerToken, + currentStep: RecoveryStep.hetznerToken, )); break; // We won't revert steps after client is authorized @@ -364,21 +369,21 @@ class ServerInstallationCubit extends Cubit { } void selectRecoveryMethod(ServerRecoveryMethods method) { - final dataState = this.state as ServerInstallationRecovery; + final dataState = state as ServerInstallationRecovery; switch (method) { case ServerRecoveryMethods.newDeviceKey: emit(dataState.copyWith( - currentStep: RecoveryStep.NewDeviceKey, + currentStep: RecoveryStep.newDeviceKey, )); break; case ServerRecoveryMethods.recoveryKey: emit(dataState.copyWith( - currentStep: RecoveryStep.RecoveryKey, + currentStep: RecoveryStep.recoveryKey, )); break; case ServerRecoveryMethods.oldToken: emit(dataState.copyWith( - currentStep: RecoveryStep.OldToken, + currentStep: RecoveryStep.oldToken, )); break; } @@ -386,7 +391,7 @@ class ServerInstallationCubit extends Cubit { Future> getServersOnHetznerAccount() async { - final dataState = this.state as ServerInstallationRecovery; + final dataState = state as ServerInstallationRecovery; final servers = await repository.getServersOnHetznerAccount(); final validated = servers .map((server) => ServerBasicInfoWithValidators.fromServerBasicInfo( @@ -399,7 +404,7 @@ class ServerInstallationCubit extends Cubit { } Future setServerId(ServerBasicInfo server) async { - final dataState = this.state as ServerInstallationRecovery; + final dataState = state as ServerInstallationRecovery; final serverDomain = dataState.serverDomain; if (serverDomain == null) { return; @@ -410,21 +415,21 @@ class ServerInstallationCubit extends Cubit { createTime: server.created, volume: ServerVolume( id: server.volumeId, - name: "recovered_volume", + name: 'recovered_volume', ), apiToken: dataState.serverDetails!.apiToken, - provider: ServerProvider.Hetzner, + provider: ServerProvider.hetzner, ); await repository.saveDomain(serverDomain); await repository.saveServerDetails(serverDetails); emit(dataState.copyWith( serverDetails: serverDetails, - currentStep: RecoveryStep.CloudflareToken, + currentStep: RecoveryStep.cloudflareToken, )); } Future setAndValidateCloudflareToken(String token) async { - final dataState = this.state as ServerInstallationRecovery; + final dataState = state as ServerInstallationRecovery; final serverDomain = dataState.serverDomain; if (serverDomain == null) { return; @@ -438,17 +443,17 @@ class ServerInstallationCubit extends Cubit { await repository.saveDomain(ServerDomain( domainName: serverDomain.domainName, zoneId: zoneId, - provider: DnsProvider.Cloudflare, + provider: DnsProvider.cloudflare, )); await repository.saveCloudFlareKey(token); emit(dataState.copyWith( serverDomain: ServerDomain( domainName: serverDomain.domainName, zoneId: zoneId, - provider: DnsProvider.Cloudflare, + provider: DnsProvider.cloudflare, ), cloudFlareKey: token, - currentStep: RecoveryStep.BackblazeToken, + currentStep: RecoveryStep.backblazeToken, )); } @@ -474,7 +479,7 @@ class ServerInstallationCubit extends Cubit { closeTimer(); repository.clearAppConfig(); - emit(ServerInstallationEmpty()); + emit(const ServerInstallationEmpty()); } Future serverDelete() async { @@ -499,6 +504,7 @@ class ServerInstallationCubit extends Cubit { )); } + @override close() { closeTimer(); return super.close(); diff --git a/lib/logic/cubit/server_installation/server_installation_repository.dart b/lib/logic/cubit/server_installation/server_installation_repository.dart index bbeb5700..e4e07804 100644 --- a/lib/logic/cubit/server_installation/server_installation_repository.dart +++ b/lib/logic/cubit/server_installation/server_installation_repository.dart @@ -62,7 +62,7 @@ class ServerInstallationRepository { ); } - if (serverDomain != null && serverDomain.provider == DnsProvider.Unknown) { + if (serverDomain != null && serverDomain.provider == DnsProvider.unknown) { return ServerInstallationRecovery( hetznerKey: hetznerToken, cloudFlareKey: cloudflareToken, @@ -101,17 +101,17 @@ class ServerInstallationRepository { ) { if (serverDetails != null) { if (hetznerToken != null) { - if (serverDetails.provider != ServerProvider.Unknown) { - if (serverDomain.provider != DnsProvider.Unknown) { - return RecoveryStep.BackblazeToken; + if (serverDetails.provider != ServerProvider.unknown) { + if (serverDomain.provider != DnsProvider.unknown) { + return RecoveryStep.backblazeToken; } - return RecoveryStep.CloudflareToken; + return RecoveryStep.cloudflareToken; } - return RecoveryStep.ServerSelection; + return RecoveryStep.serverSelection; } - return RecoveryStep.HetznerToken; + return RecoveryStep.hetznerToken; } - return RecoveryStep.Selecting; + return RecoveryStep.selecting; } void clearAppConfig() { @@ -271,7 +271,7 @@ class ServerInstallationRepository { var nav = getIt.get(); nav.showPopUpDialog( BrandAlert( - title: e.response!.data["errors"][0]["code"] == 1038 + title: e.response!.data['errors'][0]['code'] == 1038 ? 'modals.10'.tr() : 'providers.domain.states.error'.tr(), contentText: 'modals.6'.tr(), @@ -309,7 +309,7 @@ class ServerInstallationRepository { var dkimRecordString = await api.getDkim(); - await cloudflareApi.setDkim(dkimRecordString ?? "", cloudFlareDomain); + await cloudflareApi.setDkim(dkimRecordString ?? '', cloudFlareDomain); } Future isHttpServerWorking() async { @@ -408,7 +408,7 @@ class ServerInstallationRepository { id: 0, name: '', ), - provider: ServerProvider.Unknown, + provider: ServerProvider.unknown, id: 0, ip4: serverIp, startTime: null, @@ -439,7 +439,7 @@ class ServerInstallationRepository { id: 0, name: '', ), - provider: ServerProvider.Unknown, + provider: ServerProvider.unknown, id: 0, ip4: '', startTime: null, @@ -472,7 +472,7 @@ class ServerInstallationRepository { id: 0, name: '', ), - provider: ServerProvider.Unknown, + provider: ServerProvider.unknown, id: 0, ip4: '', startTime: null, @@ -487,7 +487,7 @@ class ServerInstallationRepository { Future getMainUser() async { var serverApi = ServerApi(); - final fallbackUser = User( + const fallbackUser = User( isFoundOnServer: false, note: 'Couldn\'t find main user on server, API is outdated', login: 'UNKNOWN', diff --git a/lib/logic/cubit/server_installation/server_installation_state.dart b/lib/logic/cubit/server_installation/server_installation_state.dart index 605a26ff..e6979ff4 100644 --- a/lib/logic/cubit/server_installation/server_installation_state.dart +++ b/lib/logic/cubit/server_installation/server_installation_state.dart @@ -122,7 +122,7 @@ class ServerInstallationNotFinished extends ServerInstallationState { final bool isLoading; final Map? dnsMatches; - ServerInstallationNotFinished({ + const ServerInstallationNotFinished({ String? hetznerKey, String? cloudFlareKey, BackblazeCredential? backblazeCredential, @@ -203,7 +203,7 @@ class ServerInstallationNotFinished extends ServerInstallationState { } class ServerInstallationEmpty extends ServerInstallationNotFinished { - ServerInstallationEmpty() + const ServerInstallationEmpty() : super( hetznerKey: null, cloudFlareKey: null, @@ -256,14 +256,14 @@ class ServerInstallationFinished extends ServerInstallationState { } enum RecoveryStep { - Selecting, - RecoveryKey, - NewDeviceKey, - OldToken, - HetznerToken, - ServerSelection, - CloudflareToken, - BackblazeToken, + selecting, + recoveryKey, + newDeviceKey, + oldToken, + hetznerToken, + serverSelection, + cloudflareToken, + backblazeToken, } enum ServerRecoveryCapabilities { @@ -289,8 +289,8 @@ class ServerInstallationRecovery extends ServerInstallationState { ServerDomain? serverDomain, User? rootUser, ServerHostingDetails? serverDetails, - required RecoveryStep this.currentStep, - required ServerRecoveryCapabilities this.recoveryCapabilities, + required this.currentStep, + required this.recoveryCapabilities, }) : super( hetznerKey: hetznerKey, cloudFlareKey: cloudFlareKey, diff --git a/lib/logic/cubit/services/services_cubit.dart b/lib/logic/cubit/services/services_cubit.dart index 5caa5a42..83b22086 100644 --- a/lib/logic/cubit/services/services_cubit.dart +++ b/lib/logic/cubit/services/services_cubit.dart @@ -1,7 +1,6 @@ import 'package:selfprivacy/logic/api_maps/server.dart'; import 'package:selfprivacy/logic/common_enum/common_enum.dart'; import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart'; -import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; part 'services_state.dart'; @@ -9,6 +8,7 @@ class ServicesCubit extends ServerInstallationDependendCubit { ServicesCubit(ServerInstallationCubit serverInstallationCubit) : super(serverInstallationCubit, ServicesState.allOff()); final api = ServerApi(); + @override Future load() async { if (serverInstallationCubit.state is ServerInstallationFinished) { var statuses = await api.servicesPowerCheck(); diff --git a/lib/logic/cubit/services/services_state.dart b/lib/logic/cubit/services/services_state.dart index 2503a4c7..dba7accc 100644 --- a/lib/logic/cubit/services/services_state.dart +++ b/lib/logic/cubit/services/services_state.dart @@ -15,14 +15,14 @@ class ServicesState extends ServerInstallationDependendState { final bool isSocialNetworkEnable; final bool isVpnEnable; - factory ServicesState.allOff() => ServicesState( + factory ServicesState.allOff() => const ServicesState( isPasswordManagerEnable: false, isCloudEnable: false, isGitEnable: false, isSocialNetworkEnable: false, isVpnEnable: false, ); - factory ServicesState.allOn() => ServicesState( + factory ServicesState.allOn() => const ServicesState( isPasswordManagerEnable: true, isCloudEnable: true, isGitEnable: true, diff --git a/lib/logic/cubit/users/users_cubit.dart b/lib/logic/cubit/users/users_cubit.dart index f7ce18bb..61d0a789 100644 --- a/lib/logic/cubit/users/users_cubit.dart +++ b/lib/logic/cubit/users/users_cubit.dart @@ -1,7 +1,6 @@ import 'package:hive/hive.dart'; import 'package:selfprivacy/config/hive_config.dart'; import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart'; -import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/models/hive/user.dart'; import '../../api_maps/server.dart'; @@ -14,18 +13,19 @@ class UsersCubit extends ServerInstallationDependendCubit { UsersCubit(ServerInstallationCubit serverInstallationCubit) : super( serverInstallationCubit, - UsersState( + const UsersState( [], User(login: 'root'), User(login: 'loading...'))); Box box = Hive.box(BNames.usersBox); Box serverInstallationBox = Hive.box(BNames.serverInstallationBox); final api = ServerApi(); + @override Future load() async { if (serverInstallationCubit.state is ServerInstallationFinished) { var loadedUsers = box.values.toList(); final primaryUser = serverInstallationBox.get(BNames.rootUser, - defaultValue: User(login: 'loading...')); + defaultValue: const User(login: 'loading...')); List rootKeys = [ ...serverInstallationBox.get(BNames.rootKeys, defaultValue: []) ]; @@ -308,6 +308,7 @@ class UsersCubit extends ServerInstallationDependendCubit { @override void clear() async { - emit(UsersState([], User(login: 'root'), User(login: 'loading...'))); + emit(const UsersState( + [], User(login: 'root'), User(login: 'loading...'))); } } diff --git a/lib/logic/get_it/api_config.dart b/lib/logic/get_it/api_config.dart index 1d6f2610..3e7ea4b3 100644 --- a/lib/logic/get_it/api_config.dart +++ b/lib/logic/get_it/api_config.dart @@ -6,7 +6,7 @@ import 'package:selfprivacy/logic/models/hive/server_details.dart'; import 'package:selfprivacy/logic/models/hive/server_domain.dart'; class ApiConfigModel { - Box _box = Hive.box(BNames.serverInstallationBox); + final Box _box = Hive.box(BNames.serverInstallationBox); ServerHostingDetails? get serverDetails => _serverDetails; String? get hetznerKey => _hetznerKey; diff --git a/lib/logic/get_it/console.dart b/lib/logic/get_it/console.dart index 80dc5a37..979895a1 100644 --- a/lib/logic/get_it/console.dart +++ b/lib/logic/get_it/console.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/models/message.dart'; class ConsoleModel extends ChangeNotifier { - List _messages = []; + final List _messages = []; List get messages => _messages; diff --git a/lib/logic/models/hive/backblaze_bucket.dart b/lib/logic/models/hive/backblaze_bucket.dart index e1e0dd3f..140f2122 100644 --- a/lib/logic/models/hive/backblaze_bucket.dart +++ b/lib/logic/models/hive/backblaze_bucket.dart @@ -24,6 +24,6 @@ class BackblazeBucket { @override String toString() { - return '$bucketName'; + return bucketName; } } diff --git a/lib/logic/models/hive/backblaze_credential.dart b/lib/logic/models/hive/backblaze_credential.dart index b9c06364..3f0f3ea6 100644 --- a/lib/logic/models/hive/backblaze_credential.dart +++ b/lib/logic/models/hive/backblaze_credential.dart @@ -23,7 +23,7 @@ class BackblazeCredential { } String encodedBackblazeKey(String? keyId, String? applicationKey) { - String _apiKey = '$keyId:$applicationKey'; - String encodedApiKey = base64.encode(utf8.encode(_apiKey)); + String apiKey = '$keyId:$applicationKey'; + String encodedApiKey = base64.encode(utf8.encode(apiKey)); return encodedApiKey; } diff --git a/lib/logic/models/hive/server_details.dart b/lib/logic/models/hive/server_details.dart index e9bb5f38..a5e5a575 100644 --- a/lib/logic/models/hive/server_details.dart +++ b/lib/logic/models/hive/server_details.dart @@ -32,7 +32,7 @@ class ServerHostingDetails { @HiveField(5) final String apiToken; - @HiveField(6, defaultValue: ServerProvider.Hetzner) + @HiveField(6, defaultValue: ServerProvider.hetzner) final ServerProvider provider; ServerHostingDetails copyWith({DateTime? startTime}) { @@ -47,6 +47,7 @@ class ServerHostingDetails { ); } + @override String toString() => id.toString(); } @@ -66,7 +67,7 @@ class ServerVolume { @HiveType(typeId: 101) enum ServerProvider { @HiveField(0) - Unknown, + unknown, @HiveField(1) - Hetzner, + hetzner, } diff --git a/lib/logic/models/hive/server_details.g.dart b/lib/logic/models/hive/server_details.g.dart index f52e6b37..f10628e7 100644 --- a/lib/logic/models/hive/server_details.g.dart +++ b/lib/logic/models/hive/server_details.g.dart @@ -23,7 +23,7 @@ class ServerHostingDetailsAdapter extends TypeAdapter { volume: fields[4] as ServerVolume, apiToken: fields[5] as String, provider: fields[6] == null - ? ServerProvider.Hetzner + ? ServerProvider.hetzner : fields[6] as ServerProvider, startTime: fields[2] as DateTime?, ); @@ -105,21 +105,21 @@ class ServerProviderAdapter extends TypeAdapter { ServerProvider read(BinaryReader reader) { switch (reader.readByte()) { case 0: - return ServerProvider.Unknown; + return ServerProvider.unknown; case 1: - return ServerProvider.Hetzner; + return ServerProvider.hetzner; default: - return ServerProvider.Unknown; + return ServerProvider.unknown; } } @override void write(BinaryWriter writer, ServerProvider obj) { switch (obj) { - case ServerProvider.Unknown: + case ServerProvider.unknown: writer.writeByte(0); break; - case ServerProvider.Hetzner: + case ServerProvider.hetzner: writer.writeByte(1); break; } diff --git a/lib/logic/models/hive/server_domain.dart b/lib/logic/models/hive/server_domain.dart index ab60019e..4fdd52c3 100644 --- a/lib/logic/models/hive/server_domain.dart +++ b/lib/logic/models/hive/server_domain.dart @@ -16,7 +16,7 @@ class ServerDomain { @HiveField(1) final String zoneId; - @HiveField(2, defaultValue: DnsProvider.Cloudflare) + @HiveField(2, defaultValue: DnsProvider.cloudflare) final DnsProvider provider; @override @@ -28,7 +28,7 @@ class ServerDomain { @HiveType(typeId: 100) enum DnsProvider { @HiveField(0) - Unknown, + unknown, @HiveField(1) - Cloudflare, + cloudflare, } diff --git a/lib/logic/models/hive/server_domain.g.dart b/lib/logic/models/hive/server_domain.g.dart index 7a3eb4de..3265db6b 100644 --- a/lib/logic/models/hive/server_domain.g.dart +++ b/lib/logic/models/hive/server_domain.g.dart @@ -20,7 +20,7 @@ class ServerDomainAdapter extends TypeAdapter { domainName: fields[0] as String, zoneId: fields[1] as String, provider: - fields[2] == null ? DnsProvider.Cloudflare : fields[2] as DnsProvider, + fields[2] == null ? DnsProvider.cloudflare : fields[2] as DnsProvider, ); } @@ -55,21 +55,21 @@ class DnsProviderAdapter extends TypeAdapter { DnsProvider read(BinaryReader reader) { switch (reader.readByte()) { case 0: - return DnsProvider.Unknown; + return DnsProvider.unknown; case 1: - return DnsProvider.Cloudflare; + return DnsProvider.cloudflare; default: - return DnsProvider.Unknown; + return DnsProvider.unknown; } } @override void write(BinaryWriter writer, DnsProvider obj) { switch (obj) { - case DnsProvider.Unknown: + case DnsProvider.unknown: writer.writeByte(0); break; - case DnsProvider.Cloudflare: + case DnsProvider.cloudflare: writer.writeByte(1); break; } diff --git a/lib/logic/models/hive/user.dart b/lib/logic/models/hive/user.dart index 8161f61b..94ea993f 100644 --- a/lib/logic/models/hive/user.dart +++ b/lib/logic/models/hive/user.dart @@ -8,7 +8,7 @@ part 'user.g.dart'; @HiveType(typeId: 1) class User extends Equatable { - User({ + const User({ required this.login, this.password, this.sshKeys = const [], @@ -22,7 +22,7 @@ class User extends Equatable { @HiveField(1) final String? password; - @HiveField(2, defaultValue: const []) + @HiveField(2, defaultValue: []) final List sshKeys; @HiveField(3, defaultValue: true) @@ -36,6 +36,7 @@ class User extends Equatable { Color get color => stringToColor(login); + @override String toString() { return '$login, ${isFoundOnServer ? 'found' : 'not found'}, ${sshKeys.length} ssh keys, note: $note'; } diff --git a/lib/logic/models/job.dart b/lib/logic/models/job.dart index 38ef2022..7ee8e418 100644 --- a/lib/logic/models/job.dart +++ b/lib/logic/models/job.dart @@ -71,7 +71,7 @@ class CreateSSHKeyJob extends Job { CreateSSHKeyJob({ required this.user, required this.publicKey, - }) : super(title: '${"jobs.create_ssh_key".tr(args: [user.login])}'); + }) : super(title: 'jobs.create_ssh_key'.tr(args: [user.login])); final User user; final String publicKey; @@ -84,7 +84,7 @@ class DeleteSSHKeyJob extends Job { DeleteSSHKeyJob({ required this.user, required this.publicKey, - }) : super(title: '${"jobs.delete_ssh_key".tr(args: [user.login])}'); + }) : super(title: 'jobs.delete_ssh_key'.tr(args: [user.login])); final User user; final String publicKey; diff --git a/lib/logic/models/json/api_token.dart b/lib/logic/models/json/api_token.dart index 60801889..867e11d5 100644 --- a/lib/logic/models/json/api_token.dart +++ b/lib/logic/models/json/api_token.dart @@ -7,12 +7,13 @@ class ApiToken { ApiToken({ required this.name, required this.date, - required this.is_caller, + required this.isCaller, }); final String name; final DateTime date; - final bool is_caller; + @JsonKey(name: 'is_caller') + final bool isCaller; factory ApiToken.fromJson(Map json) => _$ApiTokenFromJson(json); diff --git a/lib/logic/models/json/api_token.g.dart b/lib/logic/models/json/api_token.g.dart index c009f58b..b6c8b8db 100644 --- a/lib/logic/models/json/api_token.g.dart +++ b/lib/logic/models/json/api_token.g.dart @@ -9,5 +9,5 @@ part of 'api_token.dart'; ApiToken _$ApiTokenFromJson(Map json) => ApiToken( name: json['name'] as String, date: DateTime.parse(json['date'] as String), - is_caller: json['is_caller'] as bool, + isCaller: json['is_caller'] as bool, ); diff --git a/lib/logic/models/json/auto_upgrade_settings.dart b/lib/logic/models/json/auto_upgrade_settings.dart index 6007e622..77c8905d 100644 --- a/lib/logic/models/json/auto_upgrade_settings.dart +++ b/lib/logic/models/json/auto_upgrade_settings.dart @@ -8,7 +8,7 @@ class AutoUpgradeSettings extends Equatable { final bool enable; final bool allowReboot; - AutoUpgradeSettings({ + const AutoUpgradeSettings({ required this.enable, required this.allowReboot, }); diff --git a/lib/logic/models/json/recovery_token_status.dart b/lib/logic/models/json/recovery_token_status.dart index 8904f84f..6b27b028 100644 --- a/lib/logic/models/json/recovery_token_status.dart +++ b/lib/logic/models/json/recovery_token_status.dart @@ -5,7 +5,7 @@ part 'recovery_token_status.g.dart'; @JsonSerializable() class RecoveryKeyStatus extends Equatable { - RecoveryKeyStatus({ + const RecoveryKeyStatus({ required this.exists, required this.valid, this.date, diff --git a/lib/logic/models/message.dart b/lib/logic/models/message.dart index 79f21a54..176f2846 100644 --- a/lib/logic/models/message.dart +++ b/lib/logic/models/message.dart @@ -1,6 +1,6 @@ import 'package:intl/intl.dart'; -final formatter = new DateFormat('hh:mm'); +final formatter = DateFormat('hh:mm'); class Message { Message({this.text, this.type = MessageType.normal}) : time = DateTime.now(); diff --git a/lib/main.dart b/lib/main.dart index 1889f65a..6e3d181b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -85,9 +85,9 @@ class MyApp extends StatelessWidget { appSettings.isDarkModeOn ? ThemeMode.dark : ThemeMode.light, home: appSettings.isOnboardingShowing ? OnboardingPage(nextPage: InitializingPage()) - : RootPage(), + : const RootPage(), builder: (BuildContext context, Widget? widget) { - Widget error = Text('...rendering error...'); + Widget error = const Text('...rendering error...'); if (widget is Scaffold || widget is Navigator) { error = Scaffold(body: Center(child: error)); } diff --git a/lib/theming/factory/app_theme_factory.dart b/lib/theming/factory/app_theme_factory.dart index 860dd0b2..1d99c480 100644 --- a/lib/theming/factory/app_theme_factory.dart +++ b/lib/theming/factory/app_theme_factory.dart @@ -18,7 +18,7 @@ abstract class AppThemeFactory { } static Future _createAppTheme({ - bool isDark: false, + bool isDark = false, required Color fallbackColor, }) async { ColorScheme? gtkColorsScheme; @@ -39,12 +39,12 @@ abstract class AppThemeFactory { ); } - final accentColor = await SystemAccentColor(fallbackColor); + final accentColor = SystemAccentColor(fallbackColor); try { await accentColor.load(); } on MissingPluginException catch (e) { - print("_createAppTheme: ${e.message}"); + print('_createAppTheme: ${e.message}'); } final fallbackColorScheme = ColorScheme.fromSeed( diff --git a/lib/ui/components/action_button/action_button.dart b/lib/ui/components/action_button/action_button.dart index bc0393e7..e507fa0c 100644 --- a/lib/ui/components/action_button/action_button.dart +++ b/lib/ui/components/action_button/action_button.dart @@ -20,7 +20,7 @@ class ActionButton extends StatelessWidget { return TextButton( child: Text( text!, - style: isRed ? TextStyle(color: BrandColors.red1) : null, + style: isRed ? const TextStyle(color: BrandColors.red1) : null, ), onPressed: () { navigator.pop(); diff --git a/lib/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart b/lib/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart index d5718181..22430d06 100644 --- a/lib/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart +++ b/lib/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart @@ -44,9 +44,9 @@ class BrandBottomSheet extends StatelessWidget { ), ), ), - SizedBox(height: 6), + const SizedBox(height: 6), ClipRRect( - borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + borderRadius: const BorderRadius.vertical(top: Radius.circular(20)), child: ConstrainedBox( constraints: BoxConstraints(maxHeight: mainHeight), child: innerWidget, diff --git a/lib/ui/components/brand_button/brand_button.dart b/lib/ui/components/brand_button/brand_button.dart index b09b0442..398e9cc2 100644 --- a/lib/ui/components/brand_button/brand_button.dart +++ b/lib/ui/components/brand_button/brand_button.dart @@ -14,7 +14,7 @@ class BrandButton { assert(text == null || child == null, 'required title or child'); assert(text != null || child != null, 'required title or child'); return ConstrainedBox( - constraints: BoxConstraints( + constraints: const BoxConstraints( minHeight: 48, minWidth: double.infinity, ), @@ -33,7 +33,7 @@ class BrandButton { required String title, }) => ConstrainedBox( - constraints: BoxConstraints( + constraints: const BoxConstraints( minHeight: 48, minWidth: double.infinity, ), diff --git a/lib/ui/components/brand_button/FilledButton.dart b/lib/ui/components/brand_button/filled_button.dart similarity index 100% rename from lib/ui/components/brand_button/FilledButton.dart rename to lib/ui/components/brand_button/filled_button.dart index 0ac34a42..06822d4f 100644 --- a/lib/ui/components/brand_button/FilledButton.dart +++ b/lib/ui/components/brand_button/filled_button.dart @@ -16,11 +16,11 @@ class FilledButton extends StatelessWidget { Widget build(BuildContext context) { return ElevatedButton( onPressed: onPressed, - child: child ?? Text(title ?? ''), style: ElevatedButton.styleFrom( onPrimary: Theme.of(context).colorScheme.onPrimary, primary: Theme.of(context).colorScheme.primary, ).copyWith(elevation: ButtonStyleButton.allOrNull(0.0)), + child: child ?? Text(title ?? ''), ); } } diff --git a/lib/ui/components/brand_cards/brand_cards.dart b/lib/ui/components/brand_cards/brand_cards.dart index 777663cf..b290c00e 100644 --- a/lib/ui/components/brand_cards/brand_cards.dart +++ b/lib/ui/components/brand_cards/brand_cards.dart @@ -3,22 +3,22 @@ import 'package:selfprivacy/config/brand_colors.dart'; class BrandCards { static Widget big({required Widget child}) => _BrandCard( - child: child, - padding: EdgeInsets.symmetric( + padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 15, ), shadow: bigShadow, borderRadius: BorderRadius.circular(20), + child: child, ); static Widget small({required Widget child}) => _BrandCard( - child: child, - padding: EdgeInsets.symmetric( + padding: const EdgeInsets.symmetric( horizontal: 15, vertical: 10, ), shadow: bigShadow, borderRadius: BorderRadius.circular(10), + child: child, ); static Widget outlined({required Widget child}) => _OutlinedCard( child: child, @@ -70,7 +70,7 @@ class _OutlinedCard extends StatelessWidget { return Card( elevation: 0.0, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(12)), + borderRadius: const BorderRadius.all(Radius.circular(12)), side: BorderSide( color: Theme.of(context).colorScheme.outline, ), @@ -92,19 +92,19 @@ class _FilledCard extends StatelessWidget { Widget build(BuildContext context) { return Card( elevation: 0.0, - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(12)), ), clipBehavior: Clip.antiAlias, - child: child, color: Theme.of(context).colorScheme.surfaceVariant, + child: child, ); } } final bigShadow = [ BoxShadow( - offset: Offset(0, 4), + offset: const Offset(0, 4), blurRadius: 8, color: Colors.black.withOpacity(.08), ) diff --git a/lib/ui/components/brand_header/brand_header.dart b/lib/ui/components/brand_header/brand_header.dart index ca36305e..9f136466 100644 --- a/lib/ui/components/brand_header/brand_header.dart +++ b/lib/ui/components/brand_header/brand_header.dart @@ -6,7 +6,7 @@ import 'package:selfprivacy/ui/components/pre_styled_buttons/pre_styled_buttons. class BrandHeader extends StatelessWidget { const BrandHeader({ Key? key, - this.title = "", + this.title = '', this.hasBackButton = false, this.hasFlashButton = false, this.onBackButtonPressed, @@ -25,22 +25,20 @@ class BrandHeader extends StatelessWidget { padding: EdgeInsets.only( left: hasBackButton ? 1 : 15, ), - child: Container( - child: Row( - children: [ - if (hasBackButton) ...[ - IconButton( - icon: Icon(BrandIcons.arrow_left), - onPressed: - onBackButtonPressed ?? () => Navigator.of(context).pop(), - ), - SizedBox(width: 10), - ], - BrandText.h4(title), - Spacer(), - if (hasFlashButton) PreStyledButtons.flash(), + child: Row( + children: [ + if (hasBackButton) ...[ + IconButton( + icon: const Icon(BrandIcons.arrowLeft), + onPressed: + onBackButtonPressed ?? () => Navigator.of(context).pop(), + ), + const SizedBox(width: 10), ], - ), + BrandText.h4(title), + const Spacer(), + if (hasFlashButton) PreStyledButtons.flash(), + ], ), ); } diff --git a/lib/ui/components/brand_hero_screen/brand_hero_screen.dart b/lib/ui/components/brand_hero_screen/brand_hero_screen.dart index e6163cd8..105267a9 100644 --- a/lib/ui/components/brand_hero_screen/brand_hero_screen.dart +++ b/lib/ui/components/brand_hero_screen/brand_hero_screen.dart @@ -28,7 +28,7 @@ class BrandHeroScreen extends StatelessWidget { return SafeArea( child: Scaffold( appBar: PreferredSize( - preferredSize: Size.fromHeight(52.0), + preferredSize: const Size.fromHeight(52.0), child: BrandHeader( title: headerTitle, hasBackButton: hasBackButton, @@ -37,29 +37,29 @@ class BrandHeroScreen extends StatelessWidget { ), ), body: ListView( - padding: EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16.0), children: [ if (heroIcon != null) Container( + alignment: Alignment.bottomLeft, child: Icon( heroIcon, size: 48.0, ), - alignment: Alignment.bottomLeft, ), - SizedBox(height: 8.0), + const SizedBox(height: 8.0), if (heroTitle != null) Text( heroTitle!, style: Theme.of(context).textTheme.headlineMedium, textAlign: TextAlign.start, ), - SizedBox(height: 8.0), + const SizedBox(height: 8.0), if (heroSubtitle != null) Text(heroSubtitle!, style: Theme.of(context).textTheme.bodyMedium, textAlign: TextAlign.start), - SizedBox(height: 16.0), + const SizedBox(height: 16.0), ...children, ], ), diff --git a/lib/ui/components/brand_icons/brand_icons.dart b/lib/ui/components/brand_icons/brand_icons.dart index b66f8bf6..ea8e51a0 100644 --- a/lib/ui/components/brand_icons/brand_icons.dart +++ b/lib/ui/components/brand_icons/brand_icons.dart @@ -67,7 +67,7 @@ class BrandIcons { IconData(0xe815, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData upload = IconData(0xe816, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData arrow_left = + static const IconData arrowLeft = IconData(0xe818, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData shape = IconData(0xe819, fontFamily: _kFontFam, fontPackage: _kFontPkg); diff --git a/lib/ui/components/brand_loader/brand_loader.dart b/lib/ui/components/brand_loader/brand_loader.dart index 9cd5b571..ea9f754b 100644 --- a/lib/ui/components/brand_loader/brand_loader.dart +++ b/lib/ui/components/brand_loader/brand_loader.dart @@ -12,8 +12,8 @@ class _HorizontalLoader extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text('basis.wait'.tr()), - SizedBox(height: 10), - LinearProgressIndicator(minHeight: 3), + const SizedBox(height: 10), + const LinearProgressIndicator(minHeight: 3), ], ); } diff --git a/lib/ui/components/brand_radio/brand_radio.dart b/lib/ui/components/brand_radio/brand_radio.dart index 3ae64bcf..21cc2779 100644 --- a/lib/ui/components/brand_radio/brand_radio.dart +++ b/lib/ui/components/brand_radio/brand_radio.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/config/brand_colors.dart'; class BrandRadio extends StatelessWidget { - BrandRadio({ + const BrandRadio({ Key? key, required this.isChecked, }) : super(key: key); @@ -15,7 +15,7 @@ class BrandRadio extends StatelessWidget { height: 20, width: 20, alignment: Alignment.center, - padding: EdgeInsets.all(2), + padding: const EdgeInsets.all(2), decoration: BoxDecoration( shape: BoxShape.circle, border: _getBorder(), @@ -24,7 +24,7 @@ class BrandRadio extends StatelessWidget { ? Container( height: 10, width: 10, - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: BrandColors.primary, ), diff --git a/lib/ui/components/brand_radio_tile/brand_radio_tile.dart b/lib/ui/components/brand_radio_tile/brand_radio_tile.dart index 4f979a47..b2784799 100644 --- a/lib/ui/components/brand_radio_tile/brand_radio_tile.dart +++ b/lib/ui/components/brand_radio_tile/brand_radio_tile.dart @@ -21,13 +21,13 @@ class BrandRadioTile extends StatelessWidget { onTap: onPress, behavior: HitTestBehavior.translucent, child: Padding( - padding: EdgeInsets.all(2), + padding: const EdgeInsets.all(2), child: Row( children: [ BrandRadio( isChecked: isChecked, ), - SizedBox(width: 9), + const SizedBox(width: 9), BrandText.h5(text) ], ), diff --git a/lib/ui/components/brand_span_button/brand_span_button.dart b/lib/ui/components/brand_span_button/brand_span_button.dart index 6401a821..6fdef622 100644 --- a/lib/ui/components/brand_span_button/brand_span_button.dart +++ b/lib/ui/components/brand_span_button/brand_span_button.dart @@ -11,7 +11,7 @@ class BrandSpanButton extends TextSpan { }) : super( recognizer: TapGestureRecognizer()..onTap = onTap, text: text, - style: (style ?? TextStyle()).copyWith(color: BrandColors.blue), + style: (style ?? const TextStyle()).copyWith(color: BrandColors.blue), ); static link({ diff --git a/lib/ui/components/brand_tab_bar/brand_tab_bar.dart b/lib/ui/components/brand_tab_bar/brand_tab_bar.dart index 3975ee25..021c75e0 100644 --- a/lib/ui/components/brand_tab_bar/brand_tab_bar.dart +++ b/lib/ui/components/brand_tab_bar/brand_tab_bar.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart'; class BrandTabBar extends StatefulWidget { - BrandTabBar({Key? key, this.controller}) : super(key: key); + const BrandTabBar({Key? key, this.controller}) : super(key: key); final TabController? controller; @override diff --git a/lib/ui/components/brand_timer/brand_timer.dart b/lib/ui/components/brand_timer/brand_timer.dart index b82df99b..2e93d415 100644 --- a/lib/ui/components/brand_timer/brand_timer.dart +++ b/lib/ui/components/brand_timer/brand_timer.dart @@ -31,7 +31,7 @@ class _BrandTimerState extends State { _timerStart() { _timeString = differenceFromStart; - timer = Timer.periodic(Duration(seconds: 1), (Timer t) { + timer = Timer.periodic(const Duration(seconds: 1), (Timer t) { var timePassed = DateTime.now().difference(widget.startDateTime); if (timePassed > widget.duration) { t.cancel(); @@ -54,7 +54,7 @@ class _BrandTimerState extends State { Widget build(BuildContext context) { return BrandText.medium( _timeString, - style: TextStyle( + style: const TextStyle( fontWeight: NamedFontWeight.demiBold, ), ); @@ -71,10 +71,10 @@ class _BrandTimerState extends State { String _durationToString(Duration duration) { var timeLeft = widget.duration - duration; - String twoDigits(int n) => n.toString().padLeft(2, "0"); + String twoDigits(int n) => n.toString().padLeft(2, '0'); String twoDigitSeconds = twoDigits(timeLeft.inSeconds); - return "timer.sec".tr(args: [twoDigitSeconds]); + return 'timer.sec'.tr(args: [twoDigitSeconds]); } @override diff --git a/lib/ui/components/dots_indicator/dots_indicator.dart b/lib/ui/components/dots_indicator/dots_indicator.dart index ccf42aa5..e5c48bb4 100644 --- a/lib/ui/components/dots_indicator/dots_indicator.dart +++ b/lib/ui/components/dots_indicator/dots_indicator.dart @@ -16,7 +16,7 @@ class DotsIndicator extends StatelessWidget { var dots = List.generate( count, (index) => Container( - margin: EdgeInsets.symmetric(horizontal: 5, vertical: 10), + margin: const EdgeInsets.symmetric(horizontal: 5, vertical: 10), height: 10, width: 10, decoration: BoxDecoration( diff --git a/lib/ui/components/error/error.dart b/lib/ui/components/error/error.dart index ed46f547..64479cf7 100644 --- a/lib/ui/components/error/error.dart +++ b/lib/ui/components/error/error.dart @@ -16,7 +16,7 @@ class BrandError extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ Text(error.toString()), - Text('stackTrace: '), + const Text('stackTrace: '), Text(stackTrace.toString()), ], ), diff --git a/lib/ui/components/icon_status_mask/icon_status_mask.dart b/lib/ui/components/icon_status_mask/icon_status_mask.dart index cf9fd1d7..89426968 100644 --- a/lib/ui/components/icon_status_mask/icon_status_mask.dart +++ b/lib/ui/components/icon_status_mask/icon_status_mask.dart @@ -3,7 +3,7 @@ import 'package:selfprivacy/config/brand_colors.dart'; import 'package:selfprivacy/logic/models/state_types.dart'; class IconStatusMask extends StatelessWidget { - IconStatusMask({required this.child, required this.status}); + const IconStatusMask({required this.child, required this.status}); final Icon child; final StateType status; @@ -24,8 +24,8 @@ class IconStatusMask extends StatelessWidget { } return ShaderMask( shaderCallback: (bounds) => LinearGradient( - begin: Alignment(-1, -0.8), - end: Alignment(0.9, 0.9), + begin: const Alignment(-1, -0.8), + end: const Alignment(0.9, 0.9), colors: colors, tileMode: TileMode.mirror, ).createShader(bounds), diff --git a/lib/ui/components/jobs_content/jobs_content.dart b/lib/ui/components/jobs_content/jobs_content.dart index 1859cd70..cad2d7c4 100644 --- a/lib/ui/components/jobs_content/jobs_content.dart +++ b/lib/ui/components/jobs_content/jobs_content.dart @@ -24,19 +24,19 @@ class JobsContent extends StatelessWidget { var installationState = context.read().state; if (state is JobsStateEmpty) { widgets = [ - SizedBox(height: 80), + const SizedBox(height: 80), Center(child: BrandText.body1('jobs.empty'.tr())), ]; if (installationState is ServerInstallationFinished) { widgets = [ ...widgets, - SizedBox(height: 80), + const SizedBox(height: 80), BrandButton.rised( onPressed: () => context.read().upgradeServer(), text: 'jobs.upgradeServer'.tr(), ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandButton.text( onPressed: () { var nav = getIt(); @@ -61,7 +61,7 @@ class JobsContent extends StatelessWidget { } } else if (state is JobsStateLoading) { widgets = [ - SizedBox(height: 80), + const SizedBox(height: 80), BrandLoader.horizontal(), ]; } else if (state is JobsStateWithJobs) { @@ -75,7 +75,7 @@ class JobsContent extends StatelessWidget { child: Text(j.title), ), ), - SizedBox(width: 10), + const SizedBox(width: 10), ElevatedButton( style: ElevatedButton.styleFrom( primary: BrandColors.red1, @@ -91,7 +91,7 @@ class JobsContent extends StatelessWidget { ), ) .toList(), - SizedBox(height: 20), + const SizedBox(height: 20), BrandButton.rised( onPressed: () => context.read().applyAll(), text: 'jobs.start'.tr(), @@ -101,13 +101,13 @@ class JobsContent extends StatelessWidget { return ListView( padding: paddingH15V0, children: [ - SizedBox(height: 15), + const SizedBox(height: 15), Center( child: BrandText.h2( 'jobs.title'.tr(), ), ), - SizedBox(height: 20), + const SizedBox(height: 20), ...widgets ], ); diff --git a/lib/ui/components/not_ready_card/not_ready_card.dart b/lib/ui/components/not_ready_card/not_ready_card.dart index a2eac28c..8bc3ec32 100644 --- a/lib/ui/components/not_ready_card/not_ready_card.dart +++ b/lib/ui/components/not_ready_card/not_ready_card.dart @@ -11,7 +11,7 @@ class NotReadyCard extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10), + padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: BrandColors.gray6), child: RichText( @@ -19,7 +19,7 @@ class NotReadyCard extends StatelessWidget { children: [ TextSpan( text: 'not_ready_card.1'.tr(), - style: TextStyle(color: BrandColors.white), + style: const TextStyle(color: BrandColors.white), ), WidgetSpan( child: Padding( @@ -44,7 +44,7 @@ class NotReadyCard extends StatelessWidget { ), TextSpan( text: 'not_ready_card.3'.tr(), - style: TextStyle(color: BrandColors.white), + style: const TextStyle(color: BrandColors.white), ), ], ), diff --git a/lib/ui/components/one_page/one_page.dart b/lib/ui/components/one_page/one_page.dart index 9cb1afe6..30707766 100644 --- a/lib/ui/components/one_page/one_page.dart +++ b/lib/ui/components/one_page/one_page.dart @@ -18,18 +18,18 @@ class OnePage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(52), child: Column( children: [ Container( height: 51, alignment: Alignment.center, - padding: EdgeInsets.symmetric(horizontal: 15), + padding: const EdgeInsets.symmetric(horizontal: 15), child: BrandText.h4('basis.details'.tr()), ), - BrandDivider(), + const BrandDivider(), ], ), - preferredSize: Size.fromHeight(52), ), body: child, bottomNavigationBar: SafeArea( diff --git a/lib/ui/components/pre_styled_buttons/close.dart b/lib/ui/components/pre_styled_buttons/close.dart index 13f99bce..5a9e6241 100644 --- a/lib/ui/components/pre_styled_buttons/close.dart +++ b/lib/ui/components/pre_styled_buttons/close.dart @@ -13,7 +13,7 @@ class _CloseButton extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ BrandText.h4('basis.close'.tr()), - Icon(Icons.close), + const Icon(Icons.close), ], ), ); diff --git a/lib/ui/components/pre_styled_buttons/flash.dart b/lib/ui/components/pre_styled_buttons/flash.dart index 3888af29..8a0f4b98 100644 --- a/lib/ui/components/pre_styled_buttons/flash.dart +++ b/lib/ui/components/pre_styled_buttons/flash.dart @@ -1,7 +1,7 @@ part of 'pre_styled_buttons.dart'; class _BrandFlashButton extends StatefulWidget { - _BrandFlashButton({Key? key}) : super(key: key); + const _BrandFlashButton({Key? key}) : super(key: key); @override _BrandFlashButtonState createState() => _BrandFlashButtonState(); @@ -14,8 +14,8 @@ class _BrandFlashButtonState extends State<_BrandFlashButton> @override void initState() { - _animationController = - AnimationController(vsync: this, duration: Duration(milliseconds: 800)); + _animationController = AnimationController( + vsync: this, duration: const Duration(milliseconds: 800)); _colorTween = ColorTween( begin: BrandColors.black, end: BrandColors.primary, @@ -61,7 +61,7 @@ class _BrandFlashButtonState extends State<_BrandFlashButton> onPressed: () { showBrandBottomSheet( context: context, - builder: (context) => BrandBottomSheet( + builder: (context) => const BrandBottomSheet( isExpended: true, child: JobsContent(), ), diff --git a/lib/ui/components/pre_styled_buttons/flashFab.dart b/lib/ui/components/pre_styled_buttons/flash_fab.dart similarity index 92% rename from lib/ui/components/pre_styled_buttons/flashFab.dart rename to lib/ui/components/pre_styled_buttons/flash_fab.dart index 0af5bcab..fac36a37 100644 --- a/lib/ui/components/pre_styled_buttons/flashFab.dart +++ b/lib/ui/components/pre_styled_buttons/flash_fab.dart @@ -8,7 +8,7 @@ import 'package:selfprivacy/ui/components/jobs_content/jobs_content.dart'; import 'package:selfprivacy/ui/helpers/modals.dart'; class BrandFab extends StatefulWidget { - BrandFab({Key? key}) : super(key: key); + const BrandFab({Key? key}) : super(key: key); @override _BrandFabState createState() => _BrandFabState(); @@ -21,8 +21,8 @@ class _BrandFabState extends State @override void initState() { - _animationController = - AnimationController(vsync: this, duration: Duration(milliseconds: 800)); + _animationController = AnimationController( + vsync: this, duration: const Duration(milliseconds: 800)); _colorTween = ColorTween( begin: BrandColors.black, end: BrandColors.primary, @@ -68,7 +68,7 @@ class _BrandFabState extends State onPressed: () { showBrandBottomSheet( context: context, - builder: (context) => BrandBottomSheet( + builder: (context) => const BrandBottomSheet( isExpended: true, child: JobsContent(), ), diff --git a/lib/ui/components/pre_styled_buttons/pre_styled_buttons.dart b/lib/ui/components/pre_styled_buttons/pre_styled_buttons.dart index b3be1ee8..860a83a3 100644 --- a/lib/ui/components/pre_styled_buttons/pre_styled_buttons.dart +++ b/lib/ui/components/pre_styled_buttons/pre_styled_buttons.dart @@ -18,5 +18,5 @@ class PreStyledButtons { }) => _CloseButton(onPress: onPress); - static Widget flash() => _BrandFlashButton(); + static Widget flash() => const _BrandFlashButton(); } diff --git a/lib/ui/components/progress_bar/progress_bar.dart b/lib/ui/components/progress_bar/progress_bar.dart index 41b23c86..393fcc70 100644 --- a/lib/ui/components/progress_bar/progress_bar.dart +++ b/lib/ui/components/progress_bar/progress_bar.dart @@ -6,7 +6,7 @@ import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart'; import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; class ProgressBar extends StatefulWidget { - ProgressBar({ + const ProgressBar({ Key? key, required this.steps, required this.activeIndex, @@ -49,12 +49,12 @@ class _ProgressBarState extends State { odd.insert( 0, - SizedBox( + const SizedBox( width: 10, ), ); odd.add( - SizedBox( + const SizedBox( width: 20, ), ); @@ -63,12 +63,12 @@ class _ProgressBarState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ BrandText.h2('Progress'), - SizedBox(height: 10), + const SizedBox(height: 10), Row( - children: even, mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: even, ), - SizedBox(height: 7), + const SizedBox(height: 7), Container( alignment: Alignment.centerLeft, decoration: BoxDecoration( @@ -82,23 +82,23 @@ class _ProgressBarState extends State { height: 5, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - gradient: LinearGradient( + gradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: BrandColors.stableGradientColors, ), ), - duration: Duration( + duration: const Duration( milliseconds: 300, ), ); }, ), ), - SizedBox(height: 5), + const SizedBox(height: 5), Row( - children: odd, mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: odd, ), ], ); @@ -114,7 +114,7 @@ class _ProgressBarState extends State { style = isActive ? style!.copyWith(fontWeight: FontWeight.w700) : style; return Container( - padding: EdgeInsets.only(left: 10), + padding: const EdgeInsets.only(left: 10), height: 20, alignment: Alignment.center, child: RichText( @@ -123,9 +123,9 @@ class _ProgressBarState extends State { style: progressTextStyleLight, children: [ checked - ? WidgetSpan( + ? const WidgetSpan( child: Padding( - padding: const EdgeInsets.only(bottom: 2, right: 2), + padding: EdgeInsets.only(bottom: 2, right: 2), child: Icon(BrandIcons.check, size: 11), )) : TextSpan(text: '${index + 1}.', style: style), diff --git a/lib/ui/components/switch_block/switch_bloc.dart b/lib/ui/components/switch_block/switch_bloc.dart index cddb2859..3b5531cd 100644 --- a/lib/ui/components/switch_block/switch_bloc.dart +++ b/lib/ui/components/switch_block/switch_bloc.dart @@ -16,8 +16,8 @@ class SwitcherBlock extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - padding: EdgeInsets.only(top: 20, bottom: 5), - decoration: BoxDecoration( + padding: const EdgeInsets.only(top: 20, bottom: 5), + decoration: const BoxDecoration( border: Border( bottom: BorderSide(width: 1, color: BrandColors.dividerColor), )), @@ -26,7 +26,7 @@ class SwitcherBlock extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible(child: child), - SizedBox(width: 5), + const SizedBox(width: 5), Switch( activeColor: BrandColors.green1, activeTrackColor: BrandColors.green2, diff --git a/lib/ui/helpers/modals.dart b/lib/ui/helpers/modals.dart index 69f6b6d8..540b11ec 100644 --- a/lib/ui/helpers/modals.dart +++ b/lib/ui/helpers/modals.dart @@ -9,6 +9,6 @@ Future showBrandBottomSheet({ builder: builder, barrierColor: Colors.black45, context: context, - shadow: BoxShadow(color: Colors.transparent), + shadow: const BoxShadow(color: Colors.transparent), backgroundColor: Colors.transparent, ); diff --git a/lib/ui/pages/backup_details/backup_details.dart b/lib/ui/pages/backup_details/backup_details.dart index 8a5eb688..78d45a5b 100644 --- a/lib/ui/pages/backup_details/backup_details.dart +++ b/lib/ui/pages/backup_details/backup_details.dart @@ -72,7 +72,7 @@ class _BackupDetailsState extends State : () async { await context.read().createBackup(); }, - leading: Icon( + leading: const Icon( Icons.add_circle_outline_rounded, ), title: Text( @@ -105,7 +105,7 @@ class _BackupDetailsState extends State ), if (backupStatus == BackupStatusEnum.error) ListTile( - leading: Icon( + leading: const Icon( Icons.error_outline, color: BrandColors.red1, ), @@ -117,7 +117,7 @@ class _BackupDetailsState extends State ], ), ), - SizedBox(height: 16), + const SizedBox(height: 16), // Card with a list of existing backups // Each list item has a date // When clicked, starts the restore action @@ -128,7 +128,7 @@ class _BackupDetailsState extends State crossAxisAlignment: CrossAxisAlignment.start, children: [ ListTile( - leading: Icon( + leading: const Icon( Icons.refresh, ), title: Text( @@ -136,12 +136,12 @@ class _BackupDetailsState extends State style: Theme.of(context).textTheme.headline6, ), ), - Divider( + const Divider( height: 1.0, ), if (backups.isEmpty) ListTile( - leading: Icon( + leading: const Icon( Icons.error_outline, ), title: Text('providers.backup.no_backups'.tr()), @@ -174,11 +174,7 @@ class _BackupDetailsState extends State )); }, title: Text( - MaterialLocalizations.of(context) - .formatShortDate(backup.time) + - ' ' + - TimeOfDay.fromDateTime(backup.time) - .format(context), + '${MaterialLocalizations.of(context).formatShortDate(backup.time)} ${TimeOfDay.fromDateTime(backup.time).format(context)}', ), ); }).toList(), @@ -186,7 +182,7 @@ class _BackupDetailsState extends State ], ), ), - SizedBox(height: 16), + const SizedBox(height: 16), BrandCards.outlined( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -203,7 +199,7 @@ class _BackupDetailsState extends State if (providerState != StateType.uninitialized) Column( children: [ - Divider( + const Divider( height: 1.0, ), ListTile( @@ -218,7 +214,7 @@ class _BackupDetailsState extends State .forceUpdateBackups() }, ), - Divider( + const Divider( height: 1.0, ), ListTile( diff --git a/lib/ui/pages/dns_details/dns_details.dart b/lib/ui/pages/dns_details/dns_details.dart index 3b5fd555..b93de2f9 100644 --- a/lib/ui/pages/dns_details/dns_details.dart +++ b/lib/ui/pages/dns_details/dns_details.dart @@ -16,26 +16,26 @@ class _DnsDetailsPageState extends State { Widget _getStateCard(DnsRecordsStatus dnsState, Function fixCallback) { var description = ''; var subtitle = ''; - var icon = Icon( + var icon = const Icon( Icons.check, color: Colors.green, ); switch (dnsState) { case DnsRecordsStatus.uninitialized: description = 'providers.domain.states.uninitialized'.tr(); - icon = Icon( + icon = const Icon( Icons.refresh, ); break; case DnsRecordsStatus.refreshing: description = 'providers.domain.states.refreshing'.tr(); - icon = Icon( + icon = const Icon( Icons.refresh, ); break; case DnsRecordsStatus.good: description = 'providers.domain.states.ok'.tr(); - icon = Icon( + icon = const Icon( Icons.check, color: Colors.green, ); @@ -43,7 +43,7 @@ class _DnsDetailsPageState extends State { case DnsRecordsStatus.error: description = 'providers.domain.states.error'.tr(); subtitle = 'providers.domain.states.error_subtitle'.tr(); - icon = Icon( + icon = const Icon( Icons.error, color: Colors.red, ); @@ -104,7 +104,7 @@ class _DnsDetailsPageState extends State { ), ), - SizedBox(height: 16.0), + const SizedBox(height: 16.0), // Outlined card with a list of A records and their // status. BrandCards.outlined( @@ -128,7 +128,7 @@ class _DnsDetailsPageState extends State { .map( (dnsRecord) => Column( children: [ - Divider( + const Divider( height: 1.0, ), ListTile( @@ -162,7 +162,7 @@ class _DnsDetailsPageState extends State { ], ), ), - SizedBox(height: 16.0), + const SizedBox(height: 16.0), BrandCards.outlined( child: Column( children: [ @@ -184,7 +184,7 @@ class _DnsDetailsPageState extends State { .map( (dnsRecord) => Column( children: [ - Divider( + const Divider( height: 1.0, ), ListTile( diff --git a/lib/ui/pages/more/about/about.dart b/lib/ui/pages/more/about/about.dart index b927c785..53faa191 100644 --- a/lib/ui/pages/more/about/about.dart +++ b/lib/ui/pages/more/about/about.dart @@ -11,14 +11,12 @@ class AboutPage extends StatelessWidget { return SafeArea( child: Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'more.about_project'.tr(), hasBackButton: true), - preferredSize: Size.fromHeight(52), ), - body: Container( - child: BrandMarkdown( - fileName: 'about', - ), + body: const BrandMarkdown( + fileName: 'about', ), ), ); diff --git a/lib/ui/pages/more/app_settings/app_setting.dart b/lib/ui/pages/more/app_settings/app_setting.dart index 37bbe83e..f490bc11 100644 --- a/lib/ui/pages/more/app_settings/app_setting.dart +++ b/lib/ui/pages/more/app_settings/app_setting.dart @@ -28,17 +28,17 @@ class _AppSettingsPageState extends State { child: Builder(builder: (context) { return Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'more.settings.title'.tr(), hasBackButton: true), - preferredSize: Size.fromHeight(52), ), body: ListView( padding: paddingH15V0, children: [ - BrandDivider(), + const BrandDivider(), Container( - padding: EdgeInsets.only(top: 20, bottom: 5), - decoration: BoxDecoration( + padding: const EdgeInsets.only(top: 20, bottom: 5), + decoration: const BoxDecoration( border: Border( bottom: BorderSide(width: 1, color: BrandColors.dividerColor), )), @@ -52,7 +52,7 @@ class _AppSettingsPageState extends State { value: 'more.settings.2'.tr(), ), ), - SizedBox(width: 5), + const SizedBox(width: 5), BrandSwitch( value: Theme.of(context).brightness == Brightness.dark, onChanged: (value) => context @@ -63,8 +63,8 @@ class _AppSettingsPageState extends State { ), ), Container( - padding: EdgeInsets.only(top: 20, bottom: 5), - decoration: BoxDecoration( + padding: const EdgeInsets.only(top: 20, bottom: 5), + decoration: const BoxDecoration( border: Border( bottom: BorderSide(width: 1, color: BrandColors.dividerColor), )), @@ -78,14 +78,14 @@ class _AppSettingsPageState extends State { value: 'more.settings.4'.tr(), ), ), - SizedBox(width: 5), + const SizedBox(width: 5), ElevatedButton( style: ElevatedButton.styleFrom( primary: BrandColors.red1, ), child: Text( 'basis.reset'.tr(), - style: TextStyle( + style: const TextStyle( color: BrandColors.white, fontWeight: NamedFontWeight.demiBold, ), @@ -131,8 +131,8 @@ class _AppSettingsPageState extends State { var isDisabled = context.watch().state.serverDetails == null; return Container( - padding: EdgeInsets.only(top: 20, bottom: 5), - decoration: BoxDecoration( + padding: const EdgeInsets.only(top: 20, bottom: 5), + decoration: const BoxDecoration( border: Border( bottom: BorderSide(width: 1, color: BrandColors.dividerColor), )), @@ -146,18 +146,11 @@ class _AppSettingsPageState extends State { value: 'more.settings.6'.tr(), ), ), - SizedBox(width: 5), + const SizedBox(width: 5), ElevatedButton( style: ElevatedButton.styleFrom( primary: BrandColors.red1, ), - child: Text( - 'basis.delete'.tr(), - style: TextStyle( - color: BrandColors.white, - fontWeight: NamedFontWeight.demiBold, - ), - ), onPressed: isDisabled ? null : () { @@ -177,7 +170,8 @@ class _AppSettingsPageState extends State { builder: (context) { return Container( alignment: Alignment.center, - child: CircularProgressIndicator(), + child: + const CircularProgressIndicator(), ); }); await context @@ -193,6 +187,13 @@ class _AppSettingsPageState extends State { }, ); }, + child: Text( + 'basis.delete'.tr(), + style: const TextStyle( + color: BrandColors.white, + fontWeight: NamedFontWeight.demiBold, + ), + ), ), ], ), @@ -220,9 +221,9 @@ class _TextColumn extends StatelessWidget { title, style: TextStyle(color: hasWarning ? BrandColors.warning : null), ), - SizedBox(height: 5), + const SizedBox(height: 5), BrandText.body1(value, - style: TextStyle( + style: const TextStyle( fontSize: 13, height: 1.53, color: BrandColors.gray1, diff --git a/lib/ui/pages/more/console/console.dart b/lib/ui/pages/more/console/console.dart index 2e129f79..984f20b3 100644 --- a/lib/ui/pages/more/console/console.dart +++ b/lib/ui/pages/more/console/console.dart @@ -35,13 +35,13 @@ class _ConsoleState extends State { return SafeArea( child: Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(53), child: Column( - children: [ + children: const [ BrandHeader(title: 'Console', hasBackButton: true), BrandDivider(), ], ), - preferredSize: Size.fromHeight(53), ), body: FutureBuilder( future: getIt.allReady(), @@ -53,7 +53,7 @@ class _ConsoleState extends State { reverse: true, shrinkWrap: true, children: [ - SizedBox(height: 20), + const SizedBox(height: 20), ...UnmodifiableListView(messages .map((message) { var isError = message.type == MessageType.warning; @@ -84,7 +84,7 @@ class _ConsoleState extends State { return Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, - children: [ + children: const [ Text('Waiting for initialisation'), SizedBox( height: 16, diff --git a/lib/ui/pages/more/info/info.dart b/lib/ui/pages/more/info/info.dart index ef0628a6..639fab4e 100644 --- a/lib/ui/pages/more/info/info.dart +++ b/lib/ui/pages/more/info/info.dart @@ -14,14 +14,14 @@ class InfoPage extends StatelessWidget { return SafeArea( child: Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(52), child: BrandHeader(title: 'more.about_app'.tr(), hasBackButton: true), - preferredSize: Size.fromHeight(52), ), body: ListView( padding: paddingH15V0, children: [ - BrandDivider(), - SizedBox(height: 10), + const BrandDivider(), + const SizedBox(height: 10), FutureBuilder( future: _version(), builder: (context, snapshot) { diff --git a/lib/ui/pages/more/more.dart b/lib/ui/pages/more/more.dart index d91ee769..790170c5 100644 --- a/lib/ui/pages/more/more.dart +++ b/lib/ui/pages/more/more.dart @@ -27,11 +27,11 @@ class MorePage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'basis.more'.tr(), hasFlashButton: true, ), - preferredSize: Size.fromHeight(52), ), body: ListView( children: [ @@ -39,7 +39,7 @@ class MorePage extends StatelessWidget { padding: paddingH15V0, child: Column( children: [ - BrandDivider(), + const BrandDivider(), _NavItem( title: 'more.configuration_wizard'.tr(), iconData: BrandIcons.triangle, @@ -48,27 +48,27 @@ class MorePage extends StatelessWidget { _NavItem( title: 'more.settings.title'.tr(), iconData: BrandIcons.settings, - goTo: AppSettingsPage(), + goTo: const AppSettingsPage(), ), _NavItem( title: 'more.about_project'.tr(), iconData: BrandIcons.engineer, - goTo: AboutPage(), + goTo: const AboutPage(), ), _NavItem( title: 'more.about_app'.tr(), iconData: BrandIcons.fire, - goTo: InfoPage(), + goTo: const InfoPage(), ), _NavItem( title: 'more.onboarding'.tr(), iconData: BrandIcons.start, - goTo: OnboardingPage(nextPage: RootPage()), + goTo: const OnboardingPage(nextPage: RootPage()), ), _NavItem( title: 'more.console'.tr(), iconData: BrandIcons.terminal, - goTo: Console(), + goTo: const Console(), ), _NavItem( isEnabled: context.read().state @@ -131,8 +131,8 @@ class _MoreMenuItem extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - padding: EdgeInsets.symmetric(vertical: 24), - decoration: BoxDecoration( + padding: const EdgeInsets.symmetric(vertical: 24), + decoration: const BoxDecoration( border: Border( bottom: BorderSide( width: 1.0, @@ -148,7 +148,7 @@ class _MoreMenuItem extends StatelessWidget { color: isActive ? null : Colors.grey, ), ), - Spacer(), + const Spacer(), SizedBox( width: 56, child: Icon( diff --git a/lib/ui/pages/onboarding/onboarding.dart b/lib/ui/pages/onboarding/onboarding.dart index 6416a5b0..eecd55c8 100644 --- a/lib/ui/pages/onboarding/onboarding.dart +++ b/lib/ui/pages/onboarding/onboarding.dart @@ -53,11 +53,11 @@ class _OnboardingPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: 30), + const SizedBox(height: 30), BrandText.h2( 'onboarding.page1_title'.tr(), ), - SizedBox(height: 20), + const SizedBox(height: 20), BrandText.body2('onboarding.page1_text'.tr()), Flexible( child: Center( @@ -75,13 +75,13 @@ class _OnboardingPageState extends State { onPressed: () { pageController.animateToPage( 1, - duration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), curve: Curves.easeIn, ); }, text: 'basis.next'.tr(), ), - SizedBox(height: 30), + const SizedBox(height: 30), ], ), ); @@ -94,11 +94,11 @@ class _OnboardingPageState extends State { ), child: Column( children: [ - SizedBox(height: 30), + const SizedBox(height: 30), BrandText.h2('onboarding.page2_title'.tr()), - SizedBox(height: 20), + const SizedBox(height: 20), BrandText.body2('onboarding.page2_text'.tr()), - SizedBox(height: 20), + const SizedBox(height: 20), Center( child: Image.asset( _fileName( @@ -131,7 +131,7 @@ class _OnboardingPageState extends State { }, text: 'basis.got_it'.tr(), ), - SizedBox(height: 30), + const SizedBox(height: 30), ], ), ); diff --git a/lib/ui/pages/providers/providers.dart b/lib/ui/pages/providers/providers.dart index 333ee66b..754e7866 100644 --- a/lib/ui/pages/providers/providers.dart +++ b/lib/ui/pages/providers/providers.dart @@ -21,7 +21,7 @@ import 'package:selfprivacy/utils/route_transitions/basic.dart'; var navigatorKey = GlobalKey(); class ProvidersPage extends StatefulWidget { - ProvidersPage({Key? key}) : super(key: key); + const ProvidersPage({Key? key}) : super(key: key); @override _ProvidersPageState createState() => _ProvidersPageState(); @@ -49,7 +49,7 @@ class _ProvidersPageState extends State { final cards = ProviderType.values .map( (type) => Padding( - padding: EdgeInsets.only(bottom: 30), + padding: const EdgeInsets.only(bottom: 30), child: _Card( provider: ProviderModel( state: isReady @@ -67,18 +67,18 @@ class _ProvidersPageState extends State { .toList(); return Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'providers.page_title'.tr(), hasFlashButton: true, ), - preferredSize: Size.fromHeight(52), ), body: ListView( padding: paddingH15V0, children: [ if (!isReady) ...[ - NotReadyCard(), - SizedBox(height: 24), + const NotReadyCard(), + const SizedBox(height: 24), ], ...cards, ], @@ -111,7 +111,7 @@ class _Card extends StatelessWidget { stableText = 'providers.server.status'.tr(); onTap = () => showBrandBottomSheet( context: context, - builder: (context) => BrandBottomSheet( + builder: (context) => const BrandBottomSheet( isExpended: true, child: ServerDetailsScreen(), ), @@ -132,7 +132,7 @@ class _Card extends StatelessWidget { stableText = 'providers.backup.status'.tr(); onTap = () => Navigator.of(context).push(materialRoute( - BackupDetails(), + const BackupDetails(), )); break; } @@ -146,12 +146,12 @@ class _Card extends StatelessWidget { status: provider.state, child: Icon(provider.icon, size: 30, color: Colors.white), ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.h2(title), - SizedBox(height: 10), + const SizedBox(height: 10), if (message != null) ...[ BrandText.body2(message), - SizedBox(height: 10), + const SizedBox(height: 10), ], if (provider.state == StateType.stable) BrandText.body2(stableText), ], diff --git a/lib/ui/pages/rootRoute.dart b/lib/ui/pages/root_route.dart similarity index 92% rename from lib/ui/pages/rootRoute.dart rename to lib/ui/pages/root_route.dart index eabb0a10..d66d73c3 100644 --- a/lib/ui/pages/rootRoute.dart +++ b/lib/ui/pages/root_route.dart @@ -7,7 +7,7 @@ import 'package:selfprivacy/ui/pages/providers/providers.dart'; import 'package:selfprivacy/ui/pages/services/services.dart'; import 'package:selfprivacy/ui/pages/users/users.dart'; -import '../components/pre_styled_buttons/flashFab.dart'; +import '../components/pre_styled_buttons/flash_fab.dart'; class RootPage extends StatefulWidget { const RootPage({Key? key}) : super(key: key); @@ -42,7 +42,7 @@ class _RootPageState extends State create: (_) => ChangeTab(tabController.animateTo), child: TabBarView( controller: tabController, - children: [ + children: const [ ProvidersPage(), ServicesPage(), UsersPage(), @@ -53,7 +53,7 @@ class _RootPageState extends State bottomNavigationBar: BrandTabBar( controller: tabController, ), - floatingActionButton: BrandFab(), + floatingActionButton: const BrandFab(), ), ); } diff --git a/lib/ui/pages/server_details/chart.dart b/lib/ui/pages/server_details/chart.dart index 242df725..7829234b 100644 --- a/lib/ui/pages/server_details/chart.dart +++ b/lib/ui/pages/server_details/chart.dart @@ -19,33 +19,33 @@ class _Chart extends StatelessWidget { ]; } else if (state is HetznerMetricsLoaded) { charts = [ - Legend(color: Colors.red, text: 'CPU %'), - SizedBox(height: 20), + const Legend(color: Colors.red, text: 'CPU %'), + const SizedBox(height: 20), getCpuChart(state), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ BrandText.small('Public Network interface packets per sec'), - SizedBox(width: 10), - Legend(color: Colors.red, text: 'IN'), - SizedBox(width: 5), - Legend(color: Colors.green, text: 'OUT'), + const SizedBox(width: 10), + const Legend(color: Colors.red, text: 'IN'), + const SizedBox(width: 5), + const Legend(color: Colors.green, text: 'OUT'), ], ), - SizedBox(height: 20), + const SizedBox(height: 20), getPpsChart(state), - SizedBox(height: 1), + const SizedBox(height: 1), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ BrandText.small('Public Network interface bytes per sec'), - SizedBox(width: 10), - Legend(color: Colors.red, text: 'IN'), - SizedBox(width: 5), - Legend(color: Colors.green, text: 'OUT'), + const SizedBox(width: 10), + const Legend(color: Colors.red, text: 'IN'), + const SizedBox(width: 5), + const Legend(color: Colors.green, text: 'OUT'), ], ), - SizedBox(height: 20), + const SizedBox(height: 20), getBandwidthChart(state), ]; } else { @@ -57,7 +57,7 @@ class _Chart extends StatelessWidget { child: Column( children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10), + padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -88,7 +88,7 @@ class _Chart extends StatelessWidget { Widget getCpuChart(HetznerMetricsLoaded state) { var data = state.cpu; - return Container( + return SizedBox( height: 200, child: CpuChart(data, state.period, state.start), ); @@ -98,7 +98,7 @@ class _Chart extends StatelessWidget { var ppsIn = state.ppsIn; var ppsOut = state.ppsOut; - return Container( + return SizedBox( height: 200, child: NetworkChart( [ppsIn, ppsOut], @@ -112,7 +112,7 @@ class _Chart extends StatelessWidget { var ppsIn = state.bandwidthIn; var ppsOut = state.bandwidthOut; - return Container( + return SizedBox( height: 200, child: NetworkChart( [ppsIn, ppsOut], @@ -138,7 +138,7 @@ class Legend extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ _ColoredBox(color: color), - SizedBox(width: 5), + const SizedBox(width: 5), BrandText.small(text), ], ); diff --git a/lib/ui/pages/server_details/cpu_chart.dart b/lib/ui/pages/server_details/cpu_chart.dart index fd131e61..113c797b 100644 --- a/lib/ui/pages/server_details/cpu_chart.dart +++ b/lib/ui/pages/server_details/cpu_chart.dart @@ -7,7 +7,7 @@ import 'package:selfprivacy/logic/models/hetzner_metrics.dart'; import 'package:intl/intl.dart'; class CpuChart extends StatelessWidget { - CpuChart(this.data, this.period, this.start); + const CpuChart(this.data, this.period, this.start); final List data; final Period period; @@ -54,13 +54,13 @@ class CpuChart extends StatelessWidget { return Padding( padding: const EdgeInsets.all(8.0), child: RotatedBox( + quarterTurns: 1, child: Text(bottomTitle(value.toInt()), - style: TextStyle( + style: const TextStyle( fontSize: 10, color: Colors.purple, fontWeight: FontWeight.bold, )), - quarterTurns: 1, ), ); }, @@ -71,7 +71,7 @@ class CpuChart extends StatelessWidget { sideTitles: SideTitles( getTitlesWidget: (value, titleMeta) { return Padding( - padding: EdgeInsets.only(right: 15), + padding: const EdgeInsets.only(right: 15), child: Text( value.toInt().toString(), style: progressTextStyleLight.copyWith( diff --git a/lib/ui/pages/server_details/header.dart b/lib/ui/pages/server_details/header.dart index 92abf3f8..b28a5efc 100644 --- a/lib/ui/pages/server_details/header.dart +++ b/lib/ui/pages/server_details/header.dart @@ -16,17 +16,17 @@ class _Header extends StatelessWidget { children: [ IconStatusMask( status: providerState, - child: Icon( + child: const Icon( BrandIcons.server, size: 40, color: Colors.white, ), ), - SizedBox(width: 10), + const SizedBox(width: 10), BrandText.h2('providers.server.card_title'.tr()), - Spacer(), + const Spacer(), Padding( - padding: EdgeInsets.symmetric( + padding: const EdgeInsets.symmetric( vertical: 4, horizontal: 2, ), @@ -41,12 +41,12 @@ class _Header extends StatelessWidget { break; } }, - icon: Icon(Icons.more_vert), + icon: const Icon(Icons.more_vert), itemBuilder: (BuildContext context) => [ PopupMenuItem<_PopupMenuItemType>( value: _PopupMenuItemType.setting, child: Container( - padding: EdgeInsets.only(left: 5), + padding: const EdgeInsets.only(left: 5), child: Text('basis.settings'.tr()), ), ), diff --git a/lib/ui/pages/server_details/network_charts.dart b/lib/ui/pages/server_details/network_charts.dart index 8827eb9f..4e0b385e 100644 --- a/lib/ui/pages/server_details/network_charts.dart +++ b/lib/ui/pages/server_details/network_charts.dart @@ -9,7 +9,7 @@ import 'package:selfprivacy/logic/models/hetzner_metrics.dart'; import 'package:intl/intl.dart'; class NetworkChart extends StatelessWidget { - NetworkChart( + const NetworkChart( this.listData, this.period, this.start, @@ -76,13 +76,13 @@ class NetworkChart extends StatelessWidget { return Padding( padding: const EdgeInsets.all(8.0), child: RotatedBox( + quarterTurns: 1, child: Text(bottomTitle(value.toInt()), - style: TextStyle( + style: const TextStyle( fontSize: 10, color: Colors.purple, fontWeight: FontWeight.bold, )), - quarterTurns: 1, ), ); }, @@ -94,7 +94,7 @@ class NetworkChart extends StatelessWidget { reservedSize: 50, getTitlesWidget: (value, titleMeta) { return Padding( - padding: EdgeInsets.only(right: 5), + padding: const EdgeInsets.only(right: 5), child: Text( value.toInt().toString(), style: progressTextStyleLight.copyWith( diff --git a/lib/ui/pages/server_details/server_details_screen.dart b/lib/ui/pages/server_details/server_details_screen.dart index 56e7e18d..8fe4b04e 100644 --- a/lib/ui/pages/server_details/server_details_screen.dart +++ b/lib/ui/pages/server_details/server_details_screen.dart @@ -69,25 +69,25 @@ class _ServerDetailsScreenState extends State create: (context) => ServerDetailsCubit()..check(), child: Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(52), child: Column( children: [ Container( height: 51, alignment: Alignment.center, - padding: EdgeInsets.symmetric(horizontal: 15), + padding: const EdgeInsets.symmetric(horizontal: 15), child: BrandText.h4('basis.details'.tr()), ), - BrandDivider(), + const BrandDivider(), ], ), - preferredSize: Size.fromHeight(52), ), body: TabBarView( - physics: NeverScrollableScrollPhysics(), + physics: const NeverScrollableScrollPhysics(), controller: tabController, children: [ SingleChildScrollView( - physics: ClampingScrollPhysics(), + physics: const ClampingScrollPhysics(), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -103,13 +103,13 @@ class _ServerDetailsScreenState extends State ], ), ), - SizedBox(height: 10), + const SizedBox(height: 10), BlocProvider( create: (context) => HetznerMetricsCubit()..restart(), - child: _Chart(), + child: const _Chart(), ), - SizedBox(height: 20), - _TextDetails(), + const SizedBox(height: 20), + const _TextDetails(), ], ), ), diff --git a/lib/ui/pages/server_details/server_settings.dart b/lib/ui/pages/server_details/server_settings.dart index cca5fcea..f5047d6c 100644 --- a/lib/ui/pages/server_details/server_settings.dart +++ b/lib/ui/pages/server_details/server_settings.dart @@ -12,47 +12,45 @@ class _ServerSettings extends StatelessWidget { Widget build(BuildContext context) { var serverDetailsState = context.watch().state; if (serverDetailsState is ServerDetailsNotReady) { - return Text('not ready'); + return const Text('not ready'); } else if (serverDetailsState is! Loaded) { return BrandLoader.horizontal(); } return ListView( padding: paddingH15V0, children: [ - SizedBox(height: 10), + const SizedBox(height: 10), Container( height: 52, alignment: Alignment.centerLeft, - padding: EdgeInsets.only(left: 1), - child: Container( - child: Row( - children: [ - IconButton( - icon: Icon(BrandIcons.arrow_left), - onPressed: () => tabController.animateTo(0), - ), - SizedBox(width: 10), - BrandText.h4('basis.settings'.tr()), - ], - ), + padding: const EdgeInsets.only(left: 1), + child: Row( + children: [ + IconButton( + icon: const Icon(BrandIcons.arrowLeft), + onPressed: () => tabController.animateTo(0), + ), + const SizedBox(width: 10), + BrandText.h4('basis.settings'.tr()), + ], ), ), - BrandDivider(), + const BrandDivider(), SwitcherBlock( onChange: (_) {}, - child: _TextColumn( + isActive: serverDetailsState.autoUpgradeSettings.enable, + child: const _TextColumn( title: 'Allow Auto-upgrade', value: 'Wether to allow automatic packages upgrades', ), - isActive: serverDetailsState.autoUpgradeSettings.enable, ), SwitcherBlock( onChange: (_) {}, - child: _TextColumn( + isActive: serverDetailsState.autoUpgradeSettings.allowReboot, + child: const _TextColumn( title: 'Reboot after upgrade', value: 'Reboot without prompt after applying updates', ), - isActive: serverDetailsState.autoUpgradeSettings.allowReboot, ), _Button( onTap: () { @@ -83,8 +81,8 @@ class _Button extends StatelessWidget { return InkWell( onTap: onTap, child: Container( - padding: EdgeInsets.only(top: 20, bottom: 5), - decoration: BoxDecoration( + padding: const EdgeInsets.only(top: 20, bottom: 5), + decoration: const BoxDecoration( border: Border( bottom: BorderSide(width: 1, color: BrandColors.dividerColor), )), @@ -114,7 +112,7 @@ class _TextColumn extends StatelessWidget { title, style: TextStyle(color: hasWarning ? BrandColors.warning : null), ), - SizedBox(height: 5), + const SizedBox(height: 5), BrandText.body1( value, style: TextStyle( diff --git a/lib/ui/pages/server_details/text_details.dart b/lib/ui/pages/server_details/text_details.dart index 3d1c751d..397f7da1 100644 --- a/lib/ui/pages/server_details/text_details.dart +++ b/lib/ui/pages/server_details/text_details.dart @@ -17,9 +17,9 @@ class _TextDetails extends StatelessWidget { return Column( children: [ Center(child: BrandText.h3('providers.server.bottom_sheet.2'.tr())), - SizedBox(height: 10), + const SizedBox(height: 10), Table( - columnWidths: { + columnWidths: const { 0: FractionColumnWidth(.5), 1: FractionColumnWidth(.5), }, @@ -41,7 +41,7 @@ class _TextDetails extends StatelessWidget { children: [ getRowTitle('Status:'), getRowValue( - '${data.status.toString().split('.')[1].toUpperCase()}', + data.status.toString().split('.')[1].toUpperCase(), isBold: true, ), ], @@ -74,7 +74,7 @@ class _TextDetails extends StatelessWidget { children: [ getRowTitle('Price monthly:'), getRowValue( - '${data.serverType.prices[1].monthly.toString()}', + data.serverType.prices[1].monthly.toString(), ), ], ), @@ -82,17 +82,17 @@ class _TextDetails extends StatelessWidget { children: [ getRowTitle('Price hourly:'), getRowValue( - '${data.serverType.prices[1].hourly.toString()}', + data.serverType.prices[1].hourly.toString(), ), ], ), ], ), - SizedBox(height: 30), + const SizedBox(height: 30), Center(child: BrandText.h3('providers.server.bottom_sheet.3'.tr())), - SizedBox(height: 10), + const SizedBox(height: 10), Table( - columnWidths: { + columnWidths: const { 0: FractionColumnWidth(.5), 1: FractionColumnWidth(.5), }, @@ -102,7 +102,7 @@ class _TextDetails extends StatelessWidget { children: [ getRowTitle('Country:'), getRowValue( - '${data.location.country}', + data.location.country, ), ], ), @@ -120,7 +120,7 @@ class _TextDetails extends StatelessWidget { ), ], ), - SizedBox(height: 20), + const SizedBox(height: 20), ], ); } else { @@ -142,7 +142,7 @@ class _TextDetails extends StatelessWidget { return BrandText.body1( title, style: isBold - ? TextStyle( + ? const TextStyle( fontWeight: NamedFontWeight.demiBold, ) : null, diff --git a/lib/ui/pages/server_details/time_zone/lang.dart b/lib/ui/pages/server_details/time_zone/lang.dart index 4ea55019..b46fa721 100644 --- a/lib/ui/pages/server_details/time_zone/lang.dart +++ b/lib/ui/pages/server_details/time_zone/lang.dart @@ -1,431 +1,431 @@ final russian = { - "Pacific/Midway": "Мидуэй", - "Pacific/Niue": "Ниуэ", - "Pacific/Pago_Pago": "Паго-Паго", - "America/Adak": "Адак", - "Pacific/Honolulu": "Гонолулу", - "Pacific/Johnston": "Джонстон", - "Pacific/Rarotonga": "Раротонга", - "Pacific/Tahiti": "Таити", - "US/Hawaii": "Гавайи", - "Pacific/Marquesas": "Маркизские острова", - "America/Sitka": "Ситка", - "America/Anchorage": "Анкоридж", - "America/Metlakatla": "Метлакатла", - "America/Juneau": "Джуно", - "US/Alaska": "Аляска", - "America/Nome": "Ном", - "America/Yakutat": "Якутат", - "Pacific/Gambier": "Гамбье", - "America/Tijuana": "Тихуана", - "Pacific/Pitcairn": "Питкэрн", - "US/Pacific": "США/Тихий океан", - "Canada/Pacific": "США/Тихий океан", - "America/Los_Angeles": "Лос-Анджелес", - "America/Vancouver": "Ванкувер", - "America/Santa_Isabel": "Санта-Изабель", - "America/Chihuahua": "Чихуахуа", - "America/Cambridge_Bay": "Кембридж-Бэй", - "America/Inuvik": "Инувик", - "America/Boise": "Бойсе", - "America/Dawson": "Доусон", - "America/Mazatlan": "Масатлан", - "America/Dawson_Creek": "Доусон-Крик", - "US/Arizona": "Аризона", - "America/Denver": "Денвер", - "US/Mountain": "гора", - "America/Edmonton": "Эдмонтон", - "America/Yellowknife": "Йеллоунайф", - "America/Ojinaga": "Охинага", - "America/Phoenix": "Феникс", - "America/Whitehorse": "Белая лошадь", - "Canada/Mountain": "гора", - "America/Hermosillo": "Эрмосильо", - "America/Creston": "Крестон", - "America/Swift_Current": "Свифт Керрент", - "America/Tegucigalpa": "Тегусигальпа", - "America/Regina": "Регина", - "America/Rankin_Inlet": "Ранкин-Инлет", - "America/Rainy_River": "Райни-Ривер", - "America/Winnipeg": "Виннипег", - "America/North_Dakota/Center": "Северная Дакота/Центр", - "America/North_Dakota/Beulah": "Северная Дакота/Беула", - "America/Monterrey": "Монтеррей", - "America/Mexico_City": "Мехико", - "US/Central": "Центральный", - "America/Merida": "Мерида", - "America/Menominee": "Меномини", - "America/Matamoros": "Матаморос", - "America/Managua": "Манагуа", - "America/North_Dakota/New_Salem": "Северная Дакота/Нью-Салем", - "Pacific/Galapagos": "Галапагосские острова", - "America/Indiana/Tell_City": "Индиана/Телл-Сити", - "America/Indiana/Knox": "Индиана/Нокс", - "Canada/Central": "Центральный", - "America/Guatemala": "Гватемала", - "America/El_Salvador": "Сальвадор", - "America/Costa_Rica": "Коста-Рика", - "America/Chicago": "Чикаго", - "America/Belize": "Белиз", - "America/Bahia_Banderas": "Баия де Бандерас", - "America/Resolute": "Резольют", - "America/Atikokan": "Атикокан", - "America/Lima": "Лима", - "America/Bogota": "Богота", - "America/Cancun": "Канкун", - "America/Cayman": "Кайман", - "America/Detroit": "Детройт", - "America/Indiana/Indianapolis": "Индиана/Индианаполис", - "America/Eirunepe": "Эйрунепе", - "America/Grand_Turk": "Гранд-Терк", - "America/Guayaquil": "Гуаякиль", - "America/Havana": "Гавана", - "America/Indiana/Marengo": "Индиана/Маренго", - "America/Indiana/Petersburg": "Индиана/Петербург", - "America/Indiana/Vevay": "Индиана/Вева", - "America/Indiana/Vincennes": "Индиана/Винсеннес", - "America/Indiana/Winamac": "Индиана/Винамак", - "America/Iqaluit": "Икалуит", - "America/Jamaica": "Ямайка", - "America/Kentucky/Louisville": "Кентукки/Луисвилл", - "America/Nassau": "Нассау", - "America/Toronto": "Торонто", - "America/Montreal": "Монреаль", - "America/Pangnirtung": "Пангниртунг", - "America/Port-au-Prince": "Порт-о-Пренс", - "America/Kentucky/Monticello": "Кентукки/Монтичелло", - "Canada/Eastern": "Канада/Восточное", - "US/Eastern": "США/Восточное", - "America/Thunder_Bay": "Тандер-Бей", - "Pacific/Easter": "Пасха", - "America/Panama": "Панама", - "America/Nipigon": "Нипигон", - "America/Rio_Branco": "Рио-Бранко", - "America/New_York": "Нью-Йорк", - "Canada/Atlantic": "Атлантика", - "America/Kralendijk": "Кралендейк", - "America/La_Paz": "Ла-Пас", - "America/Halifax": "Галифакс", - "America/Lower_Princes": "Лоуэр-Принс-Куотер", - "America/Manaus": "Манаус", - "America/Marigot": "Мариго", - "America/Martinique": "Мартиника", - "America/Moncton": "Монктон", - "America/Guyana": "Гайана", - "America/Montserrat": "Монтсеррат", - "America/Guadeloupe": "Гваделупа", - "America/Grenada": "Гренада", - "America/Goose_Bay": "Гуз-Бей", - "America/Glace_Bay": "Глас Бэй", - "America/Curacao": "Кюрасао", - "America/Cuiaba": "Куяба", - "America/Port_of_Spain": "Порт-оф-Спейн", - "America/Porto_Velho": "Порту-Велью", - "America/Puerto_Rico": "Пуэрто-Рико", - "America/Caracas": "Каракас", - "America/Santo_Domingo": "Санто-Доминго", - "America/St_Barthelemy": "Святой Бартелеми", - "Atlantic/Bermuda": "Бермуды", - "America/St_Kitts": "Сент-Китс", - "America/St_Lucia": "Святая Люсия", - "America/St_Thomas": "Сент-Томас", - "America/St_Vincent": "Сент-Винсент", - "America/Thule": "Туле", - "America/Campo_Grande": "Кампу-Гранди", - "America/Boa_Vista": "Боа-Виста", - "America/Tortola": "Тортола", - "America/Aruba": "Аруба", - "America/Blanc-Sablon": "Блан-Саблон", - "America/Barbados": "Барбадос", - "America/Anguilla": "Ангилья", - "America/Antigua": "Антигуа", - "America/Dominica": "Доминика", - "Canada/Newfoundland": "Ньюфаундленд", - "America/St_Johns": "Сент-Джонс", - "America/Sao_Paulo": "Сан-Паулу", - "Atlantic/Stanley": "Стэнли", - "America/Miquelon": "Микелон", - "America/Argentina/Salta": "Аргентина/Сальта", - "America/Montevideo": "Монтевидео", - "America/Argentina/Rio_Gallegos": "Аргентина/Рио-Гальегос", - "America/Argentina/Mendoza": "Аргентина/Мендоса", - "America/Argentina/La_Rioja": "Аргентина/Ла-Риоха", - "America/Argentina/Jujuy": "Аргентина/Жужуй", - "Antarctica/Rothera": "Ротера", - "America/Argentina/Cordoba": "Аргентина/Кордова", - "America/Argentina/Catamarca": "Аргентина/Катамарка", - "America/Argentina/Ushuaia": "Аргентина/Ушуая", - "America/Argentina/Tucuman": "Аргентина/Тукуман", - "America/Paramaribo": "Парамарибо", - "America/Argentina/San_Luis": "Аргентина/Сан-Луис", - "America/Recife": "Ресифи", - "America/Argentina/Buenos_Aires": "Аргентина/Буэнос-Айрес", - "America/Asuncion": "Асунсьон", - "America/Maceio": "Масейо", - "America/Santarem": "Сантарен", - "America/Santiago": "Сантьяго", - "Antarctica/Palmer": "Палмер", - "America/Argentina/San_Juan": "Аргентина/Сан-Хуан", - "America/Fortaleza": "Форталеза", - "America/Cayenne": "Кайенна", - "America/Godthab": "Годтаб", - "America/Belem": "Белен", - "America/Araguaina": "Арагуайна", - "America/Bahia": "Баия", - "Atlantic/South_Georgia": "Южная_Грузия", - "America/Noronha": "Норонья", - "Atlantic/Azores": "Азорские острова", - "Atlantic/Cape_Verde": "Кабо-Верде", - "America/Scoresbysund": "Скорсбисунд", - "Africa/Accra": "Аккра", - "Atlantic/Faroe": "Фарерские острова", - "Europe/Guernsey": "Гернси", - "Africa/Dakar": "Дакар", - "Europe/Isle_of_Man": "Остров Мэн", - "Africa/Conakry": "Конакри", - "Africa/Abidjan": "Абиджан", - "Atlantic/Canary": "канарейка", - "Africa/Banjul": "Банжул", - "Europe/Jersey": "Джерси", - "Atlantic/St_Helena": "Остров Святой Елены", - "Africa/Bissau": "Бисау", - "Europe/London": "Лондон", - "Africa/Nouakchott": "Нуакшот", - "Africa/Lome": "Ломе", - "America/Danmarkshavn": "Данмарксхавн", - "Africa/Ouagadougou": "Уагадугу", - "Europe/Lisbon": "Лиссабон", - "Africa/Sao_Tome": "Сан-Томе", - "Africa/Monrovia": "Монровия", - "Atlantic/Reykjavik": "Рейкьявик", - "Antarctica/Troll": "Тролль", - "Atlantic/Madeira": "Мадейра", - "Africa/Bamako": "Бамако", - "Europe/Dublin": "Дублин", - "Africa/Freetown": "Фритаун", - "Europe/Monaco": "Монако", - "Europe/Skopje": "Скопье", - "Europe/Amsterdam": "Амстердам", - "Africa/Tunis": "Тунис", - "Arctic/Longyearbyen": "Лонгйир", - "Africa/Bangui": "Банги", - "Africa/Lagos": "Лагос", - "Africa/Douala": "Дуала", - "Africa/Libreville": "Либревиль", - "Europe/Belgrade": "Белград", - "Europe/Stockholm": "Стокгольм", - "Europe/Berlin": "Берлин", - "Europe/Zurich": "Цюрих", - "Europe/Zagreb": "Загреб", - "Europe/Warsaw": "Варшава", - "Africa/Luanda": "Луанда", - "Africa/Porto-Novo": "Порто-Ново", - "Africa/Brazzaville": "Браззавиль", - "Europe/Vienna": "Вена", - "Europe/Vatican": "Ватикан", - "Europe/Vaduz": "Вадуц", - "Europe/Tirane": "Тиран", - "Europe/Bratislava": "Братислава", - "Europe/Brussels": "Брюссель", - "Europe/Paris": "Париж", - "Europe/Sarajevo": "Сараево", - "Europe/San_Marino": "Сан-Марино", - "Europe/Rome": "Рим", - "Africa/El_Aaiun": "Эль-Аайун", - "Africa/Casablanca": "Касабланка", - "Europe/Malta": "Мальта", - "Africa/Ceuta": "Сеута", - "Europe/Gibraltar": "Гибралтар", - "Africa/Malabo": "Малабо", - "Europe/Busingen": "Бузинген", - "Africa/Ndjamena": "Нджамена", - "Europe/Andorra": "Андорра", - "Europe/Oslo": "Осло", - "Europe/Luxembourg": "Люксембург", - "Africa/Niamey": "Ниамей", - "Europe/Copenhagen": "Копенгаген", - "Europe/Madrid": "Мадрид", - "Europe/Budapest": "Будапешт", - "Africa/Algiers": "Алжир", - "Europe/Ljubljana": "Любляна", - "Europe/Podgorica": "Подгорица", - "Africa/Kinshasa": "Киншаса", - "Europe/Prague": "Прага", - "Europe/Riga": "Рига", - "Africa/Bujumbura": "Бужумбура", - "Africa/Lubumbashi": "Лубумбаши", - "Europe/Bucharest": "Бухарест", - "Africa/Blantyre": "Блантайр", - "Asia/Nicosia": "Никосия", - "Europe/Sofia": "София", - "Asia/Jerusalem": "Иерусалим", - "Europe/Tallinn": "Таллинн", - "Europe/Uzhgorod": "Ужгород", - "Africa/Lusaka": "Лусака", - "Europe/Mariehamn": "Мариехамн", - "Asia/Hebron": "Хеврон", - "Asia/Gaza": "Газа", - "Asia/Damascus": "Дамаск", - "Europe/Zaporozhye": "Запорожье", - "Asia/Beirut": "Бейрут", - "Africa/Juba": "Джуба", - "Africa/Harare": "Хараре", - "Europe/Athens": "Афины", - "Europe/Kiev": "Киев", - "Europe/Kaliningrad": "Калининград", - "Africa/Khartoum": "Хартум", - "Africa/Cairo": "Каир", - "Africa/Kigali": "Кигали", - "Asia/Amman": "Амман", - "Africa/Maputo": "Мапуту", - "Africa/Gaborone": "Габороне", - "Africa/Tripoli": "Триполи", - "Africa/Maseru": "Масеру", - "Africa/Windhoek": "Виндхук", - "Africa/Johannesburg": "Йоханнесбург", - "Europe/Chisinau": "Кишинев", - "Africa/Mbabane": "Мбабане", - "Europe/Vilnius": "Вильнюс", - "Europe/Helsinki": "Хельсинки", - "Europe/Moscow": "Москва", - "Africa/Kampala": "Кампала", - "Africa/Nairobi": "Найроби", - "Africa/Asmara": "Асмэра", - "Europe/Istanbul": "Стамбул", - "Asia/Riyadh": "Эр-Рияд", - "Asia/Qatar": "Катар", - "Europe/Minsk": "Минск", - "Indian/Comoro": "Коморо", - "Asia/Kuwait": "Кувейт", - "Africa/Addis_Ababa": "Аддис-Абеба", - "Africa/Dar_es_Salaam": "Дар-эс-Салам", - "Europe/Volgograd": "Волгоград", - "Indian/Antananarivo": "Антананариву", - "Asia/Bahrain": "Бахрейн", - "Asia/Baghdad": "Багдад", - "Indian/Mayotte": "Майотта", - "Africa/Djibouti": "Джибути", - "Europe/Simferopol": "Симферополь", - "Asia/Aden": "Аден", - "Antarctica/Syowa": "Сёва", - "Africa/Mogadishu": "Могадишо", - "Asia/Tehran": "Тегеран", - "Asia/Yerevan": "Ереван", - "Asia/Tbilisi": "Тбилиси", - "Asia/Muscat": "Мускат", - "Europe/Samara": "Самара", - "Indian/Mahe": "Маэ", - "Asia/Baku": "Баку", - "Indian/Mauritius": "Маврикий", - "Indian/Reunion": "Воссоединение", - "Asia/Dubai": "Дубай", - "Asia/Kabul": "Кабул", - "Asia/Ashgabat": "Ашхабад", - "Antarctica/Mawson": "Моусон", - "Asia/Aqtau": "Актау", - "Asia/Yekaterinburg": "Екатеринбург", - "Asia/Aqtobe": "Актобе", - "Asia/Dushanbe": "Душанбе", - "Asia/Tashkent": "Ташкент", - "Asia/Samarkand": "Самарканд", - "Asia/Qyzylorda": "Кызылорда", - "Asia/Oral": "Оральный", - "Asia/Karachi": "Карачи", - "Indian/Kerguelen": "Кергелен", - "Indian/Maldives": "Мальдивы", - "Asia/Kolkata": "Калькутта", - "Asia/Colombo": "Коломбо", - "Asia/Kathmandu": "Катманду", - "Antarctica/Vostok": "Восток", - "Asia/Almaty": "Алматы", - "Asia/Urumqi": "Урумчи", - "Asia/Thimphu": "Тхимпху", - "Asia/Omsk": "Омск", - "Asia/Dhaka": "Дакка", - "Indian/Chagos": "Чагос", - "Asia/Bishkek": "Бишкек", - "Asia/Rangoon": "Рангун", - "Indian/Cocos": "кокосы", - "Asia/Bangkok": "Бангкок", - "Asia/Hovd": "Ховд", - "Asia/Novokuznetsk": "Новокузнецк", - "Asia/Vientiane": "Вьентьян", - "Asia/Krasnoyarsk": "Красноярск", - "Antarctica/Davis": "Дэвис", - "Asia/Novosibirsk": "Новосибирск", - "Asia/Phnom_Penh": "Пномпень", - "Asia/Pontianak": "Понтианак", - "Asia/Jakarta": "Джакарта", - "Asia/Ho_Chi_Minh": "Хо Ши Мин", - "Indian/Christmas": "Рождество", - "Asia/Manila": "Манила", - "Asia/Makassar": "Макассар", - "Asia/Macau": "Макао", - "Asia/Kuala_Lumpur": "Куала-Лумпур", - "Asia/Singapore": "Сингапур", - "Asia/Shanghai": "Шанхай", - "Asia/Irkutsk": "Иркутск", - "Asia/Kuching": "Кучинг", - "Asia/Hong_Kong": "Гонконг", - "Australia/Perth": "Перт", - "Asia/Taipei": "Тайбэй", - "Asia/Brunei": "Бруней", - "Asia/Choibalsan": "Чойбалсан", - "Asia/Ulaanbaatar": "Улан-Батор", - "Australia/Eucla": "Евкла", - "Asia/Yakutsk": "Якутск", - "Asia/Dili": "Дили", - "Pacific/Palau": "Палау", - "Asia/Jayapura": "Джаяпура", - "Asia/Seoul": "Сеул", - "Asia/Pyongyang": "Пхеньян", - "Asia/Khandyga": "Хандыга", - "Asia/Chita": "Чита", - "Asia/Tokyo": "Токио", - "Australia/Darwin": "Дарвин", - "Pacific/Saipan": "Сайпан", - "Australia/Brisbane": "Брисбен", - "Pacific/Port_Moresby": "Порт-Морсби", - "Pacific/Chuuk": "Чуук", - "Antarctica/DumontDUrville": "Дюмон-д'Юрвиль", - "Pacific/Guam": "Гуам", - "Australia/Lindeman": "Линдеман", - "Asia/Ust-Nera": "Усть-Нера", - "Asia/Vladivostok": "Владивосток", - "Australia/Broken_Hill": "Брокен-Хилл", - "Australia/Adelaide": "Аделаида", - "Asia/Sakhalin": "Сахалин", - "Pacific/Guadalcanal": "Гуадалканал", - "Pacific/Efate": "Эфате", - "Antarctica/Casey": "Кейси", - "Antarctica/Macquarie": "Маккуори", - "Pacific/Kosrae": "Косрае", - "Australia/Sydney": "Сидней", - "Pacific/Noumea": "Нумеа", - "Australia/Melbourne": "Мельбурн", - "Australia/Lord_Howe": "Остров Лорд-Хау", - "Australia/Hobart": "Хобарт", - "Pacific/Pohnpei": "Понпеи", - "Australia/Currie": "Карри", - "Asia/Srednekolymsk": "Среднеколымск", - "Asia/Magadan": "Магадан", - "Pacific/Kwajalein": "Кваджалейн", - "Pacific/Majuro": "Маджуро", - "Pacific/Funafuti": "Фунафути", - "Asia/Anadyr": "Анадырь", - "Pacific/Nauru": "Науру", - "Asia/Kamchatka": "Камчатка", - "Pacific/Fiji": "Фиджи", - "Pacific/Norfolk": "Норфолк", - "Pacific/Tarawa": "Тарава", - "Pacific/Wallis": "Уоллис", - "Pacific/Wake": "Будить", - "Pacific/Tongatapu": "Тонгатапу", - "Antarctica/McMurdo": "МакМердо", - "Pacific/Enderbury": "Эндербери", - "Pacific/Fakaofo": "Факаофо", - "Pacific/Auckland": "Окленд", - "Pacific/Chatham": "Чатем", - "Pacific/Kiritimati": "Киритимати", - "Pacific/Apia": "Апиа", + 'Pacific/Midway': 'Мидуэй', + 'Pacific/Niue': 'Ниуэ', + 'Pacific/Pago_Pago': 'Паго-Паго', + 'America/Adak': 'Адак', + 'Pacific/Honolulu': 'Гонолулу', + 'Pacific/Johnston': 'Джонстон', + 'Pacific/Rarotonga': 'Раротонга', + 'Pacific/Tahiti': 'Таити', + 'US/Hawaii': 'Гавайи', + 'Pacific/Marquesas': 'Маркизские острова', + 'America/Sitka': 'Ситка', + 'America/Anchorage': 'Анкоридж', + 'America/Metlakatla': 'Метлакатла', + 'America/Juneau': 'Джуно', + 'US/Alaska': 'Аляска', + 'America/Nome': 'Ном', + 'America/Yakutat': 'Якутат', + 'Pacific/Gambier': 'Гамбье', + 'America/Tijuana': 'Тихуана', + 'Pacific/Pitcairn': 'Питкэрн', + 'US/Pacific': 'США/Тихий океан', + 'Canada/Pacific': 'США/Тихий океан', + 'America/Los_Angeles': 'Лос-Анджелес', + 'America/Vancouver': 'Ванкувер', + 'America/Santa_Isabel': 'Санта-Изабель', + 'America/Chihuahua': 'Чихуахуа', + 'America/Cambridge_Bay': 'Кембридж-Бэй', + 'America/Inuvik': 'Инувик', + 'America/Boise': 'Бойсе', + 'America/Dawson': 'Доусон', + 'America/Mazatlan': 'Масатлан', + 'America/Dawson_Creek': 'Доусон-Крик', + 'US/Arizona': 'Аризона', + 'America/Denver': 'Денвер', + 'US/Mountain': 'гора', + 'America/Edmonton': 'Эдмонтон', + 'America/Yellowknife': 'Йеллоунайф', + 'America/Ojinaga': 'Охинага', + 'America/Phoenix': 'Феникс', + 'America/Whitehorse': 'Белая лошадь', + 'Canada/Mountain': 'гора', + 'America/Hermosillo': 'Эрмосильо', + 'America/Creston': 'Крестон', + 'America/Swift_Current': 'Свифт Керрент', + 'America/Tegucigalpa': 'Тегусигальпа', + 'America/Regina': 'Регина', + 'America/Rankin_Inlet': 'Ранкин-Инлет', + 'America/Rainy_River': 'Райни-Ривер', + 'America/Winnipeg': 'Виннипег', + 'America/North_Dakota/Center': 'Северная Дакота/Центр', + 'America/North_Dakota/Beulah': 'Северная Дакота/Беула', + 'America/Monterrey': 'Монтеррей', + 'America/Mexico_City': 'Мехико', + 'US/Central': 'Центральный', + 'America/Merida': 'Мерида', + 'America/Menominee': 'Меномини', + 'America/Matamoros': 'Матаморос', + 'America/Managua': 'Манагуа', + 'America/North_Dakota/New_Salem': 'Северная Дакота/Нью-Салем', + 'Pacific/Galapagos': 'Галапагосские острова', + 'America/Indiana/Tell_City': 'Индиана/Телл-Сити', + 'America/Indiana/Knox': 'Индиана/Нокс', + 'Canada/Central': 'Центральный', + 'America/Guatemala': 'Гватемала', + 'America/El_Salvador': 'Сальвадор', + 'America/Costa_Rica': 'Коста-Рика', + 'America/Chicago': 'Чикаго', + 'America/Belize': 'Белиз', + 'America/Bahia_Banderas': 'Баия де Бандерас', + 'America/Resolute': 'Резольют', + 'America/Atikokan': 'Атикокан', + 'America/Lima': 'Лима', + 'America/Bogota': 'Богота', + 'America/Cancun': 'Канкун', + 'America/Cayman': 'Кайман', + 'America/Detroit': 'Детройт', + 'America/Indiana/Indianapolis': 'Индиана/Индианаполис', + 'America/Eirunepe': 'Эйрунепе', + 'America/Grand_Turk': 'Гранд-Терк', + 'America/Guayaquil': 'Гуаякиль', + 'America/Havana': 'Гавана', + 'America/Indiana/Marengo': 'Индиана/Маренго', + 'America/Indiana/Petersburg': 'Индиана/Петербург', + 'America/Indiana/Vevay': 'Индиана/Вева', + 'America/Indiana/Vincennes': 'Индиана/Винсеннес', + 'America/Indiana/Winamac': 'Индиана/Винамак', + 'America/Iqaluit': 'Икалуит', + 'America/Jamaica': 'Ямайка', + 'America/Kentucky/Louisville': 'Кентукки/Луисвилл', + 'America/Nassau': 'Нассау', + 'America/Toronto': 'Торонто', + 'America/Montreal': 'Монреаль', + 'America/Pangnirtung': 'Пангниртунг', + 'America/Port-au-Prince': 'Порт-о-Пренс', + 'America/Kentucky/Monticello': 'Кентукки/Монтичелло', + 'Canada/Eastern': 'Канада/Восточное', + 'US/Eastern': 'США/Восточное', + 'America/Thunder_Bay': 'Тандер-Бей', + 'Pacific/Easter': 'Пасха', + 'America/Panama': 'Панама', + 'America/Nipigon': 'Нипигон', + 'America/Rio_Branco': 'Рио-Бранко', + 'America/New_York': 'Нью-Йорк', + 'Canada/Atlantic': 'Атлантика', + 'America/Kralendijk': 'Кралендейк', + 'America/La_Paz': 'Ла-Пас', + 'America/Halifax': 'Галифакс', + 'America/Lower_Princes': 'Лоуэр-Принс-Куотер', + 'America/Manaus': 'Манаус', + 'America/Marigot': 'Мариго', + 'America/Martinique': 'Мартиника', + 'America/Moncton': 'Монктон', + 'America/Guyana': 'Гайана', + 'America/Montserrat': 'Монтсеррат', + 'America/Guadeloupe': 'Гваделупа', + 'America/Grenada': 'Гренада', + 'America/Goose_Bay': 'Гуз-Бей', + 'America/Glace_Bay': 'Глас Бэй', + 'America/Curacao': 'Кюрасао', + 'America/Cuiaba': 'Куяба', + 'America/Port_of_Spain': 'Порт-оф-Спейн', + 'America/Porto_Velho': 'Порту-Велью', + 'America/Puerto_Rico': 'Пуэрто-Рико', + 'America/Caracas': 'Каракас', + 'America/Santo_Domingo': 'Санто-Доминго', + 'America/St_Barthelemy': 'Святой Бартелеми', + 'Atlantic/Bermuda': 'Бермуды', + 'America/St_Kitts': 'Сент-Китс', + 'America/St_Lucia': 'Святая Люсия', + 'America/St_Thomas': 'Сент-Томас', + 'America/St_Vincent': 'Сент-Винсент', + 'America/Thule': 'Туле', + 'America/Campo_Grande': 'Кампу-Гранди', + 'America/Boa_Vista': 'Боа-Виста', + 'America/Tortola': 'Тортола', + 'America/Aruba': 'Аруба', + 'America/Blanc-Sablon': 'Блан-Саблон', + 'America/Barbados': 'Барбадос', + 'America/Anguilla': 'Ангилья', + 'America/Antigua': 'Антигуа', + 'America/Dominica': 'Доминика', + 'Canada/Newfoundland': 'Ньюфаундленд', + 'America/St_Johns': 'Сент-Джонс', + 'America/Sao_Paulo': 'Сан-Паулу', + 'Atlantic/Stanley': 'Стэнли', + 'America/Miquelon': 'Микелон', + 'America/Argentina/Salta': 'Аргентина/Сальта', + 'America/Montevideo': 'Монтевидео', + 'America/Argentina/Rio_Gallegos': 'Аргентина/Рио-Гальегос', + 'America/Argentina/Mendoza': 'Аргентина/Мендоса', + 'America/Argentina/La_Rioja': 'Аргентина/Ла-Риоха', + 'America/Argentina/Jujuy': 'Аргентина/Жужуй', + 'Antarctica/Rothera': 'Ротера', + 'America/Argentina/Cordoba': 'Аргентина/Кордова', + 'America/Argentina/Catamarca': 'Аргентина/Катамарка', + 'America/Argentina/Ushuaia': 'Аргентина/Ушуая', + 'America/Argentina/Tucuman': 'Аргентина/Тукуман', + 'America/Paramaribo': 'Парамарибо', + 'America/Argentina/San_Luis': 'Аргентина/Сан-Луис', + 'America/Recife': 'Ресифи', + 'America/Argentina/Buenos_Aires': 'Аргентина/Буэнос-Айрес', + 'America/Asuncion': 'Асунсьон', + 'America/Maceio': 'Масейо', + 'America/Santarem': 'Сантарен', + 'America/Santiago': 'Сантьяго', + 'Antarctica/Palmer': 'Палмер', + 'America/Argentina/San_Juan': 'Аргентина/Сан-Хуан', + 'America/Fortaleza': 'Форталеза', + 'America/Cayenne': 'Кайенна', + 'America/Godthab': 'Годтаб', + 'America/Belem': 'Белен', + 'America/Araguaina': 'Арагуайна', + 'America/Bahia': 'Баия', + 'Atlantic/South_Georgia': 'Южная_Грузия', + 'America/Noronha': 'Норонья', + 'Atlantic/Azores': 'Азорские острова', + 'Atlantic/Cape_Verde': 'Кабо-Верде', + 'America/Scoresbysund': 'Скорсбисунд', + 'Africa/Accra': 'Аккра', + 'Atlantic/Faroe': 'Фарерские острова', + 'Europe/Guernsey': 'Гернси', + 'Africa/Dakar': 'Дакар', + 'Europe/Isle_of_Man': 'Остров Мэн', + 'Africa/Conakry': 'Конакри', + 'Africa/Abidjan': 'Абиджан', + 'Atlantic/Canary': 'канарейка', + 'Africa/Banjul': 'Банжул', + 'Europe/Jersey': 'Джерси', + 'Atlantic/St_Helena': 'Остров Святой Елены', + 'Africa/Bissau': 'Бисау', + 'Europe/London': 'Лондон', + 'Africa/Nouakchott': 'Нуакшот', + 'Africa/Lome': 'Ломе', + 'America/Danmarkshavn': 'Данмарксхавн', + 'Africa/Ouagadougou': 'Уагадугу', + 'Europe/Lisbon': 'Лиссабон', + 'Africa/Sao_Tome': 'Сан-Томе', + 'Africa/Monrovia': 'Монровия', + 'Atlantic/Reykjavik': 'Рейкьявик', + 'Antarctica/Troll': 'Тролль', + 'Atlantic/Madeira': 'Мадейра', + 'Africa/Bamako': 'Бамако', + 'Europe/Dublin': 'Дублин', + 'Africa/Freetown': 'Фритаун', + 'Europe/Monaco': 'Монако', + 'Europe/Skopje': 'Скопье', + 'Europe/Amsterdam': 'Амстердам', + 'Africa/Tunis': 'Тунис', + 'Arctic/Longyearbyen': 'Лонгйир', + 'Africa/Bangui': 'Банги', + 'Africa/Lagos': 'Лагос', + 'Africa/Douala': 'Дуала', + 'Africa/Libreville': 'Либревиль', + 'Europe/Belgrade': 'Белград', + 'Europe/Stockholm': 'Стокгольм', + 'Europe/Berlin': 'Берлин', + 'Europe/Zurich': 'Цюрих', + 'Europe/Zagreb': 'Загреб', + 'Europe/Warsaw': 'Варшава', + 'Africa/Luanda': 'Луанда', + 'Africa/Porto-Novo': 'Порто-Ново', + 'Africa/Brazzaville': 'Браззавиль', + 'Europe/Vienna': 'Вена', + 'Europe/Vatican': 'Ватикан', + 'Europe/Vaduz': 'Вадуц', + 'Europe/Tirane': 'Тиран', + 'Europe/Bratislava': 'Братислава', + 'Europe/Brussels': 'Брюссель', + 'Europe/Paris': 'Париж', + 'Europe/Sarajevo': 'Сараево', + 'Europe/San_Marino': 'Сан-Марино', + 'Europe/Rome': 'Рим', + 'Africa/El_Aaiun': 'Эль-Аайун', + 'Africa/Casablanca': 'Касабланка', + 'Europe/Malta': 'Мальта', + 'Africa/Ceuta': 'Сеута', + 'Europe/Gibraltar': 'Гибралтар', + 'Africa/Malabo': 'Малабо', + 'Europe/Busingen': 'Бузинген', + 'Africa/Ndjamena': 'Нджамена', + 'Europe/Andorra': 'Андорра', + 'Europe/Oslo': 'Осло', + 'Europe/Luxembourg': 'Люксембург', + 'Africa/Niamey': 'Ниамей', + 'Europe/Copenhagen': 'Копенгаген', + 'Europe/Madrid': 'Мадрид', + 'Europe/Budapest': 'Будапешт', + 'Africa/Algiers': 'Алжир', + 'Europe/Ljubljana': 'Любляна', + 'Europe/Podgorica': 'Подгорица', + 'Africa/Kinshasa': 'Киншаса', + 'Europe/Prague': 'Прага', + 'Europe/Riga': 'Рига', + 'Africa/Bujumbura': 'Бужумбура', + 'Africa/Lubumbashi': 'Лубумбаши', + 'Europe/Bucharest': 'Бухарест', + 'Africa/Blantyre': 'Блантайр', + 'Asia/Nicosia': 'Никосия', + 'Europe/Sofia': 'София', + 'Asia/Jerusalem': 'Иерусалим', + 'Europe/Tallinn': 'Таллинн', + 'Europe/Uzhgorod': 'Ужгород', + 'Africa/Lusaka': 'Лусака', + 'Europe/Mariehamn': 'Мариехамн', + 'Asia/Hebron': 'Хеврон', + 'Asia/Gaza': 'Газа', + 'Asia/Damascus': 'Дамаск', + 'Europe/Zaporozhye': 'Запорожье', + 'Asia/Beirut': 'Бейрут', + 'Africa/Juba': 'Джуба', + 'Africa/Harare': 'Хараре', + 'Europe/Athens': 'Афины', + 'Europe/Kiev': 'Киев', + 'Europe/Kaliningrad': 'Калининград', + 'Africa/Khartoum': 'Хартум', + 'Africa/Cairo': 'Каир', + 'Africa/Kigali': 'Кигали', + 'Asia/Amman': 'Амман', + 'Africa/Maputo': 'Мапуту', + 'Africa/Gaborone': 'Габороне', + 'Africa/Tripoli': 'Триполи', + 'Africa/Maseru': 'Масеру', + 'Africa/Windhoek': 'Виндхук', + 'Africa/Johannesburg': 'Йоханнесбург', + 'Europe/Chisinau': 'Кишинев', + 'Africa/Mbabane': 'Мбабане', + 'Europe/Vilnius': 'Вильнюс', + 'Europe/Helsinki': 'Хельсинки', + 'Europe/Moscow': 'Москва', + 'Africa/Kampala': 'Кампала', + 'Africa/Nairobi': 'Найроби', + 'Africa/Asmara': 'Асмэра', + 'Europe/Istanbul': 'Стамбул', + 'Asia/Riyadh': 'Эр-Рияд', + 'Asia/Qatar': 'Катар', + 'Europe/Minsk': 'Минск', + 'Indian/Comoro': 'Коморо', + 'Asia/Kuwait': 'Кувейт', + 'Africa/Addis_Ababa': 'Аддис-Абеба', + 'Africa/Dar_es_Salaam': 'Дар-эс-Салам', + 'Europe/Volgograd': 'Волгоград', + 'Indian/Antananarivo': 'Антананариву', + 'Asia/Bahrain': 'Бахрейн', + 'Asia/Baghdad': 'Багдад', + 'Indian/Mayotte': 'Майотта', + 'Africa/Djibouti': 'Джибути', + 'Europe/Simferopol': 'Симферополь', + 'Asia/Aden': 'Аден', + 'Antarctica/Syowa': 'Сёва', + 'Africa/Mogadishu': 'Могадишо', + 'Asia/Tehran': 'Тегеран', + 'Asia/Yerevan': 'Ереван', + 'Asia/Tbilisi': 'Тбилиси', + 'Asia/Muscat': 'Мускат', + 'Europe/Samara': 'Самара', + 'Indian/Mahe': 'Маэ', + 'Asia/Baku': 'Баку', + 'Indian/Mauritius': 'Маврикий', + 'Indian/Reunion': 'Воссоединение', + 'Asia/Dubai': 'Дубай', + 'Asia/Kabul': 'Кабул', + 'Asia/Ashgabat': 'Ашхабад', + 'Antarctica/Mawson': 'Моусон', + 'Asia/Aqtau': 'Актау', + 'Asia/Yekaterinburg': 'Екатеринбург', + 'Asia/Aqtobe': 'Актобе', + 'Asia/Dushanbe': 'Душанбе', + 'Asia/Tashkent': 'Ташкент', + 'Asia/Samarkand': 'Самарканд', + 'Asia/Qyzylorda': 'Кызылорда', + 'Asia/Oral': 'Оральный', + 'Asia/Karachi': 'Карачи', + 'Indian/Kerguelen': 'Кергелен', + 'Indian/Maldives': 'Мальдивы', + 'Asia/Kolkata': 'Калькутта', + 'Asia/Colombo': 'Коломбо', + 'Asia/Kathmandu': 'Катманду', + 'Antarctica/Vostok': 'Восток', + 'Asia/Almaty': 'Алматы', + 'Asia/Urumqi': 'Урумчи', + 'Asia/Thimphu': 'Тхимпху', + 'Asia/Omsk': 'Омск', + 'Asia/Dhaka': 'Дакка', + 'Indian/Chagos': 'Чагос', + 'Asia/Bishkek': 'Бишкек', + 'Asia/Rangoon': 'Рангун', + 'Indian/Cocos': 'кокосы', + 'Asia/Bangkok': 'Бангкок', + 'Asia/Hovd': 'Ховд', + 'Asia/Novokuznetsk': 'Новокузнецк', + 'Asia/Vientiane': 'Вьентьян', + 'Asia/Krasnoyarsk': 'Красноярск', + 'Antarctica/Davis': 'Дэвис', + 'Asia/Novosibirsk': 'Новосибирск', + 'Asia/Phnom_Penh': 'Пномпень', + 'Asia/Pontianak': 'Понтианак', + 'Asia/Jakarta': 'Джакарта', + 'Asia/Ho_Chi_Minh': 'Хо Ши Мин', + 'Indian/Christmas': 'Рождество', + 'Asia/Manila': 'Манила', + 'Asia/Makassar': 'Макассар', + 'Asia/Macau': 'Макао', + 'Asia/Kuala_Lumpur': 'Куала-Лумпур', + 'Asia/Singapore': 'Сингапур', + 'Asia/Shanghai': 'Шанхай', + 'Asia/Irkutsk': 'Иркутск', + 'Asia/Kuching': 'Кучинг', + 'Asia/Hong_Kong': 'Гонконг', + 'Australia/Perth': 'Перт', + 'Asia/Taipei': 'Тайбэй', + 'Asia/Brunei': 'Бруней', + 'Asia/Choibalsan': 'Чойбалсан', + 'Asia/Ulaanbaatar': 'Улан-Батор', + 'Australia/Eucla': 'Евкла', + 'Asia/Yakutsk': 'Якутск', + 'Asia/Dili': 'Дили', + 'Pacific/Palau': 'Палау', + 'Asia/Jayapura': 'Джаяпура', + 'Asia/Seoul': 'Сеул', + 'Asia/Pyongyang': 'Пхеньян', + 'Asia/Khandyga': 'Хандыга', + 'Asia/Chita': 'Чита', + 'Asia/Tokyo': 'Токио', + 'Australia/Darwin': 'Дарвин', + 'Pacific/Saipan': 'Сайпан', + 'Australia/Brisbane': 'Брисбен', + 'Pacific/Port_Moresby': 'Порт-Морсби', + 'Pacific/Chuuk': 'Чуук', + 'Antarctica/DumontDUrville': "Дюмон-д'Юрвиль", + 'Pacific/Guam': 'Гуам', + 'Australia/Lindeman': 'Линдеман', + 'Asia/Ust-Nera': 'Усть-Нера', + 'Asia/Vladivostok': 'Владивосток', + 'Australia/Broken_Hill': 'Брокен-Хилл', + 'Australia/Adelaide': 'Аделаида', + 'Asia/Sakhalin': 'Сахалин', + 'Pacific/Guadalcanal': 'Гуадалканал', + 'Pacific/Efate': 'Эфате', + 'Antarctica/Casey': 'Кейси', + 'Antarctica/Macquarie': 'Маккуори', + 'Pacific/Kosrae': 'Косрае', + 'Australia/Sydney': 'Сидней', + 'Pacific/Noumea': 'Нумеа', + 'Australia/Melbourne': 'Мельбурн', + 'Australia/Lord_Howe': 'Остров Лорд-Хау', + 'Australia/Hobart': 'Хобарт', + 'Pacific/Pohnpei': 'Понпеи', + 'Australia/Currie': 'Карри', + 'Asia/Srednekolymsk': 'Среднеколымск', + 'Asia/Magadan': 'Магадан', + 'Pacific/Kwajalein': 'Кваджалейн', + 'Pacific/Majuro': 'Маджуро', + 'Pacific/Funafuti': 'Фунафути', + 'Asia/Anadyr': 'Анадырь', + 'Pacific/Nauru': 'Науру', + 'Asia/Kamchatka': 'Камчатка', + 'Pacific/Fiji': 'Фиджи', + 'Pacific/Norfolk': 'Норфолк', + 'Pacific/Tarawa': 'Тарава', + 'Pacific/Wallis': 'Уоллис', + 'Pacific/Wake': 'Будить', + 'Pacific/Tongatapu': 'Тонгатапу', + 'Antarctica/McMurdo': 'МакМердо', + 'Pacific/Enderbury': 'Эндербери', + 'Pacific/Fakaofo': 'Факаофо', + 'Pacific/Auckland': 'Окленд', + 'Pacific/Chatham': 'Чатем', + 'Pacific/Kiritimati': 'Киритимати', + 'Pacific/Apia': 'Апиа', }; diff --git a/lib/ui/pages/server_details/time_zone/time_zone.dart b/lib/ui/pages/server_details/time_zone/time_zone.dart index cdc0fa65..0ae610cf 100644 --- a/lib/ui/pages/server_details/time_zone/time_zone.dart +++ b/lib/ui/pages/server_details/time_zone/time_zone.dart @@ -5,7 +5,7 @@ final List locations = timeZoneDatabase.locations.values.toList() l1.currentTimeZone.offset.compareTo(l2.currentTimeZone.offset)); class SelectTimezone extends StatefulWidget { - SelectTimezone({Key? key}) : super(key: key); + const SelectTimezone({Key? key}) : super(key: key); @override _SelectTimezoneState createState() => _SelectTimezoneState(); @@ -28,7 +28,7 @@ class _SelectTimezoneState extends State { if (index >= 0) { controller.animateTo(60.0 * index, - duration: Duration(milliseconds: 300), curve: Curves.easeIn); + duration: const Duration(milliseconds: 300), curve: Curves.easeIn); } } @@ -41,12 +41,12 @@ class _SelectTimezoneState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: PreferredSize( + appBar: const PreferredSize( + preferredSize: Size.fromHeight(52), child: BrandHeader( title: 'select timezone', hasBackButton: true, ), - preferredSize: Size.fromHeight(52), ), body: ListView( controller: controller, @@ -71,31 +71,31 @@ class _SelectTimezoneState extends State { key, Container( height: 60, - padding: EdgeInsets.symmetric(horizontal: 20), + padding: const EdgeInsets.symmetric(horizontal: 20), + decoration: const BoxDecoration( + border: Border( + bottom: BorderSide( + color: BrandColors.dividerColor, + )), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ BrandText.body1( timezoneName, - style: TextStyle( + style: const TextStyle( fontSize: 16, fontWeight: FontWeight.bold, ), ), BrandText.small( 'GMT ${duration.toDayHourMinuteFormat()} ${area.isNotEmpty ? '($area)' : ''}', - style: TextStyle( + style: const TextStyle( fontSize: 13, )), ], ), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: BrandColors.dividerColor, - )), - ), ), ); }) diff --git a/lib/ui/pages/services/services.dart b/lib/ui/pages/services/services.dart index d2619420..77134124 100644 --- a/lib/ui/pages/services/services.dart +++ b/lib/ui/pages/services/services.dart @@ -21,7 +21,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:selfprivacy/utils/ui_helpers.dart'; import 'package:url_launcher/url_launcher_string.dart'; -import '../rootRoute.dart'; +import '../root_route.dart'; const switchableServices = [ ServiceTypes.passwordManager, @@ -32,7 +32,7 @@ const switchableServices = [ ]; class ServicesPage extends StatefulWidget { - ServicesPage({Key? key}) : super(key: key); + const ServicesPage({Key? key}) : super(key: key); @override _ServicesPageState createState() => _ServicesPageState(); @@ -62,21 +62,21 @@ class _ServicesPageState extends State { return Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'basis.services'.tr(), hasFlashButton: true, ), - preferredSize: Size.fromHeight(52), ), body: ListView( padding: paddingH15V0, children: [ BrandText.body1('services.title'.tr()), - SizedBox(height: 24), - if (!isReady) ...[NotReadyCard(), SizedBox(height: 24)], + const SizedBox(height: 24), + if (!isReady) ...[const NotReadyCard(), const SizedBox(height: 24)], ...ServiceTypes.values .map((t) => Padding( - padding: EdgeInsets.only( + padding: const EdgeInsets.only( bottom: 30, ), child: _Card(serviceType: t), @@ -145,7 +145,7 @@ class _Card extends StatelessWidget { child: Icon(serviceType.icon, size: 30, color: Colors.white), ), if (isReady && switchableService) ...[ - Spacer(), + const Spacer(), Builder( builder: (context) { late bool isActive; @@ -179,9 +179,9 @@ class _Card extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.h2(serviceType.title), - SizedBox(height: 10), + const SizedBox(height: 10), if (serviceType.subdomain != '') Column( children: [ @@ -193,7 +193,7 @@ class _Card extends StatelessWidget { style: linkStyle, ), ), - SizedBox(height: 10), + const SizedBox(height: 10), ], ), if (serviceType == ServiceTypes.mail) @@ -202,12 +202,12 @@ class _Card extends StatelessWidget { domainName, style: linkStyle, ), - SizedBox(height: 10), + const SizedBox(height: 10), ]), BrandText.body2(serviceType.loginInfo), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.body2(serviceType.subtitle), - SizedBox(height: 10), + const SizedBox(height: 10), ], ), if (hasSwitchJob) @@ -282,10 +282,10 @@ class _ServiceDetails extends StatelessWidget { text: 'services.mail.bottom_sheet.1'.tr(args: [domainName]), style: textStyle, ), - WidgetSpan(child: SizedBox(width: 5)), + const WidgetSpan(child: SizedBox(width: 5)), WidgetSpan( child: Padding( - padding: EdgeInsets.only(bottom: 0.8), + padding: const EdgeInsets.only(bottom: 0.8), child: GestureDetector( child: Text( 'services.mail.bottom_sheet.2'.tr(), @@ -321,10 +321,10 @@ class _ServiceDetails extends StatelessWidget { .tr(args: [domainName]), style: textStyle, ), - WidgetSpan(child: SizedBox(width: 5)), + const WidgetSpan(child: SizedBox(width: 5)), WidgetSpan( child: Padding( - padding: EdgeInsets.only(bottom: 0.8), + padding: const EdgeInsets.only(bottom: 0.8), child: GestureDetector( onTap: () => _launchURL('https://password.$domainName'), child: Text( @@ -345,10 +345,10 @@ class _ServiceDetails extends StatelessWidget { text: 'services.video.bottom_sheet.1'.tr(args: [domainName]), style: textStyle, ), - WidgetSpan(child: SizedBox(width: 5)), + const WidgetSpan(child: SizedBox(width: 5)), WidgetSpan( child: Padding( - padding: EdgeInsets.only(bottom: 0.8), + padding: const EdgeInsets.only(bottom: 0.8), child: GestureDetector( onTap: () => _launchURL('https://meet.$domainName'), child: Text( @@ -369,10 +369,10 @@ class _ServiceDetails extends StatelessWidget { text: 'services.cloud.bottom_sheet.1'.tr(args: [domainName]), style: textStyle, ), - WidgetSpan(child: SizedBox(width: 5)), + const WidgetSpan(child: SizedBox(width: 5)), WidgetSpan( child: Padding( - padding: EdgeInsets.only(bottom: 0.8), + padding: const EdgeInsets.only(bottom: 0.8), child: GestureDetector( onTap: () => _launchURL('https://cloud.$domainName'), child: Text( @@ -394,10 +394,10 @@ class _ServiceDetails extends StatelessWidget { .tr(args: [domainName]), style: textStyle, ), - WidgetSpan(child: SizedBox(width: 5)), + const WidgetSpan(child: SizedBox(width: 5)), WidgetSpan( child: Padding( - padding: EdgeInsets.only(bottom: 0.8), + padding: const EdgeInsets.only(bottom: 0.8), child: GestureDetector( onTap: () => _launchURL('https://social.$domainName'), child: Text( @@ -418,10 +418,10 @@ class _ServiceDetails extends StatelessWidget { text: 'services.git.bottom_sheet.1'.tr(args: [domainName]), style: textStyle, ), - WidgetSpan(child: SizedBox(width: 5)), + const WidgetSpan(child: SizedBox(width: 5)), WidgetSpan( child: Padding( - padding: EdgeInsets.only(bottom: 0.8), + padding: const EdgeInsets.only(bottom: 0.8), child: GestureDetector( onTap: () => _launchURL('https://git.$domainName'), child: Text( @@ -445,7 +445,7 @@ class _ServiceDetails extends StatelessWidget { borderRadius: BorderRadius.circular(20), ), child: SingleChildScrollView( - child: Container( + child: SizedBox( width: 350, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -459,11 +459,11 @@ class _ServiceDetails extends StatelessWidget { status: status, child: Icon(icon, size: 40, color: Colors.white), ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.h2(title), - SizedBox(height: 10), + const SizedBox(height: 10), child, - SizedBox(height: 40), + const SizedBox(height: 40), Center( child: Container( child: BrandButton.rised( diff --git a/lib/ui/pages/setup/initializing.dart b/lib/ui/pages/setup/initializing.dart index 0b99c761..5121ac36 100644 --- a/lib/ui/pages/setup/initializing.dart +++ b/lib/ui/pages/setup/initializing.dart @@ -16,7 +16,7 @@ import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; 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/progress_bar/progress_bar.dart'; -import 'package:selfprivacy/ui/pages/rootRoute.dart'; +import 'package:selfprivacy/ui/pages/root_route.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recovery_routing.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart'; @@ -26,7 +26,7 @@ class InitializingPage extends StatelessWidget { var cubit = context.watch(); if (cubit.state is ServerInstallationRecovery) { - return RecoveryRouting(); + return const RecoveryRouting(); } else { var actualInitializingPage = [ () => _stepHetzner(cubit), @@ -38,13 +38,14 @@ class InitializingPage extends StatelessWidget { () => _stepCheck(cubit), () => _stepCheck(cubit), () => _stepCheck(cubit), - () => Container(child: Center(child: Text('initializing.finish'.tr()))) + () => Center(child: Text('initializing.finish'.tr())) ][cubit.state.progress.index](); return BlocListener( listener: (context, state) { if (cubit.state is ServerInstallationFinished) { - Navigator.of(context).pushReplacement(materialRoute(RootPage())); + Navigator.of(context) + .pushReplacement(materialRoute(const RootPage())); } }, child: SafeArea( @@ -56,11 +57,11 @@ class InitializingPage extends StatelessWidget { Padding( padding: paddingH15V0.copyWith(top: 10, bottom: 10), child: cubit.state.isFullyInitilized - ? SizedBox( + ? const SizedBox( height: 80, ) : ProgressBar( - steps: [ + steps: const [ 'Hetzner', 'CloudFlare', 'Backblaze', @@ -74,7 +75,7 @@ class InitializingPage extends StatelessWidget { ), _addCard( AnimatedSwitcher( - duration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), child: actualInitializingPage, ), ), @@ -96,7 +97,7 @@ class InitializingPage extends StatelessWidget { : 'basis.later'.tr(), onPressed: () { Navigator.of(context).pushAndRemoveUntil( - materialRoute(RootPage()), + materialRoute(const RootPage()), (predicate) => false, ); }, @@ -109,8 +110,8 @@ class InitializingPage extends StatelessWidget { child: BrandButton.text( title: 'basis.connect_to_existing'.tr(), onPressed: () { - Navigator.of(context).push( - materialRoute(RecoveryRouting())); + Navigator.of(context).push(materialRoute( + const RecoveryRouting())); }, ), ) @@ -137,30 +138,30 @@ class InitializingPage extends StatelessWidget { 'assets/images/logos/hetzner.png', width: 150, ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.h2('initializing.1'.tr()), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.body2('initializing.2'.tr()), - Spacer(), + const Spacer(), CubitFormTextField( formFieldCubit: context.read().apiKey, textAlign: TextAlign.center, - scrollPadding: EdgeInsets.only(bottom: 70), - decoration: InputDecoration( + scrollPadding: const EdgeInsets.only(bottom: 70), + decoration: const InputDecoration( hintText: 'Hetzner API Token', ), ), - Spacer(), + const Spacer(), BrandButton.rised( onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), text: 'basis.connect'.tr(), ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandButton.text( onPressed: () => - _showModal(context, _HowTo(fileName: 'how_hetzner')), + _showModal(context, const _HowTo(fileName: 'how_hetzner')), title: 'initializing.how'.tr(), ), ], @@ -193,31 +194,31 @@ class InitializingPage extends StatelessWidget { 'assets/images/logos/cloudflare.png', width: 150, ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.h2('initializing.3'.tr()), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.body2('initializing.4'.tr()), - Spacer(), + const Spacer(), CubitFormTextField( formFieldCubit: context.read().apiKey, textAlign: TextAlign.center, - scrollPadding: EdgeInsets.only(bottom: 70), + scrollPadding: const EdgeInsets.only(bottom: 70), decoration: InputDecoration( hintText: 'initializing.5'.tr(), ), ), - Spacer(), + const Spacer(), BrandButton.rised( onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), text: 'basis.connect'.tr(), ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandButton.text( onPressed: () => _showModal( context, - _HowTo( + const _HowTo( fileName: 'how_cloudflare', )), title: 'initializing.how'.tr(), @@ -240,39 +241,39 @@ class InitializingPage extends StatelessWidget { 'assets/images/logos/backblaze.png', height: 50, ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.h2('initializing.6'.tr()), - SizedBox(height: 10), - Spacer(), + const SizedBox(height: 10), + const Spacer(), CubitFormTextField( formFieldCubit: context.read().keyId, textAlign: TextAlign.center, - scrollPadding: EdgeInsets.only(bottom: 70), - decoration: InputDecoration( + scrollPadding: const EdgeInsets.only(bottom: 70), + decoration: const InputDecoration( hintText: 'KeyID', ), ), - Spacer(), + const Spacer(), CubitFormTextField( formFieldCubit: context.read().applicationKey, textAlign: TextAlign.center, - scrollPadding: EdgeInsets.only(bottom: 70), - decoration: InputDecoration( + scrollPadding: const EdgeInsets.only(bottom: 70), + decoration: const InputDecoration( hintText: 'Master Application Key', ), ), - Spacer(), + const Spacer(), BrandButton.rised( onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), text: 'basis.connect'.tr(), ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandButton.text( onPressed: () => _showModal( context, - _HowTo( + const _HowTo( fileName: 'how_backblaze', )), title: 'initializing.how'.tr(), @@ -295,9 +296,9 @@ class InitializingPage extends StatelessWidget { 'assets/images/logos/cloudflare.png', width: 150, ), - SizedBox(height: 30), + const SizedBox(height: 30), BrandText.h2('basis.domain'.tr()), - SizedBox(height: 10), + const SizedBox(height: 10), if (state is Empty) BrandText.body2('initializing.7'.tr()), if (state is Loading) BrandText.body2( @@ -310,7 +311,7 @@ class InitializingPage extends StatelessWidget { 'initializing.9'.tr(), ), if (state is Loaded) ...[ - SizedBox(height: 10), + const SizedBox(height: 10), Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, @@ -318,18 +319,18 @@ class InitializingPage extends StatelessWidget { children: [ Expanded( child: BrandText.h3( - '${state.domain}', + state.domain, textAlign: TextAlign.center, ), ), - Container( + SizedBox( width: 50, child: BrandButton.rised( onPressed: () => context.read().load(), child: Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, - children: [ + children: const [ Icon( Icons.refresh, color: Colors.white, @@ -342,30 +343,30 @@ class InitializingPage extends StatelessWidget { ) ], if (state is Empty) ...[ - SizedBox(height: 30), + const SizedBox(height: 30), BrandButton.rised( onPressed: () => context.read().load(), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon( + const Icon( Icons.refresh, color: Colors.white, ), - SizedBox(width: 10), + const SizedBox(width: 10), BrandText.buttonTitleText('Обновить cписок'), ], ), ), ], if (state is Loaded) ...[ - SizedBox(height: 30), + const SizedBox(height: 30), BrandButton.rised( onPressed: () => context.read().saveDomain(), text: 'initializing.10'.tr(), ), ], - SizedBox( + const SizedBox( height: 10, width: double.infinity, ), @@ -386,18 +387,18 @@ class InitializingPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ BrandText.h2('initializing.22'.tr()), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.body2('initializing.23'.tr()), - Spacer(), + const Spacer(), CubitFormTextField( formFieldCubit: context.read().userName, textAlign: TextAlign.center, - scrollPadding: EdgeInsets.only(bottom: 70), + scrollPadding: const EdgeInsets.only(bottom: 70), decoration: InputDecoration( hintText: 'basis.nickname'.tr(), ), ), - SizedBox(height: 10), + const SizedBox(height: 10), BlocBuilder, FieldCubitState>( bloc: context.read().isVisible, builder: (context, state) { @@ -406,7 +407,7 @@ class InitializingPage extends StatelessWidget { obscureText: !isVisible, formFieldCubit: context.read().password, textAlign: TextAlign.center, - scrollPadding: EdgeInsets.only(bottom: 70), + scrollPadding: const EdgeInsets.only(bottom: 70), decoration: InputDecoration( hintText: 'basis.password'.tr(), suffixIcon: IconButton( @@ -418,14 +419,14 @@ class InitializingPage extends StatelessWidget { .isVisible .setValue(!isVisible), ), - suffixIconConstraints: BoxConstraints(minWidth: 60), - prefixIconConstraints: BoxConstraints(maxWidth: 85), + suffixIconConstraints: const BoxConstraints(minWidth: 60), + prefixIconConstraints: const BoxConstraints(maxWidth: 85), prefixIcon: Container(), ), ); }, ), - Spacer(), + const Spacer(), BrandButton.rised( onPressed: formCubitState.isSubmitting ? null @@ -445,11 +446,11 @@ class InitializingPage extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Spacer(flex: 2), + const Spacer(flex: 2), BrandText.h2('initializing.final'.tr()), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.body2('initializing.11'.tr()), - Spacer(), + const Spacer(), BrandButton.rised( onPressed: isLoading ? null @@ -484,14 +485,14 @@ class InitializingPage extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: 15), + const SizedBox(height: 15), BrandText.h4( - 'initializing.checks'.tr(args: [doneCount.toString(), "4"]), + 'initializing.checks'.tr(args: [doneCount.toString(), '4']), ), - Spacer(flex: 2), - SizedBox(height: 10), + const Spacer(flex: 2), + const SizedBox(height: 10), BrandText.body2(text), - SizedBox(height: 10), + const SizedBox(height: 10), if (doneCount == 0 && state.dnsMatches != null) Column( children: state.dnsMatches!.entries.map((entry) { @@ -499,15 +500,16 @@ class InitializingPage extends StatelessWidget { var isCorrect = entry.value; return Row( children: [ - if (isCorrect) Icon(Icons.check, color: Colors.green), - if (!isCorrect) Icon(Icons.schedule, color: Colors.amber), - SizedBox(width: 10), + if (isCorrect) const Icon(Icons.check, color: Colors.green), + if (!isCorrect) + const Icon(Icons.schedule, color: Colors.amber), + const SizedBox(width: 10), Text(domain), ], ); }).toList(), ), - SizedBox(height: 10), + const SizedBox(height: 10), if (!state.isLoading) Row( children: [ diff --git a/lib/ui/pages/setup/recovering/recover_by_new_device_key.dart b/lib/ui/pages/setup/recovering/recover_by_new_device_key.dart index de5112e2..7496ef37 100644 --- a/lib/ui/pages/setup/recovering/recover_by_new_device_key.dart +++ b/lib/ui/pages/setup/recovering/recover_by_new_device_key.dart @@ -1,7 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/recovering/recovery_device_form_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart'; +import 'package:selfprivacy/ui/components/brand_button/filled_button.dart'; import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:cubit_form/cubit_form.dart'; @@ -9,20 +9,22 @@ import 'package:selfprivacy/logic/cubit/server_installation/server_installation_ import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart'; class RecoverByNewDeviceKeyInstruction extends StatelessWidget { + const RecoverByNewDeviceKeyInstruction({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BrandHeroScreen( - heroTitle: "recovering.recovery_main_header".tr(), - heroSubtitle: "recovering.method_device_description".tr(), + heroTitle: 'recovering.recovery_main_header'.tr(), + heroSubtitle: 'recovering.method_device_description'.tr(), hasBackButton: true, hasFlashButton: false, onBackButtonPressed: () => context.read().revertRecoveryStep(), children: [ FilledButton( - title: "recovering.method_device_button".tr(), + title: 'recovering.method_device_button'.tr(), onPressed: () => Navigator.of(context) - .push(materialRoute(RecoverByNewDeviceKeyInput())), + .push(materialRoute(const RecoverByNewDeviceKeyInput())), ) ], ); @@ -30,6 +32,8 @@ class RecoverByNewDeviceKeyInstruction extends StatelessWidget { } class RecoverByNewDeviceKeyInput extends StatelessWidget { + const RecoverByNewDeviceKeyInput({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var appConfig = context.watch(); @@ -43,7 +47,7 @@ class RecoverByNewDeviceKeyInput extends StatelessWidget { child: BlocListener( listener: (context, state) { if (state is ServerInstallationRecovery && - state.currentStep != RecoveryStep.NewDeviceKey) { + state.currentStep != RecoveryStep.newDeviceKey) { Navigator.of(context).pop(); } }, @@ -52,8 +56,8 @@ class RecoverByNewDeviceKeyInput extends StatelessWidget { var formCubitState = context.watch().state; return BrandHeroScreen( - heroTitle: "recovering.recovery_main_header".tr(), - heroSubtitle: "recovering.method_device_input_description".tr(), + heroTitle: 'recovering.recovery_main_header'.tr(), + heroSubtitle: 'recovering.method_device_input_description'.tr(), hasBackButton: true, hasFlashButton: false, children: [ @@ -61,14 +65,14 @@ class RecoverByNewDeviceKeyInput extends StatelessWidget { formFieldCubit: context.read().tokenField, decoration: InputDecoration( - border: OutlineInputBorder(), + border: const OutlineInputBorder(), labelText: - "recovering.method_device_input_placeholder".tr(), + 'recovering.method_device_input_placeholder'.tr(), ), ), - SizedBox(height: 16), + const SizedBox(height: 16), FilledButton( - title: "more.continue".tr(), + title: 'more.continue'.tr(), onPressed: formCubitState.isSubmitting ? null : () => diff --git a/lib/ui/pages/setup/recovering/recover_by_old_token.dart b/lib/ui/pages/setup/recovering/recover_by_old_token.dart index 363519c9..ea267a39 100644 --- a/lib/ui/pages/setup/recovering/recover_by_old_token.dart +++ b/lib/ui/pages/setup/recovering/recover_by_old_token.dart @@ -1,7 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/recovering/recovery_device_form_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart'; +import 'package:selfprivacy/ui/components/brand_button/filled_button.dart'; import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; import 'package:cubit_form/cubit_form.dart'; @@ -10,19 +10,20 @@ import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart class RecoverByOldTokenInstruction extends StatelessWidget { @override - RecoverByOldTokenInstruction({required this.instructionFilename}); + const RecoverByOldTokenInstruction({required this.instructionFilename}); + @override Widget build(BuildContext context) { return BlocListener( listener: (context, state) { if (state is ServerInstallationRecovery && - state.currentStep != RecoveryStep.Selecting) { + state.currentStep != RecoveryStep.selecting) { Navigator.of(context).pop(); Navigator.of(context).pop(); } }, child: BrandHeroScreen( - heroTitle: "recovering.recovery_main_header".tr(), + heroTitle: 'recovering.recovery_main_header'.tr(), hasBackButton: true, hasFlashButton: false, onBackButtonPressed: () => @@ -31,9 +32,9 @@ class RecoverByOldTokenInstruction extends StatelessWidget { BrandMarkdown( fileName: instructionFilename, ), - SizedBox(height: 18), + const SizedBox(height: 18), FilledButton( - title: "recovering.method_device_button".tr(), + title: 'recovering.method_device_button'.tr(), onPressed: () => context .read() .selectRecoveryMethod(ServerRecoveryMethods.oldToken), @@ -47,6 +48,8 @@ class RecoverByOldTokenInstruction extends StatelessWidget { } class RecoverByOldToken extends StatelessWidget { + const RecoverByOldToken({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var appConfig = context.watch(); @@ -62,8 +65,8 @@ class RecoverByOldToken extends StatelessWidget { var formCubitState = context.watch().state; return BrandHeroScreen( - heroTitle: "recovering.recovery_main_header".tr(), - heroSubtitle: "recovering.method_device_input_description".tr(), + heroTitle: 'recovering.recovery_main_header'.tr(), + heroSubtitle: 'recovering.method_device_input_description'.tr(), hasBackButton: true, hasFlashButton: false, children: [ @@ -71,13 +74,13 @@ class RecoverByOldToken extends StatelessWidget { formFieldCubit: context.read().tokenField, decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: "recovering.method_device_input_placeholder".tr(), + border: const OutlineInputBorder(), + labelText: 'recovering.method_device_input_placeholder'.tr(), ), ), - SizedBox(height: 18), + const SizedBox(height: 18), FilledButton( - title: "more.continue".tr(), + title: 'more.continue'.tr(), onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), diff --git a/lib/ui/pages/setup/recovering/recover_by_recovery_key.dart b/lib/ui/pages/setup/recovering/recover_by_recovery_key.dart index 34969b25..c9bd2439 100644 --- a/lib/ui/pages/setup/recovering/recover_by_recovery_key.dart +++ b/lib/ui/pages/setup/recovering/recover_by_recovery_key.dart @@ -4,10 +4,12 @@ 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/filled_button.dart'; import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart'; class RecoverByRecoveryKey extends StatelessWidget { + const RecoverByRecoveryKey({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var appConfig = context.watch(); @@ -23,8 +25,8 @@ class RecoverByRecoveryKey extends StatelessWidget { var formCubitState = context.watch().state; return BrandHeroScreen( - heroTitle: "recovering.recovery_main_header".tr(), - heroSubtitle: "recovering.method_recovery_input_description".tr(), + heroTitle: 'recovering.recovery_main_header'.tr(), + heroSubtitle: 'recovering.method_recovery_input_description'.tr(), hasBackButton: true, hasFlashButton: false, onBackButtonPressed: () => @@ -34,13 +36,13 @@ class RecoverByRecoveryKey extends StatelessWidget { formFieldCubit: context.read().tokenField, decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: "recovering.method_device_input_placeholder".tr(), + border: const OutlineInputBorder(), + labelText: 'recovering.method_device_input_placeholder'.tr(), ), ), - SizedBox(height: 16), + const SizedBox(height: 16), FilledButton( - title: "more.continue".tr(), + title: 'more.continue'.tr(), onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart b/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart index 6c1779e1..63e3a019 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart @@ -10,6 +10,8 @@ import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.da import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; class RecoveryConfirmBackblaze extends StatelessWidget { + const RecoveryConfirmBackblaze({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var appConfig = context.watch(); @@ -20,17 +22,17 @@ class RecoveryConfirmBackblaze extends StatelessWidget { var formCubitState = context.watch().state; return BrandHeroScreen( - heroTitle: "recovering.confirm_backblaze".tr(), - heroSubtitle: "recovering.confirm_backblaze_description".tr(), + heroTitle: 'recovering.confirm_backblaze'.tr(), + heroSubtitle: 'recovering.confirm_backblaze_description'.tr(), hasBackButton: true, hasFlashButton: false, children: [ CubitFormTextField( formFieldCubit: context.read().keyId, textAlign: TextAlign.center, - scrollPadding: EdgeInsets.only(bottom: 70), - decoration: InputDecoration( - border: const OutlineInputBorder(), + scrollPadding: const EdgeInsets.only(bottom: 70), + decoration: const InputDecoration( + border: OutlineInputBorder(), hintText: 'KeyID', ), ), @@ -38,9 +40,9 @@ class RecoveryConfirmBackblaze extends StatelessWidget { CubitFormTextField( formFieldCubit: context.read().applicationKey, textAlign: TextAlign.center, - scrollPadding: EdgeInsets.only(bottom: 70), - decoration: InputDecoration( - border: const OutlineInputBorder(), + scrollPadding: const EdgeInsets.only(bottom: 70), + decoration: const InputDecoration( + border: OutlineInputBorder(), hintText: 'Master Application Key', ), ), @@ -58,7 +60,7 @@ class RecoveryConfirmBackblaze extends StatelessWidget { isScrollControlled: true, backgroundColor: Colors.transparent, builder: (BuildContext context) { - return BrandBottomSheet( + return const BrandBottomSheet( isExpended: true, child: Padding( padding: paddingH15V0, diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_cloudflare.dart b/lib/ui/pages/setup/recovering/recovery_confirm_cloudflare.dart index a0966f4f..19dce048 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_cloudflare.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_cloudflare.dart @@ -10,6 +10,8 @@ import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.da import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; class RecoveryConfirmCloudflare extends StatelessWidget { + const RecoveryConfirmCloudflare({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var appConfig = context.watch(); @@ -20,9 +22,9 @@ class RecoveryConfirmCloudflare extends StatelessWidget { var formCubitState = context.watch().state; return BrandHeroScreen( - heroTitle: "recovering.confirm_cloudflare".tr(), - heroSubtitle: "recovering.confirm_cloudflare_description".tr(args: [ - appConfig.state.serverDomain?.domainName ?? "your domain" + heroTitle: 'recovering.confirm_cloudflare'.tr(), + heroSubtitle: 'recovering.confirm_cloudflare_description'.tr(args: [ + appConfig.state.serverDomain?.domainName ?? 'your domain' ]), hasBackButton: true, hasFlashButton: false, @@ -30,7 +32,7 @@ class RecoveryConfirmCloudflare extends StatelessWidget { CubitFormTextField( formFieldCubit: context.read().apiKey, textAlign: TextAlign.center, - scrollPadding: EdgeInsets.only(bottom: 70), + scrollPadding: const EdgeInsets.only(bottom: 70), decoration: InputDecoration( border: const OutlineInputBorder(), hintText: 'initializing.5'.tr(), @@ -50,7 +52,7 @@ class RecoveryConfirmCloudflare extends StatelessWidget { isScrollControlled: true, backgroundColor: Colors.transparent, builder: (BuildContext context) { - return BrandBottomSheet( + return const BrandBottomSheet( isExpended: true, child: Padding( padding: paddingH15V0, diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_server.dart b/lib/ui/pages/setup/recovering/recovery_confirm_server.dart index 8a5c45c3..0f03090e 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_server.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_server.dart @@ -1,9 +1,8 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart'; -import 'package:selfprivacy/logic/models/json/hetzner_server_info.dart'; import 'package:selfprivacy/logic/models/server_basic_info.dart'; -import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart'; +import 'package:selfprivacy/ui/components/brand_button/filled_button.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'; @@ -75,7 +74,7 @@ class _RecoveryConfirmServerState extends State { ], ); } else { - return Center( + return const Center( child: CircularProgressIndicator(), ); } @@ -90,26 +89,24 @@ class _RecoveryConfirmServerState extends State { ServerBasicInfoWithValidators server, bool showMoreServersButton, ) { - return Container( - child: Column( - children: [ - _ServerCard( - context: context, - server: server, + return Column( + children: [ + _ServerCard( + context: context, + server: server, + ), + const SizedBox(height: 16), + FilledButton( + title: 'recovering.confirm_server_accept'.tr(), + onPressed: () => _showConfirmationDialog(context, server), + ), + const SizedBox(height: 16), + if (showMoreServersButton) + BrandButton.text( + title: 'recovering.confirm_server_decline'.tr(), + onPressed: () => setState(() => _isExtended = true), ), - SizedBox(height: 16), - FilledButton( - title: 'recovering.confirm_server_accept'.tr(), - onPressed: () => _showConfirmationDialog(context, server), - ), - SizedBox(height: 16), - if (showMoreServersButton) - BrandButton.text( - title: 'recovering.confirm_server_decline'.tr(), - onPressed: () => setState(() => _isExtended = true), - ), - ], - ), + ], ); } @@ -138,7 +135,7 @@ class _RecoveryConfirmServerState extends State { child: ListTile( onTap: onTap, title: Text(server.name), - leading: Icon(Icons.dns), + leading: const Icon(Icons.dns), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/ui/pages/setup/recovering/recovery_hentzner_connected.dart b/lib/ui/pages/setup/recovering/recovery_hentzner_connected.dart index f49eb982..04093aed 100644 --- a/lib/ui/pages/setup/recovering/recovery_hentzner_connected.dart +++ b/lib/ui/pages/setup/recovering/recovery_hentzner_connected.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/config/brand_theme.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/initializing/hetzner_form_cubit.dart'; import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart'; -import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart'; +import 'package:selfprivacy/ui/components/brand_button/filled_button.dart'; import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart'; import 'package:cubit_form/cubit_form.dart'; @@ -11,6 +11,8 @@ import 'package:selfprivacy/logic/cubit/server_installation/server_installation_ import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; class RecoveryHetznerConnected extends StatelessWidget { + const RecoveryHetznerConnected({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var appConfig = context.watch(); @@ -22,9 +24,9 @@ class RecoveryHetznerConnected extends StatelessWidget { var formCubitState = context.watch().state; return BrandHeroScreen( - heroTitle: "recovering.hetzner_connected".tr(), - heroSubtitle: "recovering.hetzner_connected_description".tr(args: [ - appConfig.state.serverDomain?.domainName ?? "your domain" + heroTitle: 'recovering.hetzner_connected'.tr(), + heroSubtitle: 'recovering.hetzner_connected_description'.tr(args: [ + appConfig.state.serverDomain?.domainName ?? 'your domain' ]), hasBackButton: true, hasFlashButton: false, @@ -32,18 +34,18 @@ class RecoveryHetznerConnected extends StatelessWidget { CubitFormTextField( formFieldCubit: context.read().apiKey, decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: "recovering.hetzner_connected_placeholder".tr(), + border: const OutlineInputBorder(), + labelText: 'recovering.hetzner_connected_placeholder'.tr(), ), ), - SizedBox(height: 16), + const SizedBox(height: 16), FilledButton( - title: "more.continue".tr(), + title: 'more.continue'.tr(), onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), ), - SizedBox(height: 16), + const SizedBox(height: 16), BrandButton.text( title: 'initializing.how'.tr(), onPressed: () => showModalBottomSheet( @@ -51,7 +53,7 @@ class RecoveryHetznerConnected extends StatelessWidget { isScrollControlled: true, backgroundColor: Colors.transparent, builder: (BuildContext context) { - return BrandBottomSheet( + return const BrandBottomSheet( isExpended: true, child: Padding( padding: paddingH15V0, diff --git a/lib/ui/pages/setup/recovering/recovery_method_select.dart b/lib/ui/pages/setup/recovering/recovery_method_select.dart index 57c336b8..ed768c5a 100644 --- a/lib/ui/pages/setup/recovering/recovery_method_select.dart +++ b/lib/ui/pages/setup/recovering/recovery_method_select.dart @@ -8,42 +8,44 @@ import 'package:selfprivacy/ui/pages/setup/recovering/recover_by_old_token.dart' import 'package:selfprivacy/utils/route_transitions/basic.dart'; class RecoveryMethodSelect extends StatelessWidget { + const RecoveryMethodSelect({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BrandHeroScreen( - heroTitle: "recovering.recovery_main_header".tr(), - heroSubtitle: "recovering.method_select_description".tr(), + 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(), + 'recovering.method_select_other_device'.tr(), style: Theme.of(context).textTheme.titleMedium, ), - leading: Icon(Icons.offline_share_outlined), + leading: const Icon(Icons.offline_share_outlined), onTap: () => context .read() .selectRecoveryMethod(ServerRecoveryMethods.newDeviceKey), ), ), - SizedBox(height: 16), + const SizedBox(height: 16), BrandCards.outlined( child: ListTile( title: Text( - "recovering.method_select_recovery_key".tr(), + 'recovering.method_select_recovery_key'.tr(), style: Theme.of(context).textTheme.titleMedium, ), - leading: Icon(Icons.password_outlined), + leading: const Icon(Icons.password_outlined), onTap: () => context .read() .selectRecoveryMethod(ServerRecoveryMethods.recoveryKey), ), ), - SizedBox(height: 16), + const SizedBox(height: 16), BrandButton.text( - title: "recovering.method_select_nothing".tr(), + title: 'recovering.method_select_nothing'.tr(), onPressed: () => Navigator.of(context) .push(materialRoute(RecoveryFallbackMethodSelect())), ) @@ -53,55 +55,57 @@ class RecoveryMethodSelect extends StatelessWidget { } class RecoveryFallbackMethodSelect extends StatelessWidget { + const RecoveryFallbackMethodSelect({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BrandHeroScreen( - heroTitle: "recovering.recovery_main_header".tr(), - heroSubtitle: "recovering.fallback_select_description".tr(), + heroTitle: 'recovering.recovery_main_header'.tr(), + heroSubtitle: 'recovering.fallback_select_description'.tr(), hasBackButton: true, hasFlashButton: false, children: [ BrandCards.outlined( child: ListTile( title: Text( - "recovering.fallback_select_token_copy".tr(), + 'recovering.fallback_select_token_copy'.tr(), style: Theme.of(context).textTheme.titleMedium, ), - leading: Icon(Icons.vpn_key), + leading: const Icon(Icons.vpn_key), onTap: () => Navigator.of(context) - .push(materialRoute(RecoverByOldTokenInstruction( + .push(materialRoute(const RecoverByOldTokenInstruction( instructionFilename: 'how_fallback_old', ))), ), ), - SizedBox(height: 16), + const SizedBox(height: 16), BrandCards.outlined( child: ListTile( title: Text( - "recovering.fallback_select_root_ssh".tr(), + 'recovering.fallback_select_root_ssh'.tr(), style: Theme.of(context).textTheme.titleMedium, ), - leading: Icon(Icons.terminal), + leading: const Icon(Icons.terminal), onTap: () => Navigator.of(context) - .push(materialRoute(RecoverByOldTokenInstruction( + .push(materialRoute(const RecoverByOldTokenInstruction( instructionFilename: 'how_fallback_ssh', ))), ), ), - SizedBox(height: 16), + const SizedBox(height: 16), BrandCards.outlined( child: ListTile( title: Text( - "recovering.fallback_select_provider_console".tr(), + 'recovering.fallback_select_provider_console'.tr(), style: Theme.of(context).textTheme.titleMedium, ), subtitle: Text( - "recovering.fallback_select_provider_console_hint".tr(), + 'recovering.fallback_select_provider_console_hint'.tr(), style: Theme.of(context).textTheme.bodyMedium, ), - leading: Icon(Icons.web), + leading: const Icon(Icons.web), onTap: () => Navigator.of(context) - .push(materialRoute(RecoverByOldTokenInstruction( + .push(materialRoute(const RecoverByOldTokenInstruction( instructionFilename: 'how_fallback_terminal', ))), ), diff --git a/lib/ui/pages/setup/recovering/recovery_routing.dart b/lib/ui/pages/setup/recovering/recovery_routing.dart index 743e4aab..7ce718fd 100644 --- a/lib/ui/pages/setup/recovering/recovery_routing.dart +++ b/lib/ui/pages/setup/recovering/recovery_routing.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/recovering/recovery_domain_form_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/FilledButton.dart'; +import 'package:selfprivacy/ui/components/brand_button/filled_button.dart'; import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recover_by_old_token.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recover_by_recovery_key.dart'; @@ -16,51 +16,56 @@ import 'package:selfprivacy/ui/pages/setup/recovering/recovery_hentzner_connecte import 'package:selfprivacy/ui/pages/setup/recovering/recovery_method_select.dart'; class RecoveryRouting extends StatelessWidget { + const RecoveryRouting({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var serverInstallation = context.watch().state; - Widget currentPage = SelectDomainToRecover(); + Widget currentPage = const SelectDomainToRecover(); if (serverInstallation is ServerInstallationRecovery) { switch (serverInstallation.currentStep) { - case RecoveryStep.Selecting: + case RecoveryStep.selecting: if (serverInstallation.recoveryCapabilities != - ServerRecoveryCapabilities.none) - currentPage = RecoveryMethodSelect(); + ServerRecoveryCapabilities.none) { + currentPage = const RecoveryMethodSelect(); + } break; - case RecoveryStep.RecoveryKey: - currentPage = RecoverByRecoveryKey(); + case RecoveryStep.recoveryKey: + currentPage = const RecoverByRecoveryKey(); break; - case RecoveryStep.NewDeviceKey: + case RecoveryStep.newDeviceKey: currentPage = RecoverByNewDeviceKeyInstruction(); break; - case RecoveryStep.OldToken: + case RecoveryStep.oldToken: currentPage = RecoverByOldToken(); break; - case RecoveryStep.HetznerToken: - currentPage = RecoveryHetznerConnected(); + case RecoveryStep.hetznerToken: + currentPage = const RecoveryHetznerConnected(); break; - case RecoveryStep.ServerSelection: - currentPage = RecoveryConfirmServer(); + case RecoveryStep.serverSelection: + currentPage = const RecoveryConfirmServer(); break; - case RecoveryStep.CloudflareToken: - currentPage = RecoveryConfirmCloudflare(); + case RecoveryStep.cloudflareToken: + currentPage = const RecoveryConfirmCloudflare(); break; - case RecoveryStep.BackblazeToken: - currentPage = RecoveryConfirmBackblaze(); + case RecoveryStep.backblazeToken: + currentPage = const RecoveryConfirmBackblaze(); break; } } return AnimatedSwitcher( - duration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), child: currentPage, ); } } class SelectDomainToRecover extends StatelessWidget { + const SelectDomainToRecover({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var serverInstallation = context.watch(); @@ -75,19 +80,19 @@ class SelectDomainToRecover extends StatelessWidget { return BlocListener( listener: (context, state) { if (state is ServerInstallationRecovery) { - if (state.currentStep == RecoveryStep.Selecting) { + if (state.currentStep == RecoveryStep.selecting) { if (state.recoveryCapabilities == ServerRecoveryCapabilities.none) { context .read() - .setCustomError("recovering.domain_recover_error".tr()); + .setCustomError('recovering.domain_recover_error'.tr()); } } } }, child: BrandHeroScreen( - heroTitle: "recovering.recovery_main_header".tr(), - heroSubtitle: "recovering.domain_recovery_description".tr(), + heroTitle: 'recovering.recovery_main_header'.tr(), + heroSubtitle: 'recovering.domain_recovery_description'.tr(), hasBackButton: true, hasFlashButton: false, onBackButtonPressed: @@ -99,13 +104,13 @@ class SelectDomainToRecover extends StatelessWidget { formFieldCubit: context.read().serverDomainField, decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: "recovering.domain_recover_placeholder".tr(), + border: const OutlineInputBorder(), + labelText: 'recovering.domain_recover_placeholder'.tr(), ), ), - SizedBox(height: 16), + const SizedBox(height: 16), FilledButton( - title: "more.continue".tr(), + title: 'more.continue'.tr(), onPressed: formCubitState.isSubmitting ? null : () => diff --git a/lib/ui/pages/ssh_keys/new_ssh_key.dart b/lib/ui/pages/ssh_keys/new_ssh_key.dart index 4d7a3625..abeda0db 100644 --- a/lib/ui/pages/ssh_keys/new_ssh_key.dart +++ b/lib/ui/pages/ssh_keys/new_ssh_key.dart @@ -3,7 +3,7 @@ part of 'ssh_keys.dart'; class _NewSshKey extends StatelessWidget { final User user; - _NewSshKey(this.user); + const _NewSshKey(this.user); @override Widget build(BuildContext context) { @@ -14,11 +14,11 @@ class _NewSshKey extends StatelessWidget { var jobState = jobCubit.state; if (jobState is JobsStateWithJobs) { var jobs = jobState.jobList; - jobs.forEach((job) { + for (var job in jobs) { if (job is CreateSSHKeyJob && job.user.login == user.login) { user.sshKeys.add(job.publicKey); } - }); + } } return SshFormCubit( jobsCubit: jobCubit, @@ -41,7 +41,7 @@ class _NewSshKey extends StatelessWidget { BrandHeader( title: user.login, ), - SizedBox(width: 14), + const SizedBox(width: 14), Padding( padding: paddingH15V0, child: Column( @@ -55,14 +55,14 @@ class _NewSshKey extends StatelessWidget { ), ), ), - SizedBox(height: 30), + const SizedBox(height: 30), BrandButton.rised( onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), text: 'ssh.create'.tr(), ), - SizedBox(height: 30), + const SizedBox(height: 30), ], ), ), diff --git a/lib/ui/pages/ssh_keys/ssh_keys.dart b/lib/ui/pages/ssh_keys/ssh_keys.dart index 3967bf65..c527a972 100644 --- a/lib/ui/pages/ssh_keys/ssh_keys.dart +++ b/lib/ui/pages/ssh_keys/ssh_keys.dart @@ -21,7 +21,7 @@ part 'new_ssh_key.dart'; class SshKeysPage extends StatefulWidget { final User user; - SshKeysPage({Key? key, required this.user}) : super(key: key); + const SshKeysPage({Key? key, required this.user}) : super(key: key); @override _SshKeysPageState createState() => _SshKeysPageState(); @@ -59,7 +59,7 @@ class _SshKeysPageState extends State { 'ssh.create'.tr(), style: Theme.of(context).textTheme.headline6, ), - leading: Icon(Icons.add_circle_outline_rounded), + leading: const Icon(Icons.add_circle_outline_rounded), onTap: () { showModalBottomSheet( context: context, @@ -73,7 +73,7 @@ class _SshKeysPageState extends State { ); }, ), - Divider(height: 0), + const Divider(height: 0), // show a list of ListTiles with ssh keys // Clicking on one should delete it Column( @@ -108,13 +108,13 @@ class _SshKeysPageState extends State { TextButton( child: Text('basis.cancel'.tr()), onPressed: () { - Navigator.of(context)..pop(); + Navigator.of(context).pop(); }, ), TextButton( child: Text( 'basis.delete'.tr(), - style: TextStyle( + style: const TextStyle( color: BrandColors.red1, ), ), diff --git a/lib/ui/pages/users/empty.dart b/lib/ui/pages/users/empty.dart index e9623403..2e5c5906 100644 --- a/lib/ui/pages/users/empty.dart +++ b/lib/ui/pages/users/empty.dart @@ -12,19 +12,19 @@ class _NoUsers extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon(BrandIcons.users, size: 50, color: BrandColors.grey7), - SizedBox(height: 20), + const Icon(BrandIcons.users, size: 50, color: BrandColors.grey7), + const SizedBox(height: 20), BrandText.h2( 'users.nobody_here'.tr(), - style: TextStyle( + style: const TextStyle( color: BrandColors.grey7, ), ), - SizedBox(height: 10), + const SizedBox(height: 10), BrandText.medium( text, textAlign: TextAlign.center, - style: TextStyle( + style: const TextStyle( color: BrandColors.grey7, ), ), diff --git a/lib/ui/pages/users/fab.dart b/lib/ui/pages/users/fab.dart index d9a5a0ea..e6f0ed29 100644 --- a/lib/ui/pages/users/fab.dart +++ b/lib/ui/pages/users/fab.dart @@ -5,15 +5,15 @@ class _Fab extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: 48.0, height: 48.0, child: RawMaterialButton( fillColor: BrandColors.blue, - shape: CircleBorder(), + shape: const CircleBorder(), elevation: 0.0, highlightElevation: 2, - child: Icon( + child: const Icon( Icons.add, color: Colors.white, size: 34, diff --git a/lib/ui/pages/users/new_user.dart b/lib/ui/pages/users/new_user.dart index 05136b66..9336d5c2 100644 --- a/lib/ui/pages/users/new_user.dart +++ b/lib/ui/pages/users/new_user.dart @@ -16,11 +16,11 @@ class _NewUser extends StatelessWidget { users.addAll(context.read().state.users); if (jobState is JobsStateWithJobs) { var jobs = jobState.jobList; - jobs.forEach((job) { + for (var job in jobs) { if (job is CreateUserJob) { users.add(job.user); } - }); + } } return UserFormCubit( jobsCubit: jobCubit, @@ -43,7 +43,7 @@ class _NewUser extends StatelessWidget { BrandHeader( title: 'users.new_user'.tr(), ), - SizedBox(width: 14), + const SizedBox(width: 14), Padding( padding: paddingH15V0, child: Column( @@ -58,7 +58,7 @@ class _NewUser extends StatelessWidget { ), ), ), - SizedBox(height: 20), + const SizedBox(height: 20), CubitFormTextField( formFieldCubit: context.read().password, decoration: InputDecoration( @@ -67,7 +67,7 @@ class _NewUser extends StatelessWidget { suffixIcon: Padding( padding: const EdgeInsets.only(right: 8), child: IconButton( - icon: Icon( + icon: const Icon( BrandIcons.refresh, color: BrandColors.blue, ), @@ -77,16 +77,16 @@ class _NewUser extends StatelessWidget { ), ), ), - SizedBox(height: 30), + const SizedBox(height: 30), BrandButton.rised( onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), text: 'basis.create'.tr(), ), - SizedBox(height: 40), + const SizedBox(height: 40), Text('users.new_user_info_note'.tr()), - SizedBox(height: 30), + const SizedBox(height: 30), ], ), ), diff --git a/lib/ui/pages/users/user.dart b/lib/ui/pages/users/user.dart index a748a374..c59d53fc 100644 --- a/lib/ui/pages/users/user.dart +++ b/lib/ui/pages/users/user.dart @@ -30,7 +30,7 @@ class _User extends StatelessWidget { shape: BoxShape.circle, ), ), - SizedBox(width: 20), + const SizedBox(width: 20), Flexible( child: isRootUser ? BrandText.h4Underlined(user.login) @@ -38,7 +38,8 @@ class _User extends StatelessWidget { : BrandText.h4(user.login, style: user.isFoundOnServer ? null - : TextStyle(decoration: TextDecoration.lineThrough)), + : const TextStyle( + decoration: TextDecoration.lineThrough)), ), ], ), diff --git a/lib/ui/pages/users/user_details.dart b/lib/ui/pages/users/user_details.dart index 69f3b87e..bd7cbb2d 100644 --- a/lib/ui/pages/users/user_details.dart +++ b/lib/ui/pages/users/user_details.dart @@ -25,7 +25,7 @@ class _UserDetails extends StatelessWidget { height: 200, decoration: BoxDecoration( color: user.color, - borderRadius: BorderRadius.vertical( + borderRadius: const BorderRadius.vertical( top: Radius.circular(20), ), ), @@ -36,7 +36,7 @@ class _UserDetails extends StatelessWidget { Align( alignment: Alignment.centerRight, child: Padding( - padding: EdgeInsets.symmetric( + padding: const EdgeInsets.symmetric( vertical: 4, horizontal: 2, ), @@ -64,13 +64,13 @@ class _UserDetails extends StatelessWidget { TextButton( child: Text('basis.cancel'.tr()), onPressed: () { - Navigator.of(context)..pop(); + Navigator.of(context).pop(); }, ), TextButton( child: Text( 'basis.delete'.tr(), - style: TextStyle( + style: const TextStyle( color: BrandColors.red1, ), ), @@ -89,7 +89,7 @@ class _UserDetails extends StatelessWidget { break; } }, - icon: Icon(Icons.more_vert), + icon: const Icon(Icons.more_vert), itemBuilder: (BuildContext context) => [ // PopupMenuItem( // value: PopupMenuItemType.reset, @@ -101,10 +101,10 @@ class _UserDetails extends StatelessWidget { PopupMenuItem( value: PopupMenuItemType.delete, child: Container( - padding: EdgeInsets.only(left: 5), + padding: const EdgeInsets.only(left: 5), child: Text( 'basis.delete'.tr(), - style: TextStyle(color: BrandColors.red1), + style: const TextStyle(color: BrandColors.red1), ), ), ), @@ -112,9 +112,9 @@ class _UserDetails extends StatelessWidget { ), ), ), - Spacer(), + const Spacer(), Padding( - padding: EdgeInsets.symmetric( + padding: const EdgeInsets.symmetric( vertical: 20, horizontal: 15, ), @@ -129,7 +129,7 @@ class _UserDetails extends StatelessWidget { ], ), ), - SizedBox(height: 20), + const SizedBox(height: 20), Padding( padding: paddingH15V0.copyWith(bottom: 20), child: Column( @@ -145,7 +145,7 @@ class _UserDetails extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: 14), + const SizedBox(height: 14), BrandText.small('basis.password'.tr()), Container( height: 40, @@ -154,21 +154,21 @@ class _UserDetails extends StatelessWidget { ), ], ), - SizedBox(height: 24), - BrandDivider(), - SizedBox(height: 20), + const SizedBox(height: 24), + const BrandDivider(), + const SizedBox(height: 20), ListTile( onTap: () { Navigator.of(context) .push(materialRoute(SshKeysPage(user: user))); }, title: Text('ssh.title'.tr()), - subtitle: user.sshKeys.length > 0 + subtitle: user.sshKeys.isNotEmpty ? Text('ssh.subtitle_with_keys' .tr(args: [user.sshKeys.length.toString()])) : Text('ssh.subtitle_without_keys'.tr()), - trailing: Icon(BrandIcons.key)), - SizedBox(height: 20), + trailing: const Icon(BrandIcons.key)), + const SizedBox(height: 20), ListTile( onTap: () { Share.share( @@ -177,7 +177,7 @@ class _UserDetails extends StatelessWidget { title: Text( 'users.send_registration_data'.tr(), ), - trailing: Icon(BrandIcons.share), + trailing: const Icon(BrandIcons.share), ), ], ), diff --git a/lib/ui/pages/users/users.dart b/lib/ui/pages/users/users.dart index f10a4afa..133dfb16 100644 --- a/lib/ui/pages/users/users.dart +++ b/lib/ui/pages/users/users.dart @@ -74,13 +74,13 @@ class UsersPage extends StatelessWidget { return Scaffold( appBar: PreferredSize( + preferredSize: const Size.fromHeight(52), child: BrandHeader( title: 'basis.users'.tr(), hasFlashButton: true, ), - preferredSize: Size.fromHeight(52), ), - floatingActionButton: isReady ? _Fab() : null, + floatingActionButton: isReady ? const _Fab() : null, body: child, ); } @@ -89,8 +89,8 @@ class UsersPage extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 15), + const Padding( + padding: EdgeInsets.symmetric(horizontal: 15), child: NotReadyCard(), ), Expanded( diff --git a/lib/utils/color_utils.dart b/lib/utils/color_utils.dart index 6785c171..ac0c63ba 100644 --- a/lib/utils/color_utils.dart +++ b/lib/utils/color_utils.dart @@ -6,7 +6,7 @@ Color stringToColor(String string) { return colorPalette[index]; } -var originalColor = Color(0xFFDBD8BD); +var originalColor = const Color(0xFFDBD8BD); var count = 40; var colorPalette = List.generate( count, diff --git a/lib/utils/extensions/duration.dart b/lib/utils/extensions/duration.dart index a81627c0..49fa96b8 100644 --- a/lib/utils/extensions/duration.dart +++ b/lib/utils/extensions/duration.dart @@ -26,7 +26,7 @@ extension DurationFormatter on Duration { String toHoursMinutesSecondsFormat() { // WAT: https://flutterigniter.com/how-to-format-duration/ - return this.toString().split('.').first.padLeft(8, "0"); + return this.toString().split('.').first.padLeft(8, '0'); } String toDayHourMinuteFormat2() { @@ -36,6 +36,6 @@ extension DurationFormatter on Duration { ].map((seg) { return seg.toString().padLeft(2, '0'); }); - return segments.first + " h" + " " + segments.last + " min"; + return '${segments.first} h ${segments.last} min'; } } diff --git a/lib/utils/extensions/text_extensions.dart b/lib/utils/extensions/text_extensions.dart index 26932a11..bf810f51 100644 --- a/lib/utils/extensions/text_extensions.dart +++ b/lib/utils/extensions/text_extensions.dart @@ -3,19 +3,19 @@ import 'package:flutter/cupertino.dart'; extension TextExtension on Text { Text withColor(Color color) => Text( data!, - key: this.key, - strutStyle: this.strutStyle, - textAlign: this.textAlign, - textDirection: this.textDirection, - locale: this.locale, - softWrap: this.softWrap, - overflow: this.overflow, - textScaleFactor: this.textScaleFactor, - maxLines: this.maxLines, - semanticsLabel: this.semanticsLabel, - textWidthBasis: textWidthBasis ?? this.textWidthBasis, - style: this.style != null - ? this.style!.copyWith(color: color) + key: key, + strutStyle: strutStyle, + textAlign: textAlign, + textDirection: textDirection, + locale: locale, + softWrap: softWrap, + overflow: overflow, + textScaleFactor: textScaleFactor, + maxLines: maxLines, + semanticsLabel: semanticsLabel, + textWidthBasis: textWidthBasis ?? textWidthBasis, + style: style != null + ? style!.copyWith(color: color) : TextStyle(color: color), ); diff --git a/lib/utils/route_transitions/slide_bottom.dart b/lib/utils/route_transitions/slide_bottom.dart index 380b1142..28363e2d 100644 --- a/lib/utils/route_transitions/slide_bottom.dart +++ b/lib/utils/route_transitions/slide_bottom.dart @@ -21,7 +21,7 @@ Function transitionsBuilder = ( child: Container( decoration: animation.isCompleted ? null - : BoxDecoration( + : const BoxDecoration( border: Border( bottom: BorderSide( color: Colors.black, @@ -36,7 +36,7 @@ Function transitionsBuilder = ( class SlideBottomRoute extends PageRouteBuilder { SlideBottomRoute(this.widget) : super( - transitionDuration: Duration(milliseconds: 150), + transitionDuration: const Duration(milliseconds: 150), pageBuilder: pageBuilder(widget), transitionsBuilder: transitionsBuilder as Widget Function( BuildContext, Animation, Animation, Widget), diff --git a/lib/utils/route_transitions/slide_right.dart b/lib/utils/route_transitions/slide_right.dart index f01c4b0f..635bb021 100644 --- a/lib/utils/route_transitions/slide_right.dart +++ b/lib/utils/route_transitions/slide_right.dart @@ -21,7 +21,7 @@ Function transitionsBuilder = ( child: Container( decoration: animation.isCompleted ? null - : BoxDecoration( + : const BoxDecoration( border: Border( right: BorderSide( color: Colors.black, diff --git a/pubspec.lock b/pubspec.lock index de1631fe..e3faf1b6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -526,7 +526,7 @@ packages: source: hosted version: "3.1.3" intl: - dependency: transitive + dependency: "direct main" description: name: intl url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index a99c36a0..519f9996 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,6 +29,7 @@ dependencies: gtk_theme_fl: ^0.0.1 hive: ^2.0.5 hive_flutter: ^1.1.0 + intl: ^0.17.0 ionicons: ^0.1.2 json_annotation: ^4.4.0 local_auth: ^2.0.2 diff --git a/test/widget_test.dart b/test/widget_test.dart index aaa33419..48cbdccf 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -114,9 +114,9 @@ void main() { }); } -var regExpNewLines = RegExp(r"[\n\r]+"); -var regExpWhiteSpaces = RegExp(r"[\s]+"); -var regExpUppercaseLetters = RegExp(r"[A-Z]"); -var regExpLowercaseLetters = RegExp(r"[a-z]"); -var regExpNumbers = RegExp(r"[0-9]"); +var regExpNewLines = RegExp(r'[\n\r]+'); +var regExpWhiteSpaces = RegExp(r'[\s]+'); +var regExpUppercaseLetters = RegExp(r'[A-Z]'); +var regExpLowercaseLetters = RegExp(r'[a-z]'); +var regExpNumbers = RegExp(r'[0-9]'); var regExpSymbols = RegExp(r'(?:_|[^\w\s])+');