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

Oleksandr Sobol committed Feb 20, 2020 at 23:02 UTC dde482c4f6bee3cdf8e86f44551caec2e8920434
2 files changed +24 -20
lib/src/domain/common/openalias.dart
+23 -19
@@ -13,34 +13,38 @@ String formatDomainName(String name) {
13 Future<Map<String, String>> fetchXmrAddressAndRecipientName(String name) async {
14 final map = {"recipient_address" : name, "recipient_name" : name};
15
16 - await DnsUtils.lookupRecord(name, RRecordType.TXT, dnssec: true).then((txtRecord) {
17 - if (txtRecord != null) {
18 - String record;
16 + try {
17 + await DnsUtils.lookupRecord(name, RRecordType.TXT, dnssec: true).then((txtRecord) {
18 + if (txtRecord != null) {
19 + String record;
20
20 - for (int i = 0; i < txtRecord.length; i++) {
21 - record = txtRecord[i].data;
21 + for (int i = 0; i < txtRecord.length; i++) {
22 + record = txtRecord[i].data;
23
23 - if (record.contains("oa1:xmr") && record.contains("recipient_address")) {
24 - record = record.replaceAll('\"', "");
24 + if (record.contains("oa1:xmr") && record.contains("recipient_address")) {
25 + record = record.replaceAll('\"', "");
26
26 - final dataList = record.split(";");
27 + final dataList = record.split(";");
28
28 - map["recipient_address"] = dataList.where((item) => (item.contains("recipient_address")))
29 - .toString().replaceAll("oa1:xmr recipient_address=", "")
30 - .replaceAll("(", "").replaceAll(")", "").trim();
29 + map["recipient_address"] = dataList.where((item) => (item.contains("recipient_address")))
30 + .toString().replaceAll("oa1:xmr recipient_address=", "")
31 + .replaceAll("(", "").replaceAll(")", "").trim();
32
32 - final recipientName = dataList.where((item) => (item.contains("recipient_name"))).toString();
33 + final recipientName = dataList.where((item) => (item.contains("recipient_name"))).toString();
34
34 - if (recipientName.isNotEmpty) {
35 - map["recipient_name"] = recipientName.replaceAll("recipient_name=", "")
36 - .replaceAll("(", "").replaceAll(")", "").trim();
37 - }
35 + if (recipientName.isNotEmpty) {
36 + map["recipient_name"] = recipientName.replaceAll("recipient_name=", "")
37 + .replaceAll("(", "").replaceAll(")", "").trim();
38 + }
39
39 - break;
40 + break;
41 + }
42 }
43 }
42 - }
43 - });
44 + });
45 + } catch (e) {
46 + print("${e.toString()}");
47 + }
48
49 return map;
50 }
\ No newline at end of file
lib/src/screens/send/send_page.dart
+1 -1
@@ -58,7 +58,7 @@ class SendFormState extends State<SendForm> {
58 @override
59 void initState() {
60 _focusNode.addListener(() async {
61 - if (_addressController.text.isNotEmpty) {
61 + if (!_focusNode.hasFocus &&_addressController.text.isNotEmpty) {
62 await fetchXmrAddressAndRecipientName(formatDomainName(_addressController.text)).then((map) async {
63
64 if (_addressController.text != map["recipient_address"]) {