selfprivacy.org.app/lib/logic/cubit/app_config/app_config_state.dart

149 lines
4.2 KiB
Dart
Raw Normal View History

2021-01-06 19:35:57 +02:00
part of 'app_config_cubit.dart';
class AppConfigState extends Equatable {
const AppConfigState({
2021-03-15 17:39:44 +02:00
required this.hetznerKey,
required this.cloudFlareKey,
required this.backblazeCredential,
required this.cloudFlareDomain,
required this.rootUser,
required this.hetznerServer,
required this.isServerStarted,
required this.isServerReseted,
required this.hasFinalChecked,
required this.isLoading,
required this.error,
2021-01-06 19:35:57 +02:00
});
@override
2021-03-15 17:39:44 +02:00
List<Object?> get props => [
2021-01-06 19:35:57 +02:00
hetznerKey,
cloudFlareKey,
2021-02-03 22:26:38 +02:00
backblazeCredential,
2021-01-06 19:35:57 +02:00
cloudFlareDomain,
rootUser,
2021-01-21 09:35:38 +02:00
hetznerServer,
2021-02-16 20:48:15 +02:00
isServerStarted,
isServerReseted,
hasFinalChecked,
2021-01-06 19:35:57 +02:00
isLoading,
2021-01-19 14:05:40 +02:00
error,
2021-01-06 19:35:57 +02:00
];
2021-03-15 17:39:44 +02:00
final String? hetznerKey;
final String? cloudFlareKey;
final BackblazeCredential? backblazeCredential;
final CloudFlareDomain? cloudFlareDomain;
final User? rootUser;
final HetznerServerDetails? hetznerServer;
2021-03-23 21:50:11 +02:00
final bool isServerStarted;
final bool isServerReseted;
final bool hasFinalChecked;
2021-02-16 20:48:15 +02:00
2021-03-15 17:39:44 +02:00
final bool? isLoading;
final Exception? error;
2021-01-06 19:35:57 +02:00
AppConfigState copyWith({
2021-03-15 17:39:44 +02:00
String? hetznerKey,
String? cloudFlareKey,
BackblazeCredential? backblazeCredential,
CloudFlareDomain? cloudFlareDomain,
User? rootUser,
HetznerServerDetails? hetznerServer,
bool? isServerStarted,
bool? isServerReseted,
bool? hasFinalChecked,
bool? isLoading,
Exception? error,
2021-01-06 19:35:57 +02:00
}) =>
AppConfigState(
hetznerKey: hetznerKey ?? this.hetznerKey,
cloudFlareKey: cloudFlareKey ?? this.cloudFlareKey,
2021-02-03 22:26:38 +02:00
backblazeCredential: backblazeCredential ?? this.backblazeCredential,
2021-01-21 09:35:38 +02:00
cloudFlareDomain: cloudFlareDomain ?? this.cloudFlareDomain,
2021-01-06 19:35:57 +02:00
rootUser: rootUser ?? this.rootUser,
2021-01-21 09:35:38 +02:00
hetznerServer: hetznerServer ?? this.hetznerServer,
2021-01-21 23:01:42 +02:00
isServerStarted: isServerStarted ?? this.isServerStarted,
2021-02-16 20:48:15 +02:00
isServerReseted: isServerReseted ?? this.isServerReseted,
hasFinalChecked: hasFinalChecked ?? this.hasFinalChecked,
2021-01-06 19:35:57 +02:00
isLoading: isLoading ?? this.isLoading,
2021-01-06 21:25:53 +02:00
error: error ?? this.error,
2021-01-06 19:35:57 +02:00
);
bool get isHetznerFilled => hetznerKey != null;
bool get isCloudFlareFilled => cloudFlareKey != null;
2021-02-03 22:26:38 +02:00
bool get isBackblazeFilled => backblazeCredential != null;
2021-01-06 19:35:57 +02:00
bool get isDomainFilled => cloudFlareDomain != null;
bool get isUserFilled => rootUser != null;
2021-02-16 20:48:15 +02:00
bool get isServerCreated => hetznerServer != null;
2021-01-21 23:01:42 +02:00
2021-03-15 17:39:44 +02:00
bool get isFullyInitilized => _fulfilementList.every((el) => el!);
int get progress => _fulfilementList.where((el) => el!).length;
2021-01-06 19:35:57 +02:00
2021-03-25 10:32:00 +02:00
List<bool?> get _fulfilementList {
var res = [
isHetznerFilled,
isCloudFlareFilled,
isBackblazeFilled,
isDomainFilled,
isUserFilled,
isServerCreated,
isServerStarted,
isServerReseted,
hasFinalChecked,
];
2021-03-30 20:38:40 +03:00
print(res);
2021-03-25 10:32:00 +02:00
return res;
}
2021-01-06 19:35:57 +02:00
}
class InitialAppConfigState extends AppConfigState {
2021-02-16 20:48:15 +02:00
InitialAppConfigState()
: super(
hetznerKey: null,
cloudFlareKey: null,
backblazeCredential: null,
cloudFlareDomain: null,
rootUser: null,
hetznerServer: null,
isServerStarted: false,
isServerReseted: false,
hasFinalChecked: false,
isLoading: false,
error: null,
);
2021-01-06 19:35:57 +02:00
}
2021-02-15 20:58:29 +02:00
class TimerState extends AppConfigState {
TimerState({
2021-03-15 17:39:44 +02:00
required this.dataState,
2021-02-15 20:58:29 +02:00
this.timerStart,
this.duration,
2021-03-15 17:39:44 +02:00
required bool isLoading,
2021-02-16 20:48:15 +02:00
}) : super(
hetznerKey: dataState.hetznerKey,
cloudFlareKey: dataState.cloudFlareKey,
backblazeCredential: dataState.backblazeCredential,
cloudFlareDomain: dataState.cloudFlareDomain,
rootUser: dataState.rootUser,
hetznerServer: dataState.hetznerServer,
isServerStarted: dataState.isServerStarted,
isServerReseted: dataState.isServerReseted,
hasFinalChecked: dataState.hasFinalChecked,
isLoading: isLoading,
error: dataState.error,
);
2021-02-15 20:58:29 +02:00
final AppConfigState dataState;
2021-03-15 17:39:44 +02:00
final DateTime? timerStart;
final Duration? duration;
2021-02-15 20:58:29 +02:00
@override
2021-03-15 17:39:44 +02:00
List<Object?> get props => [
2021-02-15 20:58:29 +02:00
dataState,
timerStart,
duration,
];
}