2020-12-03 16:52:53 +00:00
|
|
|
import 'package:bloc/bloc.dart';
|
|
|
|
import 'package:equatable/equatable.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/user.dart';
|
|
|
|
export 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
part 'users_state.dart';
|
|
|
|
|
|
|
|
class UsersCubit extends Cubit<UsersState> {
|
2021-01-06 17:35:57 +00:00
|
|
|
UsersCubit() : super(UsersState([]));
|
2020-12-03 16:52:53 +00:00
|
|
|
|
|
|
|
void add(User user) {
|
2021-01-14 18:45:10 +00:00
|
|
|
var users = [...state.users];
|
2020-12-03 16:52:53 +00:00
|
|
|
users.add(user);
|
|
|
|
|
|
|
|
emit(UsersState(users));
|
|
|
|
}
|
|
|
|
|
|
|
|
void remove(User user) {
|
2021-01-14 18:45:10 +00:00
|
|
|
var users = [...state.users];
|
2020-12-03 16:52:53 +00:00
|
|
|
users.remove(user);
|
|
|
|
|
|
|
|
emit(UsersState(users));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-06 17:35:57 +00:00
|
|
|
// final initMockUsers = <User>[
|
|
|
|
// User(login: 'Heartbreaking.Goose', password: genPass()),
|
|
|
|
// User(login: 'Alma.lawson', password: genPass()),
|
|
|
|
// User(login: 'Bee.gees', password: genPass()),
|
|
|
|
// User(login: 'Bim.jennings', password: genPass()),
|
|
|
|
// User(login: 'Debra.holt', password: genPass()),
|
|
|
|
// User(login: 'Georgia.young', password: genPass()),
|
|
|
|
// User(login: 'Kenzi.lawson', password: genPass()),
|
|
|
|
// User(login: 'Le.jennings', password: genPass()),
|
|
|
|
// User(login: 'Kirill.Zh', password: genPass()),
|
|
|
|
// User(login: 'Tina.Bolton', password: genPass()),
|
|
|
|
// User(login: 'Rebekah.Lynn', password: genPass()),
|
|
|
|
// User(login: 'Aleena.Armstrong', password: genPass()),
|
|
|
|
// User(login: 'Rosemary.Williams', password: genPass()),
|
|
|
|
// User(login: 'Sullivan.Nixon', password: genPass()),
|
|
|
|
// User(login: 'Aleena.Armstrong', password: genPass()),
|
|
|
|
// ];
|