pull/90/head
Inex Code 2022-05-24 21:55:39 +03:00
parent edce25ec55
commit 14acfdec6b
131 changed files with 1289 additions and 1259 deletions

View File

@ -22,7 +22,7 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file # `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint. # producing the lint.
rules: 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 prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at # Additional information about this file can be found at

View File

@ -8,7 +8,7 @@ class SimpleBlocObserver extends BlocObserver {
SimpleBlocObserver(); SimpleBlocObserver();
@override @override
void onError(BlocBase cubit, Object error, StackTrace stackTrace) { void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
final navigator = getIt.get<NavigationService>().navigator!; final navigator = getIt.get<NavigationService>().navigator!;
navigator.push( navigator.push(
@ -19,6 +19,6 @@ class SimpleBlocObserver extends BlocObserver {
), ),
), ),
); );
super.onError(cubit, error, stackTrace); super.onError(bloc, error, stackTrace);
} }
} }

View File

@ -10,7 +10,7 @@ class BrandColors {
static const Color gray3 = Color(0xFFFAFAFA); static const Color gray3 = Color(0xFFFAFAFA);
static const Color gray4 = Color(0xFFDDDDDD); static const Color gray4 = Color(0xFFDDDDDD);
static const Color gray5 = Color(0xFFEDEEF1); 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 grey7 = Color(0xFFABABAB);
static const Color red1 = Color(0xFFFA0E0E); static const Color red1 = Color(0xFFFA0E0E);

View File

@ -9,7 +9,7 @@ final lightTheme = ThemeData(
fontFamily: 'Inter', fontFamily: 'Inter',
brightness: Brightness.light, brightness: Brightness.light,
scaffoldBackgroundColor: BrandColors.scaffoldBackground, scaffoldBackgroundColor: BrandColors.scaffoldBackground,
inputDecorationTheme: InputDecorationTheme( inputDecorationTheme: const InputDecorationTheme(
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.all(16), contentPadding: EdgeInsets.all(16),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
@ -39,7 +39,7 @@ final lightTheme = ThemeData(
color: BrandColors.red1, color: BrandColors.red1,
), ),
), ),
listTileTheme: ListTileThemeData( listTileTheme: const ListTileThemeData(
minLeadingWidth: 24.0, minLeadingWidth: 24.0,
), ),
textTheme: TextTheme( textTheme: TextTheme(
@ -48,25 +48,25 @@ final lightTheme = ThemeData(
headline3: headline3Style, headline3: headline3Style,
headline4: headline4Style, headline4: headline4Style,
bodyText1: body1Style, 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( var darkTheme = lightTheme.copyWith(
brightness: Brightness.dark, brightness: Brightness.dark,
scaffoldBackgroundColor: Color(0xFF202120), scaffoldBackgroundColor: const Color(0xFF202120),
iconTheme: IconThemeData(color: BrandColors.gray3), iconTheme: const IconThemeData(color: BrandColors.gray3),
cardColor: BrandColors.gray1, cardColor: BrandColors.gray1,
dialogBackgroundColor: Color(0xFF202120), dialogBackgroundColor: const Color(0xFF202120),
textTheme: TextTheme( textTheme: TextTheme(
headline1: headline1Style.copyWith(color: BrandColors.white), headline1: headline1Style.copyWith(color: BrandColors.white),
headline2: headline2Style.copyWith(color: BrandColors.white), headline2: headline2Style.copyWith(color: BrandColors.white),
headline3: headline3Style.copyWith(color: BrandColors.white), headline3: headline3Style.copyWith(color: BrandColors.white),
headline4: headline4Style.copyWith(color: BrandColors.white), headline4: headline4Style.copyWith(color: BrandColors.white),
bodyText1: body1Style.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), labelStyle: TextStyle(color: BrandColors.white),
hintStyle: TextStyle(color: BrandColors.white), hintStyle: TextStyle(color: BrandColors.white),
border: OutlineInputBorder( 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);

View File

@ -41,7 +41,7 @@ class HiveConfig {
} }
static Future<Uint8List> getEncryptedKey(String encKey) async { static Future<Uint8List> getEncryptedKey(String encKey) async {
final secureStorage = FlutterSecureStorage(); const secureStorage = FlutterSecureStorage();
var hasEncryptionKey = await secureStorage.containsKey(key: encKey); var hasEncryptionKey = await secureStorage.containsKey(key: encKey);
if (!hasEncryptionKey) { if (!hasEncryptionKey) {
var key = Hive.generateSecureKey(); var key = Hive.generateSecureKey();

View File

@ -11,9 +11,9 @@ class Localization extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return EasyLocalization( return EasyLocalization(
supportedLocales: [Locale('ru'), Locale('en')], supportedLocales: const [Locale('ru'), Locale('en')],
path: 'assets/translations', path: 'assets/translations',
fallbackLocale: Locale('en'), fallbackLocale: const Locale('en'),
saveLocale: false, saveLocale: false,
useOnlyLangCode: true, useOnlyLangCode: true,
child: child!, child: child!,

View File

@ -3,7 +3,7 @@ import 'package:selfprivacy/utils/named_font_weight.dart';
import 'brand_colors.dart'; import 'brand_colors.dart';
final defaultTextStyle = TextStyle( const defaultTextStyle = TextStyle(
fontSize: 15, fontSize: 15,
color: BrandColors.textColor1, color: BrandColors.textColor1,
); );
@ -51,7 +51,7 @@ final headline5Style = defaultTextStyle.copyWith(
color: BrandColors.headlineColor.withOpacity(0.8), color: BrandColors.headlineColor.withOpacity(0.8),
); );
final body1Style = defaultTextStyle; const body1Style = defaultTextStyle;
final body2Style = defaultTextStyle.copyWith( final body2Style = defaultTextStyle.copyWith(
color: BrandColors.textColor2, color: BrandColors.textColor2,
); );
@ -69,7 +69,7 @@ final smallStyle = defaultTextStyle.copyWith(fontSize: 11, height: 1.45);
final linkStyle = defaultTextStyle.copyWith(color: BrandColors.blue); final linkStyle = defaultTextStyle.copyWith(color: BrandColors.blue);
final progressTextStyleLight = TextStyle( const progressTextStyleLight = TextStyle(
fontSize: 11, fontSize: 11,
color: BrandColors.textColor1, color: BrandColors.textColor1,
height: 1.7, height: 1.7,

View File

@ -56,7 +56,7 @@ class ConsoleInterceptor extends InterceptorsWrapper {
@override @override
Future onRequest( Future onRequest(
RequestOptions options, RequestOptions options,
RequestInterceptorHandler requestInterceptorHandler, RequestInterceptorHandler handler,
) async { ) async {
addMessage( addMessage(
Message( Message(
@ -64,13 +64,13 @@ class ConsoleInterceptor extends InterceptorsWrapper {
'request-uri: ${options.uri}\nheaders: ${options.headers}\ndata: ${options.data}', 'request-uri: ${options.uri}\nheaders: ${options.headers}\ndata: ${options.data}',
), ),
); );
return super.onRequest(options, requestInterceptorHandler); return super.onRequest(options, handler);
} }
@override @override
Future onResponse( Future onResponse(
Response response, Response response,
ResponseInterceptorHandler requestInterceptorHandler, ResponseInterceptorHandler handler,
) async { ) async {
addMessage( addMessage(
Message( Message(
@ -80,7 +80,7 @@ class ConsoleInterceptor extends InterceptorsWrapper {
); );
return super.onResponse( return super.onResponse(
response, response,
requestInterceptorHandler, handler,
); );
} }

View File

@ -23,6 +23,7 @@ class BackblazeApplicationKey {
class BackblazeApi extends ApiMap { class BackblazeApi extends ApiMap {
BackblazeApi({this.hasLogger = false, this.isWithToken = true}); BackblazeApi({this.hasLogger = false, this.isWithToken = true});
@override
BaseOptions get options { BaseOptions get options {
var options = BaseOptions(baseUrl: rootAddress); var options = BaseOptions(baseUrl: rootAddress);
if (isWithToken) { if (isWithToken) {
@ -97,9 +98,9 @@ class BackblazeApi extends ApiMap {
'bucketType': 'allPrivate', 'bucketType': 'allPrivate',
'lifecycleRules': [ 'lifecycleRules': [
{ {
"daysFromHidingToDeleting": 30, 'daysFromHidingToDeleting': 30,
"daysFromUploadingToHiding": null, 'daysFromUploadingToHiding': null,
"fileNamePrefix": "" 'fileNamePrefix': ''
} }
], ],
}, },

View File

@ -25,6 +25,7 @@ class CloudflareApi extends ApiMap {
this.customToken, this.customToken,
}); });
@override
BaseOptions get options { BaseOptions get options {
var options = BaseOptions(baseUrl: rootAddress); var options = BaseOptions(baseUrl: rootAddress);
if (isWithToken) { if (isWithToken) {
@ -164,7 +165,7 @@ class CloudflareApi extends ApiMap {
await Future.wait(allCreateFutures); await Future.wait(allCreateFutures);
} on DioError catch (e) { } on DioError catch (e) {
print(e.message); print(e.message);
throw e; rethrow;
} finally { } finally {
close(client); close(client);
} }

View File

@ -10,11 +10,14 @@ import 'package:selfprivacy/logic/models/hive/user.dart';
import 'package:selfprivacy/utils/password_generator.dart'; import 'package:selfprivacy/utils/password_generator.dart';
class HetznerApi extends ApiMap { class HetznerApi extends ApiMap {
@override
bool hasLogger; bool hasLogger;
@override
bool isWithToken; bool isWithToken;
HetznerApi({this.hasLogger = false, this.isWithToken = true}); HetznerApi({this.hasLogger = false, this.isWithToken = true});
@override
BaseOptions get options { BaseOptions get options {
var options = BaseOptions(baseUrl: rootAddress); var options = BaseOptions(baseUrl: rootAddress);
if (isWithToken) { if (isWithToken) {
@ -60,12 +63,12 @@ class HetznerApi extends ApiMap {
Response dbCreateResponse = await client.post( Response dbCreateResponse = await client.post(
'/volumes', '/volumes',
data: { data: {
"size": 10, 'size': 10,
"name": StringGenerators.dbStorageName(), 'name': StringGenerators.dbStorageName(),
"labels": {"labelkey": "value"}, 'labels': {'labelkey': 'value'},
"location": "fsn1", 'location': 'fsn1',
"automount": false, 'automount': false,
"format": "ext4" 'format': 'ext4'
}, },
); );
var dbId = dbCreateResponse.data['volume']['id']; var dbId = dbCreateResponse.data['volume']['id'];
@ -93,7 +96,7 @@ class HetznerApi extends ApiMap {
final base64Password = final base64Password =
base64.encode(utf8.encode(rootUser.password ?? 'PASS')); 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"] /// add ssh key when you need it: e.g. "ssh_keys":["kherel"]
/// check the branch name, it could be "development" or "master". /// check the branch name, it could be "development" or "master".
@ -103,18 +106,18 @@ class HetznerApi extends ApiMap {
print(userdataString); print(userdataString);
final data = { final data = {
"name": hostname, 'name': hostname,
"server_type": "cx11", 'server_type': 'cx11',
"start_after_create": false, 'start_after_create': false,
"image": "ubuntu-20.04", 'image': 'ubuntu-20.04',
"volumes": [dbId], 'volumes': [dbId],
"networks": [], 'networks': [],
"user_data": userdataString, 'user_data': userdataString,
"labels": {}, 'labels': {},
"automount": true, 'automount': true,
"location": "fsn1" 'location': 'fsn1'
}; };
print("Decoded data: $data"); print('Decoded data: $data');
Response serverCreateResponse = await client.post( Response serverCreateResponse = await client.post(
'/servers', '/servers',
@ -129,7 +132,7 @@ class HetznerApi extends ApiMap {
createTime: DateTime.now(), createTime: DateTime.now(),
volume: dataBase, volume: dataBase,
apiToken: apiToken, apiToken: apiToken,
provider: ServerProvider.Hetzner, provider: ServerProvider.hetzner,
); );
} }
@ -166,7 +169,7 @@ class HetznerApi extends ApiMap {
for (var volumeId in volumes) { for (var volumeId in volumes) {
await client.post('/volumes/$volumeId/actions/detach'); 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) { for (var volumeId in volumes) {
laterFutures.add(client.delete('/volumes/$volumeId')); laterFutures.add(client.delete('/volumes/$volumeId'));
@ -203,9 +206,9 @@ class HetznerApi extends ApiMap {
var client = await getClient(); var client = await getClient();
Map<String, dynamic> queryParameters = { Map<String, dynamic> queryParameters = {
"start": start.toUtc().toIso8601String(), 'start': start.toUtc().toIso8601String(),
"end": end.toUtc().toIso8601String(), 'end': end.toUtc().toIso8601String(),
"type": type 'type': type
}; };
var res = await client.get( var res = await client.get(
'/servers/${hetznerServer!.id}/metrics', '/servers/${hetznerServer!.id}/metrics',
@ -243,8 +246,8 @@ class HetznerApi extends ApiMap {
await client.post( await client.post(
'/servers/${hetznerServer!.id}/actions/change_dns_ptr', '/servers/${hetznerServer!.id}/actions/change_dns_ptr',
data: { data: {
"ip": ip4, 'ip': ip4,
"dns_ptr": domainName, 'dns_ptr': domainName,
}, },
); );
close(client); close(client);

View File

@ -44,6 +44,7 @@ class ServerApi extends ApiMap {
this.overrideDomain, this.overrideDomain,
this.customToken}); this.customToken});
@override
BaseOptions get options { BaseOptions get options {
var options = BaseOptions(); var options = BaseOptions();
@ -73,7 +74,7 @@ class ServerApi extends ApiMap {
Response response; Response response;
var client = await getClient(); var client = await getClient();
String? apiVersion = null; String? apiVersion;
try { try {
response = await client.get('/api/version'); response = await client.get('/api/version');
@ -82,8 +83,8 @@ class ServerApi extends ApiMap {
print(e.message); print(e.message);
} finally { } finally {
close(client); close(client);
return apiVersion;
} }
return apiVersion;
} }
Future<bool> isHttpServerWorking() async { Future<bool> isHttpServerWorking() async {
@ -98,8 +99,8 @@ class ServerApi extends ApiMap {
print(e.message); print(e.message);
} finally { } finally {
close(client); close(client);
return res;
} }
return res;
} }
Future<ApiResponse<User>> createUser(User user) async { Future<ApiResponse<User>> createUser(User user) async {
@ -227,7 +228,7 @@ class ServerApi extends ApiMap {
try { try {
response = await client.put( response = await client.put(
'/services/ssh/key/send', '/services/ssh/key/send',
data: {"public_key": ssh}, data: {'public_key': ssh},
); );
} on DioError catch (e) { } on DioError catch (e) {
print(e.message); print(e.message);
@ -293,7 +294,7 @@ class ServerApi extends ApiMap {
try { try {
response = await client.delete( response = await client.delete(
'/services/ssh/keys/${user.login}', '/services/ssh/keys/${user.login}',
data: {"public_key": sshKey}, data: {'public_key': sshKey},
); );
} on DioError catch (e) { } on DioError catch (e) {
print(e.message); print(e.message);
@ -331,10 +332,11 @@ class ServerApi extends ApiMap {
res = false; res = false;
} finally { } finally {
close(client); close(client);
return res;
} }
return res;
} }
@override
String get rootAddress => String get rootAddress =>
throw UnimplementedError('not used in with implementation'); throw UnimplementedError('not used in with implementation');
@ -351,8 +353,8 @@ class ServerApi extends ApiMap {
res = false; res = false;
} finally { } finally {
close(client); close(client);
return res;
} }
return res;
} }
Future<void> switchService(ServiceTypes type, bool needToTurnOn) async { Future<void> switchService(ServiceTypes type, bool needToTurnOn) async {
@ -433,8 +435,8 @@ class ServerApi extends ApiMap {
print(e); print(e);
} finally { } finally {
close(client); close(client);
return backups;
} }
return backups;
} }
Future<BackupStatus> getBackupStatus() async { Future<BackupStatus> getBackupStatus() async {
@ -453,8 +455,8 @@ class ServerApi extends ApiMap {
print(e.message); print(e.message);
} finally { } finally {
close(client); close(client);
return status;
} }
return status;
} }
Future<void> forceBackupListReload() async { Future<void> forceBackupListReload() async {
@ -496,8 +498,8 @@ class ServerApi extends ApiMap {
print(e.message); print(e.message);
} finally { } finally {
close(client); close(client);
return result;
} }
return result;
} }
Future<bool> reboot() async { Future<bool> reboot() async {
@ -514,8 +516,8 @@ class ServerApi extends ApiMap {
print(e.message); print(e.message);
} finally { } finally {
close(client); close(client);
return result;
} }
return result;
} }
Future<bool> upgrade() async { Future<bool> upgrade() async {
@ -532,13 +534,13 @@ class ServerApi extends ApiMap {
print(e.message); print(e.message);
} finally { } finally {
close(client); close(client);
return result;
} }
return result;
} }
Future<AutoUpgradeSettings> getAutoUpgradeSettings() async { Future<AutoUpgradeSettings> getAutoUpgradeSettings() async {
Response response; Response response;
AutoUpgradeSettings settings = AutoUpgradeSettings( AutoUpgradeSettings settings = const AutoUpgradeSettings(
enable: false, enable: false,
allowReboot: false, allowReboot: false,
); );
@ -553,8 +555,8 @@ class ServerApi extends ApiMap {
print(e.message); print(e.message);
} finally { } finally {
close(client); close(client);
return settings;
} }
return settings;
} }
Future<void> updateAutoUpgradeSettings(AutoUpgradeSettings settings) async { Future<void> updateAutoUpgradeSettings(AutoUpgradeSettings settings) async {
@ -616,7 +618,7 @@ class ServerApi extends ApiMap {
} }
if (response.statusCode != HttpStatus.ok) { if (response.statusCode != HttpStatus.ok) {
return ""; return '';
} }
final base64toString = utf8.fuse(base64); final base64toString = utf8.fuse(base64);
@ -639,7 +641,7 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
errorMessage: e.message, errorMessage: e.message,
statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError,
data: RecoveryKeyStatus(exists: false, valid: false)); data: const RecoveryKeyStatus(exists: false, valid: false));
} finally { } finally {
close(client); close(client);
} }
@ -677,7 +679,7 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
errorMessage: e.message, errorMessage: e.message,
statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError,
data: ""); data: '');
} finally { } finally {
close(client); close(client);
} }
@ -686,7 +688,7 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
statusCode: code, statusCode: code,
data: response.data != null ? response.data["token"] : ''); data: response.data != null ? response.data['token'] : '');
} }
Future<ApiResponse<String>> useRecoveryToken(DeviceToken token) async { Future<ApiResponse<String>> useRecoveryToken(DeviceToken token) async {
@ -706,7 +708,7 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
errorMessage: e.message, errorMessage: e.message,
statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError,
data: ""); data: '');
} finally { } finally {
client.close(); client.close();
} }
@ -715,7 +717,7 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
statusCode: code, statusCode: code,
data: response.data != null ? response.data["token"] : ''); data: response.data != null ? response.data['token'] : '');
} }
Future<ApiResponse<String>> authorizeDevice(DeviceToken token) async { Future<ApiResponse<String>> authorizeDevice(DeviceToken token) async {
@ -735,16 +737,14 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
errorMessage: e.message, errorMessage: e.message,
statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError,
data: ""); data: '');
} finally { } finally {
client.close(); client.close();
} }
final int code = response.statusCode ?? HttpStatus.internalServerError; final int code = response.statusCode ?? HttpStatus.internalServerError;
return ApiResponse( return ApiResponse(statusCode: code, data: response.data['token'] ?? '');
statusCode: code,
data: response.data["token"] != null ? response.data["token"] : '');
} }
Future<ApiResponse<String>> createDeviceToken() async { Future<ApiResponse<String>> createDeviceToken() async {
@ -758,7 +758,7 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
errorMessage: e.message, errorMessage: e.message,
statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError,
data: ""); data: '');
} finally { } finally {
client.close(); client.close();
} }
@ -767,7 +767,7 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
statusCode: code, statusCode: code,
data: response.data != null ? response.data["token"] : ''); data: response.data != null ? response.data['token'] : '');
} }
Future<ApiResponse<String>> deleteDeviceToken() async { Future<ApiResponse<String>> deleteDeviceToken() async {
@ -781,15 +781,14 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
errorMessage: e.message, errorMessage: e.message,
statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError,
data: ""); data: '');
} finally { } finally {
client.close(); client.close();
} }
final int code = response.statusCode ?? HttpStatus.internalServerError; final int code = response.statusCode ?? HttpStatus.internalServerError;
return ApiResponse( return ApiResponse(statusCode: code, data: response.data ?? '');
statusCode: code, data: response.data != null ? response.data : '');
} }
Future<ApiResponse<List<ApiToken>>> getApiTokens() async { Future<ApiResponse<List<ApiToken>>> getApiTokens() async {
@ -828,7 +827,7 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
errorMessage: e.message, errorMessage: e.message,
statusCode: e.response?.statusCode ?? HttpStatus.internalServerError, statusCode: e.response?.statusCode ?? HttpStatus.internalServerError,
data: ""); data: '');
} finally { } finally {
client.close(); client.close();
} }
@ -837,7 +836,7 @@ class ServerApi extends ApiMap {
return ApiResponse( return ApiResponse(
statusCode: code, statusCode: code,
data: response.data != null ? response.data["token"] : ''); data: response.data != null ? response.data['token'] : '');
} }
Future<ApiResponse<void>> deleteApiToken(String device) async { Future<ApiResponse<void>> deleteApiToken(String device) async {

View File

@ -131,5 +131,5 @@ extension ServiceTypesExt on ServiceTypes {
} }
} }
String get txt => this.toString().split('.')[1]; String get txt => toString().split('.')[1];
} }

View File

@ -1,5 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';

View File

@ -1,4 +1,4 @@
import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:selfprivacy/config/hive_config.dart'; import 'package:selfprivacy/config/hive_config.dart';

View File

@ -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/backblaze.dart';
import 'package:selfprivacy/logic/api_maps/server.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/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/hive/backblaze_bucket.dart';
import 'package:selfprivacy/logic/models/json/backup.dart'; import 'package:selfprivacy/logic/models/json/backup.dart';
@ -13,16 +12,18 @@ part 'backups_state.dart';
class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> { class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
BackupsCubit(ServerInstallationCubit serverInstallationCubit) BackupsCubit(ServerInstallationCubit serverInstallationCubit)
: super(serverInstallationCubit, BackupsState(preventActions: true)); : super(
serverInstallationCubit, const BackupsState(preventActions: true));
final api = ServerApi(); final api = ServerApi();
final backblaze = BackblazeApi(); final backblaze = BackblazeApi();
@override
Future<void> load() async { Future<void> load() async {
if (serverInstallationCubit.state is ServerInstallationFinished) { if (serverInstallationCubit.state is ServerInstallationFinished) {
final bucket = getIt<ApiConfigModel>().backblazeBucket; final bucket = getIt<ApiConfigModel>().backblazeBucket;
if (bucket == null) { if (bucket == null) {
emit(BackupsState( emit(const BackupsState(
isInitialized: false, preventActions: false, refreshing: false)); isInitialized: false, preventActions: false, refreshing: false));
} else { } else {
final status = await api.getBackupStatus(); final status = await api.getBackupStatus();
@ -30,7 +31,7 @@ class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
case BackupStatusEnum.noKey: case BackupStatusEnum.noKey:
case BackupStatusEnum.notInitialized: case BackupStatusEnum.notInitialized:
emit(BackupsState( emit(BackupsState(
backups: [], backups: const [],
isInitialized: true, isInitialized: true,
preventActions: false, preventActions: false,
progress: 0, progress: 0,
@ -40,12 +41,12 @@ class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
break; break;
case BackupStatusEnum.initializing: case BackupStatusEnum.initializing:
emit(BackupsState( emit(BackupsState(
backups: [], backups: const [],
isInitialized: true, isInitialized: true,
preventActions: false, preventActions: false,
progress: 0, progress: 0,
status: status.status, status: status.status,
refreshTimer: Duration(seconds: 10), refreshTimer: const Duration(seconds: 10),
refreshing: false, refreshing: false,
)); ));
break; break;
@ -72,12 +73,12 @@ class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
progress: status.progress, progress: status.progress,
status: status.status, status: status.status,
error: status.errorMessage ?? '', error: status.errorMessage ?? '',
refreshTimer: Duration(seconds: 5), refreshTimer: const Duration(seconds: 5),
refreshing: false, refreshing: false,
)); ));
break; break;
default: default:
emit(BackupsState()); emit(const BackupsState());
} }
Timer(state.refreshTimer, () => updateBackups(useTimer: true)); Timer(state.refreshTimer, () => updateBackups(useTimer: true));
} }
@ -126,11 +127,11 @@ class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
switch (status) { switch (status) {
case BackupStatusEnum.backingUp: case BackupStatusEnum.backingUp:
case BackupStatusEnum.restoring: case BackupStatusEnum.restoring:
return Duration(seconds: 5); return const Duration(seconds: 5);
case BackupStatusEnum.initializing: case BackupStatusEnum.initializing:
return Duration(seconds: 10); return const Duration(seconds: 10);
default: default:
return Duration(seconds: 60); return const Duration(seconds: 60);
} }
} }
@ -146,8 +147,9 @@ class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
refreshTimer: refreshTimeFromState(status.status), refreshTimer: refreshTimeFromState(status.status),
refreshing: false, refreshing: false,
)); ));
if (useTimer) if (useTimer) {
Timer(state.refreshTimer, () => updateBackups(useTimer: true)); Timer(state.refreshTimer, () => updateBackups(useTimer: true));
}
} }
Future<void> forceUpdateBackups() async { Future<void> forceUpdateBackups() async {
@ -173,6 +175,6 @@ class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
@override @override
void clear() async { void clear() async {
emit(BackupsState()); emit(const BackupsState());
} }
} }

View File

@ -7,7 +7,7 @@ class BackupsState extends ServerInstallationDependendState {
this.progress = 0.0, this.progress = 0.0,
this.status = BackupStatusEnum.noKey, this.status = BackupStatusEnum.noKey,
this.preventActions = true, this.preventActions = true,
this.error = "", this.error = '',
this.refreshTimer = const Duration(seconds: 60), this.refreshTimer = const Duration(seconds: 60),
this.refreshing = true, this.refreshing = true,
}); });

View File

@ -1,6 +1,5 @@
import 'package:cubit_form/cubit_form.dart'; import 'package:cubit_form/cubit_form.dart';
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.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/hive/server_domain.dart';
import 'package:selfprivacy/logic/models/json/dns_records.dart'; import 'package:selfprivacy/logic/models/json/dns_records.dart';
@ -13,16 +12,17 @@ class DnsRecordsCubit
extends ServerInstallationDependendCubit<DnsRecordsState> { extends ServerInstallationDependendCubit<DnsRecordsState> {
DnsRecordsCubit(ServerInstallationCubit serverInstallationCubit) DnsRecordsCubit(ServerInstallationCubit serverInstallationCubit)
: super(serverInstallationCubit, : super(serverInstallationCubit,
DnsRecordsState(dnsState: DnsRecordsStatus.refreshing)); const DnsRecordsState(dnsState: DnsRecordsStatus.refreshing));
final api = ServerApi(); final api = ServerApi();
final cloudflare = CloudflareApi(); final cloudflare = CloudflareApi();
@override
Future<void> load() async { Future<void> load() async {
emit(DnsRecordsState( emit(DnsRecordsState(
dnsState: DnsRecordsStatus.refreshing, dnsState: DnsRecordsStatus.refreshing,
dnsRecords: _getDesiredDnsRecords( dnsRecords: _getDesiredDnsRecords(
serverInstallationCubit.state.serverDomain?.domainName, "", ""))); serverInstallationCubit.state.serverDomain?.domainName, '', '')));
print('Loading DNS status'); print('Loading DNS status');
if (serverInstallationCubit.state is ServerInstallationFinished) { if (serverInstallationCubit.state is ServerInstallationFinished) {
final ServerDomain? domain = serverInstallationCubit.state.serverDomain; final ServerDomain? domain = serverInstallationCubit.state.serverDomain;
@ -75,7 +75,7 @@ class DnsRecordsCubit
: DnsRecordsStatus.good, : DnsRecordsStatus.good,
)); ));
} else { } else {
emit(DnsRecordsState()); emit(const DnsRecordsState());
} }
} }
} }
@ -88,7 +88,7 @@ class DnsRecordsCubit
@override @override
Future<void> clear() async { Future<void> clear() async {
emit(DnsRecordsState(dnsState: DnsRecordsStatus.error)); emit(const DnsRecordsState(dnsState: DnsRecordsStatus.error));
} }
Future<void> refresh() async { Future<void> refresh() async {
@ -104,7 +104,7 @@ class DnsRecordsCubit
await cloudflare.removeSimilarRecords(cloudFlareDomain: domain!); await cloudflare.removeSimilarRecords(cloudFlareDomain: domain!);
await cloudflare.createMultipleDnsRecords( await cloudflare.createMultipleDnsRecords(
cloudFlareDomain: domain, ip4: ipAddress); cloudFlareDomain: domain, ip4: ipAddress);
await cloudflare.setDkim(dkimPublicKey ?? "", domain); await cloudflare.setDkim(dkimPublicKey ?? '', domain);
await load(); await load();
} }

View File

@ -42,7 +42,7 @@ class DnsRecordsState extends ServerInstallationDependendState {
class DesiredDnsRecord { class DesiredDnsRecord {
const DesiredDnsRecord({ const DesiredDnsRecord({
required this.name, required this.name,
this.type = "A", this.type = 'A',
required this.content, required this.content,
this.description = '', this.description = '',
this.category = DnsRecordsCategory.services, this.category = DnsRecordsCategory.services,

View File

@ -16,7 +16,7 @@ class FieldCubitFactory {
/// - Must not be a reserved root login /// - Must not be a reserved root login
/// - Must be unique /// - Must be unique
FieldCubit<String> createUserLoginField() { FieldCubit<String> createUserLoginField() {
final userAllowedRegExp = RegExp(r"^[a-z_][a-z0-9_]+$"); final userAllowedRegExp = RegExp(r'^[a-z_][a-z0-9_]+$');
const userMaxLength = 31; const userMaxLength = 31;
return FieldCubit( return FieldCubit(
initalValue: '', initalValue: '',
@ -40,7 +40,7 @@ class FieldCubitFactory {
/// - Must fail on the regural expression of invalid matches: [\n\r\s]+ /// - Must fail on the regural expression of invalid matches: [\n\r\s]+
/// - Must not be empty /// - Must not be empty
FieldCubit<String> createUserPasswordField() { FieldCubit<String> createUserPasswordField() {
var passwordForbiddenRegExp = RegExp(r"[\n\r\s]+"); var passwordForbiddenRegExp = RegExp(r'[\n\r\s]+');
return FieldCubit( return FieldCubit(
initalValue: '', initalValue: '',
validations: [ validations: [

View File

@ -8,7 +8,7 @@ import 'package:selfprivacy/logic/cubit/forms/validations/validations.dart';
class CloudFlareFormCubit extends FormCubit { class CloudFlareFormCubit extends FormCubit {
CloudFlareFormCubit(this.initializingCubit) { CloudFlareFormCubit(this.initializingCubit) {
var regExp = RegExp(r"\s+|[!$%^&*()@+|~=`{}\[\]:<>?,.\/]"); var regExp = RegExp(r'\s+|[!$%^&*()@+|~=`{}\[\]:<>?,.\/]');
apiKey = FieldCubit( apiKey = FieldCubit(
initalValue: '', initalValue: '',
validations: [ validations: [
@ -48,9 +48,4 @@ class CloudFlareFormCubit extends FormCubit {
} }
return true; return true;
} }
@override
Future<void> close() async {
return super.close();
}
} }

View File

@ -39,7 +39,7 @@ class DomainSetupCubit extends Cubit<DomainSetupState> {
var domain = ServerDomain( var domain = ServerDomain(
domainName: domainName, domainName: domainName,
zoneId: zoneId, zoneId: zoneId,
provider: DnsProvider.Cloudflare, provider: DnsProvider.cloudflare,
); );
serverInstallationCubit.setDomain(domain); serverInstallationCubit.setDomain(domain);

View File

@ -8,7 +8,7 @@ import 'package:selfprivacy/logic/cubit/forms/validations/validations.dart';
class HetznerFormCubit extends FormCubit { class HetznerFormCubit extends FormCubit {
HetznerFormCubit(this.serverInstallationCubit) { HetznerFormCubit(this.serverInstallationCubit) {
var regExp = RegExp(r"\s+|[-!$%^&*()@+|~=`{}\[\]:<>?,.\/]"); var regExp = RegExp(r'\s+|[-!$%^&*()@+|~=`{}\[\]:<>?,.\/]');
apiKey = FieldCubit( apiKey = FieldCubit(
initalValue: '', initalValue: '',
validations: [ validations: [

View File

@ -34,7 +34,7 @@ class RecoveryDomainFormCubit extends FormCubit {
final bool domainValid = await api.getApiVersion() != null; final bool domainValid = await api.getApiVersion() != null;
if (!domainValid) { if (!domainValid) {
serverDomainField.setError("recovering.domain_recover_error".tr()); serverDomainField.setError('recovering.domain_recover_error'.tr());
} }
return domainValid; return domainValid;

View File

@ -12,7 +12,7 @@ class SshFormCubit extends FormCubit {
required this.user, required this.user,
}) { }) {
var keyRegExp = RegExp( 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( key = FieldCubit(
initalValue: '', initalValue: '',

View File

@ -8,7 +8,7 @@ abstract class LengthStringValidation extends ValidationModel<String> {
@override @override
String? check(String value) { String? check(String value) {
var length = value.length; var length = value.length;
var errorMessage = this.errorMassage.replaceAll("[]", length.toString()); var errorMessage = errorMassage.replaceAll('[]', length.toString());
return test(value) ? errorMessage : null; return test(value) ? errorMessage : null;
} }
} }

View File

@ -1,6 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:selfprivacy/logic/common_enum/common_enum.dart'; import 'package:selfprivacy/logic/common_enum/common_enum.dart';
import 'package:selfprivacy/logic/models/hetzner_metrics.dart'; import 'package:selfprivacy/logic/models/hetzner_metrics.dart';
@ -10,12 +10,13 @@ import 'hetzner_metrics_repository.dart';
part 'hetzner_metrics_state.dart'; part 'hetzner_metrics_state.dart';
class HetznerMetricsCubit extends Cubit<HetznerMetricsState> { class HetznerMetricsCubit extends Cubit<HetznerMetricsState> {
HetznerMetricsCubit() : super(HetznerMetricsLoading(Period.day)); HetznerMetricsCubit() : super(const HetznerMetricsLoading(Period.day));
final repository = HetznerMetricsRepository(); final repository = HetznerMetricsRepository();
Timer? timer; Timer? timer;
@override
close() { close() {
closeTimer(); closeTimer();
return super.close(); return super.close();

View File

@ -11,13 +11,13 @@ class HetznerMetricsRepository {
switch (period) { switch (period) {
case Period.hour: case Period.hour:
start = end.subtract(Duration(hours: 1)); start = end.subtract(const Duration(hours: 1));
break; break;
case Period.day: case Period.day:
start = end.subtract(Duration(days: 1)); start = end.subtract(const Duration(days: 1));
break; break;
case Period.month: case Period.month:
start = end.subtract(Duration(days: 15)); start = end.subtract(const Duration(days: 15));
break; break;
} }
@ -28,14 +28,14 @@ class HetznerMetricsRepository {
api.getMetrics(start, end, 'network'), api.getMetrics(start, end, 'network'),
]); ]);
var cpuMetricsData = results[0]["metrics"]; var cpuMetricsData = results[0]['metrics'];
var networkMetricsData = results[1]["metrics"]; var networkMetricsData = results[1]['metrics'];
return HetznerMetricsLoaded( return HetznerMetricsLoaded(
period: period, period: period,
start: start, start: start,
end: end, end: end,
stepInSeconds: cpuMetricsData["step"], stepInSeconds: cpuMetricsData['step'],
cpu: timeSeriesSerializer(cpuMetricsData, 'cpu'), cpu: timeSeriesSerializer(cpuMetricsData, 'cpu'),
ppsIn: timeSeriesSerializer(networkMetricsData, 'network.0.pps.in'), ppsIn: timeSeriesSerializer(networkMetricsData, 'network.0.pps.in'),
ppsOut: timeSeriesSerializer(networkMetricsData, 'network.0.pps.out'), ppsOut: timeSeriesSerializer(networkMetricsData, 'network.0.pps.out'),
@ -51,6 +51,6 @@ class HetznerMetricsRepository {
List<TimeSeriesData> timeSeriesSerializer( List<TimeSeriesData> timeSeriesSerializer(
Map<String, dynamic> json, String type) { Map<String, dynamic> 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(); return list.map((el) => TimeSeriesData(el[0], double.parse(el[1]))).toList();
} }

View File

@ -7,7 +7,8 @@ abstract class HetznerMetricsState extends Equatable {
} }
class HetznerMetricsLoading extends HetznerMetricsState { class HetznerMetricsLoading extends HetznerMetricsState {
HetznerMetricsLoading(this.period); const HetznerMetricsLoading(this.period);
@override
final Period period; final Period period;
@override @override
@ -15,7 +16,7 @@ class HetznerMetricsLoading extends HetznerMetricsState {
} }
class HetznerMetricsLoaded extends HetznerMetricsState { class HetznerMetricsLoaded extends HetznerMetricsState {
HetznerMetricsLoaded({ const HetznerMetricsLoaded({
required this.period, required this.period,
required this.start, required this.start,
required this.end, required this.end,
@ -27,6 +28,7 @@ class HetznerMetricsLoaded extends HetznerMetricsState {
required this.bandwidthOut, required this.bandwidthOut,
}); });
@override
final Period period; final Period period;
final DateTime start; final DateTime start;
final DateTime end; final DateTime end;

View File

@ -1,4 +1,4 @@
import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:selfprivacy/logic/models/provider.dart'; import 'package:selfprivacy/logic/models/provider.dart';
import 'package:selfprivacy/logic/models/state_types.dart'; import 'package:selfprivacy/logic/models/state_types.dart';

View File

@ -7,7 +7,7 @@ part 'recovery_key_state.dart';
class RecoveryKeyCubit class RecoveryKeyCubit
extends ServerInstallationDependendCubit<RecoveryKeyState> { extends ServerInstallationDependendCubit<RecoveryKeyState> {
RecoveryKeyCubit(ServerInstallationCubit serverInstallationCubit) RecoveryKeyCubit(ServerInstallationCubit serverInstallationCubit)
: super(serverInstallationCubit, RecoveryKeyState.initial()); : super(serverInstallationCubit, const RecoveryKeyState.initial());
final api = ServerApi(); final api = ServerApi();

View File

@ -7,12 +7,12 @@ enum LoadingStatus {
error, error,
} }
class RecoveryKeyState extends ServerInstallationDependendState { class RecoveryKeyState extends ServerInstallationDependendState {
const RecoveryKeyState(this._status, this.loadingStatus); const RecoveryKeyState(this._status, this.loadingStatus);
RecoveryKeyState.initial() const RecoveryKeyState.initial()
: this(RecoveryKeyStatus(exists: false, valid: false), LoadingStatus.refreshing); : this(const RecoveryKeyStatus(exists: false, valid: false),
LoadingStatus.refreshing);
final RecoveryKeyStatus _status; final RecoveryKeyStatus _status;
final LoadingStatus loadingStatus; final LoadingStatus loadingStatus;
@ -30,7 +30,7 @@ class RecoveryKeyState extends ServerInstallationDependendState {
LoadingStatus? loadingStatus, LoadingStatus? loadingStatus,
}) { }) {
return RecoveryKeyState( return RecoveryKeyState(
status ?? this._status, status ?? _status,
loadingStatus ?? this.loadingStatus, loadingStatus ?? this.loadingStatus,
); );
} }

View File

@ -1,4 +1,4 @@
import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:selfprivacy/config/get_it_config.dart'; import 'package:selfprivacy/config/get_it_config.dart';
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_repository.dart'; import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_repository.dart';

View File

@ -8,9 +8,9 @@ class ServerDetailsRepository {
var hetznerAPi = HetznerApi(); var hetznerAPi = HetznerApi();
var selfprivacyServer = ServerApi(); var selfprivacyServer = ServerApi();
Future<_ServerDetailsRepositoryDto> load() async { Future<ServerDetailsRepositoryDto> load() async {
print('load'); print('load');
return _ServerDetailsRepositoryDto( return ServerDetailsRepositoryDto(
autoUpgradeSettings: await selfprivacyServer.getAutoUpgradeSettings(), autoUpgradeSettings: await selfprivacyServer.getAutoUpgradeSettings(),
hetznerServerInfo: await hetznerAPi.getInfo(), hetznerServerInfo: await hetznerAPi.getInfo(),
serverTimezone: await selfprivacyServer.getServerTimezone(), serverTimezone: await selfprivacyServer.getServerTimezone(),
@ -18,14 +18,14 @@ class ServerDetailsRepository {
} }
} }
class _ServerDetailsRepositoryDto { class ServerDetailsRepositoryDto {
final HetznerServerInfo hetznerServerInfo; final HetznerServerInfo hetznerServerInfo;
final TimeZoneSettings serverTimezone; final TimeZoneSettings serverTimezone;
final AutoUpgradeSettings autoUpgradeSettings; final AutoUpgradeSettings autoUpgradeSettings;
_ServerDetailsRepositoryDto({ ServerDetailsRepositoryDto({
required this.hetznerServerInfo, required this.hetznerServerInfo,
required this.serverTimezone, required this.serverTimezone,
required this.autoUpgradeSettings, required this.autoUpgradeSettings,

View File

@ -23,7 +23,7 @@ class Loaded extends ServerDetailsState {
final AutoUpgradeSettings autoUpgradeSettings; final AutoUpgradeSettings autoUpgradeSettings;
final DateTime checkTime; final DateTime checkTime;
Loaded({ const Loaded({
required this.serverInfo, required this.serverInfo,
required this.serverTimezone, required this.serverTimezone,
required this.autoUpgradeSettings, required this.autoUpgradeSettings,

View File

@ -1,6 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:selfprivacy/config/get_it_config.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'; part '../server_installation/server_installation_state.dart';
class ServerInstallationCubit extends Cubit<ServerInstallationState> { class ServerInstallationCubit extends Cubit<ServerInstallationState> {
ServerInstallationCubit() : super(ServerInstallationEmpty()); ServerInstallationCubit() : super(const ServerInstallationEmpty());
final repository = ServerInstallationRepository(); final repository = ServerInstallationRepository();
@ -54,7 +54,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
if (state is ServerInstallationRecovery) { if (state is ServerInstallationRecovery) {
emit((state as ServerInstallationRecovery).copyWith( emit((state as ServerInstallationRecovery).copyWith(
hetznerKey: hetznerKey, hetznerKey: hetznerKey,
currentStep: RecoveryStep.ServerSelection, currentStep: RecoveryStep.serverSelection,
)); ));
return; return;
} }
@ -104,12 +104,12 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
} }
void createServerAndSetDnsRecords() async { void createServerAndSetDnsRecords() async {
ServerInstallationNotFinished _stateCopy = ServerInstallationNotFinished stateCopy =
state as ServerInstallationNotFinished; state as ServerInstallationNotFinished;
var onCancel = () => emit( onCancel() => emit(
(state as ServerInstallationNotFinished).copyWith(isLoading: false)); (state as ServerInstallationNotFinished).copyWith(isLoading: false));
var onSuccess = (ServerHostingDetails serverDetails) async { onSuccess(ServerHostingDetails serverDetails) async {
await repository.createDnsRecords( await repository.createDnsRecords(
serverDetails.ip4, serverDetails.ip4,
state.serverDomain!, state.serverDomain!,
@ -120,8 +120,8 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
isLoading: false, isLoading: false,
serverDetails: serverDetails, serverDetails: serverDetails,
)); ));
runDelayed(startServerIfDnsIsOkay, Duration(seconds: 30), null); runDelayed(startServerIfDnsIsOkay, const Duration(seconds: 30), null);
}; }
try { try {
emit((state as ServerInstallationNotFinished).copyWith(isLoading: true)); emit((state as ServerInstallationNotFinished).copyWith(isLoading: true));
@ -134,7 +134,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
onSuccess: onSuccess, onSuccess: onSuccess,
); );
} catch (e) { } catch (e) {
emit(_stateCopy); emit(stateCopy);
} }
} }
@ -163,7 +163,8 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
serverDetails: server, serverDetails: server,
), ),
); );
runDelayed(resetServerIfServerIsOkay, Duration(seconds: 60), dataState); runDelayed(
resetServerIfServerIsOkay, const Duration(seconds: 60), dataState);
} else { } else {
emit( emit(
dataState.copyWith( dataState.copyWith(
@ -171,7 +172,8 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
dnsMatches: matches, dnsMatches: matches,
), ),
); );
runDelayed(startServerIfDnsIsOkay, Duration(seconds: 30), dataState); runDelayed(
startServerIfDnsIsOkay, const Duration(seconds: 30), dataState);
} }
} }
@ -183,7 +185,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
var isServerWorking = await repository.isHttpServerWorking(); var isServerWorking = await repository.isHttpServerWorking();
if (isServerWorking) { if (isServerWorking) {
var pauseDuration = Duration(seconds: 30); var pauseDuration = const Duration(seconds: 30);
emit(TimerState( emit(TimerState(
dataState: dataState, dataState: dataState,
timerStart: DateTime.now(), timerStart: DateTime.now(),
@ -202,10 +204,11 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
isLoading: false, isLoading: false,
), ),
); );
runDelayed(finishCheckIfServerIsOkay, Duration(seconds: 60), dataState); runDelayed(
finishCheckIfServerIsOkay, const Duration(seconds: 60), dataState);
}); });
} else { } else {
runDelayed(oneMoreReset, Duration(seconds: 60), dataState); runDelayed(oneMoreReset, const Duration(seconds: 60), dataState);
} }
} }
@ -219,7 +222,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
var isServerWorking = await repository.isHttpServerWorking(); var isServerWorking = await repository.isHttpServerWorking();
if (isServerWorking) { if (isServerWorking) {
var pauseDuration = Duration(seconds: 30); var pauseDuration = const Duration(seconds: 30);
emit(TimerState( emit(TimerState(
dataState: dataState, dataState: dataState,
timerStart: DateTime.now(), timerStart: DateTime.now(),
@ -238,10 +241,11 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
isLoading: false, isLoading: false,
), ),
); );
runDelayed(oneMoreReset, Duration(seconds: 60), dataState); runDelayed(oneMoreReset, const Duration(seconds: 60), dataState);
}); });
} else { } else {
runDelayed(resetServerIfServerIsOkay, Duration(seconds: 60), dataState); runDelayed(
resetServerIfServerIsOkay, const Duration(seconds: 60), dataState);
} }
} }
@ -260,7 +264,8 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
emit(dataState.finish()); emit(dataState.finish());
} else { } else {
runDelayed(finishCheckIfServerIsOkay, Duration(seconds: 60), dataState); runDelayed(
finishCheckIfServerIsOkay, const Duration(seconds: 60), dataState);
} }
} }
@ -280,7 +285,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
void submitDomainForAccessRecovery(String domain) async { void submitDomainForAccessRecovery(String domain) async {
var serverDomain = ServerDomain( var serverDomain = ServerDomain(
domainName: domain, domainName: domain,
provider: DnsProvider.Unknown, provider: DnsProvider.unknown,
zoneId: '', zoneId: '',
); );
final recoveryCapabilities = final recoveryCapabilities =
@ -291,12 +296,12 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
emit(ServerInstallationRecovery( emit(ServerInstallationRecovery(
serverDomain: serverDomain, serverDomain: serverDomain,
recoveryCapabilities: recoveryCapabilities, recoveryCapabilities: recoveryCapabilities,
currentStep: RecoveryStep.Selecting, currentStep: RecoveryStep.selecting,
)); ));
} }
void tryToRecover(String token, ServerRecoveryMethods method) async { void tryToRecover(String token, ServerRecoveryMethods method) async {
final dataState = this.state as ServerInstallationRecovery; final dataState = state as ServerInstallationRecovery;
final serverDomain = dataState.serverDomain; final serverDomain = dataState.serverDomain;
if (serverDomain == null) { if (serverDomain == null) {
return; return;
@ -324,7 +329,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
await repository.saveServerDetails(serverDetails); await repository.saveServerDetails(serverDetails);
emit(dataState.copyWith( emit(dataState.copyWith(
serverDetails: serverDetails, serverDetails: serverDetails,
currentStep: RecoveryStep.HetznerToken, currentStep: RecoveryStep.hetznerToken,
)); ));
} on ServerAuthorizationException { } on ServerAuthorizationException {
getIt<NavigationService>() getIt<NavigationService>()
@ -338,23 +343,23 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
} }
void revertRecoveryStep() { void revertRecoveryStep() {
final dataState = this.state as ServerInstallationRecovery; final dataState = state as ServerInstallationRecovery;
switch (dataState.currentStep) { switch (dataState.currentStep) {
case RecoveryStep.Selecting: case RecoveryStep.selecting:
repository.deleteDomain(); repository.deleteDomain();
emit(ServerInstallationEmpty()); emit(const ServerInstallationEmpty());
break; break;
case RecoveryStep.RecoveryKey: case RecoveryStep.recoveryKey:
case RecoveryStep.NewDeviceKey: case RecoveryStep.newDeviceKey:
case RecoveryStep.OldToken: case RecoveryStep.oldToken:
emit(dataState.copyWith( emit(dataState.copyWith(
currentStep: RecoveryStep.Selecting, currentStep: RecoveryStep.selecting,
)); ));
break; break;
case RecoveryStep.ServerSelection: case RecoveryStep.serverSelection:
repository.deleteHetznerKey(); repository.deleteHetznerKey();
emit(dataState.copyWith( emit(dataState.copyWith(
currentStep: RecoveryStep.HetznerToken, currentStep: RecoveryStep.hetznerToken,
)); ));
break; break;
// We won't revert steps after client is authorized // We won't revert steps after client is authorized
@ -364,21 +369,21 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
} }
void selectRecoveryMethod(ServerRecoveryMethods method) { void selectRecoveryMethod(ServerRecoveryMethods method) {
final dataState = this.state as ServerInstallationRecovery; final dataState = state as ServerInstallationRecovery;
switch (method) { switch (method) {
case ServerRecoveryMethods.newDeviceKey: case ServerRecoveryMethods.newDeviceKey:
emit(dataState.copyWith( emit(dataState.copyWith(
currentStep: RecoveryStep.NewDeviceKey, currentStep: RecoveryStep.newDeviceKey,
)); ));
break; break;
case ServerRecoveryMethods.recoveryKey: case ServerRecoveryMethods.recoveryKey:
emit(dataState.copyWith( emit(dataState.copyWith(
currentStep: RecoveryStep.RecoveryKey, currentStep: RecoveryStep.recoveryKey,
)); ));
break; break;
case ServerRecoveryMethods.oldToken: case ServerRecoveryMethods.oldToken:
emit(dataState.copyWith( emit(dataState.copyWith(
currentStep: RecoveryStep.OldToken, currentStep: RecoveryStep.oldToken,
)); ));
break; break;
} }
@ -386,7 +391,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
Future<List<ServerBasicInfoWithValidators>> Future<List<ServerBasicInfoWithValidators>>
getServersOnHetznerAccount() async { getServersOnHetznerAccount() async {
final dataState = this.state as ServerInstallationRecovery; final dataState = state as ServerInstallationRecovery;
final servers = await repository.getServersOnHetznerAccount(); final servers = await repository.getServersOnHetznerAccount();
final validated = servers final validated = servers
.map((server) => ServerBasicInfoWithValidators.fromServerBasicInfo( .map((server) => ServerBasicInfoWithValidators.fromServerBasicInfo(
@ -399,7 +404,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
} }
Future<void> setServerId(ServerBasicInfo server) async { Future<void> setServerId(ServerBasicInfo server) async {
final dataState = this.state as ServerInstallationRecovery; final dataState = state as ServerInstallationRecovery;
final serverDomain = dataState.serverDomain; final serverDomain = dataState.serverDomain;
if (serverDomain == null) { if (serverDomain == null) {
return; return;
@ -410,21 +415,21 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
createTime: server.created, createTime: server.created,
volume: ServerVolume( volume: ServerVolume(
id: server.volumeId, id: server.volumeId,
name: "recovered_volume", name: 'recovered_volume',
), ),
apiToken: dataState.serverDetails!.apiToken, apiToken: dataState.serverDetails!.apiToken,
provider: ServerProvider.Hetzner, provider: ServerProvider.hetzner,
); );
await repository.saveDomain(serverDomain); await repository.saveDomain(serverDomain);
await repository.saveServerDetails(serverDetails); await repository.saveServerDetails(serverDetails);
emit(dataState.copyWith( emit(dataState.copyWith(
serverDetails: serverDetails, serverDetails: serverDetails,
currentStep: RecoveryStep.CloudflareToken, currentStep: RecoveryStep.cloudflareToken,
)); ));
} }
Future<void> setAndValidateCloudflareToken(String token) async { Future<void> setAndValidateCloudflareToken(String token) async {
final dataState = this.state as ServerInstallationRecovery; final dataState = state as ServerInstallationRecovery;
final serverDomain = dataState.serverDomain; final serverDomain = dataState.serverDomain;
if (serverDomain == null) { if (serverDomain == null) {
return; return;
@ -438,17 +443,17 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
await repository.saveDomain(ServerDomain( await repository.saveDomain(ServerDomain(
domainName: serverDomain.domainName, domainName: serverDomain.domainName,
zoneId: zoneId, zoneId: zoneId,
provider: DnsProvider.Cloudflare, provider: DnsProvider.cloudflare,
)); ));
await repository.saveCloudFlareKey(token); await repository.saveCloudFlareKey(token);
emit(dataState.copyWith( emit(dataState.copyWith(
serverDomain: ServerDomain( serverDomain: ServerDomain(
domainName: serverDomain.domainName, domainName: serverDomain.domainName,
zoneId: zoneId, zoneId: zoneId,
provider: DnsProvider.Cloudflare, provider: DnsProvider.cloudflare,
), ),
cloudFlareKey: token, cloudFlareKey: token,
currentStep: RecoveryStep.BackblazeToken, currentStep: RecoveryStep.backblazeToken,
)); ));
} }
@ -474,7 +479,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
closeTimer(); closeTimer();
repository.clearAppConfig(); repository.clearAppConfig();
emit(ServerInstallationEmpty()); emit(const ServerInstallationEmpty());
} }
Future<void> serverDelete() async { Future<void> serverDelete() async {
@ -499,6 +504,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
)); ));
} }
@override
close() { close() {
closeTimer(); closeTimer();
return super.close(); return super.close();

View File

@ -62,7 +62,7 @@ class ServerInstallationRepository {
); );
} }
if (serverDomain != null && serverDomain.provider == DnsProvider.Unknown) { if (serverDomain != null && serverDomain.provider == DnsProvider.unknown) {
return ServerInstallationRecovery( return ServerInstallationRecovery(
hetznerKey: hetznerToken, hetznerKey: hetznerToken,
cloudFlareKey: cloudflareToken, cloudFlareKey: cloudflareToken,
@ -101,17 +101,17 @@ class ServerInstallationRepository {
) { ) {
if (serverDetails != null) { if (serverDetails != null) {
if (hetznerToken != null) { if (hetznerToken != null) {
if (serverDetails.provider != ServerProvider.Unknown) { if (serverDetails.provider != ServerProvider.unknown) {
if (serverDomain.provider != DnsProvider.Unknown) { if (serverDomain.provider != DnsProvider.unknown) {
return RecoveryStep.BackblazeToken; 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() { void clearAppConfig() {
@ -271,7 +271,7 @@ class ServerInstallationRepository {
var nav = getIt.get<NavigationService>(); var nav = getIt.get<NavigationService>();
nav.showPopUpDialog( nav.showPopUpDialog(
BrandAlert( BrandAlert(
title: e.response!.data["errors"][0]["code"] == 1038 title: e.response!.data['errors'][0]['code'] == 1038
? 'modals.10'.tr() ? 'modals.10'.tr()
: 'providers.domain.states.error'.tr(), : 'providers.domain.states.error'.tr(),
contentText: 'modals.6'.tr(), contentText: 'modals.6'.tr(),
@ -309,7 +309,7 @@ class ServerInstallationRepository {
var dkimRecordString = await api.getDkim(); var dkimRecordString = await api.getDkim();
await cloudflareApi.setDkim(dkimRecordString ?? "", cloudFlareDomain); await cloudflareApi.setDkim(dkimRecordString ?? '', cloudFlareDomain);
} }
Future<bool> isHttpServerWorking() async { Future<bool> isHttpServerWorking() async {
@ -408,7 +408,7 @@ class ServerInstallationRepository {
id: 0, id: 0,
name: '', name: '',
), ),
provider: ServerProvider.Unknown, provider: ServerProvider.unknown,
id: 0, id: 0,
ip4: serverIp, ip4: serverIp,
startTime: null, startTime: null,
@ -439,7 +439,7 @@ class ServerInstallationRepository {
id: 0, id: 0,
name: '', name: '',
), ),
provider: ServerProvider.Unknown, provider: ServerProvider.unknown,
id: 0, id: 0,
ip4: '', ip4: '',
startTime: null, startTime: null,
@ -472,7 +472,7 @@ class ServerInstallationRepository {
id: 0, id: 0,
name: '', name: '',
), ),
provider: ServerProvider.Unknown, provider: ServerProvider.unknown,
id: 0, id: 0,
ip4: '', ip4: '',
startTime: null, startTime: null,
@ -487,7 +487,7 @@ class ServerInstallationRepository {
Future<User> getMainUser() async { Future<User> getMainUser() async {
var serverApi = ServerApi(); var serverApi = ServerApi();
final fallbackUser = User( const fallbackUser = User(
isFoundOnServer: false, isFoundOnServer: false,
note: 'Couldn\'t find main user on server, API is outdated', note: 'Couldn\'t find main user on server, API is outdated',
login: 'UNKNOWN', login: 'UNKNOWN',

View File

@ -122,7 +122,7 @@ class ServerInstallationNotFinished extends ServerInstallationState {
final bool isLoading; final bool isLoading;
final Map<String, bool>? dnsMatches; final Map<String, bool>? dnsMatches;
ServerInstallationNotFinished({ const ServerInstallationNotFinished({
String? hetznerKey, String? hetznerKey,
String? cloudFlareKey, String? cloudFlareKey,
BackblazeCredential? backblazeCredential, BackblazeCredential? backblazeCredential,
@ -203,7 +203,7 @@ class ServerInstallationNotFinished extends ServerInstallationState {
} }
class ServerInstallationEmpty extends ServerInstallationNotFinished { class ServerInstallationEmpty extends ServerInstallationNotFinished {
ServerInstallationEmpty() const ServerInstallationEmpty()
: super( : super(
hetznerKey: null, hetznerKey: null,
cloudFlareKey: null, cloudFlareKey: null,
@ -256,14 +256,14 @@ class ServerInstallationFinished extends ServerInstallationState {
} }
enum RecoveryStep { enum RecoveryStep {
Selecting, selecting,
RecoveryKey, recoveryKey,
NewDeviceKey, newDeviceKey,
OldToken, oldToken,
HetznerToken, hetznerToken,
ServerSelection, serverSelection,
CloudflareToken, cloudflareToken,
BackblazeToken, backblazeToken,
} }
enum ServerRecoveryCapabilities { enum ServerRecoveryCapabilities {
@ -289,8 +289,8 @@ class ServerInstallationRecovery extends ServerInstallationState {
ServerDomain? serverDomain, ServerDomain? serverDomain,
User? rootUser, User? rootUser,
ServerHostingDetails? serverDetails, ServerHostingDetails? serverDetails,
required RecoveryStep this.currentStep, required this.currentStep,
required ServerRecoveryCapabilities this.recoveryCapabilities, required this.recoveryCapabilities,
}) : super( }) : super(
hetznerKey: hetznerKey, hetznerKey: hetznerKey,
cloudFlareKey: cloudFlareKey, cloudFlareKey: cloudFlareKey,

View File

@ -1,7 +1,6 @@
import 'package:selfprivacy/logic/api_maps/server.dart'; import 'package:selfprivacy/logic/api_maps/server.dart';
import 'package:selfprivacy/logic/common_enum/common_enum.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/app_config_dependent/authentication_dependend_cubit.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
part 'services_state.dart'; part 'services_state.dart';
@ -9,6 +8,7 @@ class ServicesCubit extends ServerInstallationDependendCubit<ServicesState> {
ServicesCubit(ServerInstallationCubit serverInstallationCubit) ServicesCubit(ServerInstallationCubit serverInstallationCubit)
: super(serverInstallationCubit, ServicesState.allOff()); : super(serverInstallationCubit, ServicesState.allOff());
final api = ServerApi(); final api = ServerApi();
@override
Future<void> load() async { Future<void> load() async {
if (serverInstallationCubit.state is ServerInstallationFinished) { if (serverInstallationCubit.state is ServerInstallationFinished) {
var statuses = await api.servicesPowerCheck(); var statuses = await api.servicesPowerCheck();

View File

@ -15,14 +15,14 @@ class ServicesState extends ServerInstallationDependendState {
final bool isSocialNetworkEnable; final bool isSocialNetworkEnable;
final bool isVpnEnable; final bool isVpnEnable;
factory ServicesState.allOff() => ServicesState( factory ServicesState.allOff() => const ServicesState(
isPasswordManagerEnable: false, isPasswordManagerEnable: false,
isCloudEnable: false, isCloudEnable: false,
isGitEnable: false, isGitEnable: false,
isSocialNetworkEnable: false, isSocialNetworkEnable: false,
isVpnEnable: false, isVpnEnable: false,
); );
factory ServicesState.allOn() => ServicesState( factory ServicesState.allOn() => const ServicesState(
isPasswordManagerEnable: true, isPasswordManagerEnable: true,
isCloudEnable: true, isCloudEnable: true,
isGitEnable: true, isGitEnable: true,

View File

@ -1,7 +1,6 @@
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:selfprivacy/config/hive_config.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/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 'package:selfprivacy/logic/models/hive/user.dart';
import '../../api_maps/server.dart'; import '../../api_maps/server.dart';
@ -14,18 +13,19 @@ class UsersCubit extends ServerInstallationDependendCubit<UsersState> {
UsersCubit(ServerInstallationCubit serverInstallationCubit) UsersCubit(ServerInstallationCubit serverInstallationCubit)
: super( : super(
serverInstallationCubit, serverInstallationCubit,
UsersState( const UsersState(
<User>[], User(login: 'root'), User(login: 'loading...'))); <User>[], User(login: 'root'), User(login: 'loading...')));
Box<User> box = Hive.box<User>(BNames.usersBox); Box<User> box = Hive.box<User>(BNames.usersBox);
Box serverInstallationBox = Hive.box(BNames.serverInstallationBox); Box serverInstallationBox = Hive.box(BNames.serverInstallationBox);
final api = ServerApi(); final api = ServerApi();
@override
Future<void> load() async { Future<void> load() async {
if (serverInstallationCubit.state is ServerInstallationFinished) { if (serverInstallationCubit.state is ServerInstallationFinished) {
var loadedUsers = box.values.toList(); var loadedUsers = box.values.toList();
final primaryUser = serverInstallationBox.get(BNames.rootUser, final primaryUser = serverInstallationBox.get(BNames.rootUser,
defaultValue: User(login: 'loading...')); defaultValue: const User(login: 'loading...'));
List<String> rootKeys = [ List<String> rootKeys = [
...serverInstallationBox.get(BNames.rootKeys, defaultValue: []) ...serverInstallationBox.get(BNames.rootKeys, defaultValue: [])
]; ];
@ -308,6 +308,7 @@ class UsersCubit extends ServerInstallationDependendCubit<UsersState> {
@override @override
void clear() async { void clear() async {
emit(UsersState(<User>[], User(login: 'root'), User(login: 'loading...'))); emit(const UsersState(
<User>[], User(login: 'root'), User(login: 'loading...')));
} }
} }

View File

@ -6,7 +6,7 @@ import 'package:selfprivacy/logic/models/hive/server_details.dart';
import 'package:selfprivacy/logic/models/hive/server_domain.dart'; import 'package:selfprivacy/logic/models/hive/server_domain.dart';
class ApiConfigModel { class ApiConfigModel {
Box _box = Hive.box(BNames.serverInstallationBox); final Box _box = Hive.box(BNames.serverInstallationBox);
ServerHostingDetails? get serverDetails => _serverDetails; ServerHostingDetails? get serverDetails => _serverDetails;
String? get hetznerKey => _hetznerKey; String? get hetznerKey => _hetznerKey;

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:selfprivacy/logic/models/message.dart'; import 'package:selfprivacy/logic/models/message.dart';
class ConsoleModel extends ChangeNotifier { class ConsoleModel extends ChangeNotifier {
List<Message> _messages = []; final List<Message> _messages = [];
List<Message> get messages => _messages; List<Message> get messages => _messages;

View File

@ -24,6 +24,6 @@ class BackblazeBucket {
@override @override
String toString() { String toString() {
return '$bucketName'; return bucketName;
} }
} }

View File

@ -23,7 +23,7 @@ class BackblazeCredential {
} }
String encodedBackblazeKey(String? keyId, String? applicationKey) { String encodedBackblazeKey(String? keyId, String? applicationKey) {
String _apiKey = '$keyId:$applicationKey'; String apiKey = '$keyId:$applicationKey';
String encodedApiKey = base64.encode(utf8.encode(_apiKey)); String encodedApiKey = base64.encode(utf8.encode(apiKey));
return encodedApiKey; return encodedApiKey;
} }

View File

@ -32,7 +32,7 @@ class ServerHostingDetails {
@HiveField(5) @HiveField(5)
final String apiToken; final String apiToken;
@HiveField(6, defaultValue: ServerProvider.Hetzner) @HiveField(6, defaultValue: ServerProvider.hetzner)
final ServerProvider provider; final ServerProvider provider;
ServerHostingDetails copyWith({DateTime? startTime}) { ServerHostingDetails copyWith({DateTime? startTime}) {
@ -47,6 +47,7 @@ class ServerHostingDetails {
); );
} }
@override
String toString() => id.toString(); String toString() => id.toString();
} }
@ -66,7 +67,7 @@ class ServerVolume {
@HiveType(typeId: 101) @HiveType(typeId: 101)
enum ServerProvider { enum ServerProvider {
@HiveField(0) @HiveField(0)
Unknown, unknown,
@HiveField(1) @HiveField(1)
Hetzner, hetzner,
} }

View File

@ -23,7 +23,7 @@ class ServerHostingDetailsAdapter extends TypeAdapter<ServerHostingDetails> {
volume: fields[4] as ServerVolume, volume: fields[4] as ServerVolume,
apiToken: fields[5] as String, apiToken: fields[5] as String,
provider: fields[6] == null provider: fields[6] == null
? ServerProvider.Hetzner ? ServerProvider.hetzner
: fields[6] as ServerProvider, : fields[6] as ServerProvider,
startTime: fields[2] as DateTime?, startTime: fields[2] as DateTime?,
); );
@ -105,21 +105,21 @@ class ServerProviderAdapter extends TypeAdapter<ServerProvider> {
ServerProvider read(BinaryReader reader) { ServerProvider read(BinaryReader reader) {
switch (reader.readByte()) { switch (reader.readByte()) {
case 0: case 0:
return ServerProvider.Unknown; return ServerProvider.unknown;
case 1: case 1:
return ServerProvider.Hetzner; return ServerProvider.hetzner;
default: default:
return ServerProvider.Unknown; return ServerProvider.unknown;
} }
} }
@override @override
void write(BinaryWriter writer, ServerProvider obj) { void write(BinaryWriter writer, ServerProvider obj) {
switch (obj) { switch (obj) {
case ServerProvider.Unknown: case ServerProvider.unknown:
writer.writeByte(0); writer.writeByte(0);
break; break;
case ServerProvider.Hetzner: case ServerProvider.hetzner:
writer.writeByte(1); writer.writeByte(1);
break; break;
} }

View File

@ -16,7 +16,7 @@ class ServerDomain {
@HiveField(1) @HiveField(1)
final String zoneId; final String zoneId;
@HiveField(2, defaultValue: DnsProvider.Cloudflare) @HiveField(2, defaultValue: DnsProvider.cloudflare)
final DnsProvider provider; final DnsProvider provider;
@override @override
@ -28,7 +28,7 @@ class ServerDomain {
@HiveType(typeId: 100) @HiveType(typeId: 100)
enum DnsProvider { enum DnsProvider {
@HiveField(0) @HiveField(0)
Unknown, unknown,
@HiveField(1) @HiveField(1)
Cloudflare, cloudflare,
} }

View File

@ -20,7 +20,7 @@ class ServerDomainAdapter extends TypeAdapter<ServerDomain> {
domainName: fields[0] as String, domainName: fields[0] as String,
zoneId: fields[1] as String, zoneId: fields[1] as String,
provider: 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> {
DnsProvider read(BinaryReader reader) { DnsProvider read(BinaryReader reader) {
switch (reader.readByte()) { switch (reader.readByte()) {
case 0: case 0:
return DnsProvider.Unknown; return DnsProvider.unknown;
case 1: case 1:
return DnsProvider.Cloudflare; return DnsProvider.cloudflare;
default: default:
return DnsProvider.Unknown; return DnsProvider.unknown;
} }
} }
@override @override
void write(BinaryWriter writer, DnsProvider obj) { void write(BinaryWriter writer, DnsProvider obj) {
switch (obj) { switch (obj) {
case DnsProvider.Unknown: case DnsProvider.unknown:
writer.writeByte(0); writer.writeByte(0);
break; break;
case DnsProvider.Cloudflare: case DnsProvider.cloudflare:
writer.writeByte(1); writer.writeByte(1);
break; break;
} }

View File

@ -8,7 +8,7 @@ part 'user.g.dart';
@HiveType(typeId: 1) @HiveType(typeId: 1)
class User extends Equatable { class User extends Equatable {
User({ const User({
required this.login, required this.login,
this.password, this.password,
this.sshKeys = const [], this.sshKeys = const [],
@ -22,7 +22,7 @@ class User extends Equatable {
@HiveField(1) @HiveField(1)
final String? password; final String? password;
@HiveField(2, defaultValue: const []) @HiveField(2, defaultValue: [])
final List<String> sshKeys; final List<String> sshKeys;
@HiveField(3, defaultValue: true) @HiveField(3, defaultValue: true)
@ -36,6 +36,7 @@ class User extends Equatable {
Color get color => stringToColor(login); Color get color => stringToColor(login);
@override
String toString() { String toString() {
return '$login, ${isFoundOnServer ? 'found' : 'not found'}, ${sshKeys.length} ssh keys, note: $note'; return '$login, ${isFoundOnServer ? 'found' : 'not found'}, ${sshKeys.length} ssh keys, note: $note';
} }

View File

@ -71,7 +71,7 @@ class CreateSSHKeyJob extends Job {
CreateSSHKeyJob({ CreateSSHKeyJob({
required this.user, required this.user,
required this.publicKey, 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 User user;
final String publicKey; final String publicKey;
@ -84,7 +84,7 @@ class DeleteSSHKeyJob extends Job {
DeleteSSHKeyJob({ DeleteSSHKeyJob({
required this.user, required this.user,
required this.publicKey, 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 User user;
final String publicKey; final String publicKey;

View File

@ -7,12 +7,13 @@ class ApiToken {
ApiToken({ ApiToken({
required this.name, required this.name,
required this.date, required this.date,
required this.is_caller, required this.isCaller,
}); });
final String name; final String name;
final DateTime date; final DateTime date;
final bool is_caller; @JsonKey(name: 'is_caller')
final bool isCaller;
factory ApiToken.fromJson(Map<String, dynamic> json) => factory ApiToken.fromJson(Map<String, dynamic> json) =>
_$ApiTokenFromJson(json); _$ApiTokenFromJson(json);

View File

@ -9,5 +9,5 @@ part of 'api_token.dart';
ApiToken _$ApiTokenFromJson(Map<String, dynamic> json) => ApiToken( ApiToken _$ApiTokenFromJson(Map<String, dynamic> json) => ApiToken(
name: json['name'] as String, name: json['name'] as String,
date: DateTime.parse(json['date'] as String), date: DateTime.parse(json['date'] as String),
is_caller: json['is_caller'] as bool, isCaller: json['is_caller'] as bool,
); );

View File

@ -8,7 +8,7 @@ class AutoUpgradeSettings extends Equatable {
final bool enable; final bool enable;
final bool allowReboot; final bool allowReboot;
AutoUpgradeSettings({ const AutoUpgradeSettings({
required this.enable, required this.enable,
required this.allowReboot, required this.allowReboot,
}); });

View File

@ -5,7 +5,7 @@ part 'recovery_token_status.g.dart';
@JsonSerializable() @JsonSerializable()
class RecoveryKeyStatus extends Equatable { class RecoveryKeyStatus extends Equatable {
RecoveryKeyStatus({ const RecoveryKeyStatus({
required this.exists, required this.exists,
required this.valid, required this.valid,
this.date, this.date,

View File

@ -1,6 +1,6 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
final formatter = new DateFormat('hh:mm'); final formatter = DateFormat('hh:mm');
class Message { class Message {
Message({this.text, this.type = MessageType.normal}) : time = DateTime.now(); Message({this.text, this.type = MessageType.normal}) : time = DateTime.now();

View File

@ -85,9 +85,9 @@ class MyApp extends StatelessWidget {
appSettings.isDarkModeOn ? ThemeMode.dark : ThemeMode.light, appSettings.isDarkModeOn ? ThemeMode.dark : ThemeMode.light,
home: appSettings.isOnboardingShowing home: appSettings.isOnboardingShowing
? OnboardingPage(nextPage: InitializingPage()) ? OnboardingPage(nextPage: InitializingPage())
: RootPage(), : const RootPage(),
builder: (BuildContext context, Widget? widget) { builder: (BuildContext context, Widget? widget) {
Widget error = Text('...rendering error...'); Widget error = const Text('...rendering error...');
if (widget is Scaffold || widget is Navigator) { if (widget is Scaffold || widget is Navigator) {
error = Scaffold(body: Center(child: error)); error = Scaffold(body: Center(child: error));
} }

View File

@ -18,7 +18,7 @@ abstract class AppThemeFactory {
} }
static Future<ThemeData> _createAppTheme({ static Future<ThemeData> _createAppTheme({
bool isDark: false, bool isDark = false,
required Color fallbackColor, required Color fallbackColor,
}) async { }) async {
ColorScheme? gtkColorsScheme; ColorScheme? gtkColorsScheme;
@ -39,12 +39,12 @@ abstract class AppThemeFactory {
); );
} }
final accentColor = await SystemAccentColor(fallbackColor); final accentColor = SystemAccentColor(fallbackColor);
try { try {
await accentColor.load(); await accentColor.load();
} on MissingPluginException catch (e) { } on MissingPluginException catch (e) {
print("_createAppTheme: ${e.message}"); print('_createAppTheme: ${e.message}');
} }
final fallbackColorScheme = ColorScheme.fromSeed( final fallbackColorScheme = ColorScheme.fromSeed(

View File

@ -20,7 +20,7 @@ class ActionButton extends StatelessWidget {
return TextButton( return TextButton(
child: Text( child: Text(
text!, text!,
style: isRed ? TextStyle(color: BrandColors.red1) : null, style: isRed ? const TextStyle(color: BrandColors.red1) : null,
), ),
onPressed: () { onPressed: () {
navigator.pop(); navigator.pop();

View File

@ -44,9 +44,9 @@ class BrandBottomSheet extends StatelessWidget {
), ),
), ),
), ),
SizedBox(height: 6), const SizedBox(height: 6),
ClipRRect( ClipRRect(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)), borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
child: ConstrainedBox( child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: mainHeight), constraints: BoxConstraints(maxHeight: mainHeight),
child: innerWidget, child: innerWidget,

View File

@ -14,7 +14,7 @@ class BrandButton {
assert(text == null || child == null, 'required title or child'); assert(text == null || child == null, 'required title or child');
assert(text != null || child != null, 'required title or child'); assert(text != null || child != null, 'required title or child');
return ConstrainedBox( return ConstrainedBox(
constraints: BoxConstraints( constraints: const BoxConstraints(
minHeight: 48, minHeight: 48,
minWidth: double.infinity, minWidth: double.infinity,
), ),
@ -33,7 +33,7 @@ class BrandButton {
required String title, required String title,
}) => }) =>
ConstrainedBox( ConstrainedBox(
constraints: BoxConstraints( constraints: const BoxConstraints(
minHeight: 48, minHeight: 48,
minWidth: double.infinity, minWidth: double.infinity,
), ),

View File

@ -16,11 +16,11 @@ class FilledButton extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ElevatedButton( return ElevatedButton(
onPressed: onPressed, onPressed: onPressed,
child: child ?? Text(title ?? ''),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
onPrimary: Theme.of(context).colorScheme.onPrimary, onPrimary: Theme.of(context).colorScheme.onPrimary,
primary: Theme.of(context).colorScheme.primary, primary: Theme.of(context).colorScheme.primary,
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0)), ).copyWith(elevation: ButtonStyleButton.allOrNull(0.0)),
child: child ?? Text(title ?? ''),
); );
} }
} }

View File

@ -3,22 +3,22 @@ import 'package:selfprivacy/config/brand_colors.dart';
class BrandCards { class BrandCards {
static Widget big({required Widget child}) => _BrandCard( static Widget big({required Widget child}) => _BrandCard(
child: child, padding: const EdgeInsets.symmetric(
padding: EdgeInsets.symmetric(
horizontal: 20, horizontal: 20,
vertical: 15, vertical: 15,
), ),
shadow: bigShadow, shadow: bigShadow,
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
child: child,
); );
static Widget small({required Widget child}) => _BrandCard( static Widget small({required Widget child}) => _BrandCard(
child: child, padding: const EdgeInsets.symmetric(
padding: EdgeInsets.symmetric(
horizontal: 15, horizontal: 15,
vertical: 10, vertical: 10,
), ),
shadow: bigShadow, shadow: bigShadow,
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
child: child,
); );
static Widget outlined({required Widget child}) => _OutlinedCard( static Widget outlined({required Widget child}) => _OutlinedCard(
child: child, child: child,
@ -70,7 +70,7 @@ class _OutlinedCard extends StatelessWidget {
return Card( return Card(
elevation: 0.0, elevation: 0.0,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(12)), borderRadius: const BorderRadius.all(Radius.circular(12)),
side: BorderSide( side: BorderSide(
color: Theme.of(context).colorScheme.outline, color: Theme.of(context).colorScheme.outline,
), ),
@ -92,19 +92,19 @@ class _FilledCard extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card( return Card(
elevation: 0.0, elevation: 0.0,
shape: RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(12)), borderRadius: BorderRadius.all(Radius.circular(12)),
), ),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: child,
color: Theme.of(context).colorScheme.surfaceVariant, color: Theme.of(context).colorScheme.surfaceVariant,
child: child,
); );
} }
} }
final bigShadow = [ final bigShadow = [
BoxShadow( BoxShadow(
offset: Offset(0, 4), offset: const Offset(0, 4),
blurRadius: 8, blurRadius: 8,
color: Colors.black.withOpacity(.08), color: Colors.black.withOpacity(.08),
) )

View File

@ -6,7 +6,7 @@ import 'package:selfprivacy/ui/components/pre_styled_buttons/pre_styled_buttons.
class BrandHeader extends StatelessWidget { class BrandHeader extends StatelessWidget {
const BrandHeader({ const BrandHeader({
Key? key, Key? key,
this.title = "", this.title = '',
this.hasBackButton = false, this.hasBackButton = false,
this.hasFlashButton = false, this.hasFlashButton = false,
this.onBackButtonPressed, this.onBackButtonPressed,
@ -25,22 +25,20 @@ class BrandHeader extends StatelessWidget {
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: hasBackButton ? 1 : 15, left: hasBackButton ? 1 : 15,
), ),
child: Container( child: Row(
child: Row( children: [
children: [ if (hasBackButton) ...[
if (hasBackButton) ...[ IconButton(
IconButton( icon: const Icon(BrandIcons.arrowLeft),
icon: Icon(BrandIcons.arrow_left), onPressed:
onPressed: onBackButtonPressed ?? () => Navigator.of(context).pop(),
onBackButtonPressed ?? () => Navigator.of(context).pop(), ),
), const SizedBox(width: 10),
SizedBox(width: 10),
],
BrandText.h4(title),
Spacer(),
if (hasFlashButton) PreStyledButtons.flash(),
], ],
), BrandText.h4(title),
const Spacer(),
if (hasFlashButton) PreStyledButtons.flash(),
],
), ),
); );
} }

View File

@ -28,7 +28,7 @@ class BrandHeroScreen extends StatelessWidget {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: Size.fromHeight(52.0), preferredSize: const Size.fromHeight(52.0),
child: BrandHeader( child: BrandHeader(
title: headerTitle, title: headerTitle,
hasBackButton: hasBackButton, hasBackButton: hasBackButton,
@ -37,29 +37,29 @@ class BrandHeroScreen extends StatelessWidget {
), ),
), ),
body: ListView( body: ListView(
padding: EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
children: <Widget>[ children: <Widget>[
if (heroIcon != null) if (heroIcon != null)
Container( Container(
alignment: Alignment.bottomLeft,
child: Icon( child: Icon(
heroIcon, heroIcon,
size: 48.0, size: 48.0,
), ),
alignment: Alignment.bottomLeft,
), ),
SizedBox(height: 8.0), const SizedBox(height: 8.0),
if (heroTitle != null) if (heroTitle != null)
Text( Text(
heroTitle!, heroTitle!,
style: Theme.of(context).textTheme.headlineMedium, style: Theme.of(context).textTheme.headlineMedium,
textAlign: TextAlign.start, textAlign: TextAlign.start,
), ),
SizedBox(height: 8.0), const SizedBox(height: 8.0),
if (heroSubtitle != null) if (heroSubtitle != null)
Text(heroSubtitle!, Text(heroSubtitle!,
style: Theme.of(context).textTheme.bodyMedium, style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.start), textAlign: TextAlign.start),
SizedBox(height: 16.0), const SizedBox(height: 16.0),
...children, ...children,
], ],
), ),

View File

@ -67,7 +67,7 @@ class BrandIcons {
IconData(0xe815, fontFamily: _kFontFam, fontPackage: _kFontPkg); IconData(0xe815, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData upload = static const IconData upload =
IconData(0xe816, fontFamily: _kFontFam, fontPackage: _kFontPkg); IconData(0xe816, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData arrow_left = static const IconData arrowLeft =
IconData(0xe818, fontFamily: _kFontFam, fontPackage: _kFontPkg); IconData(0xe818, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData shape = static const IconData shape =
IconData(0xe819, fontFamily: _kFontFam, fontPackage: _kFontPkg); IconData(0xe819, fontFamily: _kFontFam, fontPackage: _kFontPkg);

View File

@ -12,8 +12,8 @@ class _HorizontalLoader extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text('basis.wait'.tr()), Text('basis.wait'.tr()),
SizedBox(height: 10), const SizedBox(height: 10),
LinearProgressIndicator(minHeight: 3), const LinearProgressIndicator(minHeight: 3),
], ],
); );
} }

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:selfprivacy/config/brand_colors.dart'; import 'package:selfprivacy/config/brand_colors.dart';
class BrandRadio extends StatelessWidget { class BrandRadio extends StatelessWidget {
BrandRadio({ const BrandRadio({
Key? key, Key? key,
required this.isChecked, required this.isChecked,
}) : super(key: key); }) : super(key: key);
@ -15,7 +15,7 @@ class BrandRadio extends StatelessWidget {
height: 20, height: 20,
width: 20, width: 20,
alignment: Alignment.center, alignment: Alignment.center,
padding: EdgeInsets.all(2), padding: const EdgeInsets.all(2),
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
border: _getBorder(), border: _getBorder(),
@ -24,7 +24,7 @@ class BrandRadio extends StatelessWidget {
? Container( ? Container(
height: 10, height: 10,
width: 10, width: 10,
decoration: BoxDecoration( decoration: const BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: BrandColors.primary, color: BrandColors.primary,
), ),

View File

@ -21,13 +21,13 @@ class BrandRadioTile extends StatelessWidget {
onTap: onPress, onTap: onPress,
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
child: Padding( child: Padding(
padding: EdgeInsets.all(2), padding: const EdgeInsets.all(2),
child: Row( child: Row(
children: [ children: [
BrandRadio( BrandRadio(
isChecked: isChecked, isChecked: isChecked,
), ),
SizedBox(width: 9), const SizedBox(width: 9),
BrandText.h5(text) BrandText.h5(text)
], ],
), ),

View File

@ -11,7 +11,7 @@ class BrandSpanButton extends TextSpan {
}) : super( }) : super(
recognizer: TapGestureRecognizer()..onTap = onTap, recognizer: TapGestureRecognizer()..onTap = onTap,
text: text, text: text,
style: (style ?? TextStyle()).copyWith(color: BrandColors.blue), style: (style ?? const TextStyle()).copyWith(color: BrandColors.blue),
); );
static link({ static link({

View File

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart'; import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
class BrandTabBar extends StatefulWidget { class BrandTabBar extends StatefulWidget {
BrandTabBar({Key? key, this.controller}) : super(key: key); const BrandTabBar({Key? key, this.controller}) : super(key: key);
final TabController? controller; final TabController? controller;
@override @override

View File

@ -31,7 +31,7 @@ class _BrandTimerState extends State<BrandTimer> {
_timerStart() { _timerStart() {
_timeString = differenceFromStart; _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); var timePassed = DateTime.now().difference(widget.startDateTime);
if (timePassed > widget.duration) { if (timePassed > widget.duration) {
t.cancel(); t.cancel();
@ -54,7 +54,7 @@ class _BrandTimerState extends State<BrandTimer> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BrandText.medium( return BrandText.medium(
_timeString, _timeString,
style: TextStyle( style: const TextStyle(
fontWeight: NamedFontWeight.demiBold, fontWeight: NamedFontWeight.demiBold,
), ),
); );
@ -71,10 +71,10 @@ class _BrandTimerState extends State<BrandTimer> {
String _durationToString(Duration duration) { String _durationToString(Duration duration) {
var timeLeft = widget.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); String twoDigitSeconds = twoDigits(timeLeft.inSeconds);
return "timer.sec".tr(args: [twoDigitSeconds]); return 'timer.sec'.tr(args: [twoDigitSeconds]);
} }
@override @override

View File

@ -16,7 +16,7 @@ class DotsIndicator extends StatelessWidget {
var dots = List.generate( var dots = List.generate(
count, count,
(index) => Container( (index) => Container(
margin: EdgeInsets.symmetric(horizontal: 5, vertical: 10), margin: const EdgeInsets.symmetric(horizontal: 5, vertical: 10),
height: 10, height: 10,
width: 10, width: 10,
decoration: BoxDecoration( decoration: BoxDecoration(

View File

@ -16,7 +16,7 @@ class BrandError extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text(error.toString()), Text(error.toString()),
Text('stackTrace: '), const Text('stackTrace: '),
Text(stackTrace.toString()), Text(stackTrace.toString()),
], ],
), ),

View File

@ -3,7 +3,7 @@ import 'package:selfprivacy/config/brand_colors.dart';
import 'package:selfprivacy/logic/models/state_types.dart'; import 'package:selfprivacy/logic/models/state_types.dart';
class IconStatusMask extends StatelessWidget { class IconStatusMask extends StatelessWidget {
IconStatusMask({required this.child, required this.status}); const IconStatusMask({required this.child, required this.status});
final Icon child; final Icon child;
final StateType status; final StateType status;
@ -24,8 +24,8 @@ class IconStatusMask extends StatelessWidget {
} }
return ShaderMask( return ShaderMask(
shaderCallback: (bounds) => LinearGradient( shaderCallback: (bounds) => LinearGradient(
begin: Alignment(-1, -0.8), begin: const Alignment(-1, -0.8),
end: Alignment(0.9, 0.9), end: const Alignment(0.9, 0.9),
colors: colors, colors: colors,
tileMode: TileMode.mirror, tileMode: TileMode.mirror,
).createShader(bounds), ).createShader(bounds),

View File

@ -24,19 +24,19 @@ class JobsContent extends StatelessWidget {
var installationState = context.read<ServerInstallationCubit>().state; var installationState = context.read<ServerInstallationCubit>().state;
if (state is JobsStateEmpty) { if (state is JobsStateEmpty) {
widgets = [ widgets = [
SizedBox(height: 80), const SizedBox(height: 80),
Center(child: BrandText.body1('jobs.empty'.tr())), Center(child: BrandText.body1('jobs.empty'.tr())),
]; ];
if (installationState is ServerInstallationFinished) { if (installationState is ServerInstallationFinished) {
widgets = [ widgets = [
...widgets, ...widgets,
SizedBox(height: 80), const SizedBox(height: 80),
BrandButton.rised( BrandButton.rised(
onPressed: () => context.read<JobsCubit>().upgradeServer(), onPressed: () => context.read<JobsCubit>().upgradeServer(),
text: 'jobs.upgradeServer'.tr(), text: 'jobs.upgradeServer'.tr(),
), ),
SizedBox(height: 10), const SizedBox(height: 10),
BrandButton.text( BrandButton.text(
onPressed: () { onPressed: () {
var nav = getIt<NavigationService>(); var nav = getIt<NavigationService>();
@ -61,7 +61,7 @@ class JobsContent extends StatelessWidget {
} }
} else if (state is JobsStateLoading) { } else if (state is JobsStateLoading) {
widgets = [ widgets = [
SizedBox(height: 80), const SizedBox(height: 80),
BrandLoader.horizontal(), BrandLoader.horizontal(),
]; ];
} else if (state is JobsStateWithJobs) { } else if (state is JobsStateWithJobs) {
@ -75,7 +75,7 @@ class JobsContent extends StatelessWidget {
child: Text(j.title), child: Text(j.title),
), ),
), ),
SizedBox(width: 10), const SizedBox(width: 10),
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: BrandColors.red1, primary: BrandColors.red1,
@ -91,7 +91,7 @@ class JobsContent extends StatelessWidget {
), ),
) )
.toList(), .toList(),
SizedBox(height: 20), const SizedBox(height: 20),
BrandButton.rised( BrandButton.rised(
onPressed: () => context.read<JobsCubit>().applyAll(), onPressed: () => context.read<JobsCubit>().applyAll(),
text: 'jobs.start'.tr(), text: 'jobs.start'.tr(),
@ -101,13 +101,13 @@ class JobsContent extends StatelessWidget {
return ListView( return ListView(
padding: paddingH15V0, padding: paddingH15V0,
children: [ children: [
SizedBox(height: 15), const SizedBox(height: 15),
Center( Center(
child: BrandText.h2( child: BrandText.h2(
'jobs.title'.tr(), 'jobs.title'.tr(),
), ),
), ),
SizedBox(height: 20), const SizedBox(height: 20),
...widgets ...widgets
], ],
); );

View File

@ -11,7 +11,7 @@ class NotReadyCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), color: BrandColors.gray6), borderRadius: BorderRadius.circular(15), color: BrandColors.gray6),
child: RichText( child: RichText(
@ -19,7 +19,7 @@ class NotReadyCard extends StatelessWidget {
children: [ children: [
TextSpan( TextSpan(
text: 'not_ready_card.1'.tr(), text: 'not_ready_card.1'.tr(),
style: TextStyle(color: BrandColors.white), style: const TextStyle(color: BrandColors.white),
), ),
WidgetSpan( WidgetSpan(
child: Padding( child: Padding(
@ -44,7 +44,7 @@ class NotReadyCard extends StatelessWidget {
), ),
TextSpan( TextSpan(
text: 'not_ready_card.3'.tr(), text: 'not_ready_card.3'.tr(),
style: TextStyle(color: BrandColors.white), style: const TextStyle(color: BrandColors.white),
), ),
], ],
), ),

View File

@ -18,18 +18,18 @@ class OnePage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(52),
child: Column( child: Column(
children: [ children: [
Container( Container(
height: 51, height: 51,
alignment: Alignment.center, alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 15), padding: const EdgeInsets.symmetric(horizontal: 15),
child: BrandText.h4('basis.details'.tr()), child: BrandText.h4('basis.details'.tr()),
), ),
BrandDivider(), const BrandDivider(),
], ],
), ),
preferredSize: Size.fromHeight(52),
), ),
body: child, body: child,
bottomNavigationBar: SafeArea( bottomNavigationBar: SafeArea(

View File

@ -13,7 +13,7 @@ class _CloseButton extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
BrandText.h4('basis.close'.tr()), BrandText.h4('basis.close'.tr()),
Icon(Icons.close), const Icon(Icons.close),
], ],
), ),
); );

View File

@ -1,7 +1,7 @@
part of 'pre_styled_buttons.dart'; part of 'pre_styled_buttons.dart';
class _BrandFlashButton extends StatefulWidget { class _BrandFlashButton extends StatefulWidget {
_BrandFlashButton({Key? key}) : super(key: key); const _BrandFlashButton({Key? key}) : super(key: key);
@override @override
_BrandFlashButtonState createState() => _BrandFlashButtonState(); _BrandFlashButtonState createState() => _BrandFlashButtonState();
@ -14,8 +14,8 @@ class _BrandFlashButtonState extends State<_BrandFlashButton>
@override @override
void initState() { void initState() {
_animationController = _animationController = AnimationController(
AnimationController(vsync: this, duration: Duration(milliseconds: 800)); vsync: this, duration: const Duration(milliseconds: 800));
_colorTween = ColorTween( _colorTween = ColorTween(
begin: BrandColors.black, begin: BrandColors.black,
end: BrandColors.primary, end: BrandColors.primary,
@ -61,7 +61,7 @@ class _BrandFlashButtonState extends State<_BrandFlashButton>
onPressed: () { onPressed: () {
showBrandBottomSheet( showBrandBottomSheet(
context: context, context: context,
builder: (context) => BrandBottomSheet( builder: (context) => const BrandBottomSheet(
isExpended: true, isExpended: true,
child: JobsContent(), child: JobsContent(),
), ),

View File

@ -8,7 +8,7 @@ import 'package:selfprivacy/ui/components/jobs_content/jobs_content.dart';
import 'package:selfprivacy/ui/helpers/modals.dart'; import 'package:selfprivacy/ui/helpers/modals.dart';
class BrandFab extends StatefulWidget { class BrandFab extends StatefulWidget {
BrandFab({Key? key}) : super(key: key); const BrandFab({Key? key}) : super(key: key);
@override @override
_BrandFabState createState() => _BrandFabState(); _BrandFabState createState() => _BrandFabState();
@ -21,8 +21,8 @@ class _BrandFabState extends State<BrandFab>
@override @override
void initState() { void initState() {
_animationController = _animationController = AnimationController(
AnimationController(vsync: this, duration: Duration(milliseconds: 800)); vsync: this, duration: const Duration(milliseconds: 800));
_colorTween = ColorTween( _colorTween = ColorTween(
begin: BrandColors.black, begin: BrandColors.black,
end: BrandColors.primary, end: BrandColors.primary,
@ -68,7 +68,7 @@ class _BrandFabState extends State<BrandFab>
onPressed: () { onPressed: () {
showBrandBottomSheet( showBrandBottomSheet(
context: context, context: context,
builder: (context) => BrandBottomSheet( builder: (context) => const BrandBottomSheet(
isExpended: true, isExpended: true,
child: JobsContent(), child: JobsContent(),
), ),

View File

@ -18,5 +18,5 @@ class PreStyledButtons {
}) => }) =>
_CloseButton(onPress: onPress); _CloseButton(onPress: onPress);
static Widget flash() => _BrandFlashButton(); static Widget flash() => const _BrandFlashButton();
} }

View File

@ -6,7 +6,7 @@ import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
class ProgressBar extends StatefulWidget { class ProgressBar extends StatefulWidget {
ProgressBar({ const ProgressBar({
Key? key, Key? key,
required this.steps, required this.steps,
required this.activeIndex, required this.activeIndex,
@ -49,12 +49,12 @@ class _ProgressBarState extends State<ProgressBar> {
odd.insert( odd.insert(
0, 0,
SizedBox( const SizedBox(
width: 10, width: 10,
), ),
); );
odd.add( odd.add(
SizedBox( const SizedBox(
width: 20, width: 20,
), ),
); );
@ -63,12 +63,12 @@ class _ProgressBarState extends State<ProgressBar> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
BrandText.h2('Progress'), BrandText.h2('Progress'),
SizedBox(height: 10), const SizedBox(height: 10),
Row( Row(
children: even,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: even,
), ),
SizedBox(height: 7), const SizedBox(height: 7),
Container( Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -82,23 +82,23 @@ class _ProgressBarState extends State<ProgressBar> {
height: 5, height: 5,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
gradient: LinearGradient( gradient: const LinearGradient(
begin: Alignment.topLeft, begin: Alignment.topLeft,
end: Alignment.bottomRight, end: Alignment.bottomRight,
colors: BrandColors.stableGradientColors, colors: BrandColors.stableGradientColors,
), ),
), ),
duration: Duration( duration: const Duration(
milliseconds: 300, milliseconds: 300,
), ),
); );
}, },
), ),
), ),
SizedBox(height: 5), const SizedBox(height: 5),
Row( Row(
children: odd,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: odd,
), ),
], ],
); );
@ -114,7 +114,7 @@ class _ProgressBarState extends State<ProgressBar> {
style = isActive ? style!.copyWith(fontWeight: FontWeight.w700) : style; style = isActive ? style!.copyWith(fontWeight: FontWeight.w700) : style;
return Container( return Container(
padding: EdgeInsets.only(left: 10), padding: const EdgeInsets.only(left: 10),
height: 20, height: 20,
alignment: Alignment.center, alignment: Alignment.center,
child: RichText( child: RichText(
@ -123,9 +123,9 @@ class _ProgressBarState extends State<ProgressBar> {
style: progressTextStyleLight, style: progressTextStyleLight,
children: [ children: [
checked checked
? WidgetSpan( ? const WidgetSpan(
child: Padding( child: Padding(
padding: const EdgeInsets.only(bottom: 2, right: 2), padding: EdgeInsets.only(bottom: 2, right: 2),
child: Icon(BrandIcons.check, size: 11), child: Icon(BrandIcons.check, size: 11),
)) ))
: TextSpan(text: '${index + 1}.', style: style), : TextSpan(text: '${index + 1}.', style: style),

View File

@ -16,8 +16,8 @@ class SwitcherBlock extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: EdgeInsets.only(top: 20, bottom: 5), padding: const EdgeInsets.only(top: 20, bottom: 5),
decoration: BoxDecoration( decoration: const BoxDecoration(
border: Border( border: Border(
bottom: BorderSide(width: 1, color: BrandColors.dividerColor), bottom: BorderSide(width: 1, color: BrandColors.dividerColor),
)), )),
@ -26,7 +26,7 @@ class SwitcherBlock extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Flexible(child: child), Flexible(child: child),
SizedBox(width: 5), const SizedBox(width: 5),
Switch( Switch(
activeColor: BrandColors.green1, activeColor: BrandColors.green1,
activeTrackColor: BrandColors.green2, activeTrackColor: BrandColors.green2,

View File

@ -9,6 +9,6 @@ Future<T?> showBrandBottomSheet<T>({
builder: builder, builder: builder,
barrierColor: Colors.black45, barrierColor: Colors.black45,
context: context, context: context,
shadow: BoxShadow(color: Colors.transparent), shadow: const BoxShadow(color: Colors.transparent),
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
); );

View File

@ -72,7 +72,7 @@ class _BackupDetailsState extends State<BackupDetails>
: () async { : () async {
await context.read<BackupsCubit>().createBackup(); await context.read<BackupsCubit>().createBackup();
}, },
leading: Icon( leading: const Icon(
Icons.add_circle_outline_rounded, Icons.add_circle_outline_rounded,
), ),
title: Text( title: Text(
@ -105,7 +105,7 @@ class _BackupDetailsState extends State<BackupDetails>
), ),
if (backupStatus == BackupStatusEnum.error) if (backupStatus == BackupStatusEnum.error)
ListTile( ListTile(
leading: Icon( leading: const Icon(
Icons.error_outline, Icons.error_outline,
color: BrandColors.red1, color: BrandColors.red1,
), ),
@ -117,7 +117,7 @@ class _BackupDetailsState extends State<BackupDetails>
], ],
), ),
), ),
SizedBox(height: 16), const SizedBox(height: 16),
// Card with a list of existing backups // Card with a list of existing backups
// Each list item has a date // Each list item has a date
// When clicked, starts the restore action // When clicked, starts the restore action
@ -128,7 +128,7 @@ class _BackupDetailsState extends State<BackupDetails>
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
ListTile( ListTile(
leading: Icon( leading: const Icon(
Icons.refresh, Icons.refresh,
), ),
title: Text( title: Text(
@ -136,12 +136,12 @@ class _BackupDetailsState extends State<BackupDetails>
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.headline6,
), ),
), ),
Divider( const Divider(
height: 1.0, height: 1.0,
), ),
if (backups.isEmpty) if (backups.isEmpty)
ListTile( ListTile(
leading: Icon( leading: const Icon(
Icons.error_outline, Icons.error_outline,
), ),
title: Text('providers.backup.no_backups'.tr()), title: Text('providers.backup.no_backups'.tr()),
@ -174,11 +174,7 @@ class _BackupDetailsState extends State<BackupDetails>
)); ));
}, },
title: Text( title: Text(
MaterialLocalizations.of(context) '${MaterialLocalizations.of(context).formatShortDate(backup.time)} ${TimeOfDay.fromDateTime(backup.time).format(context)}',
.formatShortDate(backup.time) +
' ' +
TimeOfDay.fromDateTime(backup.time)
.format(context),
), ),
); );
}).toList(), }).toList(),
@ -186,7 +182,7 @@ class _BackupDetailsState extends State<BackupDetails>
], ],
), ),
), ),
SizedBox(height: 16), const SizedBox(height: 16),
BrandCards.outlined( BrandCards.outlined(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -203,7 +199,7 @@ class _BackupDetailsState extends State<BackupDetails>
if (providerState != StateType.uninitialized) if (providerState != StateType.uninitialized)
Column( Column(
children: [ children: [
Divider( const Divider(
height: 1.0, height: 1.0,
), ),
ListTile( ListTile(
@ -218,7 +214,7 @@ class _BackupDetailsState extends State<BackupDetails>
.forceUpdateBackups() .forceUpdateBackups()
}, },
), ),
Divider( const Divider(
height: 1.0, height: 1.0,
), ),
ListTile( ListTile(

View File

@ -16,26 +16,26 @@ class _DnsDetailsPageState extends State<DnsDetailsPage> {
Widget _getStateCard(DnsRecordsStatus dnsState, Function fixCallback) { Widget _getStateCard(DnsRecordsStatus dnsState, Function fixCallback) {
var description = ''; var description = '';
var subtitle = ''; var subtitle = '';
var icon = Icon( var icon = const Icon(
Icons.check, Icons.check,
color: Colors.green, color: Colors.green,
); );
switch (dnsState) { switch (dnsState) {
case DnsRecordsStatus.uninitialized: case DnsRecordsStatus.uninitialized:
description = 'providers.domain.states.uninitialized'.tr(); description = 'providers.domain.states.uninitialized'.tr();
icon = Icon( icon = const Icon(
Icons.refresh, Icons.refresh,
); );
break; break;
case DnsRecordsStatus.refreshing: case DnsRecordsStatus.refreshing:
description = 'providers.domain.states.refreshing'.tr(); description = 'providers.domain.states.refreshing'.tr();
icon = Icon( icon = const Icon(
Icons.refresh, Icons.refresh,
); );
break; break;
case DnsRecordsStatus.good: case DnsRecordsStatus.good:
description = 'providers.domain.states.ok'.tr(); description = 'providers.domain.states.ok'.tr();
icon = Icon( icon = const Icon(
Icons.check, Icons.check,
color: Colors.green, color: Colors.green,
); );
@ -43,7 +43,7 @@ class _DnsDetailsPageState extends State<DnsDetailsPage> {
case DnsRecordsStatus.error: case DnsRecordsStatus.error:
description = 'providers.domain.states.error'.tr(); description = 'providers.domain.states.error'.tr();
subtitle = 'providers.domain.states.error_subtitle'.tr(); subtitle = 'providers.domain.states.error_subtitle'.tr();
icon = Icon( icon = const Icon(
Icons.error, Icons.error,
color: Colors.red, color: Colors.red,
); );
@ -104,7 +104,7 @@ class _DnsDetailsPageState extends State<DnsDetailsPage> {
), ),
), ),
SizedBox(height: 16.0), const SizedBox(height: 16.0),
// Outlined card with a list of A records and their // Outlined card with a list of A records and their
// status. // status.
BrandCards.outlined( BrandCards.outlined(
@ -128,7 +128,7 @@ class _DnsDetailsPageState extends State<DnsDetailsPage> {
.map( .map(
(dnsRecord) => Column( (dnsRecord) => Column(
children: [ children: [
Divider( const Divider(
height: 1.0, height: 1.0,
), ),
ListTile( ListTile(
@ -162,7 +162,7 @@ class _DnsDetailsPageState extends State<DnsDetailsPage> {
], ],
), ),
), ),
SizedBox(height: 16.0), const SizedBox(height: 16.0),
BrandCards.outlined( BrandCards.outlined(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
@ -184,7 +184,7 @@ class _DnsDetailsPageState extends State<DnsDetailsPage> {
.map( .map(
(dnsRecord) => Column( (dnsRecord) => Column(
children: [ children: [
Divider( const Divider(
height: 1.0, height: 1.0,
), ),
ListTile( ListTile(

View File

@ -11,14 +11,12 @@ class AboutPage extends StatelessWidget {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(52),
child: BrandHeader( child: BrandHeader(
title: 'more.about_project'.tr(), hasBackButton: true), title: 'more.about_project'.tr(), hasBackButton: true),
preferredSize: Size.fromHeight(52),
), ),
body: Container( body: const BrandMarkdown(
child: BrandMarkdown( fileName: 'about',
fileName: 'about',
),
), ),
), ),
); );

View File

@ -28,17 +28,17 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
child: Builder(builder: (context) { child: Builder(builder: (context) {
return Scaffold( return Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(52),
child: BrandHeader( child: BrandHeader(
title: 'more.settings.title'.tr(), hasBackButton: true), title: 'more.settings.title'.tr(), hasBackButton: true),
preferredSize: Size.fromHeight(52),
), ),
body: ListView( body: ListView(
padding: paddingH15V0, padding: paddingH15V0,
children: [ children: [
BrandDivider(), const BrandDivider(),
Container( Container(
padding: EdgeInsets.only(top: 20, bottom: 5), padding: const EdgeInsets.only(top: 20, bottom: 5),
decoration: BoxDecoration( decoration: const BoxDecoration(
border: Border( border: Border(
bottom: BorderSide(width: 1, color: BrandColors.dividerColor), bottom: BorderSide(width: 1, color: BrandColors.dividerColor),
)), )),
@ -52,7 +52,7 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
value: 'more.settings.2'.tr(), value: 'more.settings.2'.tr(),
), ),
), ),
SizedBox(width: 5), const SizedBox(width: 5),
BrandSwitch( BrandSwitch(
value: Theme.of(context).brightness == Brightness.dark, value: Theme.of(context).brightness == Brightness.dark,
onChanged: (value) => context onChanged: (value) => context
@ -63,8 +63,8 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
), ),
), ),
Container( Container(
padding: EdgeInsets.only(top: 20, bottom: 5), padding: const EdgeInsets.only(top: 20, bottom: 5),
decoration: BoxDecoration( decoration: const BoxDecoration(
border: Border( border: Border(
bottom: BorderSide(width: 1, color: BrandColors.dividerColor), bottom: BorderSide(width: 1, color: BrandColors.dividerColor),
)), )),
@ -78,14 +78,14 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
value: 'more.settings.4'.tr(), value: 'more.settings.4'.tr(),
), ),
), ),
SizedBox(width: 5), const SizedBox(width: 5),
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: BrandColors.red1, primary: BrandColors.red1,
), ),
child: Text( child: Text(
'basis.reset'.tr(), 'basis.reset'.tr(),
style: TextStyle( style: const TextStyle(
color: BrandColors.white, color: BrandColors.white,
fontWeight: NamedFontWeight.demiBold, fontWeight: NamedFontWeight.demiBold,
), ),
@ -131,8 +131,8 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
var isDisabled = var isDisabled =
context.watch<ServerInstallationCubit>().state.serverDetails == null; context.watch<ServerInstallationCubit>().state.serverDetails == null;
return Container( return Container(
padding: EdgeInsets.only(top: 20, bottom: 5), padding: const EdgeInsets.only(top: 20, bottom: 5),
decoration: BoxDecoration( decoration: const BoxDecoration(
border: Border( border: Border(
bottom: BorderSide(width: 1, color: BrandColors.dividerColor), bottom: BorderSide(width: 1, color: BrandColors.dividerColor),
)), )),
@ -146,18 +146,11 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
value: 'more.settings.6'.tr(), value: 'more.settings.6'.tr(),
), ),
), ),
SizedBox(width: 5), const SizedBox(width: 5),
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: BrandColors.red1, primary: BrandColors.red1,
), ),
child: Text(
'basis.delete'.tr(),
style: TextStyle(
color: BrandColors.white,
fontWeight: NamedFontWeight.demiBold,
),
),
onPressed: isDisabled onPressed: isDisabled
? null ? null
: () { : () {
@ -177,7 +170,8 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
builder: (context) { builder: (context) {
return Container( return Container(
alignment: Alignment.center, alignment: Alignment.center,
child: CircularProgressIndicator(), child:
const CircularProgressIndicator(),
); );
}); });
await context await context
@ -193,6 +187,13 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
}, },
); );
}, },
child: Text(
'basis.delete'.tr(),
style: const TextStyle(
color: BrandColors.white,
fontWeight: NamedFontWeight.demiBold,
),
),
), ),
], ],
), ),
@ -220,9 +221,9 @@ class _TextColumn extends StatelessWidget {
title, title,
style: TextStyle(color: hasWarning ? BrandColors.warning : null), style: TextStyle(color: hasWarning ? BrandColors.warning : null),
), ),
SizedBox(height: 5), const SizedBox(height: 5),
BrandText.body1(value, BrandText.body1(value,
style: TextStyle( style: const TextStyle(
fontSize: 13, fontSize: 13,
height: 1.53, height: 1.53,
color: BrandColors.gray1, color: BrandColors.gray1,

View File

@ -35,13 +35,13 @@ class _ConsoleState extends State<Console> {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(53),
child: Column( child: Column(
children: [ children: const [
BrandHeader(title: 'Console', hasBackButton: true), BrandHeader(title: 'Console', hasBackButton: true),
BrandDivider(), BrandDivider(),
], ],
), ),
preferredSize: Size.fromHeight(53),
), ),
body: FutureBuilder( body: FutureBuilder(
future: getIt.allReady(), future: getIt.allReady(),
@ -53,7 +53,7 @@ class _ConsoleState extends State<Console> {
reverse: true, reverse: true,
shrinkWrap: true, shrinkWrap: true,
children: [ children: [
SizedBox(height: 20), const SizedBox(height: 20),
...UnmodifiableListView(messages ...UnmodifiableListView(messages
.map((message) { .map((message) {
var isError = message.type == MessageType.warning; var isError = message.type == MessageType.warning;
@ -84,7 +84,7 @@ class _ConsoleState extends State<Console> {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: const [
Text('Waiting for initialisation'), Text('Waiting for initialisation'),
SizedBox( SizedBox(
height: 16, height: 16,

View File

@ -14,14 +14,14 @@ class InfoPage extends StatelessWidget {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(52),
child: BrandHeader(title: 'more.about_app'.tr(), hasBackButton: true), child: BrandHeader(title: 'more.about_app'.tr(), hasBackButton: true),
preferredSize: Size.fromHeight(52),
), ),
body: ListView( body: ListView(
padding: paddingH15V0, padding: paddingH15V0,
children: [ children: [
BrandDivider(), const BrandDivider(),
SizedBox(height: 10), const SizedBox(height: 10),
FutureBuilder( FutureBuilder(
future: _version(), future: _version(),
builder: (context, snapshot) { builder: (context, snapshot) {

View File

@ -27,11 +27,11 @@ class MorePage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(52),
child: BrandHeader( child: BrandHeader(
title: 'basis.more'.tr(), title: 'basis.more'.tr(),
hasFlashButton: true, hasFlashButton: true,
), ),
preferredSize: Size.fromHeight(52),
), ),
body: ListView( body: ListView(
children: [ children: [
@ -39,7 +39,7 @@ class MorePage extends StatelessWidget {
padding: paddingH15V0, padding: paddingH15V0,
child: Column( child: Column(
children: [ children: [
BrandDivider(), const BrandDivider(),
_NavItem( _NavItem(
title: 'more.configuration_wizard'.tr(), title: 'more.configuration_wizard'.tr(),
iconData: BrandIcons.triangle, iconData: BrandIcons.triangle,
@ -48,27 +48,27 @@ class MorePage extends StatelessWidget {
_NavItem( _NavItem(
title: 'more.settings.title'.tr(), title: 'more.settings.title'.tr(),
iconData: BrandIcons.settings, iconData: BrandIcons.settings,
goTo: AppSettingsPage(), goTo: const AppSettingsPage(),
), ),
_NavItem( _NavItem(
title: 'more.about_project'.tr(), title: 'more.about_project'.tr(),
iconData: BrandIcons.engineer, iconData: BrandIcons.engineer,
goTo: AboutPage(), goTo: const AboutPage(),
), ),
_NavItem( _NavItem(
title: 'more.about_app'.tr(), title: 'more.about_app'.tr(),
iconData: BrandIcons.fire, iconData: BrandIcons.fire,
goTo: InfoPage(), goTo: const InfoPage(),
), ),
_NavItem( _NavItem(
title: 'more.onboarding'.tr(), title: 'more.onboarding'.tr(),
iconData: BrandIcons.start, iconData: BrandIcons.start,
goTo: OnboardingPage(nextPage: RootPage()), goTo: const OnboardingPage(nextPage: RootPage()),
), ),
_NavItem( _NavItem(
title: 'more.console'.tr(), title: 'more.console'.tr(),
iconData: BrandIcons.terminal, iconData: BrandIcons.terminal,
goTo: Console(), goTo: const Console(),
), ),
_NavItem( _NavItem(
isEnabled: context.read<ServerInstallationCubit>().state isEnabled: context.read<ServerInstallationCubit>().state
@ -131,8 +131,8 @@ class _MoreMenuItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: EdgeInsets.symmetric(vertical: 24), padding: const EdgeInsets.symmetric(vertical: 24),
decoration: BoxDecoration( decoration: const BoxDecoration(
border: Border( border: Border(
bottom: BorderSide( bottom: BorderSide(
width: 1.0, width: 1.0,
@ -148,7 +148,7 @@ class _MoreMenuItem extends StatelessWidget {
color: isActive ? null : Colors.grey, color: isActive ? null : Colors.grey,
), ),
), ),
Spacer(), const Spacer(),
SizedBox( SizedBox(
width: 56, width: 56,
child: Icon( child: Icon(

View File

@ -53,11 +53,11 @@ class _OnboardingPageState extends State<OnboardingPage> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox(height: 30), const SizedBox(height: 30),
BrandText.h2( BrandText.h2(
'onboarding.page1_title'.tr(), 'onboarding.page1_title'.tr(),
), ),
SizedBox(height: 20), const SizedBox(height: 20),
BrandText.body2('onboarding.page1_text'.tr()), BrandText.body2('onboarding.page1_text'.tr()),
Flexible( Flexible(
child: Center( child: Center(
@ -75,13 +75,13 @@ class _OnboardingPageState extends State<OnboardingPage> {
onPressed: () { onPressed: () {
pageController.animateToPage( pageController.animateToPage(
1, 1,
duration: Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
curve: Curves.easeIn, curve: Curves.easeIn,
); );
}, },
text: 'basis.next'.tr(), text: 'basis.next'.tr(),
), ),
SizedBox(height: 30), const SizedBox(height: 30),
], ],
), ),
); );
@ -94,11 +94,11 @@ class _OnboardingPageState extends State<OnboardingPage> {
), ),
child: Column( child: Column(
children: [ children: [
SizedBox(height: 30), const SizedBox(height: 30),
BrandText.h2('onboarding.page2_title'.tr()), BrandText.h2('onboarding.page2_title'.tr()),
SizedBox(height: 20), const SizedBox(height: 20),
BrandText.body2('onboarding.page2_text'.tr()), BrandText.body2('onboarding.page2_text'.tr()),
SizedBox(height: 20), const SizedBox(height: 20),
Center( Center(
child: Image.asset( child: Image.asset(
_fileName( _fileName(
@ -131,7 +131,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
}, },
text: 'basis.got_it'.tr(), text: 'basis.got_it'.tr(),
), ),
SizedBox(height: 30), const SizedBox(height: 30),
], ],
), ),
); );

View File

@ -21,7 +21,7 @@ import 'package:selfprivacy/utils/route_transitions/basic.dart';
var navigatorKey = GlobalKey<NavigatorState>(); var navigatorKey = GlobalKey<NavigatorState>();
class ProvidersPage extends StatefulWidget { class ProvidersPage extends StatefulWidget {
ProvidersPage({Key? key}) : super(key: key); const ProvidersPage({Key? key}) : super(key: key);
@override @override
_ProvidersPageState createState() => _ProvidersPageState(); _ProvidersPageState createState() => _ProvidersPageState();
@ -49,7 +49,7 @@ class _ProvidersPageState extends State<ProvidersPage> {
final cards = ProviderType.values final cards = ProviderType.values
.map( .map(
(type) => Padding( (type) => Padding(
padding: EdgeInsets.only(bottom: 30), padding: const EdgeInsets.only(bottom: 30),
child: _Card( child: _Card(
provider: ProviderModel( provider: ProviderModel(
state: isReady state: isReady
@ -67,18 +67,18 @@ class _ProvidersPageState extends State<ProvidersPage> {
.toList(); .toList();
return Scaffold( return Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(52),
child: BrandHeader( child: BrandHeader(
title: 'providers.page_title'.tr(), title: 'providers.page_title'.tr(),
hasFlashButton: true, hasFlashButton: true,
), ),
preferredSize: Size.fromHeight(52),
), ),
body: ListView( body: ListView(
padding: paddingH15V0, padding: paddingH15V0,
children: [ children: [
if (!isReady) ...[ if (!isReady) ...[
NotReadyCard(), const NotReadyCard(),
SizedBox(height: 24), const SizedBox(height: 24),
], ],
...cards, ...cards,
], ],
@ -111,7 +111,7 @@ class _Card extends StatelessWidget {
stableText = 'providers.server.status'.tr(); stableText = 'providers.server.status'.tr();
onTap = () => showBrandBottomSheet( onTap = () => showBrandBottomSheet(
context: context, context: context,
builder: (context) => BrandBottomSheet( builder: (context) => const BrandBottomSheet(
isExpended: true, isExpended: true,
child: ServerDetailsScreen(), child: ServerDetailsScreen(),
), ),
@ -132,7 +132,7 @@ class _Card extends StatelessWidget {
stableText = 'providers.backup.status'.tr(); stableText = 'providers.backup.status'.tr();
onTap = () => Navigator.of(context).push(materialRoute( onTap = () => Navigator.of(context).push(materialRoute(
BackupDetails(), const BackupDetails(),
)); ));
break; break;
} }
@ -146,12 +146,12 @@ class _Card extends StatelessWidget {
status: provider.state, status: provider.state,
child: Icon(provider.icon, size: 30, color: Colors.white), child: Icon(provider.icon, size: 30, color: Colors.white),
), ),
SizedBox(height: 10), const SizedBox(height: 10),
BrandText.h2(title), BrandText.h2(title),
SizedBox(height: 10), const SizedBox(height: 10),
if (message != null) ...[ if (message != null) ...[
BrandText.body2(message), BrandText.body2(message),
SizedBox(height: 10), const SizedBox(height: 10),
], ],
if (provider.state == StateType.stable) BrandText.body2(stableText), if (provider.state == StateType.stable) BrandText.body2(stableText),
], ],

View File

@ -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/services/services.dart';
import 'package:selfprivacy/ui/pages/users/users.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 { class RootPage extends StatefulWidget {
const RootPage({Key? key}) : super(key: key); const RootPage({Key? key}) : super(key: key);
@ -42,7 +42,7 @@ class _RootPageState extends State<RootPage>
create: (_) => ChangeTab(tabController.animateTo), create: (_) => ChangeTab(tabController.animateTo),
child: TabBarView( child: TabBarView(
controller: tabController, controller: tabController,
children: [ children: const [
ProvidersPage(), ProvidersPage(),
ServicesPage(), ServicesPage(),
UsersPage(), UsersPage(),
@ -53,7 +53,7 @@ class _RootPageState extends State<RootPage>
bottomNavigationBar: BrandTabBar( bottomNavigationBar: BrandTabBar(
controller: tabController, controller: tabController,
), ),
floatingActionButton: BrandFab(), floatingActionButton: const BrandFab(),
), ),
); );
} }

View File

@ -19,33 +19,33 @@ class _Chart extends StatelessWidget {
]; ];
} else if (state is HetznerMetricsLoaded) { } else if (state is HetznerMetricsLoaded) {
charts = [ charts = [
Legend(color: Colors.red, text: 'CPU %'), const Legend(color: Colors.red, text: 'CPU %'),
SizedBox(height: 20), const SizedBox(height: 20),
getCpuChart(state), getCpuChart(state),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
BrandText.small('Public Network interface packets per sec'), BrandText.small('Public Network interface packets per sec'),
SizedBox(width: 10), const SizedBox(width: 10),
Legend(color: Colors.red, text: 'IN'), const Legend(color: Colors.red, text: 'IN'),
SizedBox(width: 5), const SizedBox(width: 5),
Legend(color: Colors.green, text: 'OUT'), const Legend(color: Colors.green, text: 'OUT'),
], ],
), ),
SizedBox(height: 20), const SizedBox(height: 20),
getPpsChart(state), getPpsChart(state),
SizedBox(height: 1), const SizedBox(height: 1),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
BrandText.small('Public Network interface bytes per sec'), BrandText.small('Public Network interface bytes per sec'),
SizedBox(width: 10), const SizedBox(width: 10),
Legend(color: Colors.red, text: 'IN'), const Legend(color: Colors.red, text: 'IN'),
SizedBox(width: 5), const SizedBox(width: 5),
Legend(color: Colors.green, text: 'OUT'), const Legend(color: Colors.green, text: 'OUT'),
], ],
), ),
SizedBox(height: 20), const SizedBox(height: 20),
getBandwidthChart(state), getBandwidthChart(state),
]; ];
} else { } else {
@ -57,7 +57,7 @@ class _Chart extends StatelessWidget {
child: Column( child: Column(
children: [ children: [
Padding( Padding(
padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -88,7 +88,7 @@ class _Chart extends StatelessWidget {
Widget getCpuChart(HetznerMetricsLoaded state) { Widget getCpuChart(HetznerMetricsLoaded state) {
var data = state.cpu; var data = state.cpu;
return Container( return SizedBox(
height: 200, height: 200,
child: CpuChart(data, state.period, state.start), child: CpuChart(data, state.period, state.start),
); );
@ -98,7 +98,7 @@ class _Chart extends StatelessWidget {
var ppsIn = state.ppsIn; var ppsIn = state.ppsIn;
var ppsOut = state.ppsOut; var ppsOut = state.ppsOut;
return Container( return SizedBox(
height: 200, height: 200,
child: NetworkChart( child: NetworkChart(
[ppsIn, ppsOut], [ppsIn, ppsOut],
@ -112,7 +112,7 @@ class _Chart extends StatelessWidget {
var ppsIn = state.bandwidthIn; var ppsIn = state.bandwidthIn;
var ppsOut = state.bandwidthOut; var ppsOut = state.bandwidthOut;
return Container( return SizedBox(
height: 200, height: 200,
child: NetworkChart( child: NetworkChart(
[ppsIn, ppsOut], [ppsIn, ppsOut],
@ -138,7 +138,7 @@ class Legend extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
_ColoredBox(color: color), _ColoredBox(color: color),
SizedBox(width: 5), const SizedBox(width: 5),
BrandText.small(text), BrandText.small(text),
], ],
); );

View File

@ -7,7 +7,7 @@ import 'package:selfprivacy/logic/models/hetzner_metrics.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
class CpuChart extends StatelessWidget { class CpuChart extends StatelessWidget {
CpuChart(this.data, this.period, this.start); const CpuChart(this.data, this.period, this.start);
final List<TimeSeriesData> data; final List<TimeSeriesData> data;
final Period period; final Period period;
@ -54,13 +54,13 @@ class CpuChart extends StatelessWidget {
return Padding( return Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: RotatedBox( child: RotatedBox(
quarterTurns: 1,
child: Text(bottomTitle(value.toInt()), child: Text(bottomTitle(value.toInt()),
style: TextStyle( style: const TextStyle(
fontSize: 10, fontSize: 10,
color: Colors.purple, color: Colors.purple,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
)), )),
quarterTurns: 1,
), ),
); );
}, },
@ -71,7 +71,7 @@ class CpuChart extends StatelessWidget {
sideTitles: SideTitles( sideTitles: SideTitles(
getTitlesWidget: (value, titleMeta) { getTitlesWidget: (value, titleMeta) {
return Padding( return Padding(
padding: EdgeInsets.only(right: 15), padding: const EdgeInsets.only(right: 15),
child: Text( child: Text(
value.toInt().toString(), value.toInt().toString(),
style: progressTextStyleLight.copyWith( style: progressTextStyleLight.copyWith(

View File

@ -16,17 +16,17 @@ class _Header extends StatelessWidget {
children: [ children: [
IconStatusMask( IconStatusMask(
status: providerState, status: providerState,
child: Icon( child: const Icon(
BrandIcons.server, BrandIcons.server,
size: 40, size: 40,
color: Colors.white, color: Colors.white,
), ),
), ),
SizedBox(width: 10), const SizedBox(width: 10),
BrandText.h2('providers.server.card_title'.tr()), BrandText.h2('providers.server.card_title'.tr()),
Spacer(), const Spacer(),
Padding( Padding(
padding: EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 4, vertical: 4,
horizontal: 2, horizontal: 2,
), ),
@ -41,12 +41,12 @@ class _Header extends StatelessWidget {
break; break;
} }
}, },
icon: Icon(Icons.more_vert), icon: const Icon(Icons.more_vert),
itemBuilder: (BuildContext context) => [ itemBuilder: (BuildContext context) => [
PopupMenuItem<_PopupMenuItemType>( PopupMenuItem<_PopupMenuItemType>(
value: _PopupMenuItemType.setting, value: _PopupMenuItemType.setting,
child: Container( child: Container(
padding: EdgeInsets.only(left: 5), padding: const EdgeInsets.only(left: 5),
child: Text('basis.settings'.tr()), child: Text('basis.settings'.tr()),
), ),
), ),

View File

@ -9,7 +9,7 @@ import 'package:selfprivacy/logic/models/hetzner_metrics.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
class NetworkChart extends StatelessWidget { class NetworkChart extends StatelessWidget {
NetworkChart( const NetworkChart(
this.listData, this.listData,
this.period, this.period,
this.start, this.start,
@ -76,13 +76,13 @@ class NetworkChart extends StatelessWidget {
return Padding( return Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: RotatedBox( child: RotatedBox(
quarterTurns: 1,
child: Text(bottomTitle(value.toInt()), child: Text(bottomTitle(value.toInt()),
style: TextStyle( style: const TextStyle(
fontSize: 10, fontSize: 10,
color: Colors.purple, color: Colors.purple,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
)), )),
quarterTurns: 1,
), ),
); );
}, },
@ -94,7 +94,7 @@ class NetworkChart extends StatelessWidget {
reservedSize: 50, reservedSize: 50,
getTitlesWidget: (value, titleMeta) { getTitlesWidget: (value, titleMeta) {
return Padding( return Padding(
padding: EdgeInsets.only(right: 5), padding: const EdgeInsets.only(right: 5),
child: Text( child: Text(
value.toInt().toString(), value.toInt().toString(),
style: progressTextStyleLight.copyWith( style: progressTextStyleLight.copyWith(

View File

@ -69,25 +69,25 @@ class _ServerDetailsScreenState extends State<ServerDetailsScreen>
create: (context) => ServerDetailsCubit()..check(), create: (context) => ServerDetailsCubit()..check(),
child: Scaffold( child: Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(52),
child: Column( child: Column(
children: [ children: [
Container( Container(
height: 51, height: 51,
alignment: Alignment.center, alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 15), padding: const EdgeInsets.symmetric(horizontal: 15),
child: BrandText.h4('basis.details'.tr()), child: BrandText.h4('basis.details'.tr()),
), ),
BrandDivider(), const BrandDivider(),
], ],
), ),
preferredSize: Size.fromHeight(52),
), ),
body: TabBarView( body: TabBarView(
physics: NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
controller: tabController, controller: tabController,
children: [ children: [
SingleChildScrollView( SingleChildScrollView(
physics: ClampingScrollPhysics(), physics: const ClampingScrollPhysics(),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -103,13 +103,13 @@ class _ServerDetailsScreenState extends State<ServerDetailsScreen>
], ],
), ),
), ),
SizedBox(height: 10), const SizedBox(height: 10),
BlocProvider( BlocProvider(
create: (context) => HetznerMetricsCubit()..restart(), create: (context) => HetznerMetricsCubit()..restart(),
child: _Chart(), child: const _Chart(),
), ),
SizedBox(height: 20), const SizedBox(height: 20),
_TextDetails(), const _TextDetails(),
], ],
), ),
), ),

Some files were not shown because too many files have changed in this diff Show More