2021-08-29 09:50:24 +00:00
|
|
|
part of 'services_cubit.dart';
|
|
|
|
|
2022-05-17 13:31:34 +00:00
|
|
|
class ServicesState extends ServerInstallationDependendState {
|
2022-06-05 19:36:32 +00:00
|
|
|
factory ServicesState.allOn() => const ServicesState(
|
|
|
|
isPasswordManagerEnable: true,
|
|
|
|
isCloudEnable: true,
|
|
|
|
isGitEnable: true,
|
|
|
|
isSocialNetworkEnable: true,
|
|
|
|
isVpnEnable: true,
|
|
|
|
);
|
|
|
|
|
|
|
|
factory ServicesState.allOff() => const ServicesState(
|
|
|
|
isPasswordManagerEnable: false,
|
|
|
|
isCloudEnable: false,
|
|
|
|
isGitEnable: false,
|
|
|
|
isSocialNetworkEnable: false,
|
|
|
|
isVpnEnable: false,
|
|
|
|
);
|
2021-08-29 13:54:28 +00:00
|
|
|
const ServicesState({
|
|
|
|
required this.isPasswordManagerEnable,
|
|
|
|
required this.isCloudEnable,
|
|
|
|
required this.isGitEnable,
|
|
|
|
required this.isSocialNetworkEnable,
|
|
|
|
required this.isVpnEnable,
|
|
|
|
});
|
|
|
|
|
|
|
|
final bool isPasswordManagerEnable;
|
|
|
|
final bool isCloudEnable;
|
|
|
|
final bool isGitEnable;
|
|
|
|
final bool isSocialNetworkEnable;
|
|
|
|
final bool isVpnEnable;
|
|
|
|
|
|
|
|
ServicesState enableList(
|
2022-06-05 19:36:32 +00:00
|
|
|
final List<ServiceTypes> list,
|
2021-08-29 13:54:28 +00:00
|
|
|
) =>
|
|
|
|
ServicesState(
|
|
|
|
isPasswordManagerEnable: list.contains(ServiceTypes.passwordManager)
|
|
|
|
? true
|
|
|
|
: isPasswordManagerEnable,
|
|
|
|
isCloudEnable: list.contains(ServiceTypes.cloud) ? true : isCloudEnable,
|
|
|
|
isGitEnable:
|
|
|
|
list.contains(ServiceTypes.git) ? true : isPasswordManagerEnable,
|
|
|
|
isSocialNetworkEnable: list.contains(ServiceTypes.socialNetwork)
|
|
|
|
? true
|
|
|
|
: isPasswordManagerEnable,
|
|
|
|
isVpnEnable:
|
|
|
|
list.contains(ServiceTypes.vpn) ? true : isPasswordManagerEnable,
|
|
|
|
);
|
|
|
|
|
|
|
|
ServicesState disableList(
|
2022-06-05 19:36:32 +00:00
|
|
|
final List<ServiceTypes> list,
|
2021-08-29 13:54:28 +00:00
|
|
|
) =>
|
|
|
|
ServicesState(
|
|
|
|
isPasswordManagerEnable: list.contains(ServiceTypes.passwordManager)
|
|
|
|
? false
|
|
|
|
: isPasswordManagerEnable,
|
|
|
|
isCloudEnable:
|
|
|
|
list.contains(ServiceTypes.cloud) ? false : isCloudEnable,
|
|
|
|
isGitEnable:
|
|
|
|
list.contains(ServiceTypes.git) ? false : isPasswordManagerEnable,
|
|
|
|
isSocialNetworkEnable: list.contains(ServiceTypes.socialNetwork)
|
|
|
|
? false
|
|
|
|
: isPasswordManagerEnable,
|
|
|
|
isVpnEnable:
|
|
|
|
list.contains(ServiceTypes.vpn) ? false : isPasswordManagerEnable,
|
|
|
|
);
|
2021-08-29 09:50:24 +00:00
|
|
|
|
|
|
|
@override
|
2021-08-29 13:54:28 +00:00
|
|
|
List<Object> get props => [
|
|
|
|
isPasswordManagerEnable,
|
|
|
|
isCloudEnable,
|
|
|
|
isGitEnable,
|
|
|
|
isSocialNetworkEnable,
|
|
|
|
isVpnEnable
|
|
|
|
];
|
2021-08-29 15:02:51 +00:00
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
bool isEnableByType(final ServiceTypes type) {
|
2021-08-29 15:02:51 +00:00
|
|
|
switch (type) {
|
|
|
|
case ServiceTypes.passwordManager:
|
|
|
|
return isPasswordManagerEnable;
|
|
|
|
case ServiceTypes.cloud:
|
|
|
|
return isCloudEnable;
|
|
|
|
case ServiceTypes.socialNetwork:
|
|
|
|
return isSocialNetworkEnable;
|
|
|
|
case ServiceTypes.git:
|
|
|
|
return isGitEnable;
|
|
|
|
case ServiceTypes.vpn:
|
|
|
|
return isVpnEnable;
|
|
|
|
default:
|
|
|
|
throw Exception('wrong state');
|
|
|
|
}
|
|
|
|
}
|
2021-08-29 09:50:24 +00:00
|
|
|
}
|