CWA-69 | added focusNode to address_text_field, got recipient name in the openalias, added focusNode listener in the send_page

This commit is contained in:
Oleksandr Sobol 2020-02-20 23:02:41 +02:00
parent 91091a8d19
commit dde482c4f6
2 changed files with 25 additions and 21 deletions

View file

@ -13,34 +13,38 @@ String formatDomainName(String name) {
Future<Map<String, String>> fetchXmrAddressAndRecipientName(String name) async {
final map = {"recipient_address" : name, "recipient_name" : name};
await DnsUtils.lookupRecord(name, RRecordType.TXT, dnssec: true).then((txtRecord) {
if (txtRecord != null) {
String record;
try {
await DnsUtils.lookupRecord(name, RRecordType.TXT, dnssec: true).then((txtRecord) {
if (txtRecord != null) {
String record;
for (int i = 0; i < txtRecord.length; i++) {
record = txtRecord[i].data;
for (int i = 0; i < txtRecord.length; i++) {
record = txtRecord[i].data;
if (record.contains("oa1:xmr") && record.contains("recipient_address")) {
record = record.replaceAll('\"', "");
if (record.contains("oa1:xmr") && record.contains("recipient_address")) {
record = record.replaceAll('\"', "");
final dataList = record.split(";");
final dataList = record.split(";");
map["recipient_address"] = dataList.where((item) => (item.contains("recipient_address")))
.toString().replaceAll("oa1:xmr recipient_address=", "")
.replaceAll("(", "").replaceAll(")", "").trim();
final recipientName = dataList.where((item) => (item.contains("recipient_name"))).toString();
if (recipientName.isNotEmpty) {
map["recipient_name"] = recipientName.replaceAll("recipient_name=", "")
map["recipient_address"] = dataList.where((item) => (item.contains("recipient_address")))
.toString().replaceAll("oa1:xmr recipient_address=", "")
.replaceAll("(", "").replaceAll(")", "").trim();
}
break;
final recipientName = dataList.where((item) => (item.contains("recipient_name"))).toString();
if (recipientName.isNotEmpty) {
map["recipient_name"] = recipientName.replaceAll("recipient_name=", "")
.replaceAll("(", "").replaceAll(")", "").trim();
}
break;
}
}
}
}
});
});
} catch (e) {
print("${e.toString()}");
}
return map;
}

View file

@ -58,7 +58,7 @@ class SendFormState extends State<SendForm> {
@override
void initState() {
_focusNode.addListener(() async {
if (_addressController.text.isNotEmpty) {
if (!_focusNode.hasFocus &&_addressController.text.isNotEmpty) {
await fetchXmrAddressAndRecipientName(formatDomainName(_addressController.text)).then((map) async {
if (_addressController.text != map["recipient_address"]) {