@swmansion/react-native-bottom-sheet 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -55
- package/android/src/main/java/com/swmansion/reactnativebottomsheet/BottomSheetView.kt +9 -13
- package/ios/RNSBottomSheetHostingView.swift +16 -17
- package/lib/module/BottomSheet.js +1 -3
- package/lib/module/BottomSheet.js.map +1 -1
- package/lib/typescript/src/BottomSheet.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/BottomSheet.tsx +2 -7
package/README.md
CHANGED
|
@@ -7,6 +7,15 @@
|
|
|
7
7
|
React Native Bottom Sheet provides bottom‍-‍sheet components for
|
|
8
8
|
React Native.
|
|
9
9
|
|
|
10
|
+
## Highlights
|
|
11
|
+
|
|
12
|
+
- Native implementation for optimal performance.
|
|
13
|
+
- Bring your own sheet surface.
|
|
14
|
+
- Dynamic, content‍-‍based sizing out of the box.
|
|
15
|
+
- Position tracking for driving UI tied to sheets.
|
|
16
|
+
- Programmatic‍-‍only detents for snap points unreachable
|
|
17
|
+
by dragging.
|
|
18
|
+
|
|
10
19
|
## Getting started
|
|
11
20
|
|
|
12
21
|
1. Install React Native Bottom Sheet:
|
|
@@ -15,20 +24,16 @@ React Native.
|
|
|
15
24
|
npm i @swmansion/react-native-bottom-sheet
|
|
16
25
|
```
|
|
17
26
|
|
|
18
|
-
2. Ensure the peer
|
|
27
|
+
2. Ensure the peer dependency is installed:
|
|
19
28
|
|
|
20
29
|
```sh
|
|
21
|
-
npm i react-native-
|
|
30
|
+
npm i react-native-safe-area-context@^4.0.0
|
|
22
31
|
```
|
|
23
32
|
|
|
24
|
-
3. Wrap your app with
|
|
33
|
+
3. Wrap your app with `BottomSheetProvider`:
|
|
25
34
|
|
|
26
35
|
```tsx
|
|
27
|
-
const App = () =>
|
|
28
|
-
<GestureHandlerRootView>
|
|
29
|
-
<BottomSheetProvider>{/* ... */}</BottomSheetProvider>
|
|
30
|
-
</GestureHandlerRootView>
|
|
31
|
-
);
|
|
36
|
+
const App = () => <BottomSheetProvider>{/* ... */}</BottomSheetProvider>;
|
|
32
37
|
```
|
|
33
38
|
|
|
34
39
|
## Usage
|
|
@@ -86,22 +91,14 @@ const insets = useSafeAreaInsets();
|
|
|
86
91
|
|
|
87
92
|
#### Scrim
|
|
88
93
|
|
|
89
|
-
Tapping the scrim collapses the sheet.
|
|
90
|
-
|
|
91
|
-
1 when the first nonzero detent is reached:
|
|
94
|
+
Tapping the scrim collapses the sheet. Use `scrimColor` to customize
|
|
95
|
+
its color:
|
|
92
96
|
|
|
93
97
|
```tsx
|
|
94
98
|
<ModalBottomSheet
|
|
95
99
|
index={index}
|
|
96
100
|
onIndexChange={setIndex}
|
|
97
|
-
|
|
98
|
-
<Animated.View
|
|
99
|
-
style={useAnimatedStyle(() => ({
|
|
100
|
-
backgroundColor: `rgba(0, 0, 255, ${0.3 * progress.value})`,
|
|
101
|
-
flex: 1,
|
|
102
|
-
}))}
|
|
103
|
-
/>
|
|
104
|
-
)}
|
|
101
|
+
scrimColor="rgba(0, 0, 0, 0.3)"
|
|
105
102
|
>
|
|
106
103
|
{/* ... */}
|
|
107
104
|
</ModalBottomSheet>
|
|
@@ -115,8 +112,8 @@ available screen height). The default detents are `[0, 'max']`.
|
|
|
115
112
|
|
|
116
113
|
The `index` prop is a zero‍-‍based index into the `detents` array.
|
|
117
114
|
`onIndexChange` is called when the sheet snaps to a different detent after
|
|
118
|
-
a
|
|
119
|
-
state.
|
|
115
|
+
a drag. You can also control the sheet externally by updating the
|
|
116
|
+
index state.
|
|
120
117
|
|
|
121
118
|
```tsx
|
|
122
119
|
const [index, setIndex] = useState(0);
|
|
@@ -150,55 +147,38 @@ drag snapping but can still be targeted via `index` updates.
|
|
|
150
147
|
|
|
151
148
|
### Position tracking
|
|
152
149
|
|
|
153
|
-
|
|
154
|
-
the
|
|
155
|
-
screen to the top of the sheet). Use it to drive animations tied to the
|
|
156
|
-
sheet position.
|
|
157
|
-
|
|
158
|
-
```tsx
|
|
159
|
-
const position = useSharedValue(0);
|
|
160
|
-
```
|
|
150
|
+
Use `onPositionChange` to observe the sheet’s current position (the distance in
|
|
151
|
+
pixels from the bottom of the screen to the top of the sheet).
|
|
161
152
|
|
|
162
153
|
```tsx
|
|
163
154
|
<BottomSheet // Or `ModalBottomSheet`.
|
|
164
155
|
index={index}
|
|
165
156
|
onIndexChange={setIndex}
|
|
166
|
-
|
|
157
|
+
onPositionChange={(position) => {
|
|
158
|
+
console.log(position);
|
|
159
|
+
}}
|
|
167
160
|
>
|
|
168
161
|
{/* ... */}
|
|
169
162
|
</BottomSheet>
|
|
170
163
|
```
|
|
171
164
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
Use the `openAnimationConfig` and `closeAnimationConfig` props to tweak the
|
|
175
|
-
spring parameters for opening and closing.
|
|
176
|
-
|
|
177
|
-
### Scrollable content
|
|
178
|
-
|
|
179
|
-
For scrollable sheet content, use `BottomSheetScrollView` or
|
|
180
|
-
`BottomSheetFlatList` instead of the standard React Native components. These
|
|
181
|
-
integrate scrolling with the sheet’s drag gesture so that dragging down while
|
|
182
|
-
scrolled to the top collapses the sheet.
|
|
183
|
-
|
|
184
|
-
If you need a custom scrollable (for example, a `FlashList`), wrap it with
|
|
185
|
-
`bottomSheetScrollable`. The returned component forwards the underlying
|
|
186
|
-
scrollable ref, so you can call any imperative methods supported by the
|
|
187
|
-
wrapped component.
|
|
165
|
+
If you want to keep the latest position in a Reanimated shared value, update it
|
|
166
|
+
from the callback:
|
|
188
167
|
|
|
189
168
|
```tsx
|
|
190
|
-
const
|
|
191
|
-
FlashListProps<string>,
|
|
192
|
-
FlashListRef<string>
|
|
193
|
-
>(FlashList);
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
```tsx
|
|
197
|
-
const listRef = useRef<FlashListRef<string>>(null);
|
|
169
|
+
const position = useSharedValue(0);
|
|
198
170
|
```
|
|
199
171
|
|
|
200
172
|
```tsx
|
|
201
|
-
<
|
|
173
|
+
<BottomSheet
|
|
174
|
+
index={index}
|
|
175
|
+
onIndexChange={setIndex}
|
|
176
|
+
onPositionChange={(nextPosition) => {
|
|
177
|
+
position.value = nextPosition;
|
|
178
|
+
}}
|
|
179
|
+
>
|
|
180
|
+
{/* ... */}
|
|
181
|
+
</BottomSheet>;
|
|
202
182
|
```
|
|
203
183
|
|
|
204
184
|
## By [Software Mansion](https://swmansion.com)
|
|
@@ -15,6 +15,7 @@ import com.facebook.react.bridge.Arguments
|
|
|
15
15
|
import com.facebook.react.uimanager.PointerEvents
|
|
16
16
|
import com.facebook.react.uimanager.StateWrapper
|
|
17
17
|
import com.facebook.react.views.view.ReactViewGroup
|
|
18
|
+
import com.facebook.react.uimanager.events.NativeGestureUtil
|
|
18
19
|
import kotlin.math.abs
|
|
19
20
|
|
|
20
21
|
private data class DetentSpec(val height: Float, val programmatic: Boolean)
|
|
@@ -322,21 +323,24 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
322
323
|
val dx = x - initialTouchX
|
|
323
324
|
val dy = y - initialTouchY
|
|
324
325
|
|
|
325
|
-
if (abs(dy) > touchSlop && abs(dy) > abs(dx)) {
|
|
326
|
+
if (abs(dy) > touchSlop && abs(dy) > abs(dx) && draggableMinTy < draggableMaxTy) {
|
|
326
327
|
if (!isAtMaxDraggable) {
|
|
327
328
|
lastTouchY = y
|
|
328
329
|
requestDisallowInterceptTouchEvent(false)
|
|
330
|
+
NativeGestureUtil.notifyNativeGestureStarted(this, ev)
|
|
329
331
|
return true
|
|
330
332
|
}
|
|
331
333
|
if (dy > 0 && isScrollViewAtTop()) {
|
|
332
334
|
lastTouchY = y
|
|
333
335
|
requestDisallowInterceptTouchEvent(false)
|
|
336
|
+
NativeGestureUtil.notifyNativeGestureStarted(this, ev)
|
|
334
337
|
return true
|
|
335
338
|
}
|
|
336
339
|
}
|
|
337
340
|
}
|
|
338
341
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
|
339
342
|
initialTouchX = 0f
|
|
343
|
+
initialTouchY = 0f
|
|
340
344
|
activePointerId = MotionEvent.INVALID_POINTER_ID
|
|
341
345
|
}
|
|
342
346
|
}
|
|
@@ -344,16 +348,7 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
344
348
|
}
|
|
345
349
|
|
|
346
350
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
347
|
-
val sheetTop = sheetContainer.top + sheetContainer.translationY
|
|
348
|
-
if (event.actionMasked == MotionEvent.ACTION_DOWN && event.y < sheetTop) {
|
|
349
|
-
return false
|
|
350
|
-
}
|
|
351
|
-
|
|
352
351
|
when (event.actionMasked) {
|
|
353
|
-
MotionEvent.ACTION_DOWN -> {
|
|
354
|
-
beginPan(event)
|
|
355
|
-
return true
|
|
356
|
-
}
|
|
357
352
|
MotionEvent.ACTION_MOVE -> {
|
|
358
353
|
if (!isPanning) beginPan(event)
|
|
359
354
|
val pointerIndex = event.findPointerIndex(activePointerId)
|
|
@@ -387,9 +382,10 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
|
|
|
387
382
|
MotionEvent.ACTION_POINTER_UP -> {
|
|
388
383
|
val actionIndex = event.actionIndex
|
|
389
384
|
if (event.getPointerId(actionIndex) == activePointerId) {
|
|
390
|
-
val
|
|
391
|
-
activePointerId = event.getPointerId(
|
|
392
|
-
lastTouchY = event.getY(
|
|
385
|
+
val newPointerIndex = if (actionIndex == 0) 1 else 0
|
|
386
|
+
activePointerId = event.getPointerId(newPointerIndex)
|
|
387
|
+
lastTouchY = event.getY(newPointerIndex)
|
|
388
|
+
velocityTracker?.clear()
|
|
393
389
|
}
|
|
394
390
|
return true
|
|
395
391
|
}
|
|
@@ -43,7 +43,7 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
43
43
|
panGesture.delegate = self
|
|
44
44
|
panGesture.cancelsTouchesInView = true
|
|
45
45
|
panGesture.delaysTouchesBegan = true
|
|
46
|
-
panGesture.delaysTouchesEnded =
|
|
46
|
+
panGesture.delaysTouchesEnded = false
|
|
47
47
|
sheetContainer.addGestureRecognizer(panGesture)
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -258,13 +258,21 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
258
258
|
sheetContainer.transform = CGAffineTransform(translationX: 0, y: newTy)
|
|
259
259
|
emitPosition()
|
|
260
260
|
|
|
261
|
-
case .ended
|
|
261
|
+
case .ended:
|
|
262
262
|
isPanning = false
|
|
263
263
|
let velocity = gesture.velocity(in: self).y
|
|
264
264
|
let currentHeight = maxHeight - sheetContainer.transform.ty
|
|
265
265
|
let index = bestSnapIndex(for: currentHeight, velocity: velocity)
|
|
266
266
|
snapToIndex(index, velocity: velocity)
|
|
267
267
|
|
|
268
|
+
case .cancelled:
|
|
269
|
+
isPanning = false
|
|
270
|
+
setContentInteractionEnabled(true)
|
|
271
|
+
let cancelVelocity = gesture.velocity(in: self).y
|
|
272
|
+
let cancelHeight = maxHeight - sheetContainer.transform.ty
|
|
273
|
+
let cancelIndex = bestSnapIndex(for: cancelHeight, velocity: cancelVelocity)
|
|
274
|
+
snapToIndex(cancelIndex, velocity: cancelVelocity)
|
|
275
|
+
|
|
268
276
|
case .failed:
|
|
269
277
|
isPanning = false
|
|
270
278
|
setContentInteractionEnabled(true)
|
|
@@ -312,7 +320,10 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
312
320
|
let velocity = panGesture.velocity(in: self)
|
|
313
321
|
guard abs(velocity.y) > abs(velocity.x) else { return false }
|
|
314
322
|
|
|
315
|
-
let
|
|
323
|
+
let draggable = detentSpecs.enumerated().filter { !$0.element.programmatic }
|
|
324
|
+
guard draggable.count > 1 else { return false }
|
|
325
|
+
|
|
326
|
+
let maxDraggableIndex = draggable.last?.offset ?? 0
|
|
316
327
|
guard targetIndex >= maxDraggableIndex else { return true }
|
|
317
328
|
|
|
318
329
|
if velocity.y < 0 {
|
|
@@ -325,24 +336,12 @@ public final class RNSBottomSheetHostingView: UIView {
|
|
|
325
336
|
}
|
|
326
337
|
|
|
327
338
|
extension RNSBottomSheetHostingView: UIGestureRecognizerDelegate {
|
|
328
|
-
public func gestureRecognizer(
|
|
329
|
-
_ gestureRecognizer: UIGestureRecognizer,
|
|
330
|
-
shouldRequireFailureOf other: UIGestureRecognizer
|
|
331
|
-
) -> Bool {
|
|
332
|
-
guard gestureRecognizer === panGesture else { return false }
|
|
333
|
-
|
|
334
|
-
if other is UITapGestureRecognizer {
|
|
335
|
-
return true
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return false
|
|
339
|
-
}
|
|
340
|
-
|
|
341
339
|
public func gestureRecognizer(
|
|
342
340
|
_ gestureRecognizer: UIGestureRecognizer,
|
|
343
341
|
shouldBeRequiredToFailBy other: UIGestureRecognizer
|
|
344
342
|
) -> Bool {
|
|
345
|
-
|
|
343
|
+
guard gestureRecognizer === panGesture else { return false }
|
|
344
|
+
return other is UIPanGestureRecognizer || other is UITapGestureRecognizer
|
|
346
345
|
}
|
|
347
346
|
|
|
348
347
|
public func gestureRecognizer(
|
|
@@ -52,7 +52,6 @@ export const BottomSheet = ({
|
|
|
52
52
|
};
|
|
53
53
|
const clampedIndex = Math.max(0, Math.min(index, resolvedDetents.length - 1));
|
|
54
54
|
const isCollapsed = (resolvedDetents[clampedIndex]?.height ?? 0) === 0;
|
|
55
|
-
const sheetPointerEvents = isCollapsed ? 'none' : 'box-none';
|
|
56
55
|
const scrimPressEnabledRef = useRef(!modal || isCollapsed);
|
|
57
56
|
const previousIsCollapsedRef = useRef(isCollapsed);
|
|
58
57
|
const firstNonzeroDetent = resolvedDetents.find(detent => detent.height > 0)?.height ?? 0;
|
|
@@ -113,7 +112,7 @@ export const BottomSheet = ({
|
|
|
113
112
|
opacity: sheetOpacity
|
|
114
113
|
}],
|
|
115
114
|
children: /*#__PURE__*/_jsx(BottomSheetNativeComponent, {
|
|
116
|
-
pointerEvents:
|
|
115
|
+
pointerEvents: "box-none",
|
|
117
116
|
style: [{
|
|
118
117
|
position: 'absolute',
|
|
119
118
|
left: 0,
|
|
@@ -131,7 +130,6 @@ export const BottomSheet = ({
|
|
|
131
130
|
style: {
|
|
132
131
|
flex: 1
|
|
133
132
|
},
|
|
134
|
-
pointerEvents: "box-none",
|
|
135
133
|
children: [children, /*#__PURE__*/_jsx(View, {
|
|
136
134
|
onLayout: handleSentinelLayout,
|
|
137
135
|
pointerEvents: "none"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","useState","Animated","Pressable","StyleSheet","View","useWindowDimensions","useSafeAreaInsets","BottomSheetNativeComponent","Portal","resolveDetent","jsx","_jsx","jsxs","_jsxs","programmatic","DefaultScrim","progress","color","style","absoluteFill","flex","backgroundColor","opacity","BottomSheet","children","detents","index","animateIn","onIndexChange","onPositionChange","modal","scrimColor","height","screenHeight","insets","maxHeight","top","contentHeight","setContentHeight","currentPositionRef","scrimProgress","Value","current","sheetOpacity","resolvedDetents","map","detent","value","Math","max","min","isDetentProgrammatic","handleSentinelLayout","event","nativeEvent","layout","y","clampedIndex","length","isCollapsed","
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","Animated","Pressable","StyleSheet","View","useWindowDimensions","useSafeAreaInsets","BottomSheetNativeComponent","Portal","resolveDetent","jsx","_jsx","jsxs","_jsxs","programmatic","DefaultScrim","progress","color","style","absoluteFill","flex","backgroundColor","opacity","BottomSheet","children","detents","index","animateIn","onIndexChange","onPositionChange","modal","scrimColor","height","screenHeight","insets","maxHeight","top","contentHeight","setContentHeight","currentPositionRef","scrimProgress","Value","current","sheetOpacity","resolvedDetents","map","detent","value","Math","max","min","isDetentProgrammatic","handleSentinelLayout","event","nativeEvent","layout","y","clampedIndex","length","isCollapsed","scrimPressEnabledRef","previousIsCollapsedRef","firstNonzeroDetent","find","setValue","undefined","frame","requestAnimationFrame","cancelAnimationFrame","handleIndexChange","handlePositionChange","position","closedIndex","findIndex","handleScrimPress","scrimElement","sheet","pointerEvents","onP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,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,GAAI,qGAUzB,gBAAgB,4CAiJlB,CAAC"}
|
package/package.json
CHANGED
package/src/BottomSheet.tsx
CHANGED
|
@@ -77,7 +77,6 @@ export const BottomSheet = ({
|
|
|
77
77
|
|
|
78
78
|
const clampedIndex = Math.max(0, Math.min(index, resolvedDetents.length - 1));
|
|
79
79
|
const isCollapsed = (resolvedDetents[clampedIndex]?.height ?? 0) === 0;
|
|
80
|
-
const sheetPointerEvents = isCollapsed ? 'none' : 'box-none';
|
|
81
80
|
const scrimPressEnabledRef = useRef(!modal || isCollapsed);
|
|
82
81
|
const previousIsCollapsedRef = useRef(isCollapsed);
|
|
83
82
|
const firstNonzeroDetent =
|
|
@@ -169,7 +168,7 @@ export const BottomSheet = ({
|
|
|
169
168
|
style={[StyleSheet.absoluteFill, { opacity: sheetOpacity }]}
|
|
170
169
|
>
|
|
171
170
|
<BottomSheetNativeComponent
|
|
172
|
-
pointerEvents=
|
|
171
|
+
pointerEvents="box-none"
|
|
173
172
|
style={[
|
|
174
173
|
{
|
|
175
174
|
position: 'absolute',
|
|
@@ -186,11 +185,7 @@ export const BottomSheet = ({
|
|
|
186
185
|
onIndexChange={handleIndexChange}
|
|
187
186
|
onPositionChange={handlePositionChange}
|
|
188
187
|
>
|
|
189
|
-
<View
|
|
190
|
-
collapsable={false}
|
|
191
|
-
style={{ flex: 1 }}
|
|
192
|
-
pointerEvents="box-none"
|
|
193
|
-
>
|
|
188
|
+
<View collapsable={false} style={{ flex: 1 }}>
|
|
194
189
|
{children}
|
|
195
190
|
<View onLayout={handleSentinelLayout} pointerEvents="none" />
|
|
196
191
|
</View>
|