mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-30 20:56:53 +00:00
Refactor App Config Cubit infrastrucute
Co-authored-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
parent
93215d90fb
commit
0d0a3a4fee
|
@ -1,6 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
||||||
|
@ -17,11 +17,11 @@ class BlocAndProviderConfig extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var isDark = false;
|
var isDark = false;
|
||||||
var appConfigCubit = AppConfigCubit()..load();
|
var serverInstallationCubit = ServerInstallationCubit()..load();
|
||||||
var usersCubit = UsersCubit(appConfigCubit);
|
var usersCubit = UsersCubit(serverInstallationCubit);
|
||||||
var servicesCubit = ServicesCubit(appConfigCubit);
|
var servicesCubit = ServicesCubit(serverInstallationCubit);
|
||||||
var backupsCubit = BackupsCubit(appConfigCubit);
|
var backupsCubit = BackupsCubit(serverInstallationCubit);
|
||||||
var dnsRecordsCubit = DnsRecordsCubit(appConfigCubit);
|
var dnsRecordsCubit = DnsRecordsCubit(serverInstallationCubit);
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
|
@ -30,7 +30,7 @@ class BlocAndProviderConfig extends StatelessWidget {
|
||||||
isOnbordingShowing: true,
|
isOnbordingShowing: true,
|
||||||
)..load(),
|
)..load(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (_) => appConfigCubit, lazy: false),
|
BlocProvider(create: (_) => serverInstallationCubit, lazy: false),
|
||||||
BlocProvider(create: (_) => ProvidersCubit()),
|
BlocProvider(create: (_) => ProvidersCubit()),
|
||||||
BlocProvider(create: (_) => usersCubit..load(), lazy: false),
|
BlocProvider(create: (_) => usersCubit..load(), lazy: false),
|
||||||
BlocProvider(create: (_) => servicesCubit..load(), lazy: false),
|
BlocProvider(create: (_) => servicesCubit..load(), lazy: false),
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
|
|
||||||
export 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
export 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
|
|
||||||
part 'authentication_dependend_state.dart';
|
part 'authentication_dependend_state.dart';
|
||||||
|
|
||||||
abstract class AppConfigDependendCubit<T extends AppConfigDependendState>
|
abstract class ServerInstallationDependendCubit<
|
||||||
extends Cubit<T> {
|
T extends ServerInstallationDependendState> extends Cubit<T> {
|
||||||
AppConfigDependendCubit(
|
ServerInstallationDependendCubit(
|
||||||
this.appConfigCubit,
|
this.appConfigCubit,
|
||||||
T initState,
|
T initState,
|
||||||
) : super(initState) {
|
) : super(initState) {
|
||||||
|
@ -17,16 +17,16 @@ abstract class AppConfigDependendCubit<T extends AppConfigDependendState>
|
||||||
checkAuthStatus(appConfigCubit.state);
|
checkAuthStatus(appConfigCubit.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkAuthStatus(AppConfigState state) {
|
void checkAuthStatus(ServerInstallationState state) {
|
||||||
if (state is AppConfigFinished) {
|
if (state is ServerInstallationFinished) {
|
||||||
load();
|
load();
|
||||||
} else if (state is AppConfigEmpty) {
|
} else if (state is ServerInstallationEmpty) {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
late StreamSubscription authCubitSubscription;
|
late StreamSubscription authCubitSubscription;
|
||||||
final AppConfigCubit appConfigCubit;
|
final ServerInstallationCubit appConfigCubit;
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
part of 'authentication_dependend_cubit.dart';
|
part of 'authentication_dependend_cubit.dart';
|
||||||
|
|
||||||
abstract class AppConfigDependendState extends Equatable {
|
abstract class ServerInstallationDependendState extends Equatable {
|
||||||
const AppConfigDependendState();
|
const ServerInstallationDependendState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,15 @@ import 'package:selfprivacy/logic/models/json/backup.dart';
|
||||||
|
|
||||||
part 'backups_state.dart';
|
part 'backups_state.dart';
|
||||||
|
|
||||||
class BackupsCubit extends AppConfigDependendCubit<BackupsState> {
|
class BackupsCubit extends ServerInstallationDependendCubit<BackupsState> {
|
||||||
BackupsCubit(AppConfigCubit appConfigCubit)
|
BackupsCubit(ServerInstallationCubit appConfigCubit)
|
||||||
: super(appConfigCubit, BackupsState(preventActions: true));
|
: super(appConfigCubit, BackupsState(preventActions: true));
|
||||||
|
|
||||||
final api = ServerApi();
|
final api = ServerApi();
|
||||||
final backblaze = BackblazeApi();
|
final backblaze = BackblazeApi();
|
||||||
|
|
||||||
Future<void> load() async {
|
Future<void> load() async {
|
||||||
if (appConfigCubit.state is AppConfigFinished) {
|
if (appConfigCubit.state is ServerInstallationFinished) {
|
||||||
final bucket = getIt<ApiConfigModel>().backblazeBucket;
|
final bucket = getIt<ApiConfigModel>().backblazeBucket;
|
||||||
if (bucket == null) {
|
if (bucket == null) {
|
||||||
emit(BackupsState(
|
emit(BackupsState(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
part of 'backups_cubit.dart';
|
part of 'backups_cubit.dart';
|
||||||
|
|
||||||
class BackupsState extends AppConfigDependendState {
|
class BackupsState extends ServerInstallationDependendState {
|
||||||
const BackupsState({
|
const BackupsState({
|
||||||
this.isInitialized = false,
|
this.isInitialized = false,
|
||||||
this.backups = const [],
|
this.backups = const [],
|
||||||
|
|
|
@ -8,8 +8,9 @@ import '../../api_maps/server.dart';
|
||||||
|
|
||||||
part 'dns_records_state.dart';
|
part 'dns_records_state.dart';
|
||||||
|
|
||||||
class DnsRecordsCubit extends AppConfigDependendCubit<DnsRecordsState> {
|
class DnsRecordsCubit
|
||||||
DnsRecordsCubit(AppConfigCubit appConfigCubit)
|
extends ServerInstallationDependendCubit<DnsRecordsState> {
|
||||||
|
DnsRecordsCubit(ServerInstallationCubit appConfigCubit)
|
||||||
: super(appConfigCubit,
|
: super(appConfigCubit,
|
||||||
DnsRecordsState(dnsState: DnsRecordsStatus.refreshing));
|
DnsRecordsState(dnsState: DnsRecordsStatus.refreshing));
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ class DnsRecordsCubit extends AppConfigDependendCubit<DnsRecordsState> {
|
||||||
dnsRecords: _getDesiredDnsRecords(
|
dnsRecords: _getDesiredDnsRecords(
|
||||||
appConfigCubit.state.serverDomain?.domainName, "", "")));
|
appConfigCubit.state.serverDomain?.domainName, "", "")));
|
||||||
print('Loading DNS status');
|
print('Loading DNS status');
|
||||||
if (appConfigCubit.state is AppConfigFinished) {
|
if (appConfigCubit.state is ServerInstallationFinished) {
|
||||||
final ServerDomain? domain = appConfigCubit.state.serverDomain;
|
final ServerDomain? domain = appConfigCubit.state.serverDomain;
|
||||||
final String? ipAddress = appConfigCubit.state.serverDetails?.ip4;
|
final String? ipAddress = appConfigCubit.state.serverDetails?.ip4;
|
||||||
if (domain != null && ipAddress != null) {
|
if (domain != null && ipAddress != null) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ enum DnsRecordsCategory {
|
||||||
other,
|
other,
|
||||||
}
|
}
|
||||||
|
|
||||||
class DnsRecordsState extends AppConfigDependendState {
|
class DnsRecordsState extends ServerInstallationDependendState {
|
||||||
const DnsRecordsState({
|
const DnsRecordsState({
|
||||||
this.dnsState = DnsRecordsStatus.uninitialized,
|
this.dnsState = DnsRecordsStatus.uninitialized,
|
||||||
this.dnsRecords = const [],
|
this.dnsRecords = const [],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/backblaze.dart';
|
import 'package:selfprivacy/logic/api_maps/backblaze.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class BackblazeFormCubit extends FormCubit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final AppConfigCubit initializingCubit;
|
final ServerInstallationCubit initializingCubit;
|
||||||
|
|
||||||
late final FieldCubit<String> keyId;
|
late final FieldCubit<String> keyId;
|
||||||
late final FieldCubit<String> applicationKey;
|
late final FieldCubit<String> applicationKey;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import 'dart:async';
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/cloudflare.dart';
|
import 'package:selfprivacy/logic/api_maps/cloudflare.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/validations/validations.dart';
|
import 'package:selfprivacy/logic/cubit/forms/validations/validations.dart';
|
||||||
|
|
||||||
class CloudFlareFormCubit extends FormCubit {
|
class CloudFlareFormCubit extends FormCubit {
|
||||||
|
@ -27,7 +27,7 @@ class CloudFlareFormCubit extends FormCubit {
|
||||||
initializingCubit.setCloudflareKey(apiKey.state.value);
|
initializingCubit.setCloudflareKey(apiKey.state.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
final AppConfigCubit initializingCubit;
|
final ServerInstallationCubit initializingCubit;
|
||||||
|
|
||||||
late final FieldCubit<String> apiKey;
|
late final FieldCubit<String> apiKey;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/cloudflare.dart';
|
import 'package:selfprivacy/logic/api_maps/cloudflare.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_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';
|
||||||
|
|
||||||
class DomainSetupCubit extends Cubit<DomainSetupState> {
|
class DomainSetupCubit extends Cubit<DomainSetupState> {
|
||||||
DomainSetupCubit(this.initializingCubit) : super(Initial());
|
DomainSetupCubit(this.initializingCubit) : super(Initial());
|
||||||
|
|
||||||
final AppConfigCubit initializingCubit;
|
final ServerInstallationCubit initializingCubit;
|
||||||
|
|
||||||
Future<void> load() async {
|
Future<void> load() async {
|
||||||
emit(Loading(LoadingTypes.loadingDomain));
|
emit(Loading(LoadingTypes.loadingDomain));
|
||||||
|
|
|
@ -3,7 +3,7 @@ import 'dart:async';
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/hetzner.dart';
|
import 'package:selfprivacy/logic/api_maps/hetzner.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/validations/validations.dart';
|
import 'package:selfprivacy/logic/cubit/forms/validations/validations.dart';
|
||||||
|
|
||||||
class HetznerFormCubit extends FormCubit {
|
class HetznerFormCubit extends FormCubit {
|
||||||
|
@ -27,7 +27,7 @@ class HetznerFormCubit extends FormCubit {
|
||||||
initializingCubit.setHetznerKey(apiKey.state.value);
|
initializingCubit.setHetznerKey(apiKey.state.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
final AppConfigCubit initializingCubit;
|
final ServerInstallationCubit initializingCubit;
|
||||||
|
|
||||||
late final FieldCubit<String> apiKey;
|
late final FieldCubit<String> apiKey;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class RootUserFormCubit extends FormCubit {
|
||||||
initializingCubit.setRootUser(user);
|
initializingCubit.setRootUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
final AppConfigCubit initializingCubit;
|
final ServerInstallationCubit initializingCubit;
|
||||||
|
|
||||||
late final FieldCubit<String> userName;
|
late final FieldCubit<String> userName;
|
||||||
late final FieldCubit<String> password;
|
late final FieldCubit<String> password;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import 'dart:async';
|
||||||
|
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/server.dart';
|
import 'package:selfprivacy/logic/api_maps/server.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
|
|
||||||
|
@ -27,6 +27,6 @@ class RecoveryDomainFormCubit extends FormCubit {
|
||||||
// ; //var client =
|
// ; //var client =
|
||||||
// }
|
// }
|
||||||
|
|
||||||
final AppConfigCubit initializingCubit;
|
final ServerInstallationCubit initializingCubit;
|
||||||
late final FieldCubit<String> serverDomainField;
|
late final FieldCubit<String> serverDomainField;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,14 @@ import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
|
|
||||||
import 'app_config_repository.dart';
|
import '../server_installation/server_installation_repository.dart';
|
||||||
|
|
||||||
export 'package:provider/provider.dart';
|
export 'package:provider/provider.dart';
|
||||||
|
|
||||||
part 'app_config_state.dart';
|
part '../server_installation/server_installation_state.dart';
|
||||||
|
|
||||||
class AppConfigCubit extends Cubit<AppConfigState> {
|
class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
AppConfigCubit() : super(AppConfigEmpty());
|
ServerInstallationCubit() : super(ServerInstallationEmpty());
|
||||||
|
|
||||||
final repository = AppConfigRepository();
|
final repository = AppConfigRepository();
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
Future<void> load() async {
|
Future<void> load() async {
|
||||||
var state = await repository.load();
|
var state = await repository.load();
|
||||||
|
|
||||||
if (state is AppConfigFinished) {
|
if (state is ServerInstallationFinished) {
|
||||||
emit(state);
|
emit(state);
|
||||||
} else if (state is AppConfigNotFinished) {
|
} else if (state is ServerInstallationNotFinished) {
|
||||||
if (state.progress == ServerSetupProgress.serverCreated) {
|
if (state.progress == ServerSetupProgress.serverCreated) {
|
||||||
startServerIfDnsIsOkay(state: state);
|
startServerIfDnsIsOkay(state: state);
|
||||||
} else if (state.progress == ServerSetupProgress.serverStarted) {
|
} else if (state.progress == ServerSetupProgress.serverStarted) {
|
||||||
|
@ -40,7 +40,7 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
} else {
|
} else {
|
||||||
emit(state);
|
emit(state);
|
||||||
}
|
}
|
||||||
} else if (state is AppConfigRecovery) {
|
} else if (state is ServerInstallationRecovery) {
|
||||||
emit(state);
|
emit(state);
|
||||||
} else {
|
} else {
|
||||||
throw 'wrong state';
|
throw 'wrong state';
|
||||||
|
@ -49,13 +49,14 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
|
|
||||||
void setHetznerKey(String hetznerKey) async {
|
void setHetznerKey(String hetznerKey) async {
|
||||||
await repository.saveHetznerKey(hetznerKey);
|
await repository.saveHetznerKey(hetznerKey);
|
||||||
emit((state as AppConfigNotFinished).copyWith(hetznerKey: hetznerKey));
|
emit((state as ServerInstallationNotFinished)
|
||||||
|
.copyWith(hetznerKey: hetznerKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCloudflareKey(String cloudFlareKey) async {
|
void setCloudflareKey(String cloudFlareKey) async {
|
||||||
await repository.saveCloudFlareKey(cloudFlareKey);
|
await repository.saveCloudFlareKey(cloudFlareKey);
|
||||||
emit(
|
emit((state as ServerInstallationNotFinished)
|
||||||
(state as AppConfigNotFinished).copyWith(cloudFlareKey: cloudFlareKey));
|
.copyWith(cloudFlareKey: cloudFlareKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBackblazeKey(String keyId, String applicationKey) async {
|
void setBackblazeKey(String keyId, String applicationKey) async {
|
||||||
|
@ -64,24 +65,26 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
applicationKey: applicationKey,
|
applicationKey: applicationKey,
|
||||||
);
|
);
|
||||||
await repository.saveBackblazeKey(backblazeCredential);
|
await repository.saveBackblazeKey(backblazeCredential);
|
||||||
emit((state as AppConfigNotFinished)
|
emit((state as ServerInstallationNotFinished)
|
||||||
.copyWith(backblazeCredential: backblazeCredential));
|
.copyWith(backblazeCredential: backblazeCredential));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDomain(ServerDomain serverDomain) async {
|
void setDomain(ServerDomain serverDomain) async {
|
||||||
await repository.saveDomain(serverDomain);
|
await repository.saveDomain(serverDomain);
|
||||||
emit((state as AppConfigNotFinished).copyWith(serverDomain: serverDomain));
|
emit((state as ServerInstallationNotFinished)
|
||||||
|
.copyWith(serverDomain: serverDomain));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRootUser(User rootUser) async {
|
void setRootUser(User rootUser) async {
|
||||||
await repository.saveRootUser(rootUser);
|
await repository.saveRootUser(rootUser);
|
||||||
emit((state as AppConfigNotFinished).copyWith(rootUser: rootUser));
|
emit((state as ServerInstallationNotFinished).copyWith(rootUser: rootUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
void createServerAndSetDnsRecords() async {
|
void createServerAndSetDnsRecords() async {
|
||||||
AppConfigNotFinished _stateCopy = state as AppConfigNotFinished;
|
ServerInstallationNotFinished _stateCopy =
|
||||||
var onCancel =
|
state as ServerInstallationNotFinished;
|
||||||
() => emit((state as AppConfigNotFinished).copyWith(isLoading: false));
|
var onCancel = () => emit(
|
||||||
|
(state as ServerInstallationNotFinished).copyWith(isLoading: false));
|
||||||
|
|
||||||
var onSuccess = (ServerHostingDetails serverDetails) async {
|
var onSuccess = (ServerHostingDetails serverDetails) async {
|
||||||
await repository.createDnsRecords(
|
await repository.createDnsRecords(
|
||||||
|
@ -90,7 +93,7 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
onCancel: onCancel,
|
onCancel: onCancel,
|
||||||
);
|
);
|
||||||
|
|
||||||
emit((state as AppConfigNotFinished).copyWith(
|
emit((state as ServerInstallationNotFinished).copyWith(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
serverDetails: serverDetails,
|
serverDetails: serverDetails,
|
||||||
));
|
));
|
||||||
|
@ -98,7 +101,7 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
emit((state as AppConfigNotFinished).copyWith(isLoading: true));
|
emit((state as ServerInstallationNotFinished).copyWith(isLoading: true));
|
||||||
await repository.createServer(
|
await repository.createServer(
|
||||||
state.rootUser!,
|
state.rootUser!,
|
||||||
state.serverDomain!.domainName,
|
state.serverDomain!.domainName,
|
||||||
|
@ -112,8 +115,8 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startServerIfDnsIsOkay({AppConfigNotFinished? state}) async {
|
void startServerIfDnsIsOkay({ServerInstallationNotFinished? state}) async {
|
||||||
final dataState = state ?? this.state as AppConfigNotFinished;
|
final dataState = state ?? this.state as ServerInstallationNotFinished;
|
||||||
|
|
||||||
emit(TimerState(dataState: dataState, isLoading: true));
|
emit(TimerState(dataState: dataState, isLoading: true));
|
||||||
|
|
||||||
|
@ -149,8 +152,8 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void oneMoreReset({AppConfigNotFinished? state}) async {
|
void oneMoreReset({ServerInstallationNotFinished? state}) async {
|
||||||
final dataState = state ?? this.state as AppConfigNotFinished;
|
final dataState = state ?? this.state as ServerInstallationNotFinished;
|
||||||
|
|
||||||
emit(TimerState(dataState: dataState, isLoading: true));
|
emit(TimerState(dataState: dataState, isLoading: true));
|
||||||
|
|
||||||
|
@ -184,9 +187,9 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetServerIfServerIsOkay({
|
void resetServerIfServerIsOkay({
|
||||||
AppConfigNotFinished? state,
|
ServerInstallationNotFinished? state,
|
||||||
}) async {
|
}) async {
|
||||||
final dataState = state ?? this.state as AppConfigNotFinished;
|
final dataState = state ?? this.state as ServerInstallationNotFinished;
|
||||||
|
|
||||||
emit(TimerState(dataState: dataState, isLoading: true));
|
emit(TimerState(dataState: dataState, isLoading: true));
|
||||||
|
|
||||||
|
@ -220,9 +223,9 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishCheckIfServerIsOkay({
|
void finishCheckIfServerIsOkay({
|
||||||
AppConfigNotFinished? state,
|
ServerInstallationNotFinished? state,
|
||||||
}) async {
|
}) async {
|
||||||
final dataState = state ?? this.state as AppConfigNotFinished;
|
final dataState = state ?? this.state as ServerInstallationNotFinished;
|
||||||
|
|
||||||
emit(TimerState(dataState: dataState, isLoading: true));
|
emit(TimerState(dataState: dataState, isLoading: true));
|
||||||
|
|
||||||
|
@ -238,9 +241,9 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runDelayed(
|
void runDelayed(void Function() work, Duration delay,
|
||||||
void Function() work, Duration delay, AppConfigNotFinished? state) async {
|
ServerInstallationNotFinished? state) async {
|
||||||
final dataState = state ?? this.state as AppConfigNotFinished;
|
final dataState = state ?? this.state as ServerInstallationNotFinished;
|
||||||
|
|
||||||
emit(TimerState(
|
emit(TimerState(
|
||||||
dataState: dataState,
|
dataState: dataState,
|
||||||
|
@ -255,7 +258,7 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
closeTimer();
|
closeTimer();
|
||||||
|
|
||||||
repository.clearAppConfig();
|
repository.clearAppConfig();
|
||||||
emit(AppConfigEmpty());
|
emit(ServerInstallationEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> serverDelete() async {
|
Future<void> serverDelete() async {
|
||||||
|
@ -266,7 +269,7 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
await getIt<SSHModel>().clear();
|
await getIt<SSHModel>().clear();
|
||||||
}
|
}
|
||||||
await repository.deleteRecords();
|
await repository.deleteRecords();
|
||||||
emit(AppConfigNotFinished(
|
emit(ServerInstallationNotFinished(
|
||||||
hetznerKey: state.hetznerKey,
|
hetznerKey: state.hetznerKey,
|
||||||
serverDomain: state.serverDomain,
|
serverDomain: state.serverDomain,
|
||||||
cloudFlareKey: state.cloudFlareKey,
|
cloudFlareKey: state.cloudFlareKey,
|
|
@ -15,12 +15,12 @@ import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
|
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
||||||
|
|
||||||
import 'app_config_cubit.dart';
|
import '../server_installation/server_installation_cubit.dart';
|
||||||
|
|
||||||
class AppConfigRepository {
|
class AppConfigRepository {
|
||||||
Box box = Hive.box(BNames.appConfig);
|
Box box = Hive.box(BNames.appConfig);
|
||||||
|
|
||||||
Future<AppConfigState> load() async {
|
Future<ServerInstallationState> load() async {
|
||||||
final hetznerToken = getIt<ApiConfigModel>().hetznerKey;
|
final hetznerToken = getIt<ApiConfigModel>().hetznerKey;
|
||||||
final cloudflareToken = getIt<ApiConfigModel>().cloudFlareKey;
|
final cloudflareToken = getIt<ApiConfigModel>().cloudFlareKey;
|
||||||
final serverDomain = getIt<ApiConfigModel>().serverDomain;
|
final serverDomain = getIt<ApiConfigModel>().serverDomain;
|
||||||
|
@ -28,7 +28,7 @@ class AppConfigRepository {
|
||||||
final serverDetails = getIt<ApiConfigModel>().serverDetails;
|
final serverDetails = getIt<ApiConfigModel>().serverDetails;
|
||||||
|
|
||||||
if (box.get(BNames.hasFinalChecked, defaultValue: false)) {
|
if (box.get(BNames.hasFinalChecked, defaultValue: false)) {
|
||||||
return AppConfigFinished(
|
return ServerInstallationFinished(
|
||||||
hetznerKey: hetznerToken!,
|
hetznerKey: hetznerToken!,
|
||||||
cloudFlareKey: cloudflareToken!,
|
cloudFlareKey: cloudflareToken!,
|
||||||
serverDomain: serverDomain!,
|
serverDomain: serverDomain!,
|
||||||
|
@ -44,7 +44,7 @@ class AppConfigRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getIt<ApiConfigModel>().serverDomain?.provider == DnsProvider.Unknown) {
|
if (getIt<ApiConfigModel>().serverDomain?.provider == DnsProvider.Unknown) {
|
||||||
return AppConfigRecovery(
|
return ServerInstallationRecovery(
|
||||||
hetznerKey: hetznerToken,
|
hetznerKey: hetznerToken,
|
||||||
cloudFlareKey: cloudflareToken,
|
cloudFlareKey: cloudflareToken,
|
||||||
serverDomain: serverDomain,
|
serverDomain: serverDomain,
|
||||||
|
@ -56,7 +56,7 @@ class AppConfigRepository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AppConfigNotFinished(
|
return ServerInstallationNotFinished(
|
||||||
hetznerKey: hetznerToken,
|
hetznerKey: hetznerToken,
|
||||||
cloudFlareKey: cloudflareToken,
|
cloudFlareKey: cloudflareToken,
|
||||||
serverDomain: serverDomain,
|
serverDomain: serverDomain,
|
|
@ -1,7 +1,7 @@
|
||||||
part of 'app_config_cubit.dart';
|
part of '../server_installation/server_installation_cubit.dart';
|
||||||
|
|
||||||
abstract class AppConfigState extends Equatable {
|
abstract class ServerInstallationState extends Equatable {
|
||||||
const AppConfigState({
|
const ServerInstallationState({
|
||||||
required this.hetznerKey,
|
required this.hetznerKey,
|
||||||
required this.cloudFlareKey,
|
required this.cloudFlareKey,
|
||||||
required this.backblazeCredential,
|
required this.backblazeCredential,
|
||||||
|
@ -73,7 +73,7 @@ abstract class AppConfigState extends Equatable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TimerState extends AppConfigNotFinished {
|
class TimerState extends ServerInstallationNotFinished {
|
||||||
TimerState({
|
TimerState({
|
||||||
required this.dataState,
|
required this.dataState,
|
||||||
this.timerStart,
|
this.timerStart,
|
||||||
|
@ -93,7 +93,7 @@ class TimerState extends AppConfigNotFinished {
|
||||||
dnsMatches: dataState.dnsMatches,
|
dnsMatches: dataState.dnsMatches,
|
||||||
);
|
);
|
||||||
|
|
||||||
final AppConfigNotFinished dataState;
|
final ServerInstallationNotFinished dataState;
|
||||||
final DateTime? timerStart;
|
final DateTime? timerStart;
|
||||||
final Duration? duration;
|
final Duration? duration;
|
||||||
|
|
||||||
|
@ -118,11 +118,11 @@ enum ServerSetupProgress {
|
||||||
serverResetedSecondTime,
|
serverResetedSecondTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppConfigNotFinished extends AppConfigState {
|
class ServerInstallationNotFinished extends ServerInstallationState {
|
||||||
final bool isLoading;
|
final bool isLoading;
|
||||||
final Map<String, bool>? dnsMatches;
|
final Map<String, bool>? dnsMatches;
|
||||||
|
|
||||||
AppConfigNotFinished({
|
ServerInstallationNotFinished({
|
||||||
String? hetznerKey,
|
String? hetznerKey,
|
||||||
String? cloudFlareKey,
|
String? cloudFlareKey,
|
||||||
BackblazeCredential? backblazeCredential,
|
BackblazeCredential? backblazeCredential,
|
||||||
|
@ -160,7 +160,7 @@ class AppConfigNotFinished extends AppConfigState {
|
||||||
dnsMatches,
|
dnsMatches,
|
||||||
];
|
];
|
||||||
|
|
||||||
AppConfigNotFinished copyWith({
|
ServerInstallationNotFinished copyWith({
|
||||||
String? hetznerKey,
|
String? hetznerKey,
|
||||||
String? cloudFlareKey,
|
String? cloudFlareKey,
|
||||||
BackblazeCredential? backblazeCredential,
|
BackblazeCredential? backblazeCredential,
|
||||||
|
@ -173,7 +173,7 @@ class AppConfigNotFinished extends AppConfigState {
|
||||||
bool? isLoading,
|
bool? isLoading,
|
||||||
Map<String, bool>? dnsMatches,
|
Map<String, bool>? dnsMatches,
|
||||||
}) =>
|
}) =>
|
||||||
AppConfigNotFinished(
|
ServerInstallationNotFinished(
|
||||||
hetznerKey: hetznerKey ?? this.hetznerKey,
|
hetznerKey: hetznerKey ?? this.hetznerKey,
|
||||||
cloudFlareKey: cloudFlareKey ?? this.cloudFlareKey,
|
cloudFlareKey: cloudFlareKey ?? this.cloudFlareKey,
|
||||||
backblazeCredential: backblazeCredential ?? this.backblazeCredential,
|
backblazeCredential: backblazeCredential ?? this.backblazeCredential,
|
||||||
|
@ -189,7 +189,7 @@ class AppConfigNotFinished extends AppConfigState {
|
||||||
dnsMatches: dnsMatches ?? this.dnsMatches,
|
dnsMatches: dnsMatches ?? this.dnsMatches,
|
||||||
);
|
);
|
||||||
|
|
||||||
AppConfigFinished finish() => AppConfigFinished(
|
ServerInstallationFinished finish() => ServerInstallationFinished(
|
||||||
hetznerKey: hetznerKey!,
|
hetznerKey: hetznerKey!,
|
||||||
cloudFlareKey: cloudFlareKey!,
|
cloudFlareKey: cloudFlareKey!,
|
||||||
backblazeCredential: backblazeCredential!,
|
backblazeCredential: backblazeCredential!,
|
||||||
|
@ -202,8 +202,8 @@ class AppConfigNotFinished extends AppConfigState {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppConfigEmpty extends AppConfigNotFinished {
|
class ServerInstallationEmpty extends ServerInstallationNotFinished {
|
||||||
AppConfigEmpty()
|
ServerInstallationEmpty()
|
||||||
: super(
|
: super(
|
||||||
hetznerKey: null,
|
hetznerKey: null,
|
||||||
cloudFlareKey: null,
|
cloudFlareKey: null,
|
||||||
|
@ -219,8 +219,8 @@ class AppConfigEmpty extends AppConfigNotFinished {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppConfigFinished extends AppConfigState {
|
class ServerInstallationFinished extends ServerInstallationState {
|
||||||
const AppConfigFinished({
|
const ServerInstallationFinished({
|
||||||
required String hetznerKey,
|
required String hetznerKey,
|
||||||
required String cloudFlareKey,
|
required String cloudFlareKey,
|
||||||
required BackblazeCredential backblazeCredential,
|
required BackblazeCredential backblazeCredential,
|
||||||
|
@ -265,10 +265,10 @@ enum RecoveryStep {
|
||||||
BackblazeToken,
|
BackblazeToken,
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppConfigRecovery extends AppConfigState {
|
class ServerInstallationRecovery extends ServerInstallationState {
|
||||||
final RecoveryStep currentStep;
|
final RecoveryStep currentStep;
|
||||||
|
|
||||||
const AppConfigRecovery({
|
const ServerInstallationRecovery({
|
||||||
String? hetznerKey,
|
String? hetznerKey,
|
||||||
String? cloudFlareKey,
|
String? cloudFlareKey,
|
||||||
BackblazeCredential? backblazeCredential,
|
BackblazeCredential? backblazeCredential,
|
||||||
|
@ -301,7 +301,7 @@ class AppConfigRecovery extends AppConfigState {
|
||||||
currentStep
|
currentStep
|
||||||
];
|
];
|
||||||
|
|
||||||
AppConfigRecovery copyWith({
|
ServerInstallationRecovery copyWith({
|
||||||
String? hetznerKey,
|
String? hetznerKey,
|
||||||
String? cloudFlareKey,
|
String? cloudFlareKey,
|
||||||
BackblazeCredential? backblazeCredential,
|
BackblazeCredential? backblazeCredential,
|
||||||
|
@ -310,7 +310,7 @@ class AppConfigRecovery extends AppConfigState {
|
||||||
ServerHostingDetails? serverDetails,
|
ServerHostingDetails? serverDetails,
|
||||||
RecoveryStep? currentStep,
|
RecoveryStep? currentStep,
|
||||||
}) =>
|
}) =>
|
||||||
AppConfigRecovery(
|
ServerInstallationRecovery(
|
||||||
hetznerKey: hetznerKey ?? this.hetznerKey,
|
hetznerKey: hetznerKey ?? this.hetznerKey,
|
||||||
cloudFlareKey: cloudFlareKey ?? this.cloudFlareKey,
|
cloudFlareKey: cloudFlareKey ?? this.cloudFlareKey,
|
||||||
backblazeCredential: backblazeCredential ?? this.backblazeCredential,
|
backblazeCredential: backblazeCredential ?? this.backblazeCredential,
|
|
@ -6,14 +6,14 @@ import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_depe
|
||||||
|
|
||||||
part 'services_state.dart';
|
part 'services_state.dart';
|
||||||
|
|
||||||
class ServicesCubit extends AppConfigDependendCubit<ServicesState> {
|
class ServicesCubit extends ServerInstallationDependendCubit<ServicesState> {
|
||||||
ServicesCubit(AppConfigCubit appConfigCubit)
|
ServicesCubit(ServerInstallationCubit appConfigCubit)
|
||||||
: super(appConfigCubit, ServicesState.allOff());
|
: super(appConfigCubit, ServicesState.allOff());
|
||||||
|
|
||||||
Box box = Hive.box(BNames.servicesState);
|
Box box = Hive.box(BNames.servicesState);
|
||||||
final api = ServerApi();
|
final api = ServerApi();
|
||||||
Future<void> load() async {
|
Future<void> load() async {
|
||||||
if (appConfigCubit.state is AppConfigFinished) {
|
if (appConfigCubit.state is ServerInstallationFinished) {
|
||||||
var statuses = await api.servicesPowerCheck();
|
var statuses = await api.servicesPowerCheck();
|
||||||
emit(
|
emit(
|
||||||
ServicesState(
|
ServicesState(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
part of 'services_cubit.dart';
|
part of 'services_cubit.dart';
|
||||||
|
|
||||||
class ServicesState extends AppConfigDependendState {
|
class ServicesState extends ServerInstallationDependendState {
|
||||||
const ServicesState({
|
const ServicesState({
|
||||||
required this.isPasswordManagerEnable,
|
required this.isPasswordManagerEnable,
|
||||||
required this.isCloudEnable,
|
required this.isCloudEnable,
|
||||||
|
|
|
@ -10,8 +10,8 @@ export 'package:provider/provider.dart';
|
||||||
|
|
||||||
part 'users_state.dart';
|
part 'users_state.dart';
|
||||||
|
|
||||||
class UsersCubit extends AppConfigDependendCubit<UsersState> {
|
class UsersCubit extends ServerInstallationDependendCubit<UsersState> {
|
||||||
UsersCubit(AppConfigCubit appConfigCubit)
|
UsersCubit(ServerInstallationCubit appConfigCubit)
|
||||||
: super(
|
: super(
|
||||||
appConfigCubit,
|
appConfigCubit,
|
||||||
UsersState(
|
UsersState(
|
||||||
|
@ -22,7 +22,7 @@ class UsersCubit extends AppConfigDependendCubit<UsersState> {
|
||||||
final api = ServerApi();
|
final api = ServerApi();
|
||||||
|
|
||||||
Future<void> load() async {
|
Future<void> load() async {
|
||||||
if (appConfigCubit.state is AppConfigFinished) {
|
if (appConfigCubit.state is ServerInstallationFinished) {
|
||||||
var loadedUsers = box.values.toList();
|
var loadedUsers = box.values.toList();
|
||||||
final primaryUser = configBox.get(BNames.rootUser,
|
final primaryUser = configBox.get(BNames.rootUser,
|
||||||
defaultValue: User(login: 'loading...'));
|
defaultValue: User(login: 'loading...'));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
part of 'users_cubit.dart';
|
part of 'users_cubit.dart';
|
||||||
|
|
||||||
class UsersState extends AppConfigDependendState {
|
class UsersState extends ServerInstallationDependendState {
|
||||||
const UsersState(this.users, this.rootUser, this.primaryUser);
|
const UsersState(this.users, this.rootUser, this.primaryUser);
|
||||||
|
|
||||||
final List<User> users;
|
final List<User> users;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/config/brand_colors.dart';
|
import 'package:selfprivacy/config/brand_colors.dart';
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/backup.dart';
|
import 'package:selfprivacy/logic/models/json/backup.dart';
|
||||||
import 'package:selfprivacy/logic/models/state_types.dart';
|
import 'package:selfprivacy/logic/models/state_types.dart';
|
||||||
|
@ -28,7 +28,8 @@ class _BackupDetailsState extends State<BackupDetails>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished;
|
var isReady = context.watch<ServerInstallationCubit>().state
|
||||||
|
is ServerInstallationFinished;
|
||||||
var isBackupInitialized = context.watch<BackupsCubit>().state.isInitialized;
|
var isBackupInitialized = context.watch<BackupsCubit>().state.isInitialized;
|
||||||
var backupStatus = context.watch<BackupsCubit>().state.status;
|
var backupStatus = context.watch<BackupsCubit>().state.status;
|
||||||
var providerState = isReady && isBackupInitialized
|
var providerState = isReady && isBackupInitialized
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
|
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
|
||||||
|
@ -62,7 +62,8 @@ class _DnsDetailsPageState extends State<DnsDetailsPage> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished;
|
var isReady = context.watch<ServerInstallationCubit>().state
|
||||||
|
is ServerInstallationFinished;
|
||||||
final domain = getIt<ApiConfigModel>().serverDomain?.domainName ?? '';
|
final domain = getIt<ApiConfigModel>().serverDomain?.domainName ?? '';
|
||||||
var dnsCubit = context.watch<DnsRecordsCubit>().state;
|
var dnsCubit = context.watch<DnsRecordsCubit>().state;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/config/brand_colors.dart';
|
import 'package:selfprivacy/config/brand_colors.dart';
|
||||||
import 'package:selfprivacy/config/brand_theme.dart';
|
import 'package:selfprivacy/config/brand_theme.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
|
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart';
|
import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart';
|
||||||
|
@ -103,7 +103,7 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
|
||||||
isRed: true,
|
isRed: true,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context
|
||||||
.read<AppConfigCubit>()
|
.read<ServerInstallationCubit>()
|
||||||
.clearAppConfig();
|
.clearAppConfig();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}),
|
}),
|
||||||
|
@ -129,7 +129,7 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
|
||||||
|
|
||||||
Widget deleteServer(BuildContext context) {
|
Widget deleteServer(BuildContext context) {
|
||||||
var isDisabled =
|
var isDisabled =
|
||||||
context.watch<AppConfigCubit>().state.serverDetails == null;
|
context.watch<ServerInstallationCubit>().state.serverDetails == null;
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(top: 20, bottom: 5),
|
padding: EdgeInsets.only(top: 20, bottom: 5),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
@ -181,7 +181,7 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
await context
|
await context
|
||||||
.read<AppConfigCubit>()
|
.read<ServerInstallationCubit>()
|
||||||
.serverDelete();
|
.serverDelete();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/config/brand_theme.dart';
|
import 'package:selfprivacy/config/brand_theme.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
|
||||||
|
@ -30,7 +30,8 @@ class ProvidersPage extends StatefulWidget {
|
||||||
class _ProvidersPageState extends State<ProvidersPage> {
|
class _ProvidersPageState extends State<ProvidersPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished;
|
var isReady = context.watch<ServerInstallationCubit>().state
|
||||||
|
is ServerInstallationFinished;
|
||||||
var isBackupInitialized = context.watch<BackupsCubit>().state.isInitialized;
|
var isBackupInitialized = context.watch<BackupsCubit>().state.isInitialized;
|
||||||
var dnsStatus = context.watch<DnsRecordsCubit>().state.dnsState;
|
var dnsStatus = context.watch<DnsRecordsCubit>().state.dnsState;
|
||||||
|
|
||||||
|
@ -96,8 +97,10 @@ class _Card extends StatelessWidget {
|
||||||
String? message;
|
String? message;
|
||||||
late String stableText;
|
late String stableText;
|
||||||
late VoidCallback onTap;
|
late VoidCallback onTap;
|
||||||
var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished;
|
var isReady = context.watch<ServerInstallationCubit>().state
|
||||||
AppConfigState appConfig = context.watch<AppConfigCubit>().state;
|
is ServerInstallationFinished;
|
||||||
|
ServerInstallationState appConfig =
|
||||||
|
context.watch<ServerInstallationCubit>().state;
|
||||||
|
|
||||||
var domainName =
|
var domainName =
|
||||||
appConfig.isDomainFilled ? appConfig.serverDomain!.domainName : '';
|
appConfig.isDomainFilled ? appConfig.serverDomain!.domainName : '';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/config/brand_colors.dart';
|
import 'package:selfprivacy/config/brand_colors.dart';
|
||||||
import 'package:selfprivacy/config/brand_theme.dart';
|
import 'package:selfprivacy/config/brand_theme.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/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/hetzner_metrics/hetzner_metrics_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/hetzner_metrics/hetzner_metrics_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/state_types.dart';
|
import 'package:selfprivacy/logic/models/state_types.dart';
|
||||||
|
@ -60,7 +60,8 @@ class _ServerDetailsState extends State<ServerDetails>
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished;
|
var isReady = context.watch<ServerInstallationCubit>().state
|
||||||
|
is ServerInstallationFinished;
|
||||||
var providerState = isReady ? StateType.stable : StateType.uninitialized;
|
var providerState = isReady ? StateType.stable : StateType.uninitialized;
|
||||||
|
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
|
|
|
@ -5,7 +5,7 @@ import 'package:selfprivacy/config/brand_colors.dart';
|
||||||
import 'package:selfprivacy/config/brand_theme.dart';
|
import 'package:selfprivacy/config/brand_theme.dart';
|
||||||
import 'package:selfprivacy/config/text_themes.dart';
|
import 'package:selfprivacy/config/text_themes.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/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/job.dart';
|
import 'package:selfprivacy/logic/models/job.dart';
|
||||||
|
@ -58,7 +58,8 @@ void _launchURL(url) async {
|
||||||
class _ServicesPageState extends State<ServicesPage> {
|
class _ServicesPageState extends State<ServicesPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished;
|
var isReady = context.watch<ServerInstallationCubit>().state
|
||||||
|
is ServerInstallationFinished;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: PreferredSize(
|
appBar: PreferredSize(
|
||||||
|
@ -94,7 +95,8 @@ class _Card extends StatelessWidget {
|
||||||
final ServiceTypes serviceType;
|
final ServiceTypes serviceType;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished;
|
var isReady = context.watch<ServerInstallationCubit>().state
|
||||||
|
is ServerInstallationFinished;
|
||||||
var changeTab = context.read<ChangeTab>().onPress;
|
var changeTab = context.read<ChangeTab>().onPress;
|
||||||
|
|
||||||
var serviceState = context.watch<ServicesCubit>().state;
|
var serviceState = context.watch<ServicesCubit>().state;
|
||||||
|
@ -111,7 +113,7 @@ class _Card extends StatelessWidget {
|
||||||
(!switchableServices.contains(serviceType) ||
|
(!switchableServices.contains(serviceType) ||
|
||||||
serviceState.isEnableByType(serviceType));
|
serviceState.isEnableByType(serviceType));
|
||||||
|
|
||||||
var config = context.watch<AppConfigCubit>().state;
|
var config = context.watch<ServerInstallationCubit>().state;
|
||||||
var domainName = UiHelpers.getDomainName(config);
|
var domainName = UiHelpers.getDomainName(config);
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
|
@ -257,7 +259,7 @@ class _ServiceDetails extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
late Widget child;
|
late Widget child;
|
||||||
|
|
||||||
var config = context.watch<AppConfigCubit>().state;
|
var config = context.watch<ServerInstallationCubit>().state;
|
||||||
var domainName = UiHelpers.getDomainName(config);
|
var domainName = UiHelpers.getDomainName(config);
|
||||||
|
|
||||||
var linksStyle = body1Style.copyWith(
|
var linksStyle = body1Style.copyWith(
|
||||||
|
|
|
@ -2,7 +2,7 @@ import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/config/brand_theme.dart';
|
import 'package:selfprivacy/config/brand_theme.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/backblaze_form_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/backblaze_form_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart';
|
||||||
|
@ -23,7 +23,7 @@ import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
||||||
class InitializingPage extends StatelessWidget {
|
class InitializingPage extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var cubit = context.watch<AppConfigCubit>();
|
var cubit = context.watch<ServerInstallationCubit>();
|
||||||
var actualInitializingPage = [
|
var actualInitializingPage = [
|
||||||
() => _stepHetzner(cubit),
|
() => _stepHetzner(cubit),
|
||||||
() => _stepCloudflare(cubit),
|
() => _stepCloudflare(cubit),
|
||||||
|
@ -36,9 +36,9 @@ class InitializingPage extends StatelessWidget {
|
||||||
() => _stepCheck(cubit),
|
() => _stepCheck(cubit),
|
||||||
() => Container(child: Center(child: Text('initializing.finish'.tr())))
|
() => Container(child: Center(child: Text('initializing.finish'.tr())))
|
||||||
][cubit.state.progress.index]();
|
][cubit.state.progress.index]();
|
||||||
return BlocListener<AppConfigCubit, AppConfigState>(
|
return BlocListener<ServerInstallationCubit, ServerInstallationState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (cubit.state is AppConfigFinished) {
|
if (cubit.state is ServerInstallationFinished) {
|
||||||
Navigator.of(context).pushReplacement(materialRoute(RootPage()));
|
Navigator.of(context).pushReplacement(materialRoute(RootPage()));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -86,7 +86,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
Container(
|
Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: BrandButton.text(
|
child: BrandButton.text(
|
||||||
title: cubit.state is AppConfigFinished
|
title: cubit.state is ServerInstallationFinished
|
||||||
? 'basis.close'.tr()
|
? 'basis.close'.tr()
|
||||||
: 'basis.later'.tr(),
|
: 'basis.later'.tr(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -97,7 +97,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
(cubit.state is AppConfigFinished)
|
(cubit.state is ServerInstallationFinished)
|
||||||
? Container()
|
? Container()
|
||||||
: Container(
|
: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
@ -119,7 +119,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _stepHetzner(AppConfigCubit initializingCubit) {
|
Widget _stepHetzner(ServerInstallationCubit initializingCubit) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => HetznerFormCubit(initializingCubit),
|
create: (context) => HetznerFormCubit(initializingCubit),
|
||||||
child: Builder(builder: (context) {
|
child: Builder(builder: (context) {
|
||||||
|
@ -174,7 +174,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _stepCloudflare(AppConfigCubit initializingCubit) {
|
Widget _stepCloudflare(ServerInstallationCubit initializingCubit) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => CloudFlareFormCubit(initializingCubit),
|
create: (context) => CloudFlareFormCubit(initializingCubit),
|
||||||
child: Builder(builder: (context) {
|
child: Builder(builder: (context) {
|
||||||
|
@ -222,7 +222,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _stepBackblaze(AppConfigCubit initializingCubit) {
|
Widget _stepBackblaze(ServerInstallationCubit initializingCubit) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => BackblazeFormCubit(initializingCubit),
|
create: (context) => BackblazeFormCubit(initializingCubit),
|
||||||
child: Builder(builder: (context) {
|
child: Builder(builder: (context) {
|
||||||
|
@ -277,7 +277,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _stepDomain(AppConfigCubit initializingCubit) {
|
Widget _stepDomain(ServerInstallationCubit initializingCubit) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => DomainSetupCubit(initializingCubit)..load(),
|
create: (context) => DomainSetupCubit(initializingCubit)..load(),
|
||||||
child: Builder(builder: (context) {
|
child: Builder(builder: (context) {
|
||||||
|
@ -369,7 +369,7 @@ class InitializingPage extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _stepUser(AppConfigCubit initializingCubit) {
|
Widget _stepUser(ServerInstallationCubit initializingCubit) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) =>
|
create: (context) =>
|
||||||
RootUserFormCubit(initializingCubit, FieldCubitFactory(context)),
|
RootUserFormCubit(initializingCubit, FieldCubitFactory(context)),
|
||||||
|
@ -432,8 +432,9 @@ class InitializingPage extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _stepServer(AppConfigCubit appConfigCubit) {
|
Widget _stepServer(ServerInstallationCubit appConfigCubit) {
|
||||||
var isLoading = (appConfigCubit.state as AppConfigNotFinished).isLoading;
|
var isLoading =
|
||||||
|
(appConfigCubit.state as ServerInstallationNotFinished).isLoading;
|
||||||
return Builder(builder: (context) {
|
return Builder(builder: (context) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
@ -454,8 +455,9 @@ class InitializingPage extends StatelessWidget {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _stepCheck(AppConfigCubit appConfigCubit) {
|
Widget _stepCheck(ServerInstallationCubit appConfigCubit) {
|
||||||
assert(appConfigCubit.state is AppConfigNotFinished, 'wrong state');
|
assert(
|
||||||
|
appConfigCubit.state is ServerInstallationNotFinished, 'wrong state');
|
||||||
var state = appConfigCubit.state as TimerState;
|
var state = appConfigCubit.state as TimerState;
|
||||||
late int doneCount;
|
late int doneCount;
|
||||||
late String? text;
|
late String? text;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
|
||||||
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
|
import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.dart';
|
||||||
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
||||||
|
|
|
@ -3,7 +3,7 @@ part of 'users.dart';
|
||||||
class _NewUser extends StatelessWidget {
|
class _NewUser extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var config = context.watch<AppConfigCubit>().state;
|
var config = context.watch<ServerInstallationCubit>().state;
|
||||||
|
|
||||||
var domainName = UiHelpers.getDomainName(config);
|
var domainName = UiHelpers.getDomainName(config);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class _UserDetails extends StatelessWidget {
|
||||||
final bool isRootUser;
|
final bool isRootUser;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var config = context.watch<AppConfigCubit>().state;
|
var config = context.watch<ServerInstallationCubit>().state;
|
||||||
|
|
||||||
var domainName = UiHelpers.getDomainName(config);
|
var domainName = UiHelpers.getDomainName(config);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:selfprivacy/config/brand_colors.dart';
|
import 'package:selfprivacy/config/brand_colors.dart';
|
||||||
import 'package:selfprivacy/config/brand_theme.dart';
|
import 'package:selfprivacy/config/brand_theme.dart';
|
||||||
import 'package:selfprivacy/config/text_themes.dart';
|
import 'package:selfprivacy/config/text_themes.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/user/user_form_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/forms/user/user_form_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
|
||||||
|
@ -38,7 +38,8 @@ class UsersPage extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// final usersCubitState = context.watch<UsersCubit>().state;
|
// final usersCubitState = context.watch<UsersCubit>().state;
|
||||||
var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished;
|
var isReady = context.watch<ServerInstallationCubit>().state
|
||||||
|
is ServerInstallationFinished;
|
||||||
// final primaryUser = usersCubitState.primaryUser;
|
// final primaryUser = usersCubitState.primaryUser;
|
||||||
// final users = [primaryUser, ...usersCubitState.users];
|
// final users = [primaryUser, ...usersCubitState.users];
|
||||||
// final isEmpty = users.isEmpty;
|
// final isEmpty = users.isEmpty;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
|
|
||||||
/// it's ui helpers use only for ui components, don't use for logic components.
|
/// it's ui helpers use only for ui components, don't use for logic components.
|
||||||
|
|
||||||
class UiHelpers {
|
class UiHelpers {
|
||||||
static String getDomainName(AppConfigState config) =>
|
static String getDomainName(ServerInstallationState config) =>
|
||||||
config.isDomainFilled ? config.serverDomain!.domainName : 'example.com';
|
config.isDomainFilled ? config.serverDomain!.domainName : 'example.com';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue