replace ratom in quo wallet component (#19687)

This commit is contained in:
flexsurfer 2024-04-17 14:30:33 +02:00 committed by GitHub
parent 549efdb77c
commit 570c62e30e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 107 additions and 107 deletions

View File

@ -8,7 +8,6 @@
[quo.theme :as quo.theme]
[react-native.core :as rn]
[react-native.svg :as svg]
[reagent.core :as reagent]
[schema.core :as schema]))
(defn- circle
@ -36,38 +35,38 @@
:stroke-width "1"}]])
(defn link-linear
[]
(let [container-width (reagent/atom 100)]
(fn [{:keys [source theme]}]
(let [stroke-color (colors/resolve-color source theme)
fill-color (colors/theme-colors colors/white colors/neutral-90 theme)]
[{:keys [source theme]}]
(let [[container-width
set-container-width] (rn/use-state 100)
stroke-color (colors/resolve-color source theme)
fill-color (colors/theme-colors colors/white colors/neutral-90 theme)
on-layout (rn/use-callback #(set-container-width
(oget % :nativeEvent :layout :width)))]
[rn/view
{:style style/link-linear-container
:on-layout (fn [e]
(reset! container-width
(oget e :nativeEvent :layout :width)))}
[line stroke-color @container-width]
:on-layout on-layout}
[line stroke-color container-width]
[rn/view {:style style/left-circle-container}
[circle fill-color stroke-color]]
[rn/view {:style style/right-circle-container}
[circle fill-color stroke-color]]]))))
[circle fill-color stroke-color]]]))
(defn link-1x
[]
(let [container-width (reagent/atom 100)
stroke-color "url(#gradient)"]
(fn [{:keys [source destination theme]}]
(let [source-color (colors/resolve-color source theme)
[{:keys [source destination theme]}]
(let [[container-width
set-container-width] (rn/use-state 100)
stroke-color "url(#gradient)"
source-color (colors/resolve-color source theme)
destination-color (colors/resolve-color destination theme)
fill-color (colors/theme-colors colors/white colors/neutral-90 theme)
view-box (str "0 0 " @container-width " 58")
side-lines-path (helpers/calculate-side-lines-path-1x @container-width)
central-transform (helpers/calculate-transform @container-width)]
view-box (str "0 0 " container-width " 58")
side-lines-path (helpers/calculate-side-lines-path-1x container-width)
central-transform (helpers/calculate-transform container-width)
on-layout (rn/use-callback #(set-container-width
(oget % :nativeEvent :layout :width)))]
[rn/view
{:style style/link-1x-container
:on-layout (fn [e]
(reset! container-width
(oget e :nativeEvent :layout :width)))}
:on-layout on-layout}
[svg/svg
{:xmlns "http://www.w3.org/2000/svg"
:height "100%"
@ -98,23 +97,24 @@
[rn/view {:style style/bottom-left-circle-container}
[circle fill-color source-color]]
[rn/view {:style style/top-right-circle-container}
[circle fill-color destination-color]]]))))
[circle fill-color destination-color]]]))
(defn link-2x
[]
(let [container-width (reagent/atom 100)
stroke-color "url(#gradient)"]
(fn [{:keys [source destination theme]}]
(let [source-color (colors/resolve-color source theme)
[{:keys [source destination theme]}]
(let [[container-width
set-container-width] (rn/use-state 100)
stroke-color "url(#gradient)"
source-color (colors/resolve-color source theme)
destination-color (colors/resolve-color destination theme)
fill-color (colors/theme-colors colors/white colors/neutral-90 theme)
view-box (str "0 0 " @container-width " 114")
side-lines-path (helpers/calculate-side-lines-path-2x @container-width)
central-transform (helpers/calculate-transform @container-width)]
view-box (str "0 0 " container-width " 114")
side-lines-path (helpers/calculate-side-lines-path-2x container-width)
central-transform (helpers/calculate-transform container-width)
on-layout (rn/use-callback #(set-container-width
(oget % :nativeEvent :layout :width)))]
[rn/view
{:style style/link-2x-container
:on-layout #(reset! container-width
(oget % :nativeEvent :layout :width))}
:on-layout on-layout}
[svg/svg
{:xmlns "http://www.w3.org/2000/svg"
:height "100%"
@ -145,7 +145,7 @@
[rn/view {:style style/bottom-left-circle-container}
[circle fill-color source-color]]
[rn/view {:style style/top-right-circle-container}
[circle fill-color destination-color]]]))))
[circle fill-color destination-color]]]))
(defn- view-internal
[{:keys [shape container-style] :as props}]