parent
5d1e1f8005
commit
62f68ff44b
|
@ -14,13 +14,12 @@
|
||||||
[react-native.reanimated :as reanimated]))
|
[react-native.reanimated :as reanimated]))
|
||||||
|
|
||||||
(defn drag-gesture
|
(defn drag-gesture
|
||||||
[x-pos gestures-disabled? set-gestures-disabled disabled? track-width sliding-complete?
|
[x-pos disabled? track-width sliding-complete?
|
||||||
set-sliding-complete
|
set-sliding-complete
|
||||||
on-complete reset-fn]
|
on-complete reset-fn]
|
||||||
(let [gestures-enabled? (not (or disabled? gestures-disabled?))]
|
|
||||||
(-> (gesture/gesture-pan)
|
(-> (gesture/gesture-pan)
|
||||||
(gesture/with-test-ID :slide-button-gestures)
|
(gesture/with-test-ID :slide-button-gestures)
|
||||||
(gesture/enabled gestures-enabled?)
|
(gesture/enabled (not disabled?))
|
||||||
(gesture/min-distance 0)
|
(gesture/min-distance 0)
|
||||||
(gesture/on-update (fn [event]
|
(gesture/on-update (fn [event]
|
||||||
(let [x-translation (oops/oget event "translationX")
|
(let [x-translation (oops/oget event "translationX")
|
||||||
|
@ -28,14 +27,13 @@
|
||||||
reached-end? (>= clamped-x track-width)]
|
reached-end? (>= clamped-x track-width)]
|
||||||
(reanimated/set-shared-value x-pos clamped-x)
|
(reanimated/set-shared-value x-pos clamped-x)
|
||||||
(when (and reached-end? (not sliding-complete?))
|
(when (and reached-end? (not sliding-complete?))
|
||||||
(set-gestures-disabled true)
|
|
||||||
(set-sliding-complete true)
|
(set-sliding-complete true)
|
||||||
(when on-complete (on-complete reset-fn))))))
|
(when on-complete (on-complete reset-fn))))))
|
||||||
(gesture/on-end (fn [event]
|
(gesture/on-end (fn [event]
|
||||||
(let [x-translation (oops/oget event "translationX")
|
(let [x-translation (oops/oget event "translationX")
|
||||||
reached-end? (>= x-translation track-width)]
|
reached-end? (>= x-translation track-width)]
|
||||||
(when (not reached-end?)
|
(when (not reached-end?)
|
||||||
(animations/reset-track-position x-pos))))))))
|
(animations/reset-track-position x-pos)))))))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
"Options
|
"Options
|
||||||
|
@ -55,14 +53,11 @@
|
||||||
[track-width set-track-width] (rn/use-state nil)
|
[track-width set-track-width] (rn/use-state nil)
|
||||||
[sliding-complete?
|
[sliding-complete?
|
||||||
set-sliding-complete] (rn/use-state false)
|
set-sliding-complete] (rn/use-state false)
|
||||||
[gestures-disabled?
|
|
||||||
set-gestures-disabled] (rn/use-state disabled?)
|
|
||||||
on-track-layout (rn/use-callback
|
on-track-layout (rn/use-callback
|
||||||
#(set-track-width (oops/oget % "nativeEvent.layout.width")))
|
#(set-track-width (oops/oget % "nativeEvent.layout.width")))
|
||||||
reset-fn (rn/use-callback
|
reset-fn (rn/use-callback
|
||||||
(fn []
|
(fn []
|
||||||
(set-sliding-complete false)
|
(set-sliding-complete false)
|
||||||
(set-gestures-disabled false)
|
|
||||||
(animations/reset-track-position x-pos)))
|
(animations/reset-track-position x-pos)))
|
||||||
dimensions (rn/use-callback
|
dimensions (rn/use-callback
|
||||||
(partial utils/get-dimensions
|
(partial utils/get-dimensions
|
||||||
|
@ -77,15 +72,13 @@
|
||||||
[dimensions])
|
[dimensions])
|
||||||
custom-color (if (= type :danger) :danger customization-color)
|
custom-color (if (= type :danger) :danger customization-color)
|
||||||
gesture (rn/use-memo #(drag-gesture x-pos
|
gesture (rn/use-memo #(drag-gesture x-pos
|
||||||
gestures-disabled?
|
|
||||||
set-gestures-disabled
|
|
||||||
disabled?
|
disabled?
|
||||||
(dimensions :usable-track)
|
(dimensions :usable-track)
|
||||||
sliding-complete?
|
sliding-complete?
|
||||||
set-sliding-complete
|
set-sliding-complete
|
||||||
on-complete
|
on-complete
|
||||||
reset-fn)
|
reset-fn)
|
||||||
[gestures-disabled? sliding-complete? disabled?])]
|
[sliding-complete? disabled?])]
|
||||||
[gesture/gesture-detector
|
[gesture/gesture-detector
|
||||||
{:gesture gesture}
|
{:gesture gesture}
|
||||||
[reanimated/view
|
[reanimated/view
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [track-text customization-color auth-button-label on-auth-success on-auth-fail
|
[{:keys [track-text customization-color auth-button-label on-auth-success on-auth-fail
|
||||||
auth-button-icon-left size blur? container-style]
|
auth-button-icon-left size blur? container-style disabled?]
|
||||||
:or {container-style {:flex 1}}}]
|
:or {container-style {:flex 1}}}]
|
||||||
(let [theme (quo.theme/use-theme-value)
|
(let [theme (quo.theme/use-theme-value)
|
||||||
auth-method (rf/sub [:auth-method])
|
auth-method (rf/sub [:auth-method])
|
||||||
|
@ -31,4 +31,5 @@
|
||||||
:customization-color customization-color
|
:customization-color customization-color
|
||||||
:on-complete on-complete
|
:on-complete on-complete
|
||||||
:track-icon (if biometric-auth? :i/face-id :password)
|
:track-icon (if biometric-auth? :i/face-id :password)
|
||||||
:track-text track-text}]))
|
:track-text track-text
|
||||||
|
:disabled? disabled?}]))
|
||||||
|
|
|
@ -148,9 +148,7 @@
|
||||||
:path @derivation-path
|
:path @derivation-path
|
||||||
:account-name @account-name}])))
|
:account-name @account-name}])))
|
||||||
:auth-button-label (i18n/label :t/confirm)
|
:auth-button-label (i18n/label :t/confirm)
|
||||||
;; TODO (@rende11) Add this property when sliding button issue will fixed
|
:disabled? (empty? @account-name)
|
||||||
;; https://github.com/status-im/status-mobile/pull/18683#issuecomment-1941564785
|
|
||||||
;; :disabled? (empty? @account-name)
|
|
||||||
:container-style (style/slide-button-container bottom)}]]))))
|
:container-style (style/slide-button-container bottom)}]]))))
|
||||||
|
|
||||||
(defn- view-internal
|
(defn- view-internal
|
||||||
|
|
Loading…
Reference in New Issue