Reagent atom from theme regression #19729 (#19735)

This commit is contained in:
flexsurfer 2024-04-24 15:05:53 +02:00 committed by GitHub
parent 9db49b8ca0
commit 3794742c8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 214 additions and 218 deletions

View File

@ -59,7 +59,7 @@
:selected-storage-type :default :selected-storage-type :default
:selected-id (-> result first :id) :selected-id (-> result first :id)
:step :choose-key)))) :step :choose-key))))
:navigate-to :choose-name}) :navigate-to [:choose-name (:theme db)]})
(rf/defn generate-and-derive-addresses (rf/defn generate-and-derive-addresses
{:events [:generate-and-derive-addresses]} {:events [:generate-and-derive-addresses]}

View File

@ -12,8 +12,8 @@
container-style)) container-style))
(defn input (defn input
[] [theme]
(assoc (text/text-style {} nil) (assoc (text/text-style {} theme)
:height 32 :height 32
:flex-grow 1 :flex-grow 1
:padding-vertical 5 :padding-vertical 5

View File

@ -61,7 +61,7 @@
[rn/view {:style (style/container container-style)} [rn/view {:style (style/container container-style)}
[rn/text-input [rn/text-input
(merge {:accessibility-label :recovery-phrase-input (merge {:accessibility-label :recovery-phrase-input
:style (style/input) :style (style/input theme)
:placeholder-text-color (style/placeholder-color state theme blur?) :placeholder-text-color (style/placeholder-color state theme blur?)
:cursor-color (style/cursor-color customization-color theme) :cursor-color (style/cursor-color customization-color theme)
:keyboard-appearance theme :keyboard-appearance theme

View File

@ -63,7 +63,8 @@
(defn notification (defn notification
[{title-text :title :keys [avatar user header title-weight text body container-style theme]}] [{title-text :title :keys [avatar user header title-weight text body container-style theme]}]
(let [theme theme (let [context-theme (quo.theme/use-theme)
theme (or theme context-theme)
body (or body (when text [message text theme])) body (or body (when text [message text theme]))
header (or header header (or header
(when title-text (when title-text

View File

@ -72,7 +72,8 @@
" "
[{:keys [type icon title text action undo-duration undo-on-press container-style theme user] [{:keys [type icon title text action undo-duration undo-on-press container-style theme user]
:or {type :neutral icon :i/placeholder}}] :or {type :neutral icon :i/placeholder}}]
(let [context-theme theme (let [context-theme (quo.theme/use-theme)
context-theme (or theme context-theme)
icon-name (case type icon-name (case type
:positive (if (= theme :light) :positive (if (= theme :light)
:i/correct :i/correct

View File

@ -16,7 +16,8 @@
[schema.core :as schema])) [schema.core :as schema]))
(defn- tag-skeleton (defn- tag-skeleton
[{:keys [theme size text] :or {size 24}} logo-component] [{:keys [size text] :or {size 24}} logo-component]
(let [theme (quo.theme/use-theme)]
[rn/view {:style (style/tag-container size)} [rn/view {:style (style/tag-container size)}
logo-component logo-component
[rn/view {:style (style/tag-spacing size)} [rn/view {:style (style/tag-spacing size)}
@ -24,11 +25,12 @@
{:style (style/text theme) {:style (style/text theme)
:weight :medium :weight :medium
:size (if (= size 24) :paragraph-2 :paragraph-1)} :size (if (= size 24) :paragraph-2 :paragraph-1)}
text]]]) text]]]))
(defn- communities-tag (defn- communities-tag
[{:keys [theme size community-logo community-name blur? channel? channel-name]}] [{:keys [size community-logo community-name blur? channel? channel-name]}]
(let [text-size (if (= size 24) :paragraph-2 :paragraph-1) (let [theme (quo.theme/use-theme)
text-size (if (= size 24) :paragraph-2 :paragraph-1)
icon-size (if (= size 24) 16 20)] icon-size (if (= size 24) 16 20)]
[rn/view {:style (style/tag-container size)} [rn/view {:style (style/tag-container size)}
[fast-image/fast-image {:style (style/circle-logo size) :source community-logo}] [fast-image/fast-image {:style (style/circle-logo size) :source community-logo}]
@ -54,16 +56,18 @@
(str (subs pk 0 5) "..." (subs pk (- (count pk) 3)))) (str (subs pk 0 5) "..." (subs pk (- (count pk) 3))))
(defn- address-tag (defn- address-tag
[{:keys [theme size address]}] [{:keys [size address]}]
(let [theme (quo.theme/use-theme)]
[rn/view {:style (style/address size)} [rn/view {:style (style/address size)}
[text/text [text/text
{:style (style/text theme) {:style (style/text theme)
:weight :monospace ;; TODO: fix this style (issue #17009) :weight :monospace ;; TODO: fix this style (issue #17009)
:size (if (= size 24) :paragraph-2 :paragraph-1)} :size (if (= size 24) :paragraph-2 :paragraph-1)}
(trim-public-key address)]]) (trim-public-key address)]]))
(defn- icon-tag (defn- icon-tag
[{:keys [theme size icon blur? context]}] [{:keys [size icon blur? context]}]
(let [theme (quo.theme/use-theme)]
[rn/view {:style (style/icon size)} [rn/view {:style (style/icon size)}
[icons/icon icon [icons/icon icon
{:color (style/context-tag-icon-color theme blur?) {:color (style/context-tag-icon-color theme blur?)
@ -73,7 +77,7 @@
{:style (style/text theme) {:style (style/text theme)
:weight :medium :weight :medium
:size (if (= size 24) :paragraph-2 :paragraph-1)} :size (if (= size 24) :paragraph-2 :paragraph-1)}
context]]]) context]]]))
(defn- view-internal (defn- view-internal
[{:keys [type size state blur? customization-color profile-picture full-name users [{:keys [type size state blur? customization-color profile-picture full-name users

View File

@ -92,9 +92,9 @@
(oops/oget "nativeEvent.selection") (oops/oget "nativeEvent.selection")
(js->clj :keywordize-keys true) (js->clj :keywordize-keys true)
(on-selection-change))))] (on-selection-change))))]
(fn [{:keys [theme token customization-color show-keyboard? crypto? currency value error? (fn [{:keys [token customization-color show-keyboard? crypto? currency value error? selection]
selection]
:or {show-keyboard? true}}] :or {show-keyboard? true}}]
(let [theme (quo.theme/use-theme)]
[rn/view {:style {:flex 1}} [rn/view {:style {:flex 1}}
[rn/pressable {:on-press on-token-press} [rn/pressable {:on-press on-token-press}
[token/view [token/view
@ -121,7 +121,7 @@
[token-label [token-label
{:theme theme {:theme theme
:text (if crypto? token currency) :text (if crypto? token currency)
:value (if controlled-input? value value-internal)}]]))) :value (if controlled-input? value value-internal)}]]))))
(defn- view-internal (defn- view-internal
[{:keys [container-style value on-swap] :as props}] [{:keys [container-style value on-swap] :as props}]

View File

@ -66,7 +66,8 @@
(defn- view-info-bottom (defn- view-info-bottom
[{:keys [state time-frame metrics date begin-date end-date [{:keys [state time-frame metrics date begin-date end-date
currency-change percentage-change theme]}] currency-change percentage-change]}]
(let [theme (quo.theme/use-theme)]
[rn/view {:style style/container-info-bottom} [rn/view {:style style/container-info-bottom}
(when (= state :loading) (when (= state :loading)
[rn/view [rn/view
@ -111,7 +112,7 @@
{:metrics metrics {:metrics metrics
:currency-change currency-change :currency-change currency-change
:percentage-change percentage-change :percentage-change percentage-change
:theme theme}])])]) :theme theme}])])]))
(defn- view-internal (defn- view-internal
[props] [props]

View File

@ -94,8 +94,9 @@
:container-style style/empty-results}]) :container-style style/empty-results}])
(defn- render-list (defn- render-list
[{:keys [theme filtered-data on-viewable-items-changed scroll-enabled? on-scroll [{:keys [filtered-data on-viewable-items-changed scroll-enabled? on-scroll
on-select set-scroll-ref close sheet-animating?]}] on-select set-scroll-ref close sheet-animating?]}]
(let [theme (quo.theme/use-theme)]
[gesture/flat-list [gesture/flat-list
{:ref set-scroll-ref {:ref set-scroll-ref
:scroll-enabled @scroll-enabled? :scroll-enabled @scroll-enabled?
@ -117,7 +118,7 @@
:viewability-config {:item-visible-percent-threshold 100 :viewability-config {:item-visible-percent-threshold 100
:minimum-view-time 200} :minimum-view-time 200}
:on-viewable-items-changed on-viewable-items-changed :on-viewable-items-changed on-viewable-items-changed
:window-size (if @sheet-animating? 1 10)}]) :window-size (if @sheet-animating? 1 10)}]))
(defn- footer (defn- footer
[{:keys [active-category scroll-ref]}] [{:keys [active-category scroll-ref]}]

View File

@ -101,10 +101,11 @@
(defn scroll-page (defn scroll-page
[_ _ _] [_ _ _]
(let [scroll-height (reagent/atom negative-scroll-position-0)] (let [scroll-height (reagent/atom negative-scroll-position-0)]
(fn [{:keys [theme cover-image cover-color logo on-scroll (fn [{:keys [cover-image cover-color logo on-scroll
collapsed? height top-nav title-colum background-color navigate-back? page-nav-props collapsed? height top-nav title-colum background-color navigate-back? page-nav-props
overlay-shown? sticky-header children-style]} overlay-shown? sticky-header children-style]}
children] children]
(let [theme (quo.theme/use-theme)]
[:<> [:<>
[:f> f-scroll-page-header [:f> f-scroll-page-header
{:scroll-height @scroll-height {:scroll-height @scroll-height
@ -141,10 +142,11 @@
:flex 1}}]]) :flex 1}}]])
(when children (when children
[rn/view [rn/view
{:style (style/children-container (merge {:style (style/children-container
(merge
children-style children-style
{:border-radius (diff-with-max-min @scroll-height 16 0) {:border-radius (diff-with-max-min @scroll-height 16 0)
:background-color background-color}))} :background-color background-color}))}
(when (and (not collapsed?) cover-image) (when (and (not collapsed?) cover-image)
[:f> f-display-picture @scroll-height logo theme]) [:f> f-display-picture @scroll-height logo theme])
children])]]))) children])]]))))

View File

@ -209,8 +209,7 @@
featured-communities-count (count featured-communities)] featured-communities-count (count featured-communities)]
(fn [] (fn []
[scroll-page/scroll-page [scroll-page/scroll-page
{:theme theme {:on-scroll #(reset! scroll-height %)
:on-scroll #(reset! scroll-height %)
:page-nav-props {:background :blur} :page-nav-props {:background :blur}
:navigate-back? :true :navigate-back? :true
:height (if (> @scroll-height 360) :height (if (> @scroll-height 360)

View File

@ -147,7 +147,7 @@
(:current-chat-id db)) (:current-chat-id db))
(conj [:chat/close]))}) (conj [:chat/close]))})
{:db (assoc db :view-id go-to-view-id) {:db (assoc db :view-id go-to-view-id)
:navigate-to go-to-view-id})) :navigate-to [go-to-view-id (:theme db)]}))
(rf/defn shell-navigate-back (rf/defn shell-navigate-back
{:events [:shell/navigate-back]} {:events [:shell/navigate-back]}

View File

@ -54,10 +54,10 @@
(reset! state/modals (vec (butlast @state/modals))) (reset! state/modals (vec (butlast @state/modals)))
(reset! state/modals [])) (reset! state/modals []))
(let [component @state/dissmissing] (let [dissmissing @state/dissmissing]
(reset! state/dissmissing false) (reset! state/dissmissing false)
(when (keyword? component) (when (vector? dissmissing)
(effects/open-modal component))))) (effects/open-modal dissmissing)))))
;;;; Toast ;;;; Toast

View File

@ -86,14 +86,14 @@
;;;; Navigate to ;;;; Navigate to
(defn- navigate (defn- navigate
[component] [[component theme]]
(let [{:keys [options]} (get views/screens component)] (let [{:keys [options]} (get views/screens component)]
(dismiss-all-modals) (dismiss-all-modals)
(navigation/push (navigation/push
(name @state/root-id) (name @state/root-id)
{:component {:id component {:component {:id component
:name component :name component
:options (merge (options/root-options {:theme (:theme options)}) :options (merge (options/root-options {:theme (or (:theme options) theme)})
options)}}) options)}})
(state/navigation-state-push {:id component (state/navigation-state-push {:id component
:type :stack :type :stack
@ -139,11 +139,6 @@
(rf/reg-fx :navigate-back navigate-back) (rf/reg-fx :navigate-back navigate-back)
(rf/reg-fx :navigate-replace-fx
(fn [view-id]
(navigate-back)
(navigate view-id)))
(rf/reg-fx :navigate-back-to (rf/reg-fx :navigate-back-to
(fn [comp-id] (fn [comp-id]
(navigation/pop-to (name comp-id)) (navigation/pop-to (name comp-id))
@ -164,18 +159,19 @@
;;;; Modal ;;;; Modal
(defn open-modal (defn open-modal
[component] [[component theme]]
(let [{:keys [options]} (get views/screens component) (let [{:keys [options]} (get views/screens component)
sheet? (:sheet? options)] sheet? (:sheet? options)]
(if @state/dissmissing (if @state/dissmissing
(reset! state/dissmissing component) (reset! state/dissmissing [component theme])
(do (do
(swap! state/modals conj component) (swap! state/modals conj component)
(navigation/show-modal (navigation/show-modal
{:stack {:children [{:component {:stack {:children [{:component
{:name component {:name component
:id component :id component
:options (merge (options/root-options {:theme (:theme options)}) :options (merge (options/root-options {:theme (or (:theme options)
theme)})
options options
(when sheet? (when sheet?
options/sheet-options))}}]}}))) options/sheet-options))}}]}})))

View File

@ -37,7 +37,7 @@
(all-screens-params component screen-params)) (all-screens-params component screen-params))
:fx [[:dispatch [:hide-bottom-sheet]] :fx [[:dispatch [:hide-bottom-sheet]]
[:dispatch [:dismiss-keyboard]] [:dispatch [:dismiss-keyboard]]
[:open-modal-fx component]]})) [:open-modal-fx [component (:theme db)]]]}))
(rf/defn dismiss-modal (rf/defn dismiss-modal
{:events [:dismiss-modal]} {:events [:dismiss-modal]}
@ -80,15 +80,6 @@
{:db (assoc db :view-id stack-id) {:db (assoc db :view-id stack-id)
:effects.shell/change-tab stack-id}) :effects.shell/change-tab stack-id})
(rf/defn navigate-replace
{:events [:navigate-replace]}
[{:keys [db]} go-to-view-id screen-params]
(let [db (cond-> (assoc db :view-id go-to-view-id)
(seq screen-params)
(assoc-in [:navigation/screen-params go-to-view-id] screen-params))]
{:db db
:navigate-replace-fx go-to-view-id}))
(rf/defn hide-bottom-sheet (rf/defn hide-bottom-sheet
{:events [:hide-bottom-sheet]} {:events [:hide-bottom-sheet]}
[{:keys [db]}] [{:keys [db]}]