Wallet - Clear input on long press delete (#18732)

This commit allows clearing the amount input (in the send flow) by long-pressing the delete key.

---------

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
Mohamed Javid 2024-02-10 00:09:15 +05:30 committed by GitHub
parent 9dacc9e8af
commit d1f22cd2b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 81 additions and 78 deletions

View File

@ -7,7 +7,6 @@
[quo.components.tags.context-tag.view :as context-tag]
[quo.foundations.colors :as colors]
[quo.theme :as quo.theme]
[react-native.blur :as blur]
[react-native.core :as rn]
[schema.core :as schema]
[utils.i18n :as i18n]))
@ -41,14 +40,6 @@
(defn- view-internal
[{:keys [actions description description-text error-message role button-one-label button-two-label
blur? button-one-props button-two-props theme scroll? container-style]}]
[blur/view
{:blur-amount 20
:blur-type :transparent
:overlay-color (if blur?
colors/neutral-80-opa-1-blur
(colors/theme-colors colors/white-70-blur
colors/neutral-95-opa-70-blur
theme))}
[rn/view
{:style (merge (style/container scroll? blur? theme) container-style)}
(when (= description :top-error)
@ -99,7 +90,7 @@
(when (= description :bottom)
[text/text
{:size :paragraph-2
:style (style/description-bottom scroll? blur? theme)} description-text])]])
:style (style/description-bottom scroll? blur? theme)} description-text])])
(def view
(quo.theme/with-theme

View File

@ -15,7 +15,7 @@
(defn- view-internal
[]
(let [pressed? (reagent/atom false)]
(fn [{:keys [disabled? theme blur? on-press type]} label]
(fn [{:keys [disabled? theme blur? on-press on-long-press type]} label]
(let [label-color (style/get-label-color disabled? theme blur?)
background-color (style/toggle-background-color @pressed? blur? theme)]
[rn/pressable
@ -24,6 +24,9 @@
:on-press (fn []
(when on-press
(on-press label)))
:on-long-press (fn []
(when (fn? on-long-press)
(on-long-press label)))
:allow-multiple-presses? true
:on-press-in #(reset! pressed? true)
:on-press-out #(reset! pressed? false)

View File

@ -6,10 +6,11 @@
[react-native.core :as rn]))
(defn keyboard-item
[{:keys [item type disabled? on-press blur? theme]}]
[{:keys [item type disabled? on-press on-long-press blur? theme]}]
[keyboard-key/view
{:disabled? disabled?
:on-press on-press
:on-long-press on-long-press
:blur? blur?
:theme theme
:type type}
@ -17,7 +18,7 @@
(defn- view-internal
[]
(fn [{:keys [disabled? theme blur? left-action delete-key? on-press on-delete
(fn [{:keys [disabled? theme blur? left-action delete-key? on-press on-delete on-long-press-delete
container-style]
:or {left-action :none}}]
[rn/view
@ -66,6 +67,7 @@
:type :key
:disabled? disabled?
:on-press on-delete
:on-long-press on-long-press-delete
:blur? blur?
:theme theme}]
[keyboard-item])]]))

View File

@ -1,6 +1,6 @@
(ns status-im.contexts.communities.actions.addresses-for-permissions.events-test
(:require
[cljs.test :refer [is deftest]]
[cljs.test :refer [deftest is]]
[status-im.contexts.communities.actions.addresses-for-permissions.events :as sut]))
(def community-id "0x1")

View File

@ -155,6 +155,12 @@
(swap! input-value delete-from-string start)
(move-input-cursor input-selection (dec start)))
(reagent/flush))))
on-long-press-delete (fn [loading-routes?]
(when-not loading-routes?
(reset! input-value "")
(reset! input-error false)
(move-input-cursor input-selection 0)
(reagent/flush)))
handle-on-change (fn [v current-limit-amount]
(when (valid-input? @input-value v)
(let [num-value (or (parse-double v) 0)]
@ -291,7 +297,8 @@
:left-action :dot
:delete-key? true
:on-press #(handle-keyboard-press % loading-routes? current-limit)
:on-delete #(handle-delete loading-routes? current-limit)}]]))))
:on-delete #(handle-delete loading-routes? current-limit)
:on-long-press-delete #(on-long-press-delete loading-routes?)}]]))))
(defn- view-internal
[props]