selfprivacy.org.app/lib/logic/cubit/users/users_state.dart

35 lines
876 B
Dart
Raw Normal View History

2020-12-03 16:52:53 +00:00
part of 'users_cubit.dart';
class UsersState extends ServerInstallationDependendState {
const UsersState(this.users, this.isLoading);
2020-12-03 16:52:53 +00:00
final List<User> users;
final bool isLoading;
2022-09-05 04:34:47 +00:00
User get rootUser =>
users.firstWhere((final user) => user.type == UserType.root);
2022-09-05 04:34:47 +00:00
User get primaryUser =>
users.firstWhere((final user) => user.type == UserType.primary);
2022-09-05 04:34:47 +00:00
List<User> get normalUsers =>
users.where((final user) => user.type == UserType.normal).toList();
2020-12-03 16:52:53 +00:00
@override
List<Object> get props => [users, isLoading];
UsersState copyWith({
2022-06-05 19:36:32 +00:00
final List<User>? users,
final bool? isLoading,
}) =>
UsersState(
users ?? this.users,
isLoading ?? this.isLoading,
);
2021-01-06 17:35:57 +00:00
2022-09-05 04:34:47 +00:00
bool isLoginRegistered(final String login) =>
users.any((final User user) => user.login == login);
2021-01-06 17:35:57 +00:00
bool get isEmpty => users.isEmpty;
2020-12-03 16:52:53 +00:00
}