From 047810841250006aecce91fb00ec62ea3bcc1ef3 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 6 Mar 2023 17:21:05 -0600 Subject: [PATCH] mobile: listen to text field change, strip http/s:// if contains @ --- lib/pages/send_view/send_view.dart | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index fb05f3a38..a028b2c6c 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -580,6 +580,21 @@ class _SendViewState extends ConsumerState { }); } + if (coin == Coin.epicCash) { + sendToController.addListener(() { + _address = sendToController.text; + + if (_address != null && _address!.isNotEmpty) { + _address = _address!.trim(); + if (_address!.contains("\n")) { + _address = _address!.substring(0, _address!.indexOf("\n")); + } + + sendToController.text = httpXOREpicBox(_address!); + } + }); + } + return Background( child: Scaffold( backgroundColor: Theme.of(context).extension()!.background, @@ -904,6 +919,13 @@ class _SendViewState extends ConsumerState { "\n")); } + if (coin == + Coin.epicCash) { + // strip http:// and https:// if content contains @ + content = + httpXOREpicBox( + content); + } sendToController.text = content; _address = content; @@ -1754,3 +1776,14 @@ class _SendViewState extends ConsumerState { ); } } + +// strip http:// and https:// if epicAddress contains @ +String httpXOREpicBox(String epicAddress) { + if ((epicAddress.startsWith("http://") || + epicAddress.startsWith("https://")) && + epicAddress.contains("@")) { + epicAddress = epicAddress.replaceAll("http://", ""); + epicAddress = epicAddress.replaceAll("https://", ""); + } + return epicAddress; +}