@lodev09/react-native-true-sheet 0.9.9 → 0.10.0
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 +8 -305
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt +11 -16
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +18 -19
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +10 -0
- package/ios/TrueSheetView.swift +37 -42
- package/ios/TrueSheetViewController.swift +6 -2
- package/ios/TrueSheetViewManager.m +4 -0
- package/lib/commonjs/TrueSheet.js +20 -1
- package/lib/commonjs/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.js +20 -1
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/typescript/docs/docusaurus.config.d.ts +4 -0
- package/lib/typescript/docs/docusaurus.config.d.ts.map +1 -0
- package/lib/typescript/docs/sidebars.d.ts +4 -0
- package/lib/typescript/docs/sidebars.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheet.d.ts +4 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/TrueSheet.tsx +30 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
The true native bottom sheet 💩
|
|
7
|
+
The true native bottom sheet experience for your React Native Apps. 💩
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
@@ -15,8 +15,8 @@ The true native bottom sheet 💩
|
|
|
15
15
|
* ✅ Handles your _Scrolling_ needs, natively.
|
|
16
16
|
* ✅ Handles your _Footer_ needs, natively.
|
|
17
17
|
* ✅ Handles your _Keyboard_ needs, natively.
|
|
18
|
-
* ✅ Asynchronus `ref` [methods](#methods).
|
|
19
|
-
* ✅ Bonus! [Blur](#blurtint) support on IOS 😎
|
|
18
|
+
* ✅ Asynchronus `ref` [methods](https://sheet.lodev09.com/reference/methods#ref-methods).
|
|
19
|
+
* ✅ Bonus! [Blur](https://sheet.lodev09.com/reference/types#blurtint) support on IOS 😎
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
@@ -28,7 +28,11 @@ yarn add @lodev09/react-native-true-sheet
|
|
|
28
28
|
npm i @lodev09/react-native-true-sheet
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
## Documentation
|
|
32
|
+
|
|
33
|
+
- [Guides](https://sheet.lodev09.com/category/guides)
|
|
34
|
+
- [Reference](https://sheet.lodev09.com/category/reference)
|
|
35
|
+
- [Example](example)
|
|
32
36
|
|
|
33
37
|
## Usage
|
|
34
38
|
|
|
@@ -58,307 +62,6 @@ return (
|
|
|
58
62
|
)
|
|
59
63
|
```
|
|
60
64
|
|
|
61
|
-
## Options
|
|
62
|
-
|
|
63
|
-
Props available for `TrueSheet`.
|
|
64
|
-
Extends `ViewProps`
|
|
65
|
-
|
|
66
|
-
| Prop | Type | Default | Description | 🍎 | 🤖 |
|
|
67
|
-
| - | - | - | - | - | - |
|
|
68
|
-
| sizes | [`SheetSize[]`](#sheetsize) | `["medium", "large"]` | Array of sizes you want the sheet to support. Maximum of _**3 sizes**_ only! **_collapsed_**, **_half-expanded_**, and **_expanded_**. Example: `size={["auto", "60%", "large"]}`| ✅ | ✅ |
|
|
69
|
-
| name | `string` | - | The name to reference this sheet. It has to be **_unique_**. You can then present this sheet globally using its name. | ✅ | ✅ |
|
|
70
|
-
| backgroundColor | `ColorValue` | `"white"` | The sheet's background color. | ✅ | ✅ |
|
|
71
|
-
| cornerRadius | `number` | - | the sheet corner radius. | ✅ | ✅ |
|
|
72
|
-
| maxHeight | `number` | - | Overrides `"large"` or `"100%"` height. | ✅ | ✅ |
|
|
73
|
-
| contentContainerStyle | `StyleProp<ViewStyle>` | - | Optional content container styles. | ✅ | ✅ |
|
|
74
|
-
| FooterComponent | `ComponentType<...> \| ReactElement` | - | A component that floats at the bottom of the sheet. Accepts a functional `Component` or `ReactElement`. | ✅ | ✅ |
|
|
75
|
-
| dismissible | `boolean` | `true` | If set to `false`, the sheet will prevent interactive dismissal via dragging or clicking outside of it. | ✅ | ✅ |
|
|
76
|
-
| grabber | `boolean` | `true` | Shows a grabber (or handle). Native on IOS and styled `View` on Android. | ✅ | ✅ |
|
|
77
|
-
| grabberProps | [`TrueSheetGrabberProps`](#truesheetgrabberprops) | - | Overrides the grabber props for android. | | ✅ |
|
|
78
|
-
| blurTint | [`BlurTint`](#blurtint) | - | The blur effect style on IOS. Overrides `backgroundColor` if set. Example: `"light"`, `"dark"`, etc. | ✅ | |
|
|
79
|
-
| scrollRef | `RefObject<...>` | - | The main scrollable ref that the sheet should handle on IOS. | ✅ | |
|
|
80
|
-
|
|
81
|
-
## Methods
|
|
82
|
-
|
|
83
|
-
```tsx
|
|
84
|
-
const sheet = useRef<TrueSheet>(null)
|
|
85
|
-
|
|
86
|
-
const resize = () => {
|
|
87
|
-
sheet.current?.resize(1)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const dismiss = () => {
|
|
91
|
-
sheet.current?.dismiss()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<View>
|
|
96
|
-
<Button onPress={resize} title="Resize to 80%" />
|
|
97
|
-
<Button onPress={dismiss} title="Dimiss" />
|
|
98
|
-
<TrueSheet sizes={['auto', '80%']} ref={sheet}>
|
|
99
|
-
// ...
|
|
100
|
-
</TrueSheet>
|
|
101
|
-
</View>
|
|
102
|
-
)
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
| Name | Parameters | Description |
|
|
106
|
-
| - | - | - |
|
|
107
|
-
| present | `index: number = 0` | Present the modal sheet. Optionally accepts a size `index`. See `sizes` prop. |
|
|
108
|
-
| resize | `index: number` | Resizes the sheet programmatically by `index`. This is an alias of the `present(index)` method. |
|
|
109
|
-
| dismiss | - | Dismisses the sheet. |
|
|
110
|
-
|
|
111
|
-
### Static Methods
|
|
112
|
-
|
|
113
|
-
You can also call the above methods statically without having access to a sheet's `ref`. This is particularly useful when you want to present a sheet from anywhere.
|
|
114
|
-
|
|
115
|
-
The API is similar to the ref methods except for the required `name` prop.
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
TrueSheet.present('SHEET-NAME')
|
|
119
|
-
TrueSheet.dismiss('SHEET-NAME')
|
|
120
|
-
TrueSheet.resize('SHEET-NAME', 1)
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Example:
|
|
124
|
-
```tsx
|
|
125
|
-
// Define the sheet as usual
|
|
126
|
-
<TrueSheet name="my-sheet">
|
|
127
|
-
// ...
|
|
128
|
-
</TrueSheet>
|
|
129
|
-
```
|
|
130
|
-
```tsx
|
|
131
|
-
// Somewhere in your screen
|
|
132
|
-
const presentMySheet = async () => {
|
|
133
|
-
await TrueSheet.present('my-sheet')
|
|
134
|
-
console.log('🎉')
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<Button onPress={presentMySheet} />
|
|
139
|
-
)
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Events
|
|
143
|
-
|
|
144
|
-
```tsx
|
|
145
|
-
const handleSizeChange = (info: SizeInfo) => {
|
|
146
|
-
console.log(info)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<TrueSheet onSizeChange={handleSizeChange} sizes={['auto', '80%']} ref={sheet}>
|
|
151
|
-
// ...
|
|
152
|
-
</TrueSheet>
|
|
153
|
-
)
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
| Name | Parameters | Description |
|
|
157
|
-
| - | - | - |
|
|
158
|
-
| onPresent | [`SizeInfo`](#sizeinfo) | Called when the sheet has been presented. Comes with the size index and value. |
|
|
159
|
-
| onDismiss | - | Called when the sheet has been dismissed. |
|
|
160
|
-
| onSizeChange | [`SizeInfo`](#sizeinfo) | Called when the size of the sheet has changed. Either by dragging or presenting programatically. Comes with the size index and value. |
|
|
161
|
-
|
|
162
|
-
## Types
|
|
163
|
-
|
|
164
|
-
### `SheetSize`
|
|
165
|
-
|
|
166
|
-
```tsx
|
|
167
|
-
<TrueSheet sizes={['auto', '80%', 'large']}>
|
|
168
|
-
// ...
|
|
169
|
-
</TrueSheet>
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
| Value | Description | 🍎 | 🤖 |
|
|
173
|
-
| - | - | - | - |
|
|
174
|
-
| `"auto"` | Auto resize based on content height. | **_16+_** | ✅ |
|
|
175
|
-
| `"small"` | Translates to 25% | **_16+_** | ✅ |
|
|
176
|
-
| `"medium"` | Translates to 50% | **_15+_** | ✅ |
|
|
177
|
-
| `"large"` | Translates to 100% | ✅ | ✅ |
|
|
178
|
-
| `"${number}%"` | Fixed height in % | **_16+_** | ✅ |
|
|
179
|
-
| `number` | Fixed height | **_16+_** | ✅ |
|
|
180
|
-
|
|
181
|
-
> [!NOTE]
|
|
182
|
-
> `auto` is not guaranteed to be accurate if your content depends on various rendering logic. Experiment with it and try to keep your content size as fixed as possible.
|
|
183
|
-
>
|
|
184
|
-
> Alternatively, you can programmatically call [`resize`](#methods) to adjust the sheet size on-the-fly.
|
|
185
|
-
|
|
186
|
-
### `TrueSheetGrabberProps`
|
|
187
|
-
|
|
188
|
-
Grabber props to be used for android grabber or handle.
|
|
189
|
-
|
|
190
|
-
| Prop | Type | Default | Description |
|
|
191
|
-
| - | - | - | - |
|
|
192
|
-
| visible | `boolean` | `true` | Is grabber visible. |
|
|
193
|
-
| color | `ColorValue` | `"rgba(73,69,79,0.4)"` | Grabber color according to M3 specs. |
|
|
194
|
-
| height | `number` | `4` | Grabber height according to M3 specs. |
|
|
195
|
-
| width | `number` | `32` | Grabber width according to M3 specs. |
|
|
196
|
-
| topOffset | `number` | `0` | Grabber top position offset. |
|
|
197
|
-
|
|
198
|
-
### `BlurTint`
|
|
199
|
-
|
|
200
|
-
Blur tint that is mapped into native values in IOS.
|
|
201
|
-
|
|
202
|
-
```tsx
|
|
203
|
-
<TrueSheet blurTint="dark">
|
|
204
|
-
// ...
|
|
205
|
-
</TrueSheet>
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
| Value |
|
|
209
|
-
| - |
|
|
210
|
-
| `"light"` |
|
|
211
|
-
| `"dark"` |
|
|
212
|
-
| `"default"` |
|
|
213
|
-
| `"extraLight"` |
|
|
214
|
-
| `"regular"` |
|
|
215
|
-
| `"prominent"` |
|
|
216
|
-
| `"systemUltraThinMaterial"` |
|
|
217
|
-
| `"systemThinMaterial"` |
|
|
218
|
-
| `"systemMaterial"` |
|
|
219
|
-
| `"systemThickMaterial"` |
|
|
220
|
-
| `"systemChromeMaterial"` |
|
|
221
|
-
| `"systemUltraThinMaterialLight"` |
|
|
222
|
-
| `"systemThinMaterialLight"` |
|
|
223
|
-
| `"systemMaterialLight"` |
|
|
224
|
-
| `"systemThickMaterialLight"` |
|
|
225
|
-
| `"systemChromeMaterialLight"` |
|
|
226
|
-
| `"systemUltraThinMaterialDark"` |
|
|
227
|
-
| `"systemThinMaterialDark"` |
|
|
228
|
-
| `"systemMaterialDark"` |
|
|
229
|
-
| `"systemThickMaterialDark"` |
|
|
230
|
-
| `"systemChromeMaterialDark"` |
|
|
231
|
-
|
|
232
|
-
### `SizeInfo`
|
|
233
|
-
|
|
234
|
-
`Object` that comes with some events.
|
|
235
|
-
|
|
236
|
-
```tsx
|
|
237
|
-
{
|
|
238
|
-
index: 1,
|
|
239
|
-
value: 69
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
| Property | Type | Description |
|
|
244
|
-
| - | - | - |
|
|
245
|
-
| index | `number` | The size index from the provided sizes. See `sizes` prop. |
|
|
246
|
-
| value | `number` | The actual height value of the size. |
|
|
247
|
-
|
|
248
|
-
## Testing
|
|
249
|
-
|
|
250
|
-
When using `jest`, simply mock the entire package.
|
|
251
|
-
|
|
252
|
-
```tsx
|
|
253
|
-
jest.mock('@lodev09/react-native-true-sheet')
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
## Troubleshooting
|
|
257
|
-
|
|
258
|
-
### Presenting a sheet on top of an existing sheet on **IOS**
|
|
259
|
-
|
|
260
|
-
On IOS, presenting a sheet on top of an existing sheet will cause error.
|
|
261
|
-
|
|
262
|
-
```console
|
|
263
|
-
Attempt to present <TrueSheet.TrueSheetViewController: 0x11829f800> on <UIViewController: 0x10900eb10> (from <RNSScreen: 0x117dbf400>) which is already presenting <TrueSheet.TrueSheetViewController: 0x11a0b9200>
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
There are _two_ ways to resolve this.
|
|
267
|
-
|
|
268
|
-
1. Dismiss the "parent" sheet first
|
|
269
|
-
```tsx
|
|
270
|
-
const presentSheet2 = async () => {
|
|
271
|
-
await sheet1.current?.dismiss() // Wait for sheet 1 to dismiss ✅
|
|
272
|
-
await sheet2.current?.present() // Sheet 2 will now present 🎉
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return (
|
|
276
|
-
<>
|
|
277
|
-
<TrueSheet ref={sheet1}>
|
|
278
|
-
<Button onPress={presentSheet2} title="Present Sheet 2" />
|
|
279
|
-
// ...
|
|
280
|
-
</TrueSheet>
|
|
281
|
-
|
|
282
|
-
<TrueSheet ref={sheet2}>
|
|
283
|
-
// ...
|
|
284
|
-
</TrueSheet>
|
|
285
|
-
</>
|
|
286
|
-
)
|
|
287
|
-
```
|
|
288
|
-
2. Define the 2nd sheet within the "parent" sheet. IOS handles this automatically by default 😎.
|
|
289
|
-
```tsx
|
|
290
|
-
const presentSheet2 = async () => {
|
|
291
|
-
await sheet2.current?.present() // Sheet 2 will now present 🎉
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return (
|
|
295
|
-
<TrueSheet ref={sheet1}>
|
|
296
|
-
<Button onPress={presentSheet2} title="Present Sheet 2" />
|
|
297
|
-
|
|
298
|
-
// ...
|
|
299
|
-
|
|
300
|
-
<TrueSheet ref={sheet2}>
|
|
301
|
-
// ...
|
|
302
|
-
</TrueSheet>
|
|
303
|
-
</TrueSheet>
|
|
304
|
-
)
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
### Handling `ScrollView` on **Android**
|
|
308
|
-
|
|
309
|
-
On Android, `nestedScrollEnabled` needs to be enabled so that scrolling works when the sheet is expanded to its `maxHeight`.
|
|
310
|
-
|
|
311
|
-
```tsx
|
|
312
|
-
<TrueSheet ref={sheet}>
|
|
313
|
-
<ScrollView nestedScrollEnabled>
|
|
314
|
-
// ...
|
|
315
|
-
</ScrollView>
|
|
316
|
-
</TrueSheet>
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
### Using `react-native-gesture-handler` on **Android**
|
|
320
|
-
|
|
321
|
-
On Android, RNGH does not work by default because modals are not located under React Native Root view in native hierarchy. To fix that, components need to be wrapped with `GestureHandlerRootView`.
|
|
322
|
-
|
|
323
|
-
Example:
|
|
324
|
-
```tsx
|
|
325
|
-
import { GestureHandlerRootView } from 'react-native-gesture-handler'
|
|
326
|
-
```
|
|
327
|
-
```tsx
|
|
328
|
-
return (
|
|
329
|
-
<TrueSheet ref={sheet}>
|
|
330
|
-
<GestureHandlerRootView>
|
|
331
|
-
// ...
|
|
332
|
-
</GestureHandlerRootView>
|
|
333
|
-
</TrueSheet>
|
|
334
|
-
)
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
### Integrating `@react-navigation/native` on **IOS**
|
|
338
|
-
|
|
339
|
-
On IOS, navigating to a [React Navigation](https://reactnavigation.org) screen from within the Sheet can cause issues. To resolve this, dismiss the sheet before navigating!
|
|
340
|
-
|
|
341
|
-
Example:
|
|
342
|
-
```tsx
|
|
343
|
-
const sheet = useRef<TrueSheet>(null)
|
|
344
|
-
|
|
345
|
-
const navigate = async () => {
|
|
346
|
-
await sheet.current?.dismiss() // wait for the sheet to dismiss ✅
|
|
347
|
-
navigation.navigate('SomeScreen') // navigate to the screen 🎉
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
return (
|
|
351
|
-
<TrueSheet ref={sheet}>
|
|
352
|
-
<Button onPress={navigate} title="Navigate to SomeScreen" />
|
|
353
|
-
// ...
|
|
354
|
-
</TrueSheet>
|
|
355
|
-
)
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
### Weird layout render
|
|
359
|
-
|
|
360
|
-
The sheet does not have control over how React Native renders components and may lead to rendering issues. To resolve this, try to minimize the use of `flex=1` in your content styles. Instead, use fixed `height` or employ `flexGrow`, `flexBasis`, etc., to manage your layout requirements.
|
|
361
|
-
|
|
362
65
|
## v1 Roadmap
|
|
363
66
|
|
|
364
67
|
- [ ] Inline sheet
|
|
@@ -18,9 +18,10 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
|
|
|
18
18
|
private var keyboardManager = KeyboardManager(reactContext)
|
|
19
19
|
|
|
20
20
|
var maxScreenHeight: Int = 0
|
|
21
|
+
var contentHeight: Int = 0
|
|
22
|
+
var footerHeight: Int = 0
|
|
21
23
|
var maxSheetHeight: Int? = null
|
|
22
24
|
|
|
23
|
-
var contentView: ViewGroup? = null
|
|
24
25
|
var footerView: ViewGroup? = null
|
|
25
26
|
|
|
26
27
|
var sizes: Array<Any> = arrayOf("medium", "large")
|
|
@@ -57,7 +58,7 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
|
|
|
57
58
|
|
|
58
59
|
fun positionFooter() {
|
|
59
60
|
footerView?.apply {
|
|
60
|
-
y = (maxScreenHeight - sheetView.top -
|
|
61
|
+
y = (maxScreenHeight - sheetView.top - footerHeight).toFloat()
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -71,7 +72,7 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
|
|
|
71
72
|
/**
|
|
72
73
|
* Get the height value based on the size config value.
|
|
73
74
|
*/
|
|
74
|
-
private fun getSizeHeight(size: Any
|
|
75
|
+
private fun getSizeHeight(size: Any): Int {
|
|
75
76
|
val height =
|
|
76
77
|
when (size) {
|
|
77
78
|
is Double -> Utils.toPixel(size)
|
|
@@ -80,7 +81,7 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
|
|
|
80
81
|
|
|
81
82
|
is String -> {
|
|
82
83
|
when (size) {
|
|
83
|
-
"auto" -> contentHeight
|
|
84
|
+
"auto" -> contentHeight + footerHeight
|
|
84
85
|
|
|
85
86
|
"large" -> maxScreenHeight
|
|
86
87
|
|
|
@@ -172,11 +173,6 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
|
|
|
172
173
|
* Configure the sheet based on size preferences.
|
|
173
174
|
*/
|
|
174
175
|
fun configure() {
|
|
175
|
-
var contentHeight = 0
|
|
176
|
-
|
|
177
|
-
contentView?.let { contentHeight = it.height }
|
|
178
|
-
footerView?.let { contentHeight += it.height }
|
|
179
|
-
|
|
180
176
|
// Configure sheet sizes
|
|
181
177
|
behavior.apply {
|
|
182
178
|
skipCollapsed = false
|
|
@@ -187,23 +183,22 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
|
|
|
187
183
|
|
|
188
184
|
when (sizes.size) {
|
|
189
185
|
1 -> {
|
|
190
|
-
maxHeight = getSizeHeight(sizes[0]
|
|
191
|
-
setPeekHeight(maxHeight, isShowing)
|
|
186
|
+
maxHeight = getSizeHeight(sizes[0])
|
|
192
187
|
skipCollapsed = true
|
|
193
188
|
}
|
|
194
189
|
|
|
195
190
|
2 -> {
|
|
196
|
-
setPeekHeight(getSizeHeight(sizes[0]
|
|
197
|
-
maxHeight = getSizeHeight(sizes[1]
|
|
191
|
+
setPeekHeight(getSizeHeight(sizes[0]), isShowing)
|
|
192
|
+
maxHeight = getSizeHeight(sizes[1])
|
|
198
193
|
}
|
|
199
194
|
|
|
200
195
|
3 -> {
|
|
201
196
|
// Enables half expanded
|
|
202
197
|
isFitToContents = false
|
|
203
198
|
|
|
204
|
-
setPeekHeight(getSizeHeight(sizes[0]
|
|
205
|
-
halfExpandedRatio = getSizeHeight(sizes[1]
|
|
206
|
-
maxHeight = getSizeHeight(sizes[2]
|
|
199
|
+
setPeekHeight(getSizeHeight(sizes[0]), isShowing)
|
|
200
|
+
halfExpandedRatio = getSizeHeight(sizes[1]).toFloat() / maxScreenHeight.toFloat()
|
|
201
|
+
maxHeight = getSizeHeight(sizes[2])
|
|
207
202
|
}
|
|
208
203
|
}
|
|
209
204
|
}
|
|
@@ -52,11 +52,6 @@ class TrueSheetView(context: Context) :
|
|
|
52
52
|
*/
|
|
53
53
|
private val rootSheetView: RootSheetView
|
|
54
54
|
|
|
55
|
-
/**
|
|
56
|
-
* 1st child of the container view.
|
|
57
|
-
*/
|
|
58
|
-
private var contentView: ViewGroup? = null
|
|
59
|
-
|
|
60
55
|
/**
|
|
61
56
|
* 2nd child of the container view.
|
|
62
57
|
*/
|
|
@@ -103,19 +98,17 @@ class TrueSheetView(context: Context) :
|
|
|
103
98
|
// dispatch onDismiss event
|
|
104
99
|
eventDispatcher?.dispatchEvent(DismissEvent(surfaceId, id))
|
|
105
100
|
}
|
|
106
|
-
}
|
|
107
101
|
|
|
108
|
-
|
|
109
|
-
sheetDialog.apply {
|
|
102
|
+
// Configure sheet behavior events
|
|
110
103
|
behavior.addBottomSheetCallback(
|
|
111
104
|
object : BottomSheetBehavior.BottomSheetCallback() {
|
|
112
105
|
override fun onSlide(sheetView: View, slideOffset: Float) {
|
|
113
106
|
footerView?.let {
|
|
114
|
-
val y = (maxScreenHeight - sheetView.top -
|
|
107
|
+
val y = (maxScreenHeight - sheetView.top - footerHeight).toFloat()
|
|
115
108
|
if (slideOffset >= 0) {
|
|
116
109
|
it.y = y
|
|
117
110
|
} else {
|
|
118
|
-
it.y = y -
|
|
111
|
+
it.y = y - footerHeight * slideOffset
|
|
119
112
|
}
|
|
120
113
|
}
|
|
121
114
|
}
|
|
@@ -165,10 +158,8 @@ class TrueSheetView(context: Context) :
|
|
|
165
158
|
|
|
166
159
|
(child as ViewGroup).let {
|
|
167
160
|
// Container View's first child is the Content View
|
|
168
|
-
contentView = it.getChildAt(0) as ViewGroup
|
|
169
161
|
footerView = it.getChildAt(1) as ViewGroup
|
|
170
162
|
|
|
171
|
-
sheetDialog.contentView = contentView
|
|
172
163
|
sheetDialog.footerView = footerView
|
|
173
164
|
|
|
174
165
|
// rootView's first child is the Container View
|
|
@@ -218,18 +209,26 @@ class TrueSheetView(context: Context) :
|
|
|
218
209
|
sheetDialog.dismiss()
|
|
219
210
|
}
|
|
220
211
|
|
|
221
|
-
private fun
|
|
212
|
+
private fun configureIfShowing() {
|
|
222
213
|
if (sheetDialog.isShowing) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
sheetDialog.positionFooter()
|
|
226
|
-
}
|
|
214
|
+
sheetDialog.configure()
|
|
215
|
+
sheetDialog.positionFooter()
|
|
227
216
|
}
|
|
228
217
|
}
|
|
229
218
|
|
|
230
219
|
fun setMaxHeight(height: Int) {
|
|
231
220
|
sheetDialog.maxSheetHeight = height
|
|
232
|
-
|
|
221
|
+
configureIfShowing()
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
fun setContentHeight(height: Int) {
|
|
225
|
+
sheetDialog.contentHeight = height
|
|
226
|
+
configureIfShowing()
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
fun setFooterHeight(height: Int) {
|
|
230
|
+
sheetDialog.footerHeight = height
|
|
231
|
+
configureIfShowing()
|
|
233
232
|
}
|
|
234
233
|
|
|
235
234
|
fun setDismissible(dismissible: Boolean) {
|
|
@@ -239,7 +238,7 @@ class TrueSheetView(context: Context) :
|
|
|
239
238
|
|
|
240
239
|
fun setSizes(newSizes: Array<Any>) {
|
|
241
240
|
sheetDialog.sizes = newSizes
|
|
242
|
-
|
|
241
|
+
configureIfShowing()
|
|
243
242
|
}
|
|
244
243
|
|
|
245
244
|
/**
|
|
@@ -39,6 +39,16 @@ class TrueSheetViewManager : ViewGroupManager<TrueSheetView>() {
|
|
|
39
39
|
view.setDismissible(dismissible)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
@ReactProp(name = "contentHeight")
|
|
43
|
+
fun setContentHeight(view: TrueSheetView, height: Double) {
|
|
44
|
+
view.setContentHeight(Utils.toPixel(height))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@ReactProp(name = "footerHeight")
|
|
48
|
+
fun setFooterHeight(view: TrueSheetView, height: Double) {
|
|
49
|
+
view.setFooterHeight(Utils.toPixel(height))
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
@ReactProp(name = "sizes")
|
|
43
53
|
fun setSizes(view: TrueSheetView, sizes: ReadableArray) {
|
|
44
54
|
val result = ArrayList<Any>()
|
package/ios/TrueSheetView.swift
CHANGED
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
11
11
|
// MARK: - React properties
|
|
12
12
|
|
|
13
|
-
var maxHeight: CGFloat?
|
|
14
|
-
|
|
15
13
|
// Events
|
|
16
14
|
@objc var onDismiss: RCTDirectEventBlock?
|
|
17
15
|
@objc var onPresent: RCTDirectEventBlock?
|
|
@@ -40,24 +38,6 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
40
38
|
|
|
41
39
|
private var rctScrollView: RCTScrollView?
|
|
42
40
|
|
|
43
|
-
// Content height minus the footer height for `auto` layout
|
|
44
|
-
private var contentHeight: CGFloat {
|
|
45
|
-
guard let contentView else { return 0 }
|
|
46
|
-
|
|
47
|
-
var height = contentView.frame.height
|
|
48
|
-
|
|
49
|
-
// Add footer view's height
|
|
50
|
-
if let footerContent = footerView?.subviews.first {
|
|
51
|
-
height += footerContent.bounds.height
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Exclude bottom safe area for consistency with a Scrollable content
|
|
55
|
-
let window = UIApplication.shared.windows.first(where: { $0.isKeyWindow })
|
|
56
|
-
let bottomInset = window?.safeAreaInsets.bottom ?? 0
|
|
57
|
-
|
|
58
|
-
return height - bottomInset
|
|
59
|
-
}
|
|
60
|
-
|
|
61
41
|
// MARK: - Setup
|
|
62
42
|
|
|
63
43
|
init(with bridge: RCTBridge) {
|
|
@@ -127,7 +107,7 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
127
107
|
}
|
|
128
108
|
|
|
129
109
|
// Update content containers
|
|
130
|
-
|
|
110
|
+
setupScrollable()
|
|
131
111
|
}
|
|
132
112
|
}
|
|
133
113
|
|
|
@@ -158,14 +138,10 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
158
138
|
|
|
159
139
|
let size = CGSize(width: width, height: containerView.bounds.height)
|
|
160
140
|
bridge.uiManager.setSize(size, for: containerView)
|
|
161
|
-
|
|
162
|
-
if let footerView {
|
|
163
|
-
bridge.uiManager.setSize(size, for: footerView)
|
|
164
|
-
}
|
|
165
141
|
}
|
|
166
142
|
|
|
167
143
|
func viewControllerWillAppear() {
|
|
168
|
-
|
|
144
|
+
setupScrollable()
|
|
169
145
|
}
|
|
170
146
|
|
|
171
147
|
func viewControllerDidDismiss() {
|
|
@@ -199,6 +175,35 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
199
175
|
configureSheetIfPresented()
|
|
200
176
|
}
|
|
201
177
|
|
|
178
|
+
@objc
|
|
179
|
+
func setContentHeight(_ height: NSNumber) {
|
|
180
|
+
// Exclude bottom safe area for consistency with a Scrollable content
|
|
181
|
+
let window = UIApplication.shared.windows.first(where: { $0.isKeyWindow })
|
|
182
|
+
let bottomInset = window?.safeAreaInsets.bottom ?? 0
|
|
183
|
+
|
|
184
|
+
viewController.contentHeight = CGFloat(height.floatValue) - bottomInset
|
|
185
|
+
configureSheetIfPresented()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@objc
|
|
189
|
+
func setFooterHeight(_ height: NSNumber) {
|
|
190
|
+
guard let footerView, let footerViewHeightConstraint else {
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
viewController.footerHeight = CGFloat(height.floatValue)
|
|
195
|
+
|
|
196
|
+
if footerView.subviews.first != nil {
|
|
197
|
+
containerView?.bringSubviewToFront(footerView)
|
|
198
|
+
footerViewHeightConstraint.constant = viewController.footerHeight
|
|
199
|
+
} else {
|
|
200
|
+
containerView?.sendSubviewToBack(footerView)
|
|
201
|
+
footerViewHeightConstraint.constant = 0
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
configureSheetIfPresented()
|
|
205
|
+
}
|
|
206
|
+
|
|
202
207
|
@objc
|
|
203
208
|
func setSizes(_ sizes: [Any]) {
|
|
204
209
|
viewController.sizes = Array(sizes.prefix(3))
|
|
@@ -224,7 +229,7 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
224
229
|
|
|
225
230
|
viewController.cornerRadius = cornerRadius
|
|
226
231
|
if #available(iOS 15.0, *) {
|
|
227
|
-
|
|
232
|
+
configureIfPresented { sheet in
|
|
228
233
|
sheet.preferredCornerRadius = viewController.cornerRadius
|
|
229
234
|
}
|
|
230
235
|
}
|
|
@@ -234,7 +239,7 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
234
239
|
func setGrabber(_ visible: Bool) {
|
|
235
240
|
viewController.grabber = visible
|
|
236
241
|
if #available(iOS 15.0, *) {
|
|
237
|
-
|
|
242
|
+
configureIfPresented { sheet in
|
|
238
243
|
sheet.prefersGrabberVisible = visible
|
|
239
244
|
}
|
|
240
245
|
}
|
|
@@ -258,7 +263,7 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
258
263
|
|
|
259
264
|
/// Use to customize some properties of the Sheet
|
|
260
265
|
@available(iOS 15.0, *)
|
|
261
|
-
func
|
|
266
|
+
func configureIfPresented(completion: (UISheetPresentationController) -> Void) {
|
|
262
267
|
guard isPresented, let sheet = viewController.sheetPresentationController else {
|
|
263
268
|
return
|
|
264
269
|
}
|
|
@@ -269,11 +274,11 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
269
274
|
/// Full reconfiguration of the Sheet
|
|
270
275
|
func configureSheetIfPresented() {
|
|
271
276
|
if isPresented {
|
|
272
|
-
viewController.configureSheet(at: activeIndex ?? 0,
|
|
277
|
+
viewController.configureSheet(at: activeIndex ?? 0, nil)
|
|
273
278
|
}
|
|
274
279
|
}
|
|
275
280
|
|
|
276
|
-
func
|
|
281
|
+
func setupScrollable() {
|
|
277
282
|
guard let contentView, let containerView else { return }
|
|
278
283
|
|
|
279
284
|
// Add constraints to fix weirdness and support ScrollView
|
|
@@ -281,16 +286,6 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
281
286
|
contentView.pinTo(view: containerView, constraints: nil)
|
|
282
287
|
rctScrollView.pinTo(view: contentView, constraints: nil)
|
|
283
288
|
}
|
|
284
|
-
|
|
285
|
-
if let footerView, let footerViewHeightConstraint {
|
|
286
|
-
if let footerContent = footerView.subviews.first {
|
|
287
|
-
containerView.bringSubviewToFront(footerView)
|
|
288
|
-
footerViewHeightConstraint.constant = footerContent.bounds.height
|
|
289
|
-
} else {
|
|
290
|
-
containerView.sendSubviewToBack(footerView)
|
|
291
|
-
footerViewHeightConstraint.constant = 0
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
289
|
}
|
|
295
290
|
|
|
296
291
|
func dismiss(promise: Promise) {
|
|
@@ -317,7 +312,7 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
|
|
|
317
312
|
return
|
|
318
313
|
}
|
|
319
314
|
|
|
320
|
-
viewController.configureSheet(at: index
|
|
315
|
+
viewController.configureSheet(at: index) { sizeInfo in
|
|
321
316
|
// Trigger onSizeChange event when size is changed while presenting
|
|
322
317
|
if self.isPresented {
|
|
323
318
|
self.viewControllerSheetDidChangeSize(sizeInfo)
|
|
@@ -36,7 +36,11 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe
|
|
|
36
36
|
var detentValues: [String: SizeInfo] = [:]
|
|
37
37
|
|
|
38
38
|
var sizes: [Any] = ["medium", "large"]
|
|
39
|
+
|
|
39
40
|
var maxHeight: CGFloat?
|
|
41
|
+
var contentHeight: CGFloat = 0
|
|
42
|
+
var footerHeight: CGFloat = 0
|
|
43
|
+
|
|
40
44
|
var cornerRadius: CGFloat?
|
|
41
45
|
var grabber = true
|
|
42
46
|
|
|
@@ -123,7 +127,7 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe
|
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
/// Prepares the view controller for sheet presentation
|
|
126
|
-
func configureSheet(at index: Int = 0,
|
|
130
|
+
func configureSheet(at index: Int = 0, _ completion: ((SizeInfo) -> Void)?) {
|
|
127
131
|
let defaultSizeInfo = SizeInfo(index: index, value: view.bounds.height)
|
|
128
132
|
|
|
129
133
|
guard #available(iOS 15.0, *), let sheet = sheetPresentationController else {
|
|
@@ -136,7 +140,7 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe
|
|
|
136
140
|
var detents: [UISheetPresentationController.Detent] = []
|
|
137
141
|
|
|
138
142
|
for (index, size) in sizes.enumerated() {
|
|
139
|
-
let detent = detentFor(size, with: contentHeight, with: maxHeight) { id, value in
|
|
143
|
+
let detent = detentFor(size, with: contentHeight + footerHeight, with: maxHeight) { id, value in
|
|
140
144
|
self.detentValues[id] = SizeInfo(index: index, value: value)
|
|
141
145
|
}
|
|
142
146
|
|
|
@@ -36,4 +36,8 @@ RCT_EXPORT_VIEW_PROPERTY(cornerRadius, NSNumber)
|
|
|
36
36
|
RCT_EXPORT_VIEW_PROPERTY(grabber, BOOL)
|
|
37
37
|
RCT_EXPORT_VIEW_PROPERTY(dismissible, BOOL)
|
|
38
38
|
|
|
39
|
+
// Internal properties
|
|
40
|
+
RCT_EXPORT_VIEW_PROPERTY(contentHeight, NSNumber)
|
|
41
|
+
RCT_EXPORT_VIEW_PROPERTY(footerHeight, NSNumber)
|
|
42
|
+
|
|
39
43
|
@end
|
|
@@ -33,7 +33,11 @@ class TrueSheet extends _react.PureComponent {
|
|
|
33
33
|
this.onDismiss = this.onDismiss.bind(this);
|
|
34
34
|
this.onPresent = this.onPresent.bind(this);
|
|
35
35
|
this.onSizeChange = this.onSizeChange.bind(this);
|
|
36
|
+
this.onContentLayout = this.onContentLayout.bind(this);
|
|
37
|
+
this.onFooterLayout = this.onFooterLayout.bind(this);
|
|
36
38
|
this.state = {
|
|
39
|
+
contentHeight: undefined,
|
|
40
|
+
footerHeight: undefined,
|
|
37
41
|
scrollableHandle: null
|
|
38
42
|
};
|
|
39
43
|
}
|
|
@@ -95,6 +99,17 @@ class TrueSheet extends _react.PureComponent {
|
|
|
95
99
|
onPresent(event) {
|
|
96
100
|
this.props.onPresent?.(event.nativeEvent);
|
|
97
101
|
}
|
|
102
|
+
onFooterLayout(layout) {
|
|
103
|
+
console.log('footerHeight', layout.height);
|
|
104
|
+
this.setState({
|
|
105
|
+
footerHeight: layout.height
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
onContentLayout(layout) {
|
|
109
|
+
this.setState({
|
|
110
|
+
contentHeight: layout.height
|
|
111
|
+
});
|
|
112
|
+
}
|
|
98
113
|
onDismiss() {
|
|
99
114
|
this.props.onDismiss?.();
|
|
100
115
|
}
|
|
@@ -153,6 +168,8 @@ class TrueSheet extends _react.PureComponent {
|
|
|
153
168
|
sizes: sizes,
|
|
154
169
|
blurTint: blurTint,
|
|
155
170
|
cornerRadius: cornerRadius,
|
|
171
|
+
contentHeight: this.state.contentHeight,
|
|
172
|
+
footerHeight: this.state.footerHeight,
|
|
156
173
|
grabber: grabber,
|
|
157
174
|
dismissible: dismissible,
|
|
158
175
|
maxHeight: maxHeight,
|
|
@@ -176,9 +193,11 @@ class TrueSheet extends _react.PureComponent {
|
|
|
176
193
|
}, style]
|
|
177
194
|
}, rest), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
178
195
|
collapsable: false,
|
|
196
|
+
onLayout: e => this.onContentLayout(e.nativeEvent.layout),
|
|
179
197
|
style: contentContainerStyle
|
|
180
198
|
}, children), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
181
|
-
collapsable: false
|
|
199
|
+
collapsable: false,
|
|
200
|
+
onLayout: e => this.onFooterLayout(e.nativeEvent.layout)
|
|
182
201
|
}, /*#__PURE__*/_react.default.createElement(_TrueSheetFooter.TrueSheetFooter, {
|
|
183
202
|
Component: FooterComponent
|
|
184
203
|
})), _reactNative.Platform.OS === 'android' && /*#__PURE__*/_react.default.createElement(_TrueSheetGrabber.TrueSheetGrabber, _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_TrueSheetModule","_TrueSheetGrabber","_TrueSheetFooter","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","NATIVE_COMPONENT_NAME","LINKING_ERROR","Platform","select","ios","TrueSheetNativeView","requireNativeComponent","Error","TrueSheet","PureComponent","displayName","handles","constructor","props","ref","createRef","onDismiss","onPresent","onSizeChange","state","scrollableHandle","getHandle","name","handle","console","warn","present","index","TrueSheetModule","dismiss","resize","nodeHandle","findNodeHandle","current","updateState","scrollRef","setState","event","nativeEvent","componentDidMount","sizes","componentDidUpdate","render","backgroundColor","dismissible","grabber","grabberProps","blurTint","cornerRadius","maxHeight","FooterComponent","style","contentContainerStyle","children","rest","createElement","$nativeSheet","View","collapsable","overflow","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_TrueSheetModule","_TrueSheetGrabber","_TrueSheetFooter","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","NATIVE_COMPONENT_NAME","LINKING_ERROR","Platform","select","ios","TrueSheetNativeView","requireNativeComponent","Error","TrueSheet","PureComponent","displayName","handles","constructor","props","ref","createRef","onDismiss","onPresent","onSizeChange","onContentLayout","onFooterLayout","state","contentHeight","undefined","footerHeight","scrollableHandle","getHandle","name","handle","console","warn","present","index","TrueSheetModule","dismiss","resize","nodeHandle","findNodeHandle","current","updateState","scrollRef","setState","event","nativeEvent","layout","log","height","componentDidMount","sizes","componentDidUpdate","render","backgroundColor","dismissible","grabber","grabberProps","blurTint","cornerRadius","maxHeight","FooterComponent","style","contentContainerStyle","children","rest","createElement","$nativeSheet","View","collapsable","overflow","android","borderTopLeftRadius","borderTopRightRadius","onLayout","TrueSheetFooter","Component","OS","TrueSheetGrabber","visible","exports","position","left","zIndex"],"sourceRoot":"../../src","sources":["TrueSheet.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAYA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAAmD,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,C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d,YAAY;QAElC;QACAL,eAAe,EAAEjD,qBAAQ,CAACC,MAAM,CAAC;UAC/BC,GAAG,EAAEmD,QAAQ,GAAGhC,SAAS,GAAG4B,eAAe;UAC3CiB,OAAO,EAAEjB;QACX,CAAC;MACH,CAAC,EACDQ,KAAK;IACL,GACEG,IAAI,gBAERnG,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAACjG,YAAA,CAAAmG,IAAI;MACHC,WAAW,EAAE,KAAM;MACnBK,QAAQ,EAAGpG,CAAC,IAAK,IAAI,CAACgD,eAAe,CAAChD,CAAC,CAACwE,WAAW,CAACC,MAAM,CAAE;MAC5De,KAAK,EAAEC;IAAsB,GAE5BC,QACG,CAAC,eACPlG,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAACjG,YAAA,CAAAmG,IAAI;MAACC,WAAW,EAAE,KAAM;MAACK,QAAQ,EAAGpG,CAAC,IAAK,IAAI,CAACiD,cAAc,CAACjD,CAAC,CAACwE,WAAW,CAACC,MAAM;IAAE,gBACnFjF,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAAC9F,gBAAA,CAAAuG,eAAe;MAACC,SAAS,EAAEf;IAAgB,CAAE,CAC1C,CAAC,EACNxD,qBAAQ,CAACwE,EAAE,KAAK,SAAS,iBAAI/G,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAAC/F,iBAAA,CAAA2G,gBAAgB,EAAApF,QAAA;MAACqF,OAAO,EAAEvB;IAAQ,GAAKC,YAAY,CAAG,CACjF,CACa,CAAC;EAE1B;AACF;AAACuB,OAAA,CAAArE,SAAA,GAAAA,SAAA;AAED,MAAMwD,YAAuB,GAAG;EAC9Bc,QAAQ,EAAE,UAAU;EACpBC,IAAI,EAAE,CAAC,IAAI;EACXC,MAAM,EAAE,CAAC;AACX,CAAC","ignoreList":[]}
|
package/lib/module/TrueSheet.js
CHANGED
|
@@ -25,7 +25,11 @@ export class TrueSheet extends PureComponent {
|
|
|
25
25
|
this.onDismiss = this.onDismiss.bind(this);
|
|
26
26
|
this.onPresent = this.onPresent.bind(this);
|
|
27
27
|
this.onSizeChange = this.onSizeChange.bind(this);
|
|
28
|
+
this.onContentLayout = this.onContentLayout.bind(this);
|
|
29
|
+
this.onFooterLayout = this.onFooterLayout.bind(this);
|
|
28
30
|
this.state = {
|
|
31
|
+
contentHeight: undefined,
|
|
32
|
+
footerHeight: undefined,
|
|
29
33
|
scrollableHandle: null
|
|
30
34
|
};
|
|
31
35
|
}
|
|
@@ -87,6 +91,17 @@ export class TrueSheet extends PureComponent {
|
|
|
87
91
|
onPresent(event) {
|
|
88
92
|
this.props.onPresent?.(event.nativeEvent);
|
|
89
93
|
}
|
|
94
|
+
onFooterLayout(layout) {
|
|
95
|
+
console.log('footerHeight', layout.height);
|
|
96
|
+
this.setState({
|
|
97
|
+
footerHeight: layout.height
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
onContentLayout(layout) {
|
|
101
|
+
this.setState({
|
|
102
|
+
contentHeight: layout.height
|
|
103
|
+
});
|
|
104
|
+
}
|
|
90
105
|
onDismiss() {
|
|
91
106
|
this.props.onDismiss?.();
|
|
92
107
|
}
|
|
@@ -145,6 +160,8 @@ export class TrueSheet extends PureComponent {
|
|
|
145
160
|
sizes: sizes,
|
|
146
161
|
blurTint: blurTint,
|
|
147
162
|
cornerRadius: cornerRadius,
|
|
163
|
+
contentHeight: this.state.contentHeight,
|
|
164
|
+
footerHeight: this.state.footerHeight,
|
|
148
165
|
grabber: grabber,
|
|
149
166
|
dismissible: dismissible,
|
|
150
167
|
maxHeight: maxHeight,
|
|
@@ -168,9 +185,11 @@ export class TrueSheet extends PureComponent {
|
|
|
168
185
|
}, style]
|
|
169
186
|
}, rest), /*#__PURE__*/React.createElement(View, {
|
|
170
187
|
collapsable: false,
|
|
188
|
+
onLayout: e => this.onContentLayout(e.nativeEvent.layout),
|
|
171
189
|
style: contentContainerStyle
|
|
172
190
|
}, children), /*#__PURE__*/React.createElement(View, {
|
|
173
|
-
collapsable: false
|
|
191
|
+
collapsable: false,
|
|
192
|
+
onLayout: e => this.onFooterLayout(e.nativeEvent.layout)
|
|
174
193
|
}, /*#__PURE__*/React.createElement(TrueSheetFooter, {
|
|
175
194
|
Component: FooterComponent
|
|
176
195
|
})), Platform.OS === 'android' && /*#__PURE__*/React.createElement(TrueSheetGrabber, _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","PureComponent","createRef","requireNativeComponent","Platform","findNodeHandle","View","TrueSheetModule","TrueSheetGrabber","TrueSheetFooter","NATIVE_COMPONENT_NAME","LINKING_ERROR","select","ios","default","TrueSheetNativeView","Error","TrueSheet","displayName","handles","constructor","props","ref","onDismiss","bind","onPresent","onSizeChange","state","scrollableHandle","getHandle","name","handle","console","warn","present","index","dismiss","resize","nodeHandle","current","updateState","scrollRef","setState","event","nativeEvent","componentDidMount","sizes","length","componentDidUpdate","render","backgroundColor","dismissible","grabber","grabberProps","blurTint","cornerRadius","maxHeight","FooterComponent","style","contentContainerStyle","children","rest","createElement","$nativeSheet","_extends","collapsable","overflow","
|
|
1
|
+
{"version":3,"names":["React","PureComponent","createRef","requireNativeComponent","Platform","findNodeHandle","View","TrueSheetModule","TrueSheetGrabber","TrueSheetFooter","NATIVE_COMPONENT_NAME","LINKING_ERROR","select","ios","default","TrueSheetNativeView","Error","TrueSheet","displayName","handles","constructor","props","ref","onDismiss","bind","onPresent","onSizeChange","onContentLayout","onFooterLayout","state","contentHeight","undefined","footerHeight","scrollableHandle","getHandle","name","handle","console","warn","present","index","dismiss","resize","nodeHandle","current","updateState","scrollRef","setState","event","nativeEvent","layout","log","height","componentDidMount","sizes","length","componentDidUpdate","render","backgroundColor","dismissible","grabber","grabberProps","blurTint","cornerRadius","maxHeight","FooterComponent","style","contentContainerStyle","children","rest","createElement","$nativeSheet","_extends","collapsable","overflow","android","borderTopLeftRadius","borderTopRightRadius","onLayout","e","Component","OS","visible","position","left","zIndex"],"sourceRoot":"../../src","sources":["TrueSheet.tsx"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;AAEA,MAAMU,YAAuB,GAAG;EAC9BY,QAAQ,EAAE,UAAU;EACpBC,IAAI,EAAE,CAAC,IAAI;EACXC,MAAM,EAAE,CAAC;AACX,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docusaurus.config.d.ts","sourceRoot":"","sources":["../../../docs/docusaurus.config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAI/C,QAAA,MAAM,MAAM,EAAE,MA8Gb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebars.d.ts","sourceRoot":"","sources":["../../../docs/sidebars.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAErE,QAAA,MAAM,QAAQ,EAAE,cAOf,CAAA;AAED,eAAe,QAAQ,CAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PureComponent, type ReactNode } from 'react';
|
|
2
2
|
import type { TrueSheetProps } from './types';
|
|
3
3
|
interface TrueSheetState {
|
|
4
|
+
contentHeight?: number;
|
|
5
|
+
footerHeight?: number;
|
|
4
6
|
scrollableHandle: number | null;
|
|
5
7
|
}
|
|
6
8
|
export declare class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
@@ -31,6 +33,8 @@ export declare class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetSt
|
|
|
31
33
|
private updateState;
|
|
32
34
|
private onSizeChange;
|
|
33
35
|
private onPresent;
|
|
36
|
+
private onFooterLayout;
|
|
37
|
+
private onContentLayout;
|
|
34
38
|
private onDismiss;
|
|
35
39
|
/**
|
|
36
40
|
* Present the sheet. Optionally accepts a size `index`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrueSheet.d.ts","sourceRoot":"","sources":["../../../src/TrueSheet.tsx"],"names":[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AAC;IAIjD;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC,iBAAiB,IAAI,IAAI;IAUzB,kBAAkB,IAAI,IAAI;IAI1B,MAAM,IAAI,SAAS;CAmEpB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodev09/react-native-true-sheet",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The true native bottom sheet.
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "The true native bottom sheet experience for your React Native Apps.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
7
7
|
"types": "lib/typescript/src/index.d.ts",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
28
|
"example": "yarn workspace true-sheet-example",
|
|
29
|
+
"docs": "yarn workspace docs",
|
|
29
30
|
"test": "jest",
|
|
30
31
|
"typecheck": "tsc --noEmit",
|
|
31
32
|
"lint": "eslint --fix \"**/*.{js,ts,tsx}\"",
|
|
@@ -90,14 +91,17 @@
|
|
|
90
91
|
"react-native": "*"
|
|
91
92
|
},
|
|
92
93
|
"workspaces": [
|
|
93
|
-
"example"
|
|
94
|
+
"example",
|
|
95
|
+
"docs"
|
|
94
96
|
],
|
|
95
97
|
"packageManager": "yarn@4.1.1",
|
|
96
98
|
"jest": {
|
|
97
99
|
"preset": "react-native",
|
|
98
100
|
"modulePathIgnorePatterns": [
|
|
99
101
|
"<rootDir>/example/node_modules",
|
|
100
|
-
"<rootDir>/
|
|
102
|
+
"<rootDir>/docs/node_modules",
|
|
103
|
+
"<rootDir>/lib/",
|
|
104
|
+
"<rootDir>/docs/build"
|
|
101
105
|
]
|
|
102
106
|
},
|
|
103
107
|
"commitlint": {
|
|
@@ -129,10 +133,6 @@
|
|
|
129
133
|
},
|
|
130
134
|
"eslintConfig": {
|
|
131
135
|
"root": true,
|
|
132
|
-
"ignorePatterns": [
|
|
133
|
-
"lib",
|
|
134
|
-
"src/__mocks__"
|
|
135
|
-
],
|
|
136
136
|
"extends": [
|
|
137
137
|
"plugin:@typescript-eslint/recommended",
|
|
138
138
|
"eslint:recommended",
|
package/src/TrueSheet.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type NativeMethods,
|
|
8
8
|
type ViewStyle,
|
|
9
9
|
type NativeSyntheticEvent,
|
|
10
|
+
type LayoutRectangle,
|
|
10
11
|
} from 'react-native'
|
|
11
12
|
|
|
12
13
|
import type { TrueSheetProps, SizeInfo } from './types'
|
|
@@ -22,6 +23,8 @@ const LINKING_ERROR =
|
|
|
22
23
|
'- You are not using Expo Go\n'
|
|
23
24
|
|
|
24
25
|
interface TrueSheetNativeViewProps extends Omit<TrueSheetProps, 'onPresent' | 'onSizeChange'> {
|
|
26
|
+
contentHeight?: number
|
|
27
|
+
footerHeight?: number
|
|
25
28
|
scrollableHandle: number | null
|
|
26
29
|
onPresent: (event: NativeSyntheticEvent<SizeInfo>) => void
|
|
27
30
|
onSizeChange: (event: NativeSyntheticEvent<SizeInfo>) => void
|
|
@@ -30,6 +33,8 @@ interface TrueSheetNativeViewProps extends Omit<TrueSheetProps, 'onPresent' | 'o
|
|
|
30
33
|
type NativeRef = Component<TrueSheetNativeViewProps> & Readonly<NativeMethods>
|
|
31
34
|
|
|
32
35
|
interface TrueSheetState {
|
|
36
|
+
contentHeight?: number
|
|
37
|
+
footerHeight?: number
|
|
33
38
|
scrollableHandle: number | null
|
|
34
39
|
}
|
|
35
40
|
|
|
@@ -57,8 +62,12 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
57
62
|
this.onDismiss = this.onDismiss.bind(this)
|
|
58
63
|
this.onPresent = this.onPresent.bind(this)
|
|
59
64
|
this.onSizeChange = this.onSizeChange.bind(this)
|
|
65
|
+
this.onContentLayout = this.onContentLayout.bind(this)
|
|
66
|
+
this.onFooterLayout = this.onFooterLayout.bind(this)
|
|
60
67
|
|
|
61
68
|
this.state = {
|
|
69
|
+
contentHeight: undefined,
|
|
70
|
+
footerHeight: undefined,
|
|
62
71
|
scrollableHandle: null,
|
|
63
72
|
}
|
|
64
73
|
}
|
|
@@ -134,6 +143,19 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
134
143
|
this.props.onPresent?.(event.nativeEvent)
|
|
135
144
|
}
|
|
136
145
|
|
|
146
|
+
private onFooterLayout(layout: LayoutRectangle): void {
|
|
147
|
+
console.log('footerHeight', layout.height)
|
|
148
|
+
this.setState({
|
|
149
|
+
footerHeight: layout.height,
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private onContentLayout(layout: LayoutRectangle): void {
|
|
154
|
+
this.setState({
|
|
155
|
+
contentHeight: layout.height,
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
137
159
|
private onDismiss(): void {
|
|
138
160
|
this.props.onDismiss?.()
|
|
139
161
|
}
|
|
@@ -200,6 +222,8 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
200
222
|
sizes={sizes}
|
|
201
223
|
blurTint={blurTint}
|
|
202
224
|
cornerRadius={cornerRadius}
|
|
225
|
+
contentHeight={this.state.contentHeight}
|
|
226
|
+
footerHeight={this.state.footerHeight}
|
|
203
227
|
grabber={grabber}
|
|
204
228
|
dismissible={dismissible}
|
|
205
229
|
maxHeight={maxHeight}
|
|
@@ -225,10 +249,14 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
225
249
|
]}
|
|
226
250
|
{...rest}
|
|
227
251
|
>
|
|
228
|
-
<View
|
|
252
|
+
<View
|
|
253
|
+
collapsable={false}
|
|
254
|
+
onLayout={(e) => this.onContentLayout(e.nativeEvent.layout)}
|
|
255
|
+
style={contentContainerStyle}
|
|
256
|
+
>
|
|
229
257
|
{children}
|
|
230
258
|
</View>
|
|
231
|
-
<View collapsable={false}>
|
|
259
|
+
<View collapsable={false} onLayout={(e) => this.onFooterLayout(e.nativeEvent.layout)}>
|
|
232
260
|
<TrueSheetFooter Component={FooterComponent} />
|
|
233
261
|
</View>
|
|
234
262
|
{Platform.OS === 'android' && <TrueSheetGrabber visible={grabber} {...grabberProps} />}
|