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

124 lines
3.5 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({
this.hetznerKey,
this.cloudFlareKey,
2021-02-03 22:26:38 +02:00
this.backblazeCredential,
2021-01-06 19:35:57 +02:00
this.cloudFlareDomain,
this.rootUser,
2021-01-21 09:35:38 +02:00
this.hetznerServer,
2021-01-06 19:35:57 +02:00
this.isLoading = false,
2021-01-06 21:25:53 +02:00
this.error,
2021-02-15 20:58:29 +02:00
// this.lastDnsCheckTime,
// this.lastServerStatusCheckTime,
2021-01-21 23:01:42 +02:00
this.isDnsChecked = false,
this.isServerStarted = false,
2021-01-06 19:35:57 +02:00
});
@override
List<Object> get props => [
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,
isDnsCheckedAndServerStarted,
2021-01-06 19:35:57 +02:00
isLoading,
2021-01-19 14:05:40 +02:00
error,
2021-02-15 20:58:29 +02:00
// lastDnsCheckTime,
// lastServerStatusCheckTime,
2021-01-06 19:35:57 +02:00
];
final String hetznerKey;
final String cloudFlareKey;
2021-02-03 22:26:38 +02:00
final BackblazeCredential backblazeCredential;
2021-01-06 19:35:57 +02:00
final CloudFlareDomain cloudFlareDomain;
final User rootUser;
2021-01-21 09:35:38 +02:00
final HetznerServerDetails hetznerServer;
2021-01-21 23:01:42 +02:00
final bool isServerStarted;
final bool isDnsChecked;
2021-02-15 20:58:29 +02:00
// final DateTime lastDnsCheckTime;
// final DateTime lastServerStatusCheckTime;
2021-01-06 21:25:53 +02:00
final bool isLoading;
final Exception error;
2021-01-06 19:35:57 +02:00
AppConfigState copyWith({
String hetznerKey,
String cloudFlareKey,
2021-02-03 22:26:38 +02:00
BackblazeCredential backblazeCredential,
2021-01-21 09:35:38 +02:00
CloudFlareDomain cloudFlareDomain,
2021-01-06 19:35:57 +02:00
User rootUser,
HetznerServerDetails hetznerServer,
bool isLoading,
2021-01-06 21:25:53 +02:00
Exception error,
2021-01-19 14:05:40 +02:00
DateTime lastDnsCheckTime,
2021-01-21 23:01:42 +02:00
DateTime lastServerStatusCheckTime,
bool isServerStarted,
bool isDnsChecked,
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,
isDnsChecked: isDnsChecked ?? this.isDnsChecked,
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-02-15 20:58:29 +02:00
// lastDnsCheckTime: lastDnsCheckTime ?? this.lastDnsCheckTime,
// lastServerStatusCheckTime:
// lastServerStatusCheckTime ?? this.lastServerStatusCheckTime,
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-01-21 09:35:38 +02:00
bool get isServerFilled => hetznerServer != null;
2021-02-15 20:58:29 +02:00
bool get hasFinalChecked => isDnsCheckedAndServerStarted;
2021-01-06 21:25:53 +02:00
2021-01-21 23:01:42 +02:00
bool get isDnsCheckedAndServerStarted => isDnsChecked && isServerStarted;
2021-01-06 19:35:57 +02:00
bool get isFullyInitilized => _fulfilementList.every((el) => el);
int get progress => _fulfilementList.where((el) => el).length;
List<bool> get _fulfilementList => [
isHetznerFilled,
isCloudFlareFilled,
2021-02-03 21:51:07 +02:00
isBackblazeFilled,
2021-01-06 19:35:57 +02:00
isDomainFilled,
isUserFilled,
isServerFilled,
2021-01-21 09:35:38 +02:00
hasFinalChecked,
2021-01-06 19:35:57 +02:00
];
}
class InitialAppConfigState extends AppConfigState {
InitialAppConfigState() : super();
}
2021-02-15 20:58:29 +02:00
class TimerState extends AppConfigState {
TimerState({
this.dataState,
this.timerStart,
this.duration,
}) : super();
final AppConfigState dataState;
final DateTime timerStart;
final Duration duration;
@override
List<Object> get props => [
dataState,
timerStart,
duration,
];
}