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,
|
|
|
|
this.server,
|
2021-01-19 12:05:40 +00:00
|
|
|
this.isDnsChecked = false,
|
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-06 17:35:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<Object> get props => [
|
|
|
|
hetznerKey,
|
|
|
|
cloudFlareKey,
|
|
|
|
cloudFlareDomain,
|
|
|
|
rootUser,
|
|
|
|
server,
|
2021-01-19 12:05:40 +00:00
|
|
|
isDnsChecked,
|
2021-01-06 17:35:57 +00:00
|
|
|
isLoading,
|
2021-01-19 12:05:40 +00:00
|
|
|
error,
|
|
|
|
lastDnsCheckTime
|
2021-01-06 17:35:57 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
final String hetznerKey;
|
|
|
|
final String cloudFlareKey;
|
|
|
|
final CloudFlareDomain cloudFlareDomain;
|
|
|
|
final User rootUser;
|
|
|
|
final HetznerServerDetails server;
|
2021-01-19 12:05:40 +00:00
|
|
|
final bool isDnsChecked;
|
|
|
|
final DateTime lastDnsCheckTime;
|
2021-01-06 17:35:57 +00:00
|
|
|
|
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,
|
|
|
|
CloudFlareDomain domain,
|
|
|
|
User rootUser,
|
|
|
|
HetznerServerDetails hetznerServer,
|
2021-01-19 12:05:40 +00:00
|
|
|
bool serverStarted,
|
2021-01-06 17:35:57 +00:00
|
|
|
bool isLoading,
|
2021-01-06 19:25:53 +00:00
|
|
|
Exception error,
|
2021-01-19 12:05:40 +00:00
|
|
|
DateTime lastDnsCheckTime,
|
2021-01-06 17:35:57 +00:00
|
|
|
}) =>
|
|
|
|
AppConfigState(
|
|
|
|
hetznerKey: hetznerKey ?? this.hetznerKey,
|
|
|
|
cloudFlareKey: cloudFlareKey ?? this.cloudFlareKey,
|
|
|
|
cloudFlareDomain: domain ?? this.cloudFlareDomain,
|
|
|
|
rootUser: rootUser ?? this.rootUser,
|
|
|
|
server: hetznerServer ?? this.server,
|
2021-01-19 12:05:40 +00:00
|
|
|
isDnsChecked: serverStarted ?? 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-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;
|
|
|
|
bool get isServerFilled => server != null;
|
2021-01-06 19:25:53 +00:00
|
|
|
|
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-19 12:05:40 +00:00
|
|
|
isDnsChecked,
|
2021-01-06 17:35:57 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
class InitialAppConfigState extends AppConfigState {
|
|
|
|
InitialAppConfigState() : super();
|
|
|
|
}
|