Skip to content

Commit

Permalink
[#17288] refactor: migrate browser input previews to new api
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghafouri committed Sep 22, 2023
1 parent 7543dc9 commit 14b02c7
Showing 1 changed file with 19 additions and 46 deletions.
65 changes: 19 additions & 46 deletions src/status_im2/contexts/quo_preview/browser/browser_input.cljs
Original file line number Diff line number Diff line change
@@ -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))]])))

0 comments on commit 14b02c7

Please sign in to comment.