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

110 lines
3.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({
this.hetznerKey,
this.cloudFlareKey,
2021-02-03 21:51:07 +02:00
this.backblazeKey,
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-01-19 14:05:40 +02:00
this.lastDnsCheckTime,
2021-01-21 23:01:42 +02:00
this.lastServerStatusCheckTime,
this.isDnsChecked = false,
this.isServerStarted = false,
2021-01-21 09:35:38 +02:00
this.isDkimSetted = false,
2021-01-06 19:35:57 +02:00
});
@override
List<Object> get props => [
hetznerKey,
cloudFlareKey,
2021-02-03 21:51:07 +02:00
backblazeKey,
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-01-21 09:35:38 +02:00
lastDnsCheckTime,
2021-01-21 23:01:42 +02:00
lastServerStatusCheckTime,
2021-01-21 09:35:38 +02:00
isDkimSetted,
2021-01-06 19:35:57 +02:00
];
final String hetznerKey;
final String cloudFlareKey;
2021-02-03 21:51:07 +02:00
final String backblazeKey;
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;
final bool isDkimSetted;
2021-01-21 23:01:42 +02:00
final bool isServerStarted;
final bool isDnsChecked;
2021-01-19 14:05:40 +02:00
final DateTime lastDnsCheckTime;
2021-01-21 23:01:42 +02:00
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 21:51:07 +02:00
String backblazeKey,
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,
2021-01-21 09:35:38 +02:00
bool isDkimSetted,
2021-01-21 23:01:42 +02:00
bool isServerStarted,
bool isDnsChecked,
2021-01-06 19:35:57 +02:00
}) =>
AppConfigState(
hetznerKey: hetznerKey ?? this.hetznerKey,
cloudFlareKey: cloudFlareKey ?? this.cloudFlareKey,
2021-02-03 21:51:07 +02:00
backblazeKey: backblazeKey ?? this.backblazeKey,
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-01-19 14:05:40 +02:00
lastDnsCheckTime: lastDnsCheckTime ?? this.lastDnsCheckTime,
2021-01-21 23:01:42 +02:00
lastServerStatusCheckTime:
lastServerStatusCheckTime ?? this.lastServerStatusCheckTime,
isDkimSetted: isDkimSetted ?? this.isDkimSetted,
2021-01-06 19:35:57 +02:00
);
bool get isHetznerFilled => hetznerKey != null;
bool get isCloudFlareFilled => cloudFlareKey != null;
2021-02-03 21:51:07 +02:00
bool get isBackblazeFilled => backblazeKey != 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;
bool get hasFinalChecked => isDnsCheckedAndServerStarted && isDkimSetted;
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();
}