|
83 | 83 | (and @expanded? (< end-pan-y collapse-threshold)) |
84 | 84 | (reset! expanded? false)))))))) |
85 | 85 |
|
| 86 | +(defn handle-comp |
| 87 | + [window-width] |
| 88 | + [rn/view |
| 89 | + {:style {:width window-width |
| 90 | + :position :absolute |
| 91 | + :background-color :transparent |
| 92 | + :top 0 |
| 93 | + :height 20}} |
| 94 | + [rn/view {:style (styles/handle)}]]) |
| 95 | + |
86 | 96 | (defn bottom-sheet |
87 | 97 | [props children] |
88 | 98 | (let [{on-cancel :on-cancel |
|
140 | 150 | expandable? |
141 | 151 | show-bottom-sheet? |
142 | 152 | expanded? |
143 | | - close-bottom-sheet)] |
| 153 | + close-bottom-sheet) |
| 154 | + handle-comp [gesture/gesture-detector {:gesture bottom-sheet-gesture} |
| 155 | + [handle-comp window-width]]] |
144 | 156 |
|
145 | 157 | (react/effect! #(do |
146 | 158 | (cond |
|
200 | 212 | {:style (reanimated/apply-animations-to-style |
201 | 213 | {:opacity bg-opacity} |
202 | 214 | styles/backdrop)}]] |
203 | | - |
204 | | - [gesture/gesture-detector {:gesture bottom-sheet-gesture} |
205 | | - [reanimated/view |
206 | | - {:style (reanimated/apply-animations-to-style |
207 | | - {:transform [{:translateY translate-y}]} |
208 | | - {:width window-width |
209 | | - :height window-height})} |
210 | | - [rn/view {:style styles/container} |
211 | | - (when selected-item |
212 | | - [rn/view {:style (styles/selected-background)} |
213 | | - [selected-item]]) |
214 | | - [rn/view {:style (styles/background)} |
215 | | - [rn/keyboard-avoiding-view |
216 | | - {:behaviour (if platform/ios? :padding :height) |
217 | | - :style {:flex 1}} |
218 | | - [rn/view |
219 | | - {:style (styles/content-style insets) |
220 | | - :on-layout (when-not (and |
221 | | - (some? @content-height) |
222 | | - (> @content-height 0)) |
223 | | - on-content-layout)} |
224 | | - children]] |
225 | | - |
226 | | - (when show-handle? |
227 | | - [rn/view {:style (styles/handle)}])]]]]]))])])) |
| 215 | + (cond->> [reanimated/view |
| 216 | + {:style (reanimated/apply-animations-to-style |
| 217 | + {:transform [{:translateY translate-y}]} |
| 218 | + {:width window-width |
| 219 | + :height window-height})} |
| 220 | + [rn/view {:style styles/container} |
| 221 | + (when selected-item |
| 222 | + [rn/view {:style (styles/selected-background)} |
| 223 | + [selected-item]]) |
| 224 | + [rn/view {:style (styles/background)} |
| 225 | + [rn/keyboard-avoiding-view |
| 226 | + {:behaviour (if platform/ios? :padding :height) |
| 227 | + :style {:flex 1}} |
| 228 | + [rn/view |
| 229 | + {:style (styles/content-style insets) |
| 230 | + :on-layout (when-not (and |
| 231 | + (some? @content-height) |
| 232 | + (> @content-height 0)) |
| 233 | + on-content-layout)} |
| 234 | + children]] |
| 235 | + (when show-handle? |
| 236 | + handle-comp)]]] |
| 237 | + (not show-handle?) |
| 238 | + (conj [gesture/gesture-detector {:gesture bottom-sheet-gesture}]))]))])])) |
0 commit comments