From 81510041d071ba2c1e80cb65bf54f5d3dc863809 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Wed, 20 Sep 2023 11:57:23 +0300 Subject: [PATCH] [#17288] refactor: migrate browser input previews to new api --- .../quo_preview/browser/browser_input.cljs | 65 ++++++------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/src/status_im2/contexts/quo_preview/browser/browser_input.cljs b/src/status_im2/contexts/quo_preview/browser/browser_input.cljs index b760b5951d8..6d0a370e78c 100644 --- a/src/status_im2/contexts/quo_preview/browser/browser_input.cljs +++ b/src/status_im2/contexts/quo_preview/browser/browser_input.cljs @@ -1,55 +1,28 @@ (ns status-im2.contexts.quo-preview.browser.browser-input (:require [quo2.core :as quo] - [react-native.core :as rn] - [react-native.safe-area :as safe-area] [reagent.core :as reagent] - [utils.re-frame :as rf] [status-im2.contexts.quo-preview.preview :as preview])) (def descriptor - [{:label "Show Favicon" - :key :favicon? - :type :boolean} - {:label "Locked" - :key :locked? - :type :boolean} - {:label "Disabled" - :key :disabled? - :type :boolean}]) + [{:key :favicon? :type :boolean} + {:key :locked? :type :boolean} + {:key :blur? :type :boolean} + {:key :placeholder :type :text} + {:key :disabled? :type :boolean} + (preview/customization-color-option)]) (defn preview-browser-input [] - (reagent/with-let [keyboard-shown? (reagent/atom false) - keyboard-show-listener (.addListener rn/keyboard - "keyboardWillShow" - #(reset! keyboard-shown? true)) - keyboard-hide-listener (.addListener rn/keyboard - "keyboardWillHide" - #(reset! keyboard-shown? false)) - {:keys [bottom]} (safe-area/get-insets) - state (reagent/atom {:blur? false - :disabled? false - :favicon? false - :placeholder "Search or enter dapp domain" - :locked? false})] - [preview/preview-container - {:state state - :descriptor descriptor} - [quo/page-nav - {:type :no-title - :icon-name :i/arrow-left - :on-press #(rf/dispatch [:navigate-back])}] - - [rn/flat-list - {:key-fn str - :keyboard-should-persist-taps :always - :style {:flex 1}}] - [rn/view - [quo/browser-input - (assoc @state - :customization-color :blue - :favicon (when (:favicon? @state) :i/verified))] - [rn/view {:style {:height (if-not @keyboard-shown? bottom 0)}}]]] - (finally - (.remove keyboard-show-listener) - (.remove keyboard-hide-listener)))) + (let [state (reagent/atom {:blur? false + :disabled? false + :favicon? false + :placeholder "Search or enter dapp domain" + :locked? false})] + (fn [] + [preview/preview-container + {:state state + :descriptor descriptor} + [quo/browser-input + (assoc @state + :favicon + (when (:favicon? @state) :i/verified))]])))