Wallet: Emoji picker performance (#17891)
Wallet: Emoji picker navigation perf
This commit is contained in:
parent
e6a7c420a2
commit
a2856cf1c3
|
@ -151,6 +151,34 @@
|
||||||
(reset! filtered-data nil)
|
(reset! filtered-data nil)
|
||||||
(reset! search-text ""))
|
(reset! search-text ""))
|
||||||
|
|
||||||
|
(defn f-view
|
||||||
|
[{:keys [render-emojis? search-text on-change-text clear-states active-category scroll-ref theme]
|
||||||
|
:as sheet-opts}]
|
||||||
|
(let [search-active? (pos? (count @search-text))]
|
||||||
|
;; rendering emojis is heavy on the UI thread, we need to delay rendering until the navigation
|
||||||
|
;; animation completes. 250 is based on the default 300ms navigation duration.
|
||||||
|
(rn/use-effect #(js/setTimeout (fn [] (reset! render-emojis? true)) 250))
|
||||||
|
[rn/keyboard-avoiding-view
|
||||||
|
{:style style/flex-spacer
|
||||||
|
:keyboard-vertical-offset 8}
|
||||||
|
[rn/view {:style style/flex-spacer}
|
||||||
|
[rn/view {:style style/search-input-container}
|
||||||
|
[quo/input
|
||||||
|
{:small? true
|
||||||
|
:placeholder (i18n/label :t/emoji-search-placeholder)
|
||||||
|
:icon-name :i/search
|
||||||
|
:value @search-text
|
||||||
|
:on-change-text on-change-text
|
||||||
|
:clearable? search-active?
|
||||||
|
:on-clear clear-states}]]
|
||||||
|
(when @render-emojis?
|
||||||
|
[render-list sheet-opts])
|
||||||
|
(when-not search-active?
|
||||||
|
[footer
|
||||||
|
{:theme theme
|
||||||
|
:active-category active-category
|
||||||
|
:scroll-ref scroll-ref}])]]))
|
||||||
|
|
||||||
(defn- view-internal
|
(defn- view-internal
|
||||||
[_]
|
[_]
|
||||||
(let [{:keys [on-select]} (rf/sub [:get-screen-params])
|
(let [{:keys [on-select]} (rf/sub [:get-screen-params])
|
||||||
|
@ -158,6 +186,7 @@
|
||||||
set-scroll-ref #(reset! scroll-ref %)
|
set-scroll-ref #(reset! scroll-ref %)
|
||||||
search-text (reagent/atom "")
|
search-text (reagent/atom "")
|
||||||
filtered-data (reagent/atom nil)
|
filtered-data (reagent/atom nil)
|
||||||
|
render-emojis? (reagent/atom false)
|
||||||
active-category (reagent/atom constants/default-category)
|
active-category (reagent/atom constants/default-category)
|
||||||
clear-states #(clear {:active-category active-category
|
clear-states #(clear {:active-category active-category
|
||||||
:filtered-data filtered-data
|
:filtered-data filtered-data
|
||||||
|
@ -179,31 +208,19 @@
|
||||||
{:event event
|
{:event event
|
||||||
:active-category active-category
|
:active-category active-category
|
||||||
:should-update-active-category? (nil? @filtered-data)}))]
|
:should-update-active-category? (nil? @filtered-data)}))]
|
||||||
(fn [{:keys [theme] :as sheet-opts}]
|
(fn [sheet-opts]
|
||||||
(let [search-active? (pos? (count @search-text))]
|
[:f> f-view
|
||||||
[rn/keyboard-avoiding-view
|
(merge sheet-opts
|
||||||
{:style style/flex-spacer
|
{:render-emojis? render-emojis?
|
||||||
:keyboard-vertical-offset 8}
|
:search-text search-text
|
||||||
[rn/view {:style style/flex-spacer}
|
:on-change-text on-change-text
|
||||||
[rn/view {:style style/search-input-container}
|
:clear-states clear-states
|
||||||
[quo/input
|
:filtered-data @filtered-data
|
||||||
{:small? true
|
:set-scroll-ref set-scroll-ref
|
||||||
:placeholder (i18n/label :t/emoji-search-placeholder)
|
:on-select on-select
|
||||||
:icon-name :i/search
|
:on-viewable-items-changed on-viewable-items-changed
|
||||||
:value @search-text
|
:active-category active-category
|
||||||
:on-change-text on-change-text
|
:scroll-ref scroll-ref})])))
|
||||||
:clearable? search-active?
|
|
||||||
:on-clear clear-states}]]
|
|
||||||
[render-list
|
|
||||||
(merge {:filtered-data @filtered-data
|
|
||||||
:set-scroll-ref set-scroll-ref
|
|
||||||
:on-select on-select
|
|
||||||
:on-viewable-items-changed on-viewable-items-changed}
|
|
||||||
sheet-opts)]
|
|
||||||
(when-not search-active?
|
|
||||||
[footer
|
|
||||||
{:theme theme
|
|
||||||
:active-category active-category
|
|
||||||
:scroll-ref scroll-ref}])]]))))
|
|
||||||
|
|
||||||
(def view (quo.theme/with-theme view-internal))
|
(def view (quo.theme/with-theme view-internal))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue