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.components.tags.context-tag.view :as context-tag]
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[quo.theme :as quo.theme] [quo.theme :as quo.theme]
[react-native.blur :as blur]
[react-native.core :as rn] [react-native.core :as rn]
[schema.core :as schema] [schema.core :as schema]
[utils.i18n :as i18n])) [utils.i18n :as i18n]))
@ -41,14 +40,6 @@
(defn- view-internal (defn- view-internal
[{:keys [actions description description-text error-message role button-one-label button-two-label [{: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? 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 [rn/view
{:style (merge (style/container scroll? blur? theme) container-style)} {:style (merge (style/container scroll? blur? theme) container-style)}
(when (= description :top-error) (when (= description :top-error)
@ -99,7 +90,7 @@
(when (= description :bottom) (when (= description :bottom)
[text/text [text/text
{:size :paragraph-2 {:size :paragraph-2
:style (style/description-bottom scroll? blur? theme)} description-text])]]) :style (style/description-bottom scroll? blur? theme)} description-text])])
(def view (def view
(quo.theme/with-theme (quo.theme/with-theme

View File

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

View File

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

View File

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

View File

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