@lodev09/react-native-true-sheet 2.0.6 → 4.0.0-beta.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 +36 -8
- package/RNTrueSheet.podspec +20 -0
- package/android/build.gradle +26 -14
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +108 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerViewManager.kt +21 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +46 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentViewManager.kt +21 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +47 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterViewManager.kt +21 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +165 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +36 -4
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +257 -303
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +855 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +104 -82
- package/android/src/main/java/com/lodev09/truesheet/events/DetentChangeEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DidDismissEvent.kt +20 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DidPresentEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DragBeginEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DragChangeEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DragEndEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +20 -0
- package/android/src/main/java/com/lodev09/truesheet/events/PositionChangeEvent.kt +32 -0
- package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +27 -0
- package/android/src/main/java/com/lodev09/truesheet/events/WillDismissEvent.kt +20 -0
- package/android/src/main/java/com/lodev09/truesheet/events/WillPresentEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/{core/Utils.kt → utils/ScreenUtils.kt} +47 -17
- package/android/src/main/res/values/styles.xml +8 -0
- package/ios/TrueSheetComponentDescriptor.h +24 -0
- package/ios/TrueSheetContainerView.h +47 -0
- package/ios/TrueSheetContainerView.mm +117 -0
- package/ios/TrueSheetContentView.h +37 -0
- package/ios/TrueSheetContentView.mm +114 -0
- package/ios/TrueSheetFooterView.h +27 -0
- package/ios/TrueSheetFooterView.mm +101 -0
- package/ios/TrueSheetModule.h +44 -0
- package/ios/TrueSheetModule.mm +133 -0
- package/ios/TrueSheetView.h +53 -0
- package/ios/TrueSheetView.mm +433 -0
- package/ios/TrueSheetViewController.h +53 -0
- package/ios/TrueSheetViewController.mm +649 -0
- package/ios/events/OnDetentChangeEvent.h +28 -0
- package/ios/events/OnDetentChangeEvent.mm +30 -0
- package/ios/events/OnDidDismissEvent.h +26 -0
- package/ios/events/OnDidDismissEvent.mm +25 -0
- package/ios/events/OnDidPresentEvent.h +28 -0
- package/ios/events/OnDidPresentEvent.mm +30 -0
- package/ios/events/OnDragBeginEvent.h +28 -0
- package/ios/events/OnDragBeginEvent.mm +30 -0
- package/ios/events/OnDragChangeEvent.h +28 -0
- package/ios/events/OnDragChangeEvent.mm +30 -0
- package/ios/events/OnDragEndEvent.h +28 -0
- package/ios/events/OnDragEndEvent.mm +30 -0
- package/ios/events/OnMountEvent.h +26 -0
- package/ios/events/OnMountEvent.mm +25 -0
- package/ios/events/OnPositionChangeEvent.h +29 -0
- package/ios/events/OnPositionChangeEvent.mm +32 -0
- package/ios/events/OnSizeChangeEvent.h +28 -0
- package/ios/events/OnSizeChangeEvent.mm +30 -0
- package/ios/events/OnWillDismissEvent.h +26 -0
- package/ios/events/OnWillDismissEvent.mm +25 -0
- package/ios/events/OnWillPresentEvent.h +28 -0
- package/ios/events/OnWillPresentEvent.mm +30 -0
- package/ios/utils/GestureUtil.h +25 -0
- package/ios/utils/GestureUtil.mm +26 -0
- package/ios/utils/LayoutUtil.h +44 -0
- package/ios/utils/LayoutUtil.mm +50 -0
- package/ios/utils/WindowUtil.h +27 -0
- package/ios/utils/WindowUtil.mm +42 -0
- package/lib/module/TrueSheet.js +231 -135
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheetGrabber.js +16 -14
- package/lib/module/TrueSheetGrabber.js.map +1 -1
- package/lib/module/fabric/TrueSheetContainerViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetContentViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetFooterViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +63 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheet.js +87 -0
- package/lib/module/reanimated/ReanimatedTrueSheet.js.map +1 -0
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +72 -0
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -0
- package/lib/module/reanimated/index.js +6 -0
- package/lib/module/reanimated/index.js.map +1 -0
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.js +19 -0
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.js.map +1 -0
- package/lib/module/specs/NativeTrueSheetModule.js +12 -0
- package/lib/module/specs/NativeTrueSheetModule.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/TrueSheet.d.ts +79 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheet.types.d.ts +260 -0
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -0
- package/lib/typescript/{commonjs/src → src}/TrueSheetGrabber.d.ts +1 -1
- package/lib/typescript/src/TrueSheetGrabber.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetContentViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetContentViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +44 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/{commonjs/src → src}/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts +43 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts +57 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/index.d.ts +4 -0
- package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.d.ts +6 -0
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts +34 -0
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts.map +1 -0
- package/package.json +104 -75
- package/react-native.config.js +17 -0
- package/src/TrueSheet.tsx +285 -188
- package/src/TrueSheet.types.ts +119 -106
- package/src/TrueSheetGrabber.tsx +29 -28
- package/src/__mocks__/index.js +60 -12
- package/src/fabric/TrueSheetContainerViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetContentViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetFooterViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetViewNativeComponent.ts +63 -0
- package/src/index.ts +4 -3
- package/src/reanimated/ReanimatedTrueSheet.tsx +95 -0
- package/src/reanimated/ReanimatedTrueSheetProvider.tsx +92 -0
- package/src/reanimated/index.ts +3 -0
- package/src/reanimated/useReanimatedPositionChangeHandler.ts +26 -0
- package/src/specs/NativeTrueSheetModule.ts +38 -0
- package/TrueSheet.podspec +0 -49
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt +0 -413
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetEvent.kt +0 -22
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewModule.kt +0 -63
- package/android/src/main/java/com/lodev09/truesheet/core/KeyboardManager.kt +0 -58
- package/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt +0 -102
- package/ios/Extensions/UIBlurEffect+withTint.swift +0 -62
- package/ios/Extensions/UIView+pinTo.swift +0 -74
- package/ios/Extensions/UIViewController+detentForSize.swift +0 -134
- package/ios/TrueSheet-Bridging-Header.h +0 -14
- package/ios/TrueSheetEvent.swift +0 -48
- package/ios/TrueSheetView.swift +0 -467
- package/ios/TrueSheetViewController.swift +0 -275
- package/ios/TrueSheetViewManager.m +0 -53
- package/ios/TrueSheetViewManager.swift +0 -48
- package/ios/Utils/Logger.swift +0 -39
- package/ios/Utils/Promise.swift +0 -25
- package/lib/commonjs/TrueSheet.js +0 -258
- package/lib/commonjs/TrueSheet.js.map +0 -1
- package/lib/commonjs/TrueSheet.types.js +0 -6
- package/lib/commonjs/TrueSheet.types.js.map +0 -1
- package/lib/commonjs/TrueSheetFooter.js +0 -19
- package/lib/commonjs/TrueSheetFooter.js.map +0 -1
- package/lib/commonjs/TrueSheetGrabber.js +0 -54
- package/lib/commonjs/TrueSheetGrabber.js.map +0 -1
- package/lib/commonjs/TrueSheetModule.js +0 -19
- package/lib/commonjs/TrueSheetModule.js.map +0 -1
- package/lib/commonjs/__mocks__/index.js +0 -52
- package/lib/commonjs/__mocks__/index.js.map +0 -1
- package/lib/commonjs/index.js +0 -39
- package/lib/commonjs/index.js.map +0 -1
- package/lib/module/TrueSheetFooter.js +0 -14
- package/lib/module/TrueSheetFooter.js.map +0 -1
- package/lib/module/TrueSheetModule.js +0 -15
- package/lib/module/TrueSheetModule.js.map +0 -1
- package/lib/module/__mocks__/index.js +0 -21
- package/lib/module/__mocks__/index.js.map +0 -1
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/TrueSheet.d.ts +0 -70
- package/lib/typescript/commonjs/src/TrueSheet.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/TrueSheet.types.d.ts +0 -241
- package/lib/typescript/commonjs/src/TrueSheet.types.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/TrueSheetFooter.d.ts +0 -7
- package/lib/typescript/commonjs/src/TrueSheetFooter.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/TrueSheetGrabber.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/TrueSheetModule.d.ts +0 -2
- package/lib/typescript/commonjs/src/TrueSheetModule.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheet.d.ts +0 -70
- package/lib/typescript/module/src/TrueSheet.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheet.types.d.ts +0 -241
- package/lib/typescript/module/src/TrueSheet.types.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheetFooter.d.ts +0 -7
- package/lib/typescript/module/src/TrueSheetFooter.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheetGrabber.d.ts +0 -39
- package/lib/typescript/module/src/TrueSheetGrabber.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheetModule.d.ts +0 -2
- package/lib/typescript/module/src/TrueSheetModule.d.ts.map +0 -1
- package/lib/typescript/module/src/index.d.ts +0 -4
- package/lib/typescript/module/src/index.d.ts.map +0 -1
- package/src/TrueSheetFooter.tsx +0 -17
- package/src/TrueSheetModule.ts +0 -19
- /package/lib/{typescript/module → module}/package.json +0 -0
package/src/TrueSheet.types.ts
CHANGED
|
@@ -1,24 +1,52 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import type { ComponentType, ReactElement } from 'react';
|
|
2
|
+
import type { ColorValue, NativeSyntheticEvent, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { TrueSheetGrabberProps } from './TrueSheetGrabber';
|
|
5
|
+
|
|
6
|
+
export interface DetentInfoEventPayload {
|
|
7
|
+
/**
|
|
8
|
+
* The index position from the provided `detents`.
|
|
9
|
+
*/
|
|
10
|
+
index: number;
|
|
11
|
+
/**
|
|
12
|
+
* The Y position of the sheet relative to the screen.
|
|
13
|
+
*/
|
|
14
|
+
position: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface PositionChangeEventPayload extends DetentInfoEventPayload {
|
|
18
|
+
/**
|
|
19
|
+
* Workaround for cases where we can't get real-time position from native.
|
|
20
|
+
* When true, manually animate the position in JS.
|
|
21
|
+
*/
|
|
22
|
+
transitioning: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type MountEvent = NativeSyntheticEvent<null>;
|
|
26
|
+
export type DetentChangeEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
27
|
+
export type WillPresentEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
28
|
+
export type DidPresentEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
29
|
+
export type WillDismissEvent = NativeSyntheticEvent<null>;
|
|
30
|
+
export type DidDismissEvent = NativeSyntheticEvent<null>;
|
|
31
|
+
export type DragBeginEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
32
|
+
export type DragChangeEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
33
|
+
export type DragEndEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
34
|
+
export type PositionChangeEvent = NativeSyntheticEvent<PositionChangeEventPayload>;
|
|
35
|
+
|
|
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;
|
|
15
43
|
}
|
|
16
44
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export type
|
|
45
|
+
/**
|
|
46
|
+
* Internal event type for size changes (not exposed to users)
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export type SizeChangeEvent = NativeSyntheticEvent<SizeChangeEventPayload>;
|
|
22
50
|
|
|
23
51
|
/**
|
|
24
52
|
* Blur style mapped to native values in IOS.
|
|
@@ -46,17 +74,18 @@ export type BlurTint =
|
|
|
46
74
|
| 'systemThinMaterialDark'
|
|
47
75
|
| 'systemMaterialDark'
|
|
48
76
|
| 'systemThickMaterialDark'
|
|
49
|
-
| 'systemChromeMaterialDark'
|
|
77
|
+
| 'systemChromeMaterialDark';
|
|
50
78
|
|
|
51
79
|
/**
|
|
52
|
-
* Supported Sheet
|
|
80
|
+
* Supported Sheet detent.
|
|
53
81
|
*
|
|
54
82
|
* @platform android
|
|
55
83
|
* @platform ios 15+
|
|
56
84
|
*/
|
|
57
|
-
export type
|
|
85
|
+
export type SheetDetent =
|
|
58
86
|
/**
|
|
59
|
-
* Auto resize based on content height
|
|
87
|
+
* Auto resize based on content height, clamped to container height.
|
|
88
|
+
* Use the `maxHeight` prop to set a custom limit.
|
|
60
89
|
*
|
|
61
90
|
* @platform android
|
|
62
91
|
* @platform ios 16+
|
|
@@ -64,44 +93,13 @@ export type SheetSize =
|
|
|
64
93
|
| 'auto'
|
|
65
94
|
|
|
66
95
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @platform android
|
|
70
|
-
* @platform ios 16+
|
|
71
|
-
*/
|
|
72
|
-
| number
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Fixed height in %
|
|
96
|
+
* Relative height as a fraction (0-1) of the available height.
|
|
97
|
+
* For example, 0.5 represents 50% of the available height.
|
|
76
98
|
*
|
|
77
99
|
* @platform android
|
|
78
100
|
* @platform ios 16+
|
|
79
101
|
*/
|
|
80
|
-
|
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Translates to 25%
|
|
84
|
-
*
|
|
85
|
-
* @platform android
|
|
86
|
-
* @platform ios 16+
|
|
87
|
-
*/
|
|
88
|
-
| 'small'
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Translates to 50%
|
|
92
|
-
*
|
|
93
|
-
* @platform android
|
|
94
|
-
* @platform ios 15+
|
|
95
|
-
*/
|
|
96
|
-
| 'medium'
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Translates to 100%
|
|
100
|
-
*
|
|
101
|
-
* @platform android
|
|
102
|
-
* @platform ios 15+
|
|
103
|
-
*/
|
|
104
|
-
| 'large'
|
|
102
|
+
| number;
|
|
105
103
|
|
|
106
104
|
export interface TrueSheetProps extends ViewProps {
|
|
107
105
|
/**
|
|
@@ -118,19 +116,19 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
118
116
|
* TrueSheet.present('my-awesome-sheet')
|
|
119
117
|
* ```
|
|
120
118
|
*/
|
|
121
|
-
name?: string
|
|
119
|
+
name?: string;
|
|
122
120
|
/**
|
|
123
|
-
* The
|
|
124
|
-
* Maximum of 3
|
|
121
|
+
* The detents you want the Sheet to support.
|
|
122
|
+
* Maximum of 3 detents only; collapsed, half-expanded, expanded.
|
|
125
123
|
*
|
|
126
124
|
* Example:
|
|
127
125
|
* ```ts
|
|
128
|
-
*
|
|
126
|
+
* detents={['auto', 0.6, 1]}
|
|
129
127
|
* ```
|
|
130
128
|
*
|
|
131
|
-
* @default [
|
|
129
|
+
* @default [0.5, 1]
|
|
132
130
|
*/
|
|
133
|
-
|
|
131
|
+
detents?: SheetDetent[];
|
|
134
132
|
|
|
135
133
|
/**
|
|
136
134
|
* Specify whether the sheet background is dimmed.
|
|
@@ -140,53 +138,57 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
140
138
|
* @platform ios 15+
|
|
141
139
|
* @default true
|
|
142
140
|
*/
|
|
143
|
-
dimmed?: boolean
|
|
141
|
+
dimmed?: boolean;
|
|
144
142
|
|
|
145
143
|
/**
|
|
146
|
-
* Initially present the sheet, after mounting, at a given
|
|
144
|
+
* Initially present the sheet, after mounting, at a given detent index.
|
|
147
145
|
*
|
|
148
146
|
* @note This property is only used during the initial mount.
|
|
149
147
|
* @default -1
|
|
150
148
|
*/
|
|
151
|
-
|
|
149
|
+
initialDetentIndex?: number;
|
|
152
150
|
|
|
153
151
|
/**
|
|
154
152
|
* Specify whether the sheet should animate after mounting.
|
|
155
|
-
* Used with `
|
|
153
|
+
* Used with `initialDetentIndex`.
|
|
156
154
|
*
|
|
157
155
|
* @default true
|
|
158
156
|
*/
|
|
159
|
-
|
|
157
|
+
initialDetentAnimated?: boolean;
|
|
160
158
|
|
|
161
159
|
/**
|
|
162
|
-
* The
|
|
160
|
+
* The detent index that the sheet should start to dim the background.
|
|
163
161
|
* This is ignored if `dimmed` is set to `false`.
|
|
164
162
|
*
|
|
165
163
|
* @default 0
|
|
166
164
|
*/
|
|
167
|
-
dimmedIndex?: number
|
|
165
|
+
dimmedIndex?: number;
|
|
168
166
|
|
|
169
167
|
/**
|
|
170
168
|
* Prevents interactive dismissal of the Sheet.
|
|
171
169
|
*
|
|
172
170
|
* @default true
|
|
173
171
|
*/
|
|
174
|
-
dismissible?: boolean
|
|
172
|
+
dismissible?: boolean;
|
|
175
173
|
|
|
176
174
|
/**
|
|
177
175
|
* Main sheet background color.
|
|
178
176
|
|
|
179
177
|
* @default white
|
|
180
178
|
*/
|
|
181
|
-
backgroundColor?: ColorValue
|
|
179
|
+
backgroundColor?: ColorValue;
|
|
182
180
|
|
|
183
181
|
/**
|
|
184
182
|
* The sheet corner radius.
|
|
185
183
|
*
|
|
184
|
+
* - `undefined` (not provided): Uses system default corner radius
|
|
185
|
+
* - `0`: Sharp corners (no rounding)
|
|
186
|
+
* - `> 0`: Custom corner radius value
|
|
187
|
+
*
|
|
186
188
|
* @platform android
|
|
187
189
|
* @platform ios 15+
|
|
188
190
|
*/
|
|
189
|
-
cornerRadius?: number
|
|
191
|
+
cornerRadius?: number;
|
|
190
192
|
|
|
191
193
|
/**
|
|
192
194
|
* Shows native grabber (or handle) on IOS.
|
|
@@ -194,14 +196,14 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
194
196
|
* @platform ios
|
|
195
197
|
* @default true
|
|
196
198
|
*/
|
|
197
|
-
grabber?: boolean
|
|
199
|
+
grabber?: boolean;
|
|
198
200
|
|
|
199
201
|
/**
|
|
200
202
|
* Grabber props to be used for android grabber or handle.
|
|
201
203
|
*
|
|
202
204
|
* @platform android
|
|
203
205
|
*/
|
|
204
|
-
grabberProps?: TrueSheetGrabberProps
|
|
206
|
+
grabberProps?: TrueSheetGrabberProps;
|
|
205
207
|
|
|
206
208
|
/**
|
|
207
209
|
* The blur effect style on iOS.
|
|
@@ -209,29 +211,27 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
209
211
|
*
|
|
210
212
|
* @platform ios
|
|
211
213
|
*/
|
|
212
|
-
blurTint?: BlurTint
|
|
214
|
+
blurTint?: BlurTint;
|
|
213
215
|
|
|
214
216
|
/**
|
|
215
|
-
*
|
|
217
|
+
* Overrides `large` or `100%` height.
|
|
218
|
+
* Also sets the maximum height for 'auto' detents.
|
|
216
219
|
*/
|
|
217
|
-
|
|
220
|
+
maxHeight?: number;
|
|
218
221
|
|
|
219
222
|
/**
|
|
220
|
-
*
|
|
223
|
+
* Allows the sheet to extend behind the status bar when fully expanded in edge-to-edge mode.
|
|
224
|
+
* When false (default), the sheet stops at the bottom of the status bar.
|
|
221
225
|
*
|
|
222
|
-
* @platform
|
|
223
|
-
|
|
224
|
-
scrollRef?: RefObject<Component<unknown>>
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Overrides `large` or `100%` height.
|
|
226
|
+
* @platform android
|
|
227
|
+
* @default false
|
|
228
228
|
*/
|
|
229
|
-
|
|
229
|
+
edgeToEdgeFullScreen?: boolean;
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
232
|
* A component that floats at the bottom of the Sheet.
|
|
233
233
|
*/
|
|
234
|
-
|
|
234
|
+
footer?: ComponentType<unknown> | ReactElement;
|
|
235
235
|
|
|
236
236
|
/**
|
|
237
237
|
* Determines how the software keyboard will impact the layout of the sheet.
|
|
@@ -240,62 +240,75 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
240
240
|
* @platform android
|
|
241
241
|
* @default resize
|
|
242
242
|
*/
|
|
243
|
-
keyboardMode?: 'resize' | 'pan'
|
|
243
|
+
keyboardMode?: 'resize' | 'pan';
|
|
244
244
|
|
|
245
245
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* @platform android
|
|
246
|
+
* Called when the sheet's content is mounted and ready.
|
|
247
|
+
* The sheet automatically waits for this event before presenting.
|
|
250
248
|
*/
|
|
251
|
-
|
|
249
|
+
onMount?: (event: MountEvent) => void;
|
|
252
250
|
|
|
253
251
|
/**
|
|
254
|
-
*
|
|
252
|
+
* Called when the Sheet is about to be presented.
|
|
255
253
|
*/
|
|
256
|
-
|
|
254
|
+
onWillPresent?: (event: WillPresentEvent) => void;
|
|
257
255
|
|
|
258
256
|
/**
|
|
259
257
|
* Called when the Sheet has been presented.
|
|
260
|
-
* Comes with the
|
|
258
|
+
* Comes with the detent info.
|
|
261
259
|
*/
|
|
262
|
-
|
|
260
|
+
onDidPresent?: (event: DidPresentEvent) => void;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Called when the Sheet is about to be dismissed
|
|
264
|
+
*/
|
|
265
|
+
onWillDismiss?: (event: WillDismissEvent) => void;
|
|
263
266
|
|
|
264
267
|
/**
|
|
265
268
|
* Called when the Sheet has been dismissed
|
|
266
269
|
*/
|
|
267
|
-
|
|
270
|
+
onDidDismiss?: (event: DidDismissEvent) => void;
|
|
268
271
|
|
|
269
272
|
/**
|
|
270
|
-
* Called when the
|
|
273
|
+
* Called when the detent of the sheet has changed.
|
|
271
274
|
* Either by dragging or programatically.
|
|
272
275
|
*/
|
|
273
|
-
|
|
276
|
+
onDetentChange?: (event: DetentChangeEvent) => void;
|
|
274
277
|
|
|
275
278
|
/**
|
|
276
279
|
* Called when the sheet has began dragging.
|
|
277
|
-
* Comes with the
|
|
280
|
+
* Comes with the detent info.
|
|
278
281
|
*
|
|
279
282
|
* @platform android
|
|
280
283
|
* @platform ios 15+
|
|
281
284
|
*/
|
|
282
|
-
onDragBegin?: (event: DragBeginEvent) => void
|
|
285
|
+
onDragBegin?: (event: DragBeginEvent) => void;
|
|
283
286
|
|
|
284
287
|
/**
|
|
285
288
|
* Called when the sheet is being dragged.
|
|
286
|
-
* Comes with the
|
|
289
|
+
* Comes with the detent info.
|
|
287
290
|
*
|
|
288
291
|
* @platform android
|
|
289
292
|
* @platform ios 15+
|
|
290
293
|
*/
|
|
291
|
-
onDragChange?: (event: DragChangeEvent) => void
|
|
294
|
+
onDragChange?: (event: DragChangeEvent) => void;
|
|
292
295
|
|
|
293
296
|
/**
|
|
294
297
|
* Called when the sheet dragging has ended.
|
|
295
|
-
* Comes with the
|
|
298
|
+
* Comes with the detent info.
|
|
299
|
+
*
|
|
300
|
+
* @platform android
|
|
301
|
+
* @platform ios 15+
|
|
302
|
+
*/
|
|
303
|
+
onDragEnd?: (event: DragEndEvent) => void;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Called when the sheet's position changes.
|
|
307
|
+
* This fires continuously during sheet position changes.
|
|
308
|
+
* Comes with the detent info.
|
|
296
309
|
*
|
|
297
310
|
* @platform android
|
|
298
311
|
* @platform ios 15+
|
|
299
312
|
*/
|
|
300
|
-
|
|
313
|
+
onPositionChange?: (event: PositionChangeEvent) => void;
|
|
301
314
|
}
|
package/src/TrueSheetGrabber.tsx
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { View, type ColorValue, type
|
|
1
|
+
import { StyleSheet, View, type ColorValue, type StyleProp, type ViewStyle } from 'react-native';
|
|
2
2
|
|
|
3
|
-
const GRABBER_DEFAULT_HEIGHT = 4
|
|
4
|
-
const GRABBER_DEFAULT_WIDTH = 32
|
|
3
|
+
const GRABBER_DEFAULT_HEIGHT = 4;
|
|
4
|
+
const GRABBER_DEFAULT_WIDTH = 32;
|
|
5
5
|
|
|
6
6
|
// M3 spec: #49454F 0.4 alpha
|
|
7
|
-
const GRABBER_DEFAULT_COLOR = 'rgba(73,69,79,0.4)'
|
|
7
|
+
const GRABBER_DEFAULT_COLOR = 'rgba(73,69,79,0.4)';
|
|
8
8
|
|
|
9
9
|
export interface TrueSheetGrabberProps {
|
|
10
10
|
/**
|
|
11
11
|
* Is grabber visible.
|
|
12
12
|
* @default true
|
|
13
13
|
*/
|
|
14
|
-
visible?: boolean
|
|
14
|
+
visible?: boolean;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Optional style that overrides the default style.
|
|
18
18
|
*/
|
|
19
|
-
style?: StyleProp<ViewStyle
|
|
19
|
+
style?: StyleProp<ViewStyle>;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Grabber color according to M3 specs.
|
|
23
23
|
* @default rgba(73,69,79,0.4)
|
|
24
24
|
*/
|
|
25
|
-
color?: ColorValue
|
|
25
|
+
color?: ColorValue;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Grabber height according to M3 specs.
|
|
29
29
|
* @default 4
|
|
30
30
|
*/
|
|
31
|
-
height?: number
|
|
31
|
+
height?: number;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Grabber top position offset.
|
|
35
35
|
*
|
|
36
36
|
* @default 6
|
|
37
37
|
*/
|
|
38
|
-
topOffset?: number
|
|
38
|
+
topOffset?: number;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Grabber width according to M3 specs.
|
|
42
42
|
* @default 32
|
|
43
43
|
*/
|
|
44
|
-
width?: number
|
|
44
|
+
width?: number;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -56,26 +56,27 @@ export const TrueSheetGrabber = (props: TrueSheetGrabberProps) => {
|
|
|
56
56
|
height = GRABBER_DEFAULT_HEIGHT,
|
|
57
57
|
topOffset = 0,
|
|
58
58
|
style,
|
|
59
|
-
} = props
|
|
59
|
+
} = props;
|
|
60
60
|
|
|
61
|
-
if (!visible) return null
|
|
61
|
+
if (!visible) return null;
|
|
62
62
|
|
|
63
63
|
return (
|
|
64
|
-
<View style={[
|
|
65
|
-
<View style={[
|
|
64
|
+
<View style={[styles.wrapper, style, { height: GRABBER_DEFAULT_HEIGHT * 4, top: topOffset }]}>
|
|
65
|
+
<View style={[styles.grabber, { height, width, backgroundColor: color }]} />
|
|
66
66
|
</View>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const $wrapper: ViewStyle = {
|
|
71
|
-
position: 'absolute',
|
|
72
|
-
alignSelf: 'center',
|
|
73
|
-
paddingHorizontal: 12,
|
|
74
|
-
alignItems: 'center',
|
|
75
|
-
justifyContent: 'center',
|
|
76
|
-
zIndex: 9999,
|
|
77
|
-
}
|
|
67
|
+
);
|
|
68
|
+
};
|
|
78
69
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
const styles = StyleSheet.create({
|
|
71
|
+
wrapper: {
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
alignSelf: 'center',
|
|
74
|
+
paddingHorizontal: 12,
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
zIndex: 9999,
|
|
78
|
+
},
|
|
79
|
+
grabber: {
|
|
80
|
+
borderRadius: GRABBER_DEFAULT_HEIGHT / 2,
|
|
81
|
+
},
|
|
82
|
+
});
|
package/src/__mocks__/index.js
CHANGED
|
@@ -1,19 +1,67 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { View } from 'react-native'
|
|
3
|
-
|
|
4
|
-
export * from '../TrueSheetGrabber'
|
|
5
|
-
export * from '../TrueSheetFooter'
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
6
3
|
|
|
4
|
+
// Mock TrueSheet class component
|
|
7
5
|
export class TrueSheet extends React.Component {
|
|
8
|
-
static
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
static instances = {};
|
|
7
|
+
|
|
8
|
+
// Static methods
|
|
9
|
+
static dismiss = jest.fn((name) => Promise.resolve());
|
|
10
|
+
static present = jest.fn((name, index = 0) => Promise.resolve());
|
|
11
|
+
static resize = jest.fn((name, index) => Promise.resolve());
|
|
12
|
+
|
|
13
|
+
// Instance methods
|
|
14
|
+
dismiss = jest.fn(() => Promise.resolve());
|
|
15
|
+
present = jest.fn((index = 0) => Promise.resolve());
|
|
16
|
+
resize = jest.fn((index) => Promise.resolve());
|
|
17
|
+
|
|
18
|
+
componentDidMount() {
|
|
19
|
+
const { name } = this.props;
|
|
20
|
+
if (name) {
|
|
21
|
+
TrueSheet.instances[name] = this;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
11
24
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
componentWillUnmount() {
|
|
26
|
+
const { name } = this.props;
|
|
27
|
+
if (name) {
|
|
28
|
+
delete TrueSheet.instances[name];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
15
31
|
|
|
16
32
|
render() {
|
|
17
|
-
|
|
33
|
+
const { children, footer, style, ...rest } = this.props;
|
|
34
|
+
return (
|
|
35
|
+
<View style={style} {...rest}>
|
|
36
|
+
{children}
|
|
37
|
+
{footer}
|
|
38
|
+
</View>
|
|
39
|
+
);
|
|
18
40
|
}
|
|
19
41
|
}
|
|
42
|
+
|
|
43
|
+
// Mock ReanimatedTrueSheet
|
|
44
|
+
export class ReanimatedTrueSheet extends TrueSheet {
|
|
45
|
+
render() {
|
|
46
|
+
return <TrueSheet {...this.props} />;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Mock TrueSheetGrabber
|
|
51
|
+
export const TrueSheetGrabber = ({ style, ...props }) => (
|
|
52
|
+
<View style={style} {...props} testID="true-sheet-grabber" />
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// Mock ReanimatedTrueSheetProvider
|
|
56
|
+
export const ReanimatedTrueSheetProvider = ({ children }) => <>{children}</>;
|
|
57
|
+
|
|
58
|
+
// Mock hooks
|
|
59
|
+
export const useReanimatedTrueSheet = jest.fn(() => ({
|
|
60
|
+
animatedPosition: { value: 0 },
|
|
61
|
+
animatedIndex: { value: -1 },
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
export const useReanimatedPositionChangeHandler = jest.fn((callback) => jest.fn());
|
|
65
|
+
|
|
66
|
+
// Re-export types (these will be no-ops in JS but useful for TS consumers)
|
|
67
|
+
export * from '../TrueSheet.types';
|
|
@@ -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
|
+
// No props needed - container accesses props from parent TrueSheetView
|
|
6
|
+
}
|
|
7
|
+
|
|
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
|
+
// No props needed - size will be controlled by parent
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default codegenNativeComponent<NativeProps>('TrueSheetContentView', {});
|
|
@@ -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
|
+
// Footer-specific props can be added here if needed
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default codegenNativeComponent<NativeProps>('TrueSheetFooterView', {});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type {
|
|
3
|
+
DirectEventHandler,
|
|
4
|
+
Double,
|
|
5
|
+
Int32,
|
|
6
|
+
WithDefault,
|
|
7
|
+
Float,
|
|
8
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
9
|
+
import { codegenNativeComponent } from 'react-native';
|
|
10
|
+
|
|
11
|
+
export interface DetentInfoEventPayload {
|
|
12
|
+
index: Int32;
|
|
13
|
+
position: Double;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PositionChangeEventPayload {
|
|
17
|
+
index: Int32;
|
|
18
|
+
position: Double;
|
|
19
|
+
transitioning: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SizeChangeEventPayload {
|
|
23
|
+
width: Double;
|
|
24
|
+
height: Double;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface NativeProps extends ViewProps {
|
|
28
|
+
// Array properties
|
|
29
|
+
detents?: ReadonlyArray<Float>;
|
|
30
|
+
|
|
31
|
+
// Number properties - use 0 as default to avoid nil insertion
|
|
32
|
+
maxHeight?: WithDefault<Double, 0>;
|
|
33
|
+
background?: WithDefault<Int32, 0>;
|
|
34
|
+
cornerRadius?: WithDefault<Double, -1>;
|
|
35
|
+
initialDetentIndex?: WithDefault<Int32, -1>;
|
|
36
|
+
dimmedIndex?: WithDefault<Int32, 0>;
|
|
37
|
+
|
|
38
|
+
// String properties - use empty string as default to avoid nil insertion
|
|
39
|
+
blurTint?: WithDefault<string, ''>;
|
|
40
|
+
keyboardMode?: WithDefault<'resize' | 'pan', 'resize'>;
|
|
41
|
+
|
|
42
|
+
// Boolean properties - match defaults from TrueSheet.types.ts
|
|
43
|
+
grabber?: WithDefault<boolean, true>;
|
|
44
|
+
dismissible?: WithDefault<boolean, true>;
|
|
45
|
+
dimmed?: WithDefault<boolean, true>;
|
|
46
|
+
initialDetentAnimated?: WithDefault<boolean, true>;
|
|
47
|
+
edgeToEdgeFullScreen?: WithDefault<boolean, false>;
|
|
48
|
+
|
|
49
|
+
// Event handlers
|
|
50
|
+
onMount?: DirectEventHandler<null>;
|
|
51
|
+
onWillPresent?: DirectEventHandler<DetentInfoEventPayload>;
|
|
52
|
+
onDidPresent?: DirectEventHandler<DetentInfoEventPayload>;
|
|
53
|
+
onWillDismiss?: DirectEventHandler<null>;
|
|
54
|
+
onDidDismiss?: DirectEventHandler<null>;
|
|
55
|
+
onDetentChange?: DirectEventHandler<DetentInfoEventPayload>;
|
|
56
|
+
onDragBegin?: DirectEventHandler<DetentInfoEventPayload>;
|
|
57
|
+
onDragChange?: DirectEventHandler<DetentInfoEventPayload>;
|
|
58
|
+
onDragEnd?: DirectEventHandler<DetentInfoEventPayload>;
|
|
59
|
+
onPositionChange?: DirectEventHandler<PositionChangeEventPayload>;
|
|
60
|
+
onSizeChange?: DirectEventHandler<SizeChangeEventPayload>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default codegenNativeComponent<NativeProps>('TrueSheetView');
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from './TrueSheet'
|
|
2
|
-
export * from './TrueSheet.types'
|
|
3
|
-
export * from './TrueSheetGrabber'
|
|
1
|
+
export * from './TrueSheet';
|
|
2
|
+
export * from './TrueSheet.types';
|
|
3
|
+
export * from './TrueSheetGrabber';
|
|
4
|
+
export * from './reanimated';
|