-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#17288] refactor: migrate browser input previews to new api
- Loading branch information
1 parent
db41eb3
commit 8151004
Showing
1 changed file
with
19 additions
and
46 deletions.
There are no files selected for viewing
65 changes: 19 additions & 46 deletions
65
src/status_im2/contexts/quo_preview/browser/browser_input.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))]]))) |