2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import 'isar/models/contact_entry.dart';
|
|
|
|
import '../wallets/crypto_currency/crypto_currency.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class AddressEntryData extends ChangeNotifier {
|
|
|
|
late int id;
|
|
|
|
|
|
|
|
AddressEntryData(this.id);
|
|
|
|
|
|
|
|
String? _addressLabel;
|
|
|
|
String? _address;
|
2024-05-15 21:20:45 +00:00
|
|
|
CryptoCurrency? _coin;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
String? get addressLabel => _addressLabel;
|
|
|
|
|
|
|
|
set addressLabel(String? addressLabel) {
|
|
|
|
_addressLabel = addressLabel;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
String? get address => _address;
|
|
|
|
|
|
|
|
set address(String? address) {
|
|
|
|
_address = address;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2024-05-15 21:20:45 +00:00
|
|
|
CryptoCurrency? get coin => _coin;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2024-05-15 21:20:45 +00:00
|
|
|
set coin(CryptoCurrency? coin) {
|
2022-08-26 08:11:35 +00:00
|
|
|
_coin = coin;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2022-11-29 16:33:40 +00:00
|
|
|
bool get isEmpty {
|
|
|
|
if (address != null && address!.isNotEmpty) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (addressLabel != null && addressLabel!.isNotEmpty) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (coin != null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
bool get isValid {
|
|
|
|
if (_address == null || coin == null || _addressLabel == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (_address!.isEmpty || _addressLabel!.isEmpty) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return isValidAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool get isValidAddress {
|
2023-05-15 20:12:06 +00:00
|
|
|
if (coin == null) {
|
2023-03-28 15:17:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (_address == null) {
|
2022-08-26 08:11:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
2024-05-15 21:20:45 +00:00
|
|
|
return _coin!.validateAddress(_address!);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ContactAddressEntry buildAddressEntry() {
|
2023-05-15 20:12:06 +00:00
|
|
|
return ContactAddressEntry()
|
2024-05-15 21:20:45 +00:00
|
|
|
..coinName = coin!.identifier
|
2023-05-15 20:12:06 +00:00
|
|
|
..address = address!
|
|
|
|
..other = null
|
|
|
|
..label = addressLabel!;
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
2024-05-15 21:20:45 +00:00
|
|
|
return "AddressEntryData: { addressLabel: $addressLabel, address: $address, coin: ${coin?.identifier} }";
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
}
|