2020-12-03 16:52:53 +00:00
|
|
|
import 'dart:ui';
|
|
|
|
|
2021-04-19 12:37:51 +00:00
|
|
|
import 'package:crypt/crypt.dart';
|
2020-12-03 16:52:53 +00:00
|
|
|
import 'package:equatable/equatable.dart';
|
|
|
|
import 'package:selfprivacy/utils/color_utils.dart';
|
2021-01-06 17:35:57 +00:00
|
|
|
import 'package:hive/hive.dart';
|
2020-12-03 16:52:53 +00:00
|
|
|
|
2021-01-06 17:35:57 +00:00
|
|
|
part 'user.g.dart';
|
|
|
|
|
|
|
|
@HiveType(typeId: 1)
|
2020-12-03 16:52:53 +00:00
|
|
|
class User extends Equatable {
|
|
|
|
User({
|
2021-03-15 15:39:44 +00:00
|
|
|
required this.login,
|
|
|
|
required this.password,
|
2020-12-03 16:52:53 +00:00
|
|
|
});
|
|
|
|
|
2021-01-06 17:35:57 +00:00
|
|
|
@HiveField(0)
|
2020-12-03 16:52:53 +00:00
|
|
|
final String login;
|
2021-03-15 15:39:44 +00:00
|
|
|
|
2021-01-06 17:35:57 +00:00
|
|
|
@HiveField(1)
|
2020-12-03 16:52:53 +00:00
|
|
|
final String password;
|
|
|
|
|
|
|
|
@override
|
2021-03-15 15:39:44 +00:00
|
|
|
List<Object?> get props => [login, password];
|
2020-12-03 16:52:53 +00:00
|
|
|
|
|
|
|
Color get color => stringToColor(login);
|
2021-01-06 17:35:57 +00:00
|
|
|
|
2021-04-20 11:44:33 +00:00
|
|
|
Crypt get hashPassword => Crypt.sha512(password);
|
2021-01-06 17:35:57 +00:00
|
|
|
|
|
|
|
String toString() {
|
|
|
|
return login;
|
|
|
|
}
|
2020-12-03 16:52:53 +00:00
|
|
|
}
|