Increase long press move distance
Fix android password visibility change Do not change secure-text-entry on android password visiblity Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
This commit is contained in:
parent
7007b790d5
commit
bdb4d7fe35
|
@ -213,19 +213,19 @@
|
||||||
|
|
||||||
(defn with-easing
|
(defn with-easing
|
||||||
[{val :value
|
[{val :value
|
||||||
:keys [snap-points velocity offset state easing duration on-snap]
|
:keys [snap-points velocity offset state easing duration
|
||||||
:or {duration 250
|
animation-over]
|
||||||
easing (:ease-out easings)}}]
|
:or {duration 250
|
||||||
|
animation-over (value 1)
|
||||||
|
easing (:ease-out easings)}}]
|
||||||
(let [position (value 0)
|
(let [position (value 0)
|
||||||
c (clock)
|
c (clock)
|
||||||
animation-over (value 1)
|
|
||||||
interrupted (and* (eq state (:began gh/states))
|
interrupted (and* (eq state (:began gh/states))
|
||||||
(clock-running c))
|
(clock-running c))
|
||||||
vel (multiply velocity 1.5)
|
vel (multiply velocity 1.5)
|
||||||
to (snap-point position vel snap-points)
|
to (snap-point position vel snap-points)
|
||||||
finish-animation [(set offset position)
|
finish-animation [(set offset position)
|
||||||
(stop-clock c)
|
(stop-clock c)
|
||||||
(call* [position] on-snap)
|
|
||||||
(set animation-over 1)]]
|
(set animation-over 1)]]
|
||||||
(block
|
(block
|
||||||
[(cond* interrupted finish-animation)
|
[(cond* interrupted finish-animation)
|
||||||
|
|
|
@ -84,19 +84,17 @@
|
||||||
:animation animation}))
|
:animation animation}))
|
||||||
[type])
|
[type])
|
||||||
handle-press (fn [] (when on-press (on-press)))
|
handle-press (fn [] (when on-press (on-press)))
|
||||||
handle-press-start (fn [] (when on-press-start (on-press-start)))
|
long-gesture-handler (react/callback
|
||||||
long-gesture-handler (fn [^js evt]
|
(fn [^js evt]
|
||||||
(when (and on-long-press
|
(let [state (-> evt .-nativeEvent .-state)]
|
||||||
(= (-> evt .-nativeEvent .-state)
|
(when (and on-press-start
|
||||||
(:active gesture-handler/states)))
|
(= state (:began gesture-handler/states)))
|
||||||
(on-long-press)
|
(on-press-start))
|
||||||
(animated/set-value state (:undetermined gesture-handler/states))))]
|
(when (and on-long-press
|
||||||
(animated/code!
|
(= state (:active gesture-handler/states)))
|
||||||
(fn []
|
(on-long-press)
|
||||||
(when on-press-start
|
(animated/set-value state (:undetermined gesture-handler/states)))))
|
||||||
(animated/cond* (animated/eq state (:began gesture-handler/states))
|
[on-long-press on-press-start])]
|
||||||
(animated/call* [] handle-press-start))))
|
|
||||||
[on-press-start])
|
|
||||||
(animated/code!
|
(animated/code!
|
||||||
(fn []
|
(fn []
|
||||||
(when on-press
|
(when on-press
|
||||||
|
@ -109,6 +107,7 @@
|
||||||
{:enabled (boolean (and on-long-press (not disabled)))
|
{:enabled (boolean (and on-long-press (not disabled)))
|
||||||
:on-handler-state-change long-gesture-handler
|
:on-handler-state-change long-gesture-handler
|
||||||
:min-duration-ms long-press-duration
|
:min-duration-ms long-press-duration
|
||||||
|
:max-dist 22
|
||||||
:ref long-press-ref}
|
:ref long-press-ref}
|
||||||
[animated/view {:accessible true
|
[animated/view {:accessible true
|
||||||
:accessibility-label accessibility-label}
|
:accessibility-label accessibility-label}
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
manual-open (animated/use-value 0)
|
manual-open (animated/use-value 0)
|
||||||
manual-close (animated/use-value 0)
|
manual-close (animated/use-value 0)
|
||||||
offset (animated/use-value 0)
|
offset (animated/use-value 0)
|
||||||
|
drag-over (animated/use-value 1)
|
||||||
clock (animated/use-clock)
|
clock (animated/use-clock)
|
||||||
body-ref (react/create-ref)
|
body-ref (react/create-ref)
|
||||||
master-ref (react/create-ref)
|
master-ref (react/create-ref)
|
||||||
|
@ -85,15 +86,15 @@
|
||||||
translate-y (react/use-memo
|
translate-y (react/use-memo
|
||||||
(fn []
|
(fn []
|
||||||
(animated/with-easing
|
(animated/with-easing
|
||||||
{:value (animated/cond* (animated/less-or-eq master-translation-y 0)
|
{:value (animated/cond* (animated/less-or-eq master-translation-y 0)
|
||||||
(animated/divide master-translation-y 2)
|
(animated/divide master-translation-y 2)
|
||||||
master-translation-y)
|
master-translation-y)
|
||||||
:velocity master-velocity-y
|
:velocity master-velocity-y
|
||||||
:offset offset
|
:offset offset
|
||||||
:state master-state
|
:state master-state
|
||||||
:on-snap on-snap
|
:animation-over drag-over
|
||||||
:snap-points [open-snap-point close-snap-point]}))
|
:snap-points [open-snap-point close-snap-point]}))
|
||||||
[on-close])
|
[])
|
||||||
opacity (react/use-memo
|
opacity (react/use-memo
|
||||||
(fn []
|
(fn []
|
||||||
(animated/cond*
|
(animated/cond*
|
||||||
|
@ -104,6 +105,12 @@
|
||||||
:outputRange [1 0]
|
:outputRange [1 0]
|
||||||
:extrapolate (:clamp animated/extrapolate)})))
|
:extrapolate (:clamp animated/extrapolate)})))
|
||||||
[])]
|
[])]
|
||||||
|
(animated/code!
|
||||||
|
(fn []
|
||||||
|
(animated/cond* (animated/and* (animated/eq master-state (:end gesture-handler/states))
|
||||||
|
(animated/not* drag-over))
|
||||||
|
(animated/call* [translate-y] on-snap)))
|
||||||
|
[on-snap])
|
||||||
(animated/code!
|
(animated/code!
|
||||||
(fn []
|
(fn []
|
||||||
(animated/block
|
(animated/block
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
{:min-height (size->container-size size)
|
{:min-height (size->container-size size)
|
||||||
:padding-vertical 8
|
:padding-vertical 8
|
||||||
:flex-direction :row
|
:flex-direction :row
|
||||||
:flex 1
|
|
||||||
:align-items :center
|
:align-items :center
|
||||||
:justify-content :space-between})}]
|
:justify-content :space-between})}]
|
||||||
children))
|
children))
|
||||||
|
|
|
@ -152,8 +152,8 @@
|
||||||
cancel-label on-focus on-blur show-cancel accessibility-label
|
cancel-label on-focus on-blur show-cancel accessibility-label
|
||||||
bottom-value secure-text-entry container-style get-ref on-cancel
|
bottom-value secure-text-entry container-style get-ref on-cancel
|
||||||
monospace]
|
monospace]
|
||||||
:or {cancel-label "Cancel"}
|
:or {cancel-label "Cancel"}
|
||||||
:as props}]
|
:as props}]
|
||||||
{:pre [(check-spec ::text-input props)]}
|
{:pre [(check-spec ::text-input props)]}
|
||||||
(let [show-cancel (if (nil? show-cancel)
|
(let [show-cancel (if (nil? show-cancel)
|
||||||
;; Enabled by default on iOs and disabled on Android
|
;; Enabled by default on iOs and disabled on Android
|
||||||
|
@ -169,15 +169,17 @@
|
||||||
:on-press #(reset! visible true)}
|
:on-press #(reset! visible true)}
|
||||||
|
|
||||||
:else after)
|
:else after)
|
||||||
secure (and secure-text-entry (not @visible))
|
secure (and secure-text-entry
|
||||||
on-cancel (fn []
|
(or platform/android? (not @visible)))
|
||||||
(when on-cancel
|
on-cancel (fn []
|
||||||
(on-cancel))
|
(when on-cancel
|
||||||
(blur))
|
(on-cancel))
|
||||||
|
(blur))
|
||||||
keyboard-type (cond
|
keyboard-type (cond
|
||||||
(and platform/ios? (= keyboard-type "visible-password"))
|
(and platform/ios? (= keyboard-type "visible-password"))
|
||||||
"default"
|
"default"
|
||||||
|
|
||||||
|
;; NOTE: Now switching dynamically brakes android input
|
||||||
(and platform/android? secure-text-entry @visible)
|
(and platform/android? secure-text-entry @visible)
|
||||||
"visible-password"
|
"visible-password"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue