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

103 lines
3 KiB
Dart
Raw Normal View History

2021-01-06 17:35:57 +00:00
part of 'app_config_cubit.dart';
class AppConfigState extends Equatable {
const AppConfigState({
this.hetznerKey,
this.cloudFlareKey,
this.cloudFlareDomain,
this.rootUser,
2021-01-21 07:35:38 +00:00
this.hetznerServer,
2021-01-06 17:35:57 +00:00
this.isLoading = false,
2021-01-06 19:25:53 +00:00
this.error,
2021-01-19 12:05:40 +00:00
this.lastDnsCheckTime,
2021-01-21 21:01:42 +00:00
this.lastServerStatusCheckTime,
this.isDnsChecked = false,
this.isServerStarted = false,
2021-01-21 07:35:38 +00:00
this.isDkimSetted = false,
2021-01-06 17:35:57 +00:00
});
@override
List<Object> get props => [
hetznerKey,
cloudFlareKey,
cloudFlareDomain,
rootUser,
2021-01-21 07:35:38 +00:00
hetznerServer,
isDnsCheckedAndServerStarted,
2021-01-06 17:35:57 +00:00
isLoading,
2021-01-19 12:05:40 +00:00
error,
2021-01-21 07:35:38 +00:00
lastDnsCheckTime,
2021-01-21 21:01:42 +00:00
lastServerStatusCheckTime,
2021-01-21 07:35:38 +00:00
isDkimSetted,
2021-01-06 17:35:57 +00:00
];
final String hetznerKey;
final String cloudFlareKey;
final CloudFlareDomain cloudFlareDomain;
final User rootUser;
2021-01-21 07:35:38 +00:00
final HetznerServerDetails hetznerServer;
final bool isDkimSetted;
2021-01-21 21:01:42 +00:00
final bool isServerStarted;
final bool isDnsChecked;
2021-01-19 12:05:40 +00:00
final DateTime lastDnsCheckTime;
2021-01-21 21:01:42 +00:00
final DateTime lastServerStatusCheckTime;
2021-01-06 19:25:53 +00:00
final bool isLoading;
final Exception error;
2021-01-06 17:35:57 +00:00
AppConfigState copyWith({
String hetznerKey,
String cloudFlareKey,
2021-01-21 07:35:38 +00:00
CloudFlareDomain cloudFlareDomain,
2021-01-06 17:35:57 +00:00
User rootUser,
HetznerServerDetails hetznerServer,
bool isLoading,
2021-01-06 19:25:53 +00:00
Exception error,
2021-01-19 12:05:40 +00:00
DateTime lastDnsCheckTime,
2021-01-21 21:01:42 +00:00
DateTime lastServerStatusCheckTime,
2021-01-21 07:35:38 +00:00
bool isDkimSetted,
2021-01-21 21:01:42 +00:00
bool isServerStarted,
bool isDnsChecked,
2021-01-06 17:35:57 +00:00
}) =>
AppConfigState(
hetznerKey: hetznerKey ?? this.hetznerKey,
cloudFlareKey: cloudFlareKey ?? this.cloudFlareKey,
2021-01-21 07:35:38 +00:00
cloudFlareDomain: cloudFlareDomain ?? this.cloudFlareDomain,
2021-01-06 17:35:57 +00:00
rootUser: rootUser ?? this.rootUser,
2021-01-21 07:35:38 +00:00
hetznerServer: hetznerServer ?? this.hetznerServer,
2021-01-21 21:01:42 +00:00
isServerStarted: isServerStarted ?? this.isServerStarted,
isDnsChecked: isDnsChecked ?? this.isDnsChecked,
2021-01-06 17:35:57 +00:00
isLoading: isLoading ?? this.isLoading,
2021-01-06 19:25:53 +00:00
error: error ?? this.error,
2021-01-19 12:05:40 +00:00
lastDnsCheckTime: lastDnsCheckTime ?? this.lastDnsCheckTime,
2021-01-21 21:01:42 +00:00
lastServerStatusCheckTime:
lastServerStatusCheckTime ?? this.lastServerStatusCheckTime,
isDkimSetted: isDkimSetted ?? this.isDkimSetted,
2021-01-06 17:35:57 +00:00
);
bool get isHetznerFilled => hetznerKey != null;
bool get isCloudFlareFilled => cloudFlareKey != null;
bool get isDomainFilled => cloudFlareDomain != null;
bool get isUserFilled => rootUser != null;
2021-01-21 07:35:38 +00:00
bool get isServerFilled => hetznerServer != null;
bool get hasFinalChecked => isDnsCheckedAndServerStarted && isDkimSetted;
2021-01-06 19:25:53 +00:00
2021-01-21 21:01:42 +00:00
bool get isDnsCheckedAndServerStarted => isDnsChecked && isServerStarted;
2021-01-06 17:35:57 +00:00
bool get isFullyInitilized => _fulfilementList.every((el) => el);
int get progress => _fulfilementList.where((el) => el).length;
List<bool> get _fulfilementList => [
isHetznerFilled,
isCloudFlareFilled,
isDomainFilled,
isUserFilled,
isServerFilled,
2021-01-21 07:35:38 +00:00
hasFinalChecked,
2021-01-06 17:35:57 +00:00
];
}
class InitialAppConfigState extends AppConfigState {
InitialAppConfigState() : super();
}