From 7f2623a23e6b64ed338c9d3a211d351a3caefce3 Mon Sep 17 00:00:00 2001 From: Ibrahem Khalil Date: Tue, 24 Jan 2023 20:27:57 +0200 Subject: [PATCH] [14849] Only allow dragging inside bottom sheet when no handle is shown (#14850) --- src/status_im2/common/bottom_sheet/view.cljs | 63 ++++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/src/status_im2/common/bottom_sheet/view.cljs b/src/status_im2/common/bottom_sheet/view.cljs index 857be3f22e..1a50b042c0 100644 --- a/src/status_im2/common/bottom_sheet/view.cljs +++ b/src/status_im2/common/bottom_sheet/view.cljs @@ -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,28 +212,27 @@ {:style (reanimated/apply-animations-to-style {:opacity bg-opacity} styles/backdrop)}]] - - [gesture/gesture-detector {:gesture bottom-sheet-gesture} - [reanimated/view - {:style (reanimated/apply-animations-to-style - {:transform [{:translateY translate-y}]} - {:width window-width - :height window-height})} - [rn/view {:style styles/container} - (when selected-item - [rn/view {:style (styles/selected-background)} - [selected-item]]) - [rn/view {:style (styles/background)} - [rn/keyboard-avoiding-view - {:behaviour (if platform/ios? :padding :height) - :style {:flex 1}} - [rn/view - {:style (styles/content-style insets) - :on-layout (when-not (and - (some? @content-height) - (> @content-height 0)) - on-content-layout)} - children]] - - (when show-handle? - [rn/view {:style (styles/handle)}])]]]]]))])])) + (cond->> [reanimated/view + {:style (reanimated/apply-animations-to-style + {:transform [{:translateY translate-y}]} + {:width window-width + :height window-height})} + [rn/view {:style styles/container} + (when selected-item + [rn/view {:style (styles/selected-background)} + [selected-item]]) + [rn/view {:style (styles/background)} + [rn/keyboard-avoiding-view + {:behaviour (if platform/ios? :padding :height) + :style {:flex 1}} + [rn/view + {:style (styles/content-style insets) + :on-layout (when-not (and + (some? @content-height) + (> @content-height 0)) + on-content-layout)} + children]] + (when show-handle? + handle-comp)]]] + (not show-handle?) + (conj [gesture/gesture-detector {:gesture bottom-sheet-gesture}]))]))])]))