2020-09-26 19:17:31 +00:00
|
|
|
import 'package:cake_wallet/entities/contact.dart';
|
2021-01-08 18:10:37 +00:00
|
|
|
import 'package:cake_wallet/entities/contact_base.dart';
|
2024-11-07 01:26:14 +00:00
|
|
|
import 'package:cake_wallet/entities/record.dart';
|
|
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import 'package:mobx/mobx.dart';
|
2020-09-26 19:17:31 +00:00
|
|
|
|
|
|
|
part 'contact_record.g.dart';
|
|
|
|
|
|
|
|
class ContactRecord = ContactRecordBase with _$ContactRecord;
|
|
|
|
|
2024-11-07 01:26:14 +00:00
|
|
|
abstract class ContactRecordBase extends Record<Contact> with Store implements ContactBase {
|
2020-09-26 19:17:31 +00:00
|
|
|
ContactRecordBase(Box<Contact> source, Contact original)
|
2022-10-12 17:09:57 +00:00
|
|
|
: name = original.name,
|
|
|
|
address = original.address,
|
|
|
|
type = original.type,
|
2024-11-07 01:26:14 +00:00
|
|
|
lastChange = original.lastChange,
|
|
|
|
super(source, original);
|
2020-09-26 19:17:31 +00:00
|
|
|
|
2021-01-08 18:10:37 +00:00
|
|
|
@override
|
2020-09-26 19:17:31 +00:00
|
|
|
@observable
|
|
|
|
String name;
|
|
|
|
|
2021-01-08 18:10:37 +00:00
|
|
|
@override
|
2020-09-26 19:17:31 +00:00
|
|
|
@observable
|
|
|
|
String address;
|
|
|
|
|
2021-01-08 18:10:37 +00:00
|
|
|
@override
|
2020-09-26 19:17:31 +00:00
|
|
|
@observable
|
|
|
|
CryptoCurrency type;
|
|
|
|
|
2024-11-07 01:26:14 +00:00
|
|
|
DateTime? lastChange;
|
|
|
|
|
2020-09-26 19:17:31 +00:00
|
|
|
@override
|
|
|
|
void toBind(Contact original) {
|
|
|
|
reaction((_) => name, (String name) => original.name = name);
|
|
|
|
reaction((_) => address, (String address) => original.address = address);
|
2024-11-07 01:26:14 +00:00
|
|
|
reaction((_) => type,
|
|
|
|
(CryptoCurrency currency) => original.updateCryptoCurrency(currency: currency));
|
2020-09-26 19:17:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void fromBind(Contact original) {
|
|
|
|
name = original.name;
|
|
|
|
address = original.address;
|
|
|
|
type = original.type;
|
|
|
|
}
|
|
|
|
}
|