2020-12-03 16:52:53 +00:00
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:equatable/equatable.dart';
|
2021-01-06 17:35:57 +00:00
|
|
|
import 'package:hive/hive.dart';
|
2022-03-03 17:38:30 +00:00
|
|
|
import 'package:selfprivacy/utils/color_utils.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 {
|
2022-05-24 18:55:39 +00:00
|
|
|
const User({
|
2021-03-15 15:39:44 +00:00
|
|
|
required this.login,
|
2022-03-03 17:38:30 +00:00
|
|
|
this.password,
|
|
|
|
this.sshKeys = const [],
|
|
|
|
this.isFoundOnServer = true,
|
|
|
|
this.note,
|
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)
|
2022-03-03 17:38:30 +00:00
|
|
|
final String? password;
|
|
|
|
|
2022-05-24 18:55:39 +00:00
|
|
|
@HiveField(2, defaultValue: [])
|
2022-03-03 17:38:30 +00:00
|
|
|
final List<String> sshKeys;
|
|
|
|
|
|
|
|
@HiveField(3, defaultValue: true)
|
|
|
|
final bool isFoundOnServer;
|
|
|
|
|
|
|
|
@HiveField(4)
|
|
|
|
final String? note;
|
2020-12-03 16:52:53 +00:00
|
|
|
|
|
|
|
@override
|
2022-03-03 17:38:30 +00:00
|
|
|
List<Object?> get props => [login, password, sshKeys, isFoundOnServer, note];
|
2020-12-03 16:52:53 +00:00
|
|
|
|
|
|
|
Color get color => stringToColor(login);
|
2021-01-06 17:35:57 +00:00
|
|
|
|
2022-05-24 18:55:39 +00:00
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
String toString() =>
|
|
|
|
'$login, ${isFoundOnServer ? 'found' : 'not found'}, ${sshKeys.length} ssh keys, note: $note';
|
2020-12-03 16:52:53 +00:00
|
|
|
}
|