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:
Gheorghe Pinzaru 2020-07-06 16:32:57 +03:00
parent 7007b790d5
commit bdb4d7fe35
No known key found for this signature in database
GPG Key ID: C9A094959935A952
5 changed files with 42 additions and 35 deletions

View File

@ -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
animation-over]
:or {duration 250 :or {duration 250
animation-over (value 1)
easing (:ease-out easings)}}] 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)

View File

@ -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]
(let [state (-> evt .-nativeEvent .-state)]
(when (and on-press-start
(= state (:began gesture-handler/states)))
(on-press-start))
(when (and on-long-press (when (and on-long-press
(= (-> evt .-nativeEvent .-state) (= state (:active gesture-handler/states)))
(:active gesture-handler/states)))
(on-long-press) (on-long-press)
(animated/set-value state (:undetermined gesture-handler/states))))] (animated/set-value state (:undetermined gesture-handler/states)))))
(animated/code! [on-long-press on-press-start])]
(fn []
(when on-press-start
(animated/cond* (animated/eq state (:began gesture-handler/states))
(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}

View File

@ -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)
@ -91,9 +92,9 @@
: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

View File

@ -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))

View File

@ -169,7 +169,8 @@
: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
(or platform/android? (not @visible)))
on-cancel (fn [] on-cancel (fn []
(when on-cancel (when on-cancel
(on-cancel)) (on-cancel))
@ -178,6 +179,7 @@
(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"