part of 'tokens_bloc.dart'; enum TokenStatus { loading, valid, invalid, noAccess, } class TokenStatusWrapper { TokenStatusWrapper({ required this.data, required this.status, }); final T data; final TokenStatus status; } sealed class TokensState extends Equatable { const TokensState(); List> get serverProviderCredentials; List> get dnsProviderCredentials; List> get backupsCredentials; List get servers => _servers; List get serversWithoutProviderCredentials => servers .where( (final Server server) => server.hostingDetails.provider != ServerProviderType.unknown && serverProviderCredentials.every( ( final TokenStatusWrapper serverProviderCredential, ) => !serverProviderCredential.data.associatedServerIds .contains(server.hostingDetails.id), ), ) .toList(); Server getServerById(final int serverId) => servers.firstWhere( (final Server server) => server.hostingDetails.id == serverId, ); List get _serverProviderCredentials => getIt().serverProviderCredentials; List get _dnsProviderCredentials => getIt().dnsProviderCredentials; List get _backupsCredentials => getIt().backupsCredentials; List get _servers => getIt().servers; } final class TokensInitial extends TokensState { const TokensInitial(); @override List> get serverProviderCredentials => _serverProviderCredentials .map( (final ServerProviderCredential serverProviderCredential) => TokenStatusWrapper( data: serverProviderCredential, status: TokenStatus.loading, ), ) .toList(); @override List> get dnsProviderCredentials => _dnsProviderCredentials .map( (final DnsProviderCredential dnsProviderCredential) => TokenStatusWrapper( data: dnsProviderCredential, status: TokenStatus.loading, ), ) .toList(); @override List> get backupsCredentials => _backupsCredentials .map( (final BackupsCredential backupsCredential) => TokenStatusWrapper( data: backupsCredential, status: TokenStatus.loading, ), ) .toList(); @override List get servers => _servers; @override List get props => []; } final class TokensChecked extends TokensState { const TokensChecked({ required this.serverProviderCredentials, required this.dnsProviderCredentials, required this.backupsCredentials, }); @override final List> serverProviderCredentials; @override final List> dnsProviderCredentials; @override final List> backupsCredentials; @override List get props => [ serverProviderCredentials, dnsProviderCredentials, backupsCredentials, servers, ]; }