2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:hive/hive.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/crypto_currency.dart';
|
2020-09-07 15:13:39 +00:00
|
|
|
import 'package:cake_wallet/utils/mobx.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
part 'contact.g.dart';
|
|
|
|
|
2020-05-26 15:27:10 +00:00
|
|
|
@HiveType(typeId: 0)
|
2020-09-07 15:13:39 +00:00
|
|
|
class Contact extends HiveObject with Keyable {
|
2020-01-08 12:26:34 +00:00
|
|
|
Contact({@required this.name, @required this.address, CryptoCurrency type})
|
|
|
|
: raw = type?.raw;
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
static const boxName = 'Contacts';
|
|
|
|
|
|
|
|
@HiveField(0)
|
|
|
|
String name;
|
|
|
|
|
|
|
|
@HiveField(1)
|
|
|
|
String address;
|
|
|
|
|
|
|
|
@HiveField(2)
|
|
|
|
int raw;
|
|
|
|
|
|
|
|
CryptoCurrency get type => CryptoCurrency.deserialize(raw: raw);
|
|
|
|
|
2020-09-07 15:13:39 +00:00
|
|
|
@override
|
|
|
|
dynamic get keyIndex => key;
|
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
@override
|
|
|
|
bool operator ==(Object o) => o is Contact && o.key == key;
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get hashCode => key.hashCode;
|
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
void updateCryptoCurrency({@required CryptoCurrency currency}) =>
|
2020-01-04 19:31:52 +00:00
|
|
|
raw = currency.raw;
|
|
|
|
}
|