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