@lodev09/react-native-true-sheet 3.0.0-beta.1 → 3.0.0-beta.11
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 +7 -21
- package/RNTrueSheet.podspec +5 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +58 -60
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +10 -18
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +76 -20
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderView.kt +38 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderViewManager.kt +21 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +1 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +132 -151
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +340 -401
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +24 -11
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +111 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +33 -5
- package/android/src/main/jni/CMakeLists.txt +87 -0
- package/android/src/main/jni/TrueSheetSpec.h +17 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewComponentDescriptor.h +24 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.cpp +46 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.h +28 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.cpp +11 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.h +42 -0
- package/ios/TrueSheetContainerView.h +23 -0
- package/ios/TrueSheetContainerView.mm +80 -13
- package/ios/TrueSheetContentView.h +9 -1
- package/ios/TrueSheetContentView.mm +102 -24
- package/ios/TrueSheetFooterView.mm +2 -2
- package/ios/TrueSheetHeaderView.h +29 -0
- package/ios/TrueSheetHeaderView.mm +60 -0
- package/ios/TrueSheetView.h +0 -16
- package/ios/TrueSheetView.mm +208 -194
- package/ios/TrueSheetViewController.h +4 -3
- package/ios/TrueSheetViewController.mm +180 -272
- package/ios/utils/ConversionUtil.h +24 -0
- package/ios/utils/ConversionUtil.mm +50 -0
- package/ios/utils/LayoutUtil.h +11 -1
- package/ios/utils/LayoutUtil.mm +32 -1
- package/lib/module/TrueSheet.js +42 -35
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/fabric/TrueSheetContainerViewNativeComponent.ts +1 -1
- package/lib/module/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +6 -8
- package/lib/typescript/src/TrueSheet.d.ts +0 -3
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +30 -43
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +3 -6
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/package.json +9 -5
- package/react-native.config.js +5 -2
- package/src/TrueSheet.tsx +49 -35
- package/src/TrueSheet.types.ts +47 -61
- package/src/fabric/TrueSheetContainerViewNativeComponent.ts +1 -1
- package/src/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetViewNativeComponent.ts +6 -8
- package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +0 -27
- package/ios/events/OnSizeChangeEvent.h +0 -28
- package/ios/events/OnSizeChangeEvent.mm +0 -30
|
@@ -9,17 +9,13 @@ export interface PositionChangeEventPayload {
|
|
|
9
9
|
position: Double;
|
|
10
10
|
transitioning: boolean;
|
|
11
11
|
}
|
|
12
|
-
export interface SizeChangeEventPayload {
|
|
13
|
-
width: Double;
|
|
14
|
-
height: Double;
|
|
15
|
-
}
|
|
16
12
|
export interface NativeProps extends ViewProps {
|
|
17
13
|
detents?: ReadonlyArray<Float>;
|
|
18
14
|
maxHeight?: WithDefault<Double, 0>;
|
|
19
15
|
background?: WithDefault<Int32, 0>;
|
|
20
16
|
cornerRadius?: WithDefault<Double, -1>;
|
|
21
17
|
initialDetentIndex?: WithDefault<Int32, -1>;
|
|
22
|
-
|
|
18
|
+
dimmedDetentIndex?: WithDefault<Int32, 0>;
|
|
23
19
|
blurTint?: WithDefault<string, ''>;
|
|
24
20
|
keyboardMode?: WithDefault<'resize' | 'pan', 'resize'>;
|
|
25
21
|
grabber?: WithDefault<boolean, true>;
|
|
@@ -27,6 +23,8 @@ export interface NativeProps extends ViewProps {
|
|
|
27
23
|
dimmed?: WithDefault<boolean, true>;
|
|
28
24
|
initialDetentAnimated?: WithDefault<boolean, true>;
|
|
29
25
|
edgeToEdgeFullScreen?: WithDefault<boolean, false>;
|
|
26
|
+
scrollable?: WithDefault<boolean, false>;
|
|
27
|
+
pageSizing?: WithDefault<boolean, true>;
|
|
30
28
|
onMount?: DirectEventHandler<null>;
|
|
31
29
|
onWillPresent?: DirectEventHandler<DetentInfoEventPayload>;
|
|
32
30
|
onDidPresent?: DirectEventHandler<DetentInfoEventPayload>;
|
|
@@ -37,7 +35,6 @@ export interface NativeProps extends ViewProps {
|
|
|
37
35
|
onDragChange?: DirectEventHandler<DetentInfoEventPayload>;
|
|
38
36
|
onDragEnd?: DirectEventHandler<DetentInfoEventPayload>;
|
|
39
37
|
onPositionChange?: DirectEventHandler<PositionChangeEventPayload>;
|
|
40
|
-
onSizeChange?: DirectEventHandler<SizeChangeEventPayload>;
|
|
41
38
|
}
|
|
42
39
|
declare const _default: import("react-native").HostComponent<NativeProps>;
|
|
43
40
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrueSheetViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/TrueSheetViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACN,KAAK,EACL,WAAW,EACX,KAAK,EACN,MAAM,2CAA2C,CAAC;AAGnD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"TrueSheetViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/TrueSheetViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACN,KAAK,EACL,WAAW,EACX,KAAK,EACN,MAAM,2CAA2C,CAAC;AAGnD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAE5C,OAAO,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAG/B,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACvC,kBAAkB,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,iBAAiB,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAG1C,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,WAAW,CAAC,QAAQ,GAAG,KAAK,EAAE,QAAQ,CAAC,CAAC;IAGvD,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpC,qBAAqB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnD,oBAAoB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzC,UAAU,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAGxC,OAAO,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACnC,aAAa,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC3D,YAAY,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC1D,aAAa,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACxC,cAAc,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC5D,WAAW,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IACzD,YAAY,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC1D,SAAS,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IACvD,gBAAgB,CAAC,EAAE,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;CACnE;;AAED,wBAEG"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodev09/react-native-true-sheet",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.11",
|
|
4
4
|
"description": "The true native bottom sheet experience for your React Native Apps.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
7
7
|
"types": "./lib/typescript/src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"source": "./src/index.
|
|
10
|
+
"source": "./src/index.ts",
|
|
11
11
|
"types": "./lib/typescript/src/index.d.ts",
|
|
12
12
|
"default": "./lib/module/index.js"
|
|
13
13
|
},
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"lib",
|
|
19
19
|
"android",
|
|
20
20
|
"ios",
|
|
21
|
-
"
|
|
21
|
+
"common",
|
|
22
22
|
"*.podspec",
|
|
23
23
|
"react-native.config.js",
|
|
24
24
|
"!ios/build",
|
|
@@ -38,10 +38,11 @@
|
|
|
38
38
|
"typecheck": "tsc",
|
|
39
39
|
"lint": "eslint --fix \"**/*.{ts,tsx}\"",
|
|
40
40
|
"format": "prettier --write \"**/*.{ts,tsx}\"",
|
|
41
|
-
"tidy": "yarn typecheck && yarn lint && yarn format && scripts/
|
|
41
|
+
"tidy": "yarn typecheck && yarn lint && yarn format && scripts/objclint.sh && scripts/ktlint.sh",
|
|
42
42
|
"clean": "scripts/clean.sh",
|
|
43
43
|
"prepare": "bob build",
|
|
44
|
-
"release": "yarn tidy && release-it --only-version"
|
|
44
|
+
"release": "yarn tidy && release-it --only-version",
|
|
45
|
+
"release:beta": "yarn release --preRelease=beta"
|
|
45
46
|
},
|
|
46
47
|
"keywords": [
|
|
47
48
|
"react-native",
|
|
@@ -222,6 +223,9 @@
|
|
|
222
223
|
"TrueSheetContentView": {
|
|
223
224
|
"className": "TrueSheetContentView"
|
|
224
225
|
},
|
|
226
|
+
"TrueSheetHeaderView": {
|
|
227
|
+
"className": "TrueSheetHeaderView"
|
|
228
|
+
},
|
|
225
229
|
"TrueSheetFooterView": {
|
|
226
230
|
"className": "TrueSheetFooterView"
|
|
227
231
|
}
|
package/react-native.config.js
CHANGED
|
@@ -2,7 +2,10 @@ module.exports = {
|
|
|
2
2
|
dependency: {
|
|
3
3
|
platforms: {
|
|
4
4
|
ios: {},
|
|
5
|
-
android: {
|
|
5
|
+
android: {
|
|
6
|
+
componentDescriptors: ['TrueSheetViewComponentDescriptor'],
|
|
7
|
+
cmakeListsPath: '../android/src/main/jni/CMakeLists.txt',
|
|
8
|
+
},
|
|
6
9
|
},
|
|
7
10
|
},
|
|
8
11
|
dependencies: {
|
|
@@ -14,4 +17,4 @@ module.exports = {
|
|
|
14
17
|
},
|
|
15
18
|
},
|
|
16
19
|
},
|
|
17
|
-
}
|
|
20
|
+
};
|
package/src/TrueSheet.tsx
CHANGED
|
@@ -20,11 +20,11 @@ import type {
|
|
|
20
20
|
DidDismissEvent,
|
|
21
21
|
WillDismissEvent,
|
|
22
22
|
MountEvent,
|
|
23
|
-
SizeChangeEvent,
|
|
24
23
|
} from './TrueSheet.types';
|
|
25
24
|
import TrueSheetViewNativeComponent from './fabric/TrueSheetViewNativeComponent';
|
|
26
25
|
import TrueSheetContainerViewNativeComponent from './fabric/TrueSheetContainerViewNativeComponent';
|
|
27
26
|
import TrueSheetContentViewNativeComponent from './fabric/TrueSheetContentViewNativeComponent';
|
|
27
|
+
import TrueSheetHeaderViewNativeComponent from './fabric/TrueSheetHeaderViewNativeComponent';
|
|
28
28
|
import TrueSheetFooterViewNativeComponent from './fabric/TrueSheetFooterViewNativeComponent';
|
|
29
29
|
|
|
30
30
|
import TrueSheetModule from './specs/NativeTrueSheetModule';
|
|
@@ -46,8 +46,6 @@ type NativeRef = ComponentRef<typeof TrueSheetViewNativeComponent>;
|
|
|
46
46
|
|
|
47
47
|
interface TrueSheetState {
|
|
48
48
|
shouldRenderNativeView: boolean;
|
|
49
|
-
containerWidth?: number;
|
|
50
|
-
containerHeight?: number;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
@@ -78,8 +76,6 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
78
76
|
|
|
79
77
|
this.state = {
|
|
80
78
|
shouldRenderNativeView: shouldRenderImmediately,
|
|
81
|
-
containerWidth: undefined,
|
|
82
|
-
containerHeight: undefined,
|
|
83
79
|
};
|
|
84
80
|
|
|
85
81
|
this.onMount = this.onMount.bind(this);
|
|
@@ -92,7 +88,6 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
92
88
|
this.onDragChange = this.onDragChange.bind(this);
|
|
93
89
|
this.onDragEnd = this.onDragEnd.bind(this);
|
|
94
90
|
this.onPositionChange = this.onPositionChange.bind(this);
|
|
95
|
-
this.onSizeChange = this.onSizeChange.bind(this);
|
|
96
91
|
}
|
|
97
92
|
|
|
98
93
|
private validateDetents(): void {
|
|
@@ -255,18 +250,6 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
255
250
|
this.props.onPositionChange?.(event);
|
|
256
251
|
}
|
|
257
252
|
|
|
258
|
-
private onSizeChange(event: SizeChangeEvent): void {
|
|
259
|
-
const { width, height } = event.nativeEvent;
|
|
260
|
-
|
|
261
|
-
// Update container view dimensions in state
|
|
262
|
-
this.setState({
|
|
263
|
-
containerWidth: width,
|
|
264
|
-
containerHeight: height,
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
// Internal handler only - not exposed to users
|
|
268
|
-
}
|
|
269
|
-
|
|
270
253
|
/**
|
|
271
254
|
* Present the Sheet by `index` (Promise-based)
|
|
272
255
|
* @param index - Detent index (default: 0)
|
|
@@ -328,22 +311,25 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
328
311
|
render(): ReactNode {
|
|
329
312
|
const {
|
|
330
313
|
detents = [0.5, 1],
|
|
331
|
-
backgroundColor
|
|
314
|
+
backgroundColor,
|
|
332
315
|
dismissible = true,
|
|
333
316
|
grabber = true,
|
|
334
317
|
dimmed = true,
|
|
335
318
|
initialDetentIndex = -1,
|
|
336
319
|
initialDetentAnimated = true,
|
|
337
320
|
keyboardMode = 'resize',
|
|
338
|
-
|
|
321
|
+
dimmedDetentIndex,
|
|
339
322
|
blurTint,
|
|
340
323
|
cornerRadius,
|
|
341
324
|
maxHeight,
|
|
342
325
|
edgeToEdgeFullScreen,
|
|
326
|
+
scrollable = false,
|
|
327
|
+
pageSizing = true,
|
|
343
328
|
children,
|
|
344
329
|
style,
|
|
330
|
+
header,
|
|
345
331
|
footer,
|
|
346
|
-
|
|
332
|
+
...rest
|
|
347
333
|
} = this.props;
|
|
348
334
|
|
|
349
335
|
// Trim to max 3 detents and clamp fractions
|
|
@@ -357,8 +343,21 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
357
343
|
return Math.min(1, detent);
|
|
358
344
|
});
|
|
359
345
|
|
|
346
|
+
const containerStyle =
|
|
347
|
+
this.props.scrollable &&
|
|
348
|
+
Platform.select({
|
|
349
|
+
android: styles.scrollableAndroidContainer,
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
const contentStyle =
|
|
353
|
+
this.props.scrollable &&
|
|
354
|
+
Platform.select({
|
|
355
|
+
android: styles.scrollableContent,
|
|
356
|
+
});
|
|
357
|
+
|
|
360
358
|
return (
|
|
361
359
|
<TrueSheetViewNativeComponent
|
|
360
|
+
{...rest}
|
|
362
361
|
ref={this.nativeRef}
|
|
363
362
|
style={styles.sheetView}
|
|
364
363
|
detents={resolvedDetents}
|
|
@@ -367,13 +366,15 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
367
366
|
cornerRadius={cornerRadius}
|
|
368
367
|
grabber={grabber}
|
|
369
368
|
dimmed={dimmed}
|
|
370
|
-
|
|
369
|
+
dimmedDetentIndex={dimmedDetentIndex}
|
|
371
370
|
keyboardMode={keyboardMode}
|
|
372
371
|
initialDetentIndex={initialDetentIndex}
|
|
373
372
|
initialDetentAnimated={initialDetentAnimated}
|
|
374
373
|
dismissible={dismissible}
|
|
375
374
|
maxHeight={maxHeight}
|
|
376
375
|
edgeToEdgeFullScreen={edgeToEdgeFullScreen}
|
|
376
|
+
scrollable={scrollable}
|
|
377
|
+
pageSizing={pageSizing}
|
|
377
378
|
onMount={this.onMount}
|
|
378
379
|
onWillPresent={this.onWillPresent}
|
|
379
380
|
onDidPresent={this.onDidPresent}
|
|
@@ -384,22 +385,19 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
384
385
|
onDragChange={this.onDragChange}
|
|
385
386
|
onDragEnd={this.onDragEnd}
|
|
386
387
|
onPositionChange={this.onPositionChange}
|
|
387
|
-
onSizeChange={this.onSizeChange}
|
|
388
388
|
>
|
|
389
389
|
{this.state.shouldRenderNativeView && (
|
|
390
|
-
<TrueSheetContainerViewNativeComponent
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
>
|
|
398
|
-
<TrueSheetContentViewNativeComponent style={style} collapsable={false}>
|
|
390
|
+
<TrueSheetContainerViewNativeComponent style={containerStyle}>
|
|
391
|
+
{header && (
|
|
392
|
+
<TrueSheetHeaderViewNativeComponent>
|
|
393
|
+
{isValidElement(header) ? header : createElement(header)}
|
|
394
|
+
</TrueSheetHeaderViewNativeComponent>
|
|
395
|
+
)}
|
|
396
|
+
<TrueSheetContentViewNativeComponent style={[style, contentStyle]}>
|
|
399
397
|
{children}
|
|
400
398
|
</TrueSheetContentViewNativeComponent>
|
|
401
399
|
{footer && (
|
|
402
|
-
<TrueSheetFooterViewNativeComponent style={styles.footer}
|
|
400
|
+
<TrueSheetFooterViewNativeComponent style={styles.footer}>
|
|
403
401
|
{isValidElement(footer) ? footer : createElement(footer)}
|
|
404
402
|
</TrueSheetFooterViewNativeComponent>
|
|
405
403
|
)}
|
|
@@ -412,9 +410,25 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
412
410
|
|
|
413
411
|
const styles = StyleSheet.create({
|
|
414
412
|
sheetView: {
|
|
415
|
-
position: 'absolute',
|
|
416
|
-
width: '100%',
|
|
417
413
|
zIndex: -9999,
|
|
414
|
+
position: 'absolute',
|
|
415
|
+
top: 0,
|
|
416
|
+
left: 0,
|
|
417
|
+
right: 0,
|
|
418
|
+
|
|
419
|
+
// Android needs a fixed bottom to avoid jumping content
|
|
420
|
+
bottom: Platform.select({ android: 0 }),
|
|
421
|
+
},
|
|
422
|
+
scrollableAndroidContainer: {
|
|
423
|
+
position: 'absolute',
|
|
424
|
+
top: 0,
|
|
425
|
+
left: 0,
|
|
426
|
+
right: 0,
|
|
427
|
+
bottom: 0,
|
|
428
|
+
},
|
|
429
|
+
scrollableContent: {
|
|
430
|
+
flexGrow: 1,
|
|
431
|
+
flexBasis: 0,
|
|
418
432
|
},
|
|
419
433
|
footer: {
|
|
420
434
|
position: 'absolute',
|
package/src/TrueSheet.types.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { ComponentType, ReactElement } from 'react';
|
|
2
2
|
import type { ColorValue, NativeSyntheticEvent, ViewProps } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import type { TrueSheetGrabberProps } from './TrueSheetGrabber';
|
|
5
|
-
|
|
6
4
|
export interface DetentInfoEventPayload {
|
|
7
5
|
/**
|
|
8
6
|
* The index position from the provided `detents`.
|
|
@@ -33,21 +31,6 @@ export type DragChangeEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
|
33
31
|
export type DragEndEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
34
32
|
export type PositionChangeEvent = NativeSyntheticEvent<PositionChangeEventPayload>;
|
|
35
33
|
|
|
36
|
-
/**
|
|
37
|
-
* Internal event payload for size changes (not exposed to users)
|
|
38
|
-
* @internal
|
|
39
|
-
*/
|
|
40
|
-
export interface SizeChangeEventPayload {
|
|
41
|
-
width: number;
|
|
42
|
-
height: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Internal event type for size changes (not exposed to users)
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
49
|
-
export type SizeChangeEvent = NativeSyntheticEvent<SizeChangeEventPayload>;
|
|
50
|
-
|
|
51
34
|
/**
|
|
52
35
|
* Blur style mapped to native values in IOS.
|
|
53
36
|
*
|
|
@@ -57,30 +40,27 @@ export type BlurTint =
|
|
|
57
40
|
| 'light'
|
|
58
41
|
| 'dark'
|
|
59
42
|
| 'default'
|
|
60
|
-
| '
|
|
43
|
+
| 'extra-light'
|
|
61
44
|
| 'regular'
|
|
62
45
|
| 'prominent'
|
|
63
|
-
| '
|
|
64
|
-
| '
|
|
65
|
-
| '
|
|
66
|
-
| '
|
|
67
|
-
| '
|
|
68
|
-
| '
|
|
69
|
-
| '
|
|
70
|
-
| '
|
|
71
|
-
| '
|
|
72
|
-
| '
|
|
73
|
-
| '
|
|
74
|
-
| '
|
|
75
|
-
| '
|
|
76
|
-
| '
|
|
77
|
-
| '
|
|
46
|
+
| 'system-ultra-thin-material'
|
|
47
|
+
| 'system-thin-material'
|
|
48
|
+
| 'system-material'
|
|
49
|
+
| 'system-thick-material'
|
|
50
|
+
| 'system-chrome-material'
|
|
51
|
+
| 'system-ultra-thin-material-light'
|
|
52
|
+
| 'system-thin-material-light'
|
|
53
|
+
| 'system-material-light'
|
|
54
|
+
| 'system-thick-material-light'
|
|
55
|
+
| 'system-chrome-material-light'
|
|
56
|
+
| 'system-ultra-thin-material-dark'
|
|
57
|
+
| 'system-thin-material-dark'
|
|
58
|
+
| 'system-material-dark'
|
|
59
|
+
| 'system-thick-material-dark'
|
|
60
|
+
| 'system-chrome-material-dark';
|
|
78
61
|
|
|
79
62
|
/**
|
|
80
63
|
* Supported Sheet detent.
|
|
81
|
-
*
|
|
82
|
-
* @platform android
|
|
83
|
-
* @platform ios 15+
|
|
84
64
|
*/
|
|
85
65
|
export type SheetDetent =
|
|
86
66
|
/**
|
|
@@ -126,6 +106,9 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
126
106
|
* detents={['auto', 0.6, 1]}
|
|
127
107
|
* ```
|
|
128
108
|
*
|
|
109
|
+
* @note It's recommended to sort detents from smallest to largest.
|
|
110
|
+
* When using `auto`, place it at the first index if you plan to adjust content dynamically.
|
|
111
|
+
*
|
|
129
112
|
* @default [0.5, 1]
|
|
130
113
|
*/
|
|
131
114
|
detents?: SheetDetent[];
|
|
@@ -134,8 +117,6 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
134
117
|
* Specify whether the sheet background is dimmed.
|
|
135
118
|
* Set to `false` to allow interaction with the background components.
|
|
136
119
|
*
|
|
137
|
-
* @platform android
|
|
138
|
-
* @platform ios 15+
|
|
139
120
|
* @default true
|
|
140
121
|
*/
|
|
141
122
|
dimmed?: boolean;
|
|
@@ -162,7 +143,7 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
162
143
|
*
|
|
163
144
|
* @default 0
|
|
164
145
|
*/
|
|
165
|
-
|
|
146
|
+
dimmedDetentIndex?: number;
|
|
166
147
|
|
|
167
148
|
/**
|
|
168
149
|
* Prevents interactive dismissal of the Sheet.
|
|
@@ -173,8 +154,7 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
173
154
|
|
|
174
155
|
/**
|
|
175
156
|
* Main sheet background color.
|
|
176
|
-
|
|
177
|
-
* @default white
|
|
157
|
+
* Uses system default when not provided.
|
|
178
158
|
*/
|
|
179
159
|
backgroundColor?: ColorValue;
|
|
180
160
|
|
|
@@ -184,26 +164,28 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
184
164
|
* - `undefined` (not provided): Uses system default corner radius
|
|
185
165
|
* - `0`: Sharp corners (no rounding)
|
|
186
166
|
* - `> 0`: Custom corner radius value
|
|
187
|
-
*
|
|
188
|
-
* @platform android
|
|
189
|
-
* @platform ios 15+
|
|
190
167
|
*/
|
|
191
168
|
cornerRadius?: number;
|
|
192
169
|
|
|
193
170
|
/**
|
|
194
|
-
* Shows native grabber (or handle) on
|
|
171
|
+
* Shows a native grabber (or drag handle) on the sheet.
|
|
172
|
+
*
|
|
173
|
+
* iOS uses the native `UISheetPresentationController` grabber.
|
|
174
|
+
* Android renders a native view following Material Design 3 specifications.
|
|
195
175
|
*
|
|
196
|
-
* @platform ios
|
|
197
176
|
* @default true
|
|
198
177
|
*/
|
|
199
178
|
grabber?: boolean;
|
|
200
179
|
|
|
201
180
|
/**
|
|
202
|
-
*
|
|
181
|
+
* Controls the sheet presentation style on iPad.
|
|
182
|
+
* When enabled (true), uses a large page sheet for better readability.
|
|
183
|
+
* When disabled (false), uses a centered form sheet.
|
|
203
184
|
*
|
|
204
|
-
* @platform
|
|
185
|
+
* @platform ios 17+
|
|
186
|
+
* @default true
|
|
205
187
|
*/
|
|
206
|
-
|
|
188
|
+
pageSizing?: boolean;
|
|
207
189
|
|
|
208
190
|
/**
|
|
209
191
|
* The blur effect style on iOS.
|
|
@@ -228,11 +210,27 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
228
210
|
*/
|
|
229
211
|
edgeToEdgeFullScreen?: boolean;
|
|
230
212
|
|
|
213
|
+
/**
|
|
214
|
+
* A component that is fixed at the top of the Sheet content.
|
|
215
|
+
* Useful for search bars, titles, or other header content.
|
|
216
|
+
*/
|
|
217
|
+
header?: ComponentType<unknown> | ReactElement;
|
|
218
|
+
|
|
231
219
|
/**
|
|
232
220
|
* A component that floats at the bottom of the Sheet.
|
|
233
221
|
*/
|
|
234
222
|
footer?: ComponentType<unknown> | ReactElement;
|
|
235
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Automatically pins ScrollView or FlatList to fit within the sheet's available space.
|
|
226
|
+
* When enabled, the ScrollView's top edge will be pinned below any top sibling views,
|
|
227
|
+
* and its left, right, and bottom edges will be pinned to the container.
|
|
228
|
+
*
|
|
229
|
+
* @platform ios
|
|
230
|
+
* @default false
|
|
231
|
+
*/
|
|
232
|
+
scrollable?: boolean;
|
|
233
|
+
|
|
236
234
|
/**
|
|
237
235
|
* Determines how the software keyboard will impact the layout of the sheet.
|
|
238
236
|
* Set to `pan` if you're working with `FlatList` with a `TextInput`.
|
|
@@ -278,27 +276,18 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
278
276
|
/**
|
|
279
277
|
* Called when the sheet has began dragging.
|
|
280
278
|
* Comes with the detent info.
|
|
281
|
-
*
|
|
282
|
-
* @platform android
|
|
283
|
-
* @platform ios 15+
|
|
284
279
|
*/
|
|
285
280
|
onDragBegin?: (event: DragBeginEvent) => void;
|
|
286
281
|
|
|
287
282
|
/**
|
|
288
283
|
* Called when the sheet is being dragged.
|
|
289
284
|
* Comes with the detent info.
|
|
290
|
-
*
|
|
291
|
-
* @platform android
|
|
292
|
-
* @platform ios 15+
|
|
293
285
|
*/
|
|
294
286
|
onDragChange?: (event: DragChangeEvent) => void;
|
|
295
287
|
|
|
296
288
|
/**
|
|
297
289
|
* Called when the sheet dragging has ended.
|
|
298
290
|
* Comes with the detent info.
|
|
299
|
-
*
|
|
300
|
-
* @platform android
|
|
301
|
-
* @platform ios 15+
|
|
302
291
|
*/
|
|
303
292
|
onDragEnd?: (event: DragEndEvent) => void;
|
|
304
293
|
|
|
@@ -306,9 +295,6 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
306
295
|
* Called when the sheet's position changes.
|
|
307
296
|
* This fires continuously during sheet position changes.
|
|
308
297
|
* Comes with the detent info.
|
|
309
|
-
*
|
|
310
|
-
* @platform android
|
|
311
|
-
* @platform ios 15+
|
|
312
298
|
*/
|
|
313
299
|
onPositionChange?: (event: PositionChangeEvent) => void;
|
|
314
300
|
}
|
|
@@ -5,4 +5,4 @@ export interface NativeProps extends ViewProps {
|
|
|
5
5
|
// No props needed - container accesses props from parent TrueSheetView
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export default codegenNativeComponent<NativeProps>('TrueSheetContainerView'
|
|
8
|
+
export default codegenNativeComponent<NativeProps>('TrueSheetContainerView');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import { codegenNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface NativeProps extends ViewProps {
|
|
5
|
+
// Header-specific props can be added here if needed
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default codegenNativeComponent<NativeProps>('TrueSheetHeaderView', {});
|
|
@@ -19,11 +19,6 @@ export interface PositionChangeEventPayload {
|
|
|
19
19
|
transitioning: boolean;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export interface SizeChangeEventPayload {
|
|
23
|
-
width: Double;
|
|
24
|
-
height: Double;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
22
|
export interface NativeProps extends ViewProps {
|
|
28
23
|
// Array properties
|
|
29
24
|
detents?: ReadonlyArray<Float>;
|
|
@@ -33,7 +28,7 @@ export interface NativeProps extends ViewProps {
|
|
|
33
28
|
background?: WithDefault<Int32, 0>;
|
|
34
29
|
cornerRadius?: WithDefault<Double, -1>;
|
|
35
30
|
initialDetentIndex?: WithDefault<Int32, -1>;
|
|
36
|
-
|
|
31
|
+
dimmedDetentIndex?: WithDefault<Int32, 0>;
|
|
37
32
|
|
|
38
33
|
// String properties - use empty string as default to avoid nil insertion
|
|
39
34
|
blurTint?: WithDefault<string, ''>;
|
|
@@ -45,6 +40,8 @@ export interface NativeProps extends ViewProps {
|
|
|
45
40
|
dimmed?: WithDefault<boolean, true>;
|
|
46
41
|
initialDetentAnimated?: WithDefault<boolean, true>;
|
|
47
42
|
edgeToEdgeFullScreen?: WithDefault<boolean, false>;
|
|
43
|
+
scrollable?: WithDefault<boolean, false>;
|
|
44
|
+
pageSizing?: WithDefault<boolean, true>;
|
|
48
45
|
|
|
49
46
|
// Event handlers
|
|
50
47
|
onMount?: DirectEventHandler<null>;
|
|
@@ -57,7 +54,8 @@ export interface NativeProps extends ViewProps {
|
|
|
57
54
|
onDragChange?: DirectEventHandler<DetentInfoEventPayload>;
|
|
58
55
|
onDragEnd?: DirectEventHandler<DetentInfoEventPayload>;
|
|
59
56
|
onPositionChange?: DirectEventHandler<PositionChangeEventPayload>;
|
|
60
|
-
onSizeChange?: DirectEventHandler<SizeChangeEventPayload>;
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
export default codegenNativeComponent<NativeProps>('TrueSheetView'
|
|
59
|
+
export default codegenNativeComponent<NativeProps>('TrueSheetView', {
|
|
60
|
+
interfaceOnly: true,
|
|
61
|
+
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
package com.lodev09.truesheet.events
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.Arguments
|
|
4
|
-
import com.facebook.react.bridge.WritableMap
|
|
5
|
-
import com.facebook.react.uimanager.PixelUtil
|
|
6
|
-
import com.facebook.react.uimanager.events.Event
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Fired when the root view's size changes
|
|
10
|
-
* Payload: { width: number, height: number }
|
|
11
|
-
*/
|
|
12
|
-
class SizeChangeEvent(surfaceId: Int, viewId: Int, private val width: Int, private val height: Int) :
|
|
13
|
-
Event<SizeChangeEvent>(surfaceId, viewId) {
|
|
14
|
-
|
|
15
|
-
override fun getEventName(): String = EVENT_NAME
|
|
16
|
-
|
|
17
|
-
override fun getEventData(): WritableMap =
|
|
18
|
-
Arguments.createMap().apply {
|
|
19
|
-
putDouble("width", PixelUtil.toDIPFromPixel(width.toFloat()).toDouble())
|
|
20
|
-
putDouble("height", PixelUtil.toDIPFromPixel(height.toFloat()).toDouble())
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
companion object {
|
|
24
|
-
const val EVENT_NAME = "topSizeChange"
|
|
25
|
-
const val REGISTRATION_NAME = "onSizeChange"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Created by Jovanni Lo (@lodev09)
|
|
3
|
-
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This source code is licensed under the MIT license found in the
|
|
6
|
-
// LICENSE file in the root directory of this source tree.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
-
|
|
11
|
-
#import <Foundation/Foundation.h>
|
|
12
|
-
#import <react/renderer/components/TrueSheetSpec/EventEmitters.h>
|
|
13
|
-
|
|
14
|
-
using namespace facebook::react;
|
|
15
|
-
|
|
16
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
17
|
-
|
|
18
|
-
@interface OnSizeChangeEvent : NSObject
|
|
19
|
-
|
|
20
|
-
+ (void)emit:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
21
|
-
width:(CGFloat)width
|
|
22
|
-
height:(CGFloat)height;
|
|
23
|
-
|
|
24
|
-
@end
|
|
25
|
-
|
|
26
|
-
NS_ASSUME_NONNULL_END
|
|
27
|
-
|
|
28
|
-
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Created by Jovanni Lo (@lodev09)
|
|
3
|
-
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This source code is licensed under the MIT license found in the
|
|
6
|
-
// LICENSE file in the root directory of this source tree.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
-
|
|
11
|
-
#import "OnSizeChangeEvent.h"
|
|
12
|
-
|
|
13
|
-
@implementation OnSizeChangeEvent
|
|
14
|
-
|
|
15
|
-
+ (void)emit:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
16
|
-
width:(CGFloat)width
|
|
17
|
-
height:(CGFloat)height {
|
|
18
|
-
if (!eventEmitter)
|
|
19
|
-
return;
|
|
20
|
-
|
|
21
|
-
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
22
|
-
TrueSheetViewEventEmitter::OnSizeChange event;
|
|
23
|
-
event.width = static_cast<double>(width);
|
|
24
|
-
event.height = static_cast<double>(height);
|
|
25
|
-
emitter->onSizeChange(event);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@end
|
|
29
|
-
|
|
30
|
-
#endif // RCT_NEW_ARCH_ENABLED
|