Skip to content

Commit

Permalink
Move atoms to use-ref-atom
Browse files Browse the repository at this point in the history
  • Loading branch information
ulisesmac committed May 14, 2024
1 parent fdc08d1 commit 8f79a3f
Showing 1 changed file with 37 additions and 39 deletions.
76 changes: 37 additions & 39 deletions src/status_im/contexts/wallet/collectible/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@
[_]
(let [selected-tab (reagent/atom :overview)
on-tab-change #(reset! selected-tab %)]
(fn [{:keys [collectible set-title-ref set-title-bottom title-ref theme]}]
(let [animation-shared-element-id (rf/sub [:animation-shared-element-id])
(fn [{:keys [collectible set-title-bottom theme]}]
(let [title-ref (rn/use-ref-atom nil)
set-title-ref (rn/use-callback #(reset! title-ref %))
animation-shared-element-id (rf/sub [:animation-shared-element-id])
collectible-owner (rf/sub [:wallet/last-collectible-details-owner])
{:keys [id
preview-url
Expand Down Expand Up @@ -215,42 +217,38 @@

(defn view
[_]
(let [title-ref (atom nil)
set-title-ref #(reset! title-ref %)
title-bottom-coord (atom 0)
{:keys [top]} (safe-area/get-insets)
set-title-bottom (fn [_ y _ height]
(reset! title-bottom-coord
(+ y height -100 (if platform/ios? (- top) top))))]
(fn []
(let [theme (quo.theme/use-theme)
scroll-amount (reanimated/use-shared-value 0)
title-opacity (reanimated/use-shared-value 0)
collectible (rf/sub [:wallet/last-collectible-details])
{:keys [preview-url
collection-data
collectible-data]} collectible
{preview-uri :uri} preview-url
{collectible-name :name} collectible-data
{collection-name :name} collection-data]
(let [{:keys [top]} (safe-area/get-insets)
theme (quo.theme/use-theme)
title-bottom-coord (rn/use-ref-atom 0)
set-title-bottom (rn/use-callback
(fn [_ y _ height]
(reset! title-bottom-coord
(+ y height -100 (if platform/ios? (- top) top)))))
scroll-amount (reanimated/use-shared-value 0)
title-opacity (reanimated/use-shared-value 0)
collectible (rf/sub [:wallet/last-collectible-details])
{:keys [preview-url
collection-data
collectible-data]} collectible
{preview-uri :uri} preview-url
{collectible-name :name} collectible-data
{collection-name :name} collection-data]

(rn/use-unmount #(rf/dispatch [:wallet/clear-last-collectible-details]))
(rn/use-unmount #(rf/dispatch [:wallet/clear-last-collectible-details]))

[rn/view {:style (style/background-color theme)}
[animated-header
{:scroll-amount scroll-amount
:title-opacity title-opacity
:page-nav-type :title-description
:picture preview-uri
:title collectible-name
:description collection-name
:theme theme}]
[reanimated/scroll-view
{:style (style/scroll-view top)
:on-scroll #(on-scroll % scroll-amount title-opacity title-bottom-coord)}
[collectible-details
{:collectible collectible
:set-title-ref set-title-ref
:set-title-bottom set-title-bottom
:theme theme
:title-ref title-ref}]]]))))
[rn/view {:style (style/background-color theme)}
[animated-header
{:scroll-amount scroll-amount
:title-opacity title-opacity
:page-nav-type :title-description
:picture preview-uri
:title collectible-name
:description collection-name
:theme theme}]
[reanimated/scroll-view
{:style (style/scroll-view top)
:on-scroll #(on-scroll % scroll-amount title-opacity title-bottom-coord)}
[collectible-details
{:collectible collectible
:set-title-bottom set-title-bottom
:theme theme}]]]))

0 comments on commit 8f79a3f

Please sign in to comment.