[14849] Only allow dragging inside bottom sheet when no handle is shown (#14850)

This commit is contained in:
Ibrahem Khalil 2023-01-24 20:27:57 +02:00 committed by GitHub
parent 080b13c304
commit 7f2623a23e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 37 additions and 26 deletions

View File

@ -83,6 +83,16 @@
(and @expanded? (< end-pan-y collapse-threshold))
(reset! expanded? false))))))))
(defn handle-comp
[window-width]
[rn/view
{:style {:width window-width
:position :absolute
:background-color :transparent
:top 0
:height 20}}
[rn/view {:style (styles/handle)}]])
(defn bottom-sheet
[props children]
(let [{on-cancel :on-cancel
@ -140,7 +150,9 @@
expandable?
show-bottom-sheet?
expanded?
close-bottom-sheet)]
close-bottom-sheet)
handle-comp [gesture/gesture-detector {:gesture bottom-sheet-gesture}
[handle-comp window-width]]]
(react/effect! #(do
(cond
@ -200,9 +212,7 @@
{:style (reanimated/apply-animations-to-style
{:opacity bg-opacity}
styles/backdrop)}]]
[gesture/gesture-detector {:gesture bottom-sheet-gesture}
[reanimated/view
(cond->> [reanimated/view
{:style (reanimated/apply-animations-to-style
{:transform [{:translateY translate-y}]}
{:width window-width
@ -222,6 +232,7 @@
(> @content-height 0))
on-content-layout)}
children]]
(when show-handle?
[rn/view {:style (styles/handle)}])]]]]]))])]))
handle-comp)]]]
(not show-handle?)
(conj [gesture/gesture-detector {:gesture bottom-sheet-gesture}]))]))])]))