@lodev09/react-native-true-sheet 3.1.0-beta.9 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +8 -2
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +18 -2
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +103 -121
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +7 -2
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDialogObserver.kt +2 -2
- package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +64 -81
- package/android/src/main/res/values/styles.xml +1 -0
- package/ios/TrueSheetModule.mm +17 -2
- package/ios/TrueSheetView.h +2 -0
- package/ios/TrueSheetView.mm +32 -3
- package/ios/TrueSheetViewController.h +2 -0
- package/ios/TrueSheetViewController.mm +45 -18
- package/lib/module/TrueSheet.js +3 -1
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +5 -2
- package/lib/module/navigation/TrueSheetRouter.js +119 -0
- package/lib/module/navigation/TrueSheetRouter.js.map +1 -0
- package/lib/module/navigation/TrueSheetView.js +169 -0
- package/lib/module/navigation/TrueSheetView.js.map +1 -0
- package/lib/module/navigation/createTrueSheetNavigator.js +59 -0
- package/lib/module/navigation/createTrueSheetNavigator.js.map +1 -0
- package/lib/module/navigation/index.js +6 -0
- package/lib/module/navigation/index.js.map +1 -0
- package/lib/module/navigation/types.js +4 -0
- package/lib/module/navigation/types.js.map +1 -0
- package/lib/module/navigation/useTrueSheetNavigation.js +26 -0
- package/lib/module/navigation/useTrueSheetNavigation.js.map +1 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +24 -0
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +3 -2
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/navigation/TrueSheetRouter.d.ts +57 -0
- package/lib/typescript/src/navigation/TrueSheetRouter.d.ts.map +1 -0
- package/lib/typescript/src/navigation/TrueSheetView.d.ts +10 -0
- package/lib/typescript/src/navigation/TrueSheetView.d.ts.map +1 -0
- package/lib/typescript/src/navigation/createTrueSheetNavigator.d.ts +35 -0
- package/lib/typescript/src/navigation/createTrueSheetNavigator.d.ts.map +1 -0
- package/lib/typescript/src/navigation/index.d.ts +6 -0
- package/lib/typescript/src/navigation/index.d.ts.map +1 -0
- package/lib/typescript/src/navigation/types.d.ts +125 -0
- package/lib/typescript/src/navigation/types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts +23 -0
- package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts.map +1 -0
- package/package.json +12 -1
- package/src/TrueSheet.tsx +3 -1
- package/src/TrueSheet.types.ts +26 -0
- package/src/fabric/TrueSheetViewNativeComponent.ts +5 -2
- package/src/navigation/TrueSheetRouter.ts +172 -0
- package/src/navigation/TrueSheetView.tsx +271 -0
- package/src/navigation/createTrueSheetNavigator.tsx +89 -0
- package/src/navigation/index.ts +14 -0
- package/src/navigation/types.ts +176 -0
- package/src/navigation/useTrueSheetNavigation.ts +28 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createTrueSheetNavigator } from './createTrueSheetNavigator';
|
|
2
|
+
export { TrueSheetActions, type TrueSheetActionType } from './TrueSheetRouter';
|
|
3
|
+
export { useTrueSheetNavigation } from './useTrueSheetNavigation';
|
|
4
|
+
export type { DetentInfoEventPayload, PositionChangeEventPayload } from '../TrueSheet.types';
|
|
5
|
+
export type { TrueSheetNavigationEventMap, TrueSheetNavigationHelpers, TrueSheetNavigationOptions, TrueSheetNavigationProp, TrueSheetNavigationState, TrueSheetScreenProps, } from './types';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,YAAY,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAE7F,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { DefaultNavigatorOptions, Descriptor, NavigationHelpers, NavigationProp, NavigationState, ParamListBase, RouteProp, StackActionHelpers } from '@react-navigation/native';
|
|
2
|
+
import type { DetentInfoEventPayload, PositionChangeEventPayload, TrueSheetProps } from '../TrueSheet.types';
|
|
3
|
+
export type TrueSheetNavigationEventMap = {
|
|
4
|
+
/**
|
|
5
|
+
* Event fired when the sheet is about to be presented.
|
|
6
|
+
*/
|
|
7
|
+
sheetWillPresent: {
|
|
8
|
+
data: DetentInfoEventPayload;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Event fired when the sheet has been presented.
|
|
12
|
+
*/
|
|
13
|
+
sheetDidPresent: {
|
|
14
|
+
data: DetentInfoEventPayload;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Event fired when the sheet is about to be dismissed.
|
|
18
|
+
*/
|
|
19
|
+
sheetWillDismiss: {
|
|
20
|
+
data: undefined;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Event fired when the sheet has been dismissed.
|
|
24
|
+
*/
|
|
25
|
+
sheetDidDismiss: {
|
|
26
|
+
data: undefined;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Event fired when the sheet's detent changes.
|
|
30
|
+
*/
|
|
31
|
+
sheetDetentChange: {
|
|
32
|
+
data: DetentInfoEventPayload;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Event fired when the user starts dragging the sheet.
|
|
36
|
+
*/
|
|
37
|
+
sheetDragBegin: {
|
|
38
|
+
data: DetentInfoEventPayload;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Event fired while the user is dragging the sheet.
|
|
42
|
+
*/
|
|
43
|
+
sheetDragChange: {
|
|
44
|
+
data: DetentInfoEventPayload;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Event fired when the user stops dragging the sheet.
|
|
48
|
+
*/
|
|
49
|
+
sheetDragEnd: {
|
|
50
|
+
data: DetentInfoEventPayload;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Event fired when the sheet's position changes.
|
|
54
|
+
*/
|
|
55
|
+
sheetPositionChange: {
|
|
56
|
+
data: PositionChangeEventPayload;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Event fired when the sheet is about to regain focus.
|
|
60
|
+
*/
|
|
61
|
+
sheetWillFocus: {
|
|
62
|
+
data: undefined;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Event fired when the sheet regains focus.
|
|
66
|
+
*/
|
|
67
|
+
sheetDidFocus: {
|
|
68
|
+
data: undefined;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Event fired when the sheet is about to lose focus.
|
|
72
|
+
*/
|
|
73
|
+
sheetWillBlur: {
|
|
74
|
+
data: undefined;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Event fired when the sheet loses focus.
|
|
78
|
+
*/
|
|
79
|
+
sheetDidBlur: {
|
|
80
|
+
data: undefined;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export type TrueSheetNavigationState<ParamList extends ParamListBase> = Omit<NavigationState<ParamList>, 'routes'> & {
|
|
84
|
+
type: 'true-sheet';
|
|
85
|
+
routes: (NavigationState<ParamList>['routes'][number] & {
|
|
86
|
+
resizeIndex?: number;
|
|
87
|
+
resizeKey?: number;
|
|
88
|
+
closing?: boolean;
|
|
89
|
+
})[];
|
|
90
|
+
};
|
|
91
|
+
export type TrueSheetActionHelpers<ParamList extends ParamListBase> = StackActionHelpers<ParamList> & {
|
|
92
|
+
/**
|
|
93
|
+
* Resize the sheet to a specific detent index.
|
|
94
|
+
*/
|
|
95
|
+
resize(index?: number): void;
|
|
96
|
+
};
|
|
97
|
+
export type TrueSheetNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = string, NavigatorID extends string | undefined = undefined> = NavigationProp<ParamList, RouteName, NavigatorID, TrueSheetNavigationState<ParamList>, TrueSheetNavigationOptions, TrueSheetNavigationEventMap> & TrueSheetActionHelpers<ParamList>;
|
|
98
|
+
export type TrueSheetScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = string, NavigatorID extends string | undefined = undefined> = {
|
|
99
|
+
navigation: TrueSheetNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
100
|
+
route: RouteProp<ParamList, RouteName>;
|
|
101
|
+
};
|
|
102
|
+
export type TrueSheetNavigationHelpers = NavigationHelpers<ParamListBase, TrueSheetNavigationEventMap>;
|
|
103
|
+
/**
|
|
104
|
+
* Screen options for TrueSheet navigator screens.
|
|
105
|
+
*/
|
|
106
|
+
export type TrueSheetNavigationOptions = Pick<TrueSheetProps, 'detents' | 'backgroundColor' | 'cornerRadius' | 'dismissible' | 'draggable' | 'grabber' | 'grabberOptions' | 'dimmed' | 'dimmedDetentIndex' | 'blurTint' | 'blurOptions' | 'maxHeight' | 'edgeToEdgeFullScreen' | 'scrollable' | 'keyboardMode' | 'pageSizing' | 'header' | 'footer'> & {
|
|
107
|
+
/**
|
|
108
|
+
* The detent index to present at.
|
|
109
|
+
* @default 0
|
|
110
|
+
*/
|
|
111
|
+
detentIndex?: number;
|
|
112
|
+
};
|
|
113
|
+
export type TrueSheetNavigatorProps = DefaultNavigatorOptions<ParamListBase, string | undefined, TrueSheetNavigationState<ParamListBase>, TrueSheetNavigationOptions, TrueSheetNavigationEventMap, unknown> & {
|
|
114
|
+
/**
|
|
115
|
+
* The name of the route to use as the base screen.
|
|
116
|
+
* This screen will be rendered as a regular screen, while other screens are presented as sheets.
|
|
117
|
+
* Defaults to the first screen defined in the navigator.
|
|
118
|
+
*/
|
|
119
|
+
initialRouteName?: string;
|
|
120
|
+
};
|
|
121
|
+
export type TrueSheetDescriptor = Descriptor<TrueSheetNavigationOptions, TrueSheetNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;
|
|
122
|
+
export type TrueSheetDescriptorMap = {
|
|
123
|
+
[key: string]: TrueSheetDescriptor;
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/navigation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,SAAS,EACT,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,cAAc,EACf,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,2BAA2B,GAAG;IACxC;;OAEG;IACH,gBAAgB,EAAE;QAAE,IAAI,EAAE,sBAAsB,CAAA;KAAE,CAAC;IACnD;;OAEG;IACH,eAAe,EAAE;QAAE,IAAI,EAAE,sBAAsB,CAAA;KAAE,CAAC;IAClD;;OAEG;IACH,gBAAgB,EAAE;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC;IACtC;;OAEG;IACH,eAAe,EAAE;QAAE,IAAI,EAAE,SAAS,CAAA;KAA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AAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAC1C,0BAA0B,EAC1B,uBAAuB,CAAC,aAAa,CAAC,EACtC,SAAS,CAAC,aAAa,CAAC,CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;CACpC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ParamListBase } from '@react-navigation/native';
|
|
2
|
+
import type { TrueSheetNavigationProp } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to access TrueSheet navigation with the resize helper.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function MySheet() {
|
|
9
|
+
* const navigation = useTrueSheetNavigation();
|
|
10
|
+
*
|
|
11
|
+
* // Resize to a specific detent
|
|
12
|
+
* const handleExpand = () => {
|
|
13
|
+
* navigation.resize(1); // Resize to second detent
|
|
14
|
+
* };
|
|
15
|
+
*
|
|
16
|
+
* return (
|
|
17
|
+
* <Button title="Expand" onPress={handleExpand} />
|
|
18
|
+
* );
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function useTrueSheetNavigation<T extends ParamListBase = ParamListBase>(): TrueSheetNavigationProp<T>;
|
|
23
|
+
//# sourceMappingURL=useTrueSheetNavigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrueSheetNavigation.d.ts","sourceRoot":"","sources":["../../../../src/navigation/useTrueSheetNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE7E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CACpC,CAAC,SAAS,aAAa,GAAG,aAAa,KACpC,uBAAuB,CAAC,CAAC,CAAC,CAE9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodev09/react-native-true-sheet",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
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",
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"types": "./lib/typescript/src/reanimated/index.d.ts",
|
|
17
17
|
"default": "./lib/module/reanimated/index.js"
|
|
18
18
|
},
|
|
19
|
+
"./navigation": {
|
|
20
|
+
"source": "./src/navigation/index.ts",
|
|
21
|
+
"types": "./lib/typescript/src/navigation/index.d.ts",
|
|
22
|
+
"default": "./lib/module/navigation/index.js"
|
|
23
|
+
},
|
|
19
24
|
"./package.json": "./package.json"
|
|
20
25
|
},
|
|
21
26
|
"files": [
|
|
@@ -81,6 +86,7 @@
|
|
|
81
86
|
"@evilmartians/lefthook": "^2.0.4",
|
|
82
87
|
"@react-native/babel-preset": "^0.82.1",
|
|
83
88
|
"@react-native/eslint-config": "^0.82.1",
|
|
89
|
+
"@react-navigation/native": "^7.1.6",
|
|
84
90
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
85
91
|
"@testing-library/react-native": "^13.3.3",
|
|
86
92
|
"@types/babel__core": "^7",
|
|
@@ -92,6 +98,7 @@
|
|
|
92
98
|
"eslint-config-prettier": "^10.1.8",
|
|
93
99
|
"eslint-plugin-prettier": "^5.5.4",
|
|
94
100
|
"jest": "^29.7.0",
|
|
101
|
+
"nanoid": "^5.1.5",
|
|
95
102
|
"prettier": "^3.0.3",
|
|
96
103
|
"react": "19.1.1",
|
|
97
104
|
"react-native": "0.82.1",
|
|
@@ -107,12 +114,16 @@
|
|
|
107
114
|
"@types/react": "19.1.1"
|
|
108
115
|
},
|
|
109
116
|
"peerDependencies": {
|
|
117
|
+
"@react-navigation/native": ">=6.0.0",
|
|
110
118
|
"react": "*",
|
|
111
119
|
"react-native": "*",
|
|
112
120
|
"react-native-reanimated": ">=4.0.0",
|
|
113
121
|
"react-native-worklets": "*"
|
|
114
122
|
},
|
|
115
123
|
"peerDependenciesMeta": {
|
|
124
|
+
"@react-navigation/native": {
|
|
125
|
+
"optional": true
|
|
126
|
+
},
|
|
116
127
|
"react-native-reanimated": {
|
|
117
128
|
"optional": true
|
|
118
129
|
},
|
package/src/TrueSheet.tsx
CHANGED
|
@@ -373,6 +373,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
373
373
|
style,
|
|
374
374
|
header,
|
|
375
375
|
footer,
|
|
376
|
+
insetAdjustment = 'automatic',
|
|
376
377
|
...rest
|
|
377
378
|
} = this.props;
|
|
378
379
|
|
|
@@ -407,7 +408,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
407
408
|
detents={resolvedDetents}
|
|
408
409
|
blurTint={blurTint}
|
|
409
410
|
blurOptions={blurOptions}
|
|
410
|
-
|
|
411
|
+
backgroundColor={backgroundColor}
|
|
411
412
|
cornerRadius={cornerRadius}
|
|
412
413
|
grabber={grabber}
|
|
413
414
|
grabberOptions={{
|
|
@@ -425,6 +426,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
425
426
|
edgeToEdgeFullScreen={edgeToEdgeFullScreen}
|
|
426
427
|
scrollable={scrollable}
|
|
427
428
|
pageSizing={pageSizing}
|
|
429
|
+
insetAdjustment={insetAdjustment}
|
|
428
430
|
onMount={this.onMount}
|
|
429
431
|
onWillPresent={this.onWillPresent}
|
|
430
432
|
onDidPresent={this.onDidPresent}
|
package/src/TrueSheet.types.ts
CHANGED
|
@@ -97,6 +97,21 @@ export interface BlurOptions {
|
|
|
97
97
|
interaction?: boolean;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Inset adjustment behavior for the sheet content.
|
|
102
|
+
*/
|
|
103
|
+
export type InsetAdjustment =
|
|
104
|
+
/**
|
|
105
|
+
* Automatically adjusts the sheet height to account for system insets (safe area).
|
|
106
|
+
* This ensures the sheet content is properly inset from system UI elements.
|
|
107
|
+
*/
|
|
108
|
+
| 'automatic'
|
|
109
|
+
/**
|
|
110
|
+
* Does not adjust the sheet height for system insets.
|
|
111
|
+
* The sheet height is calculated purely from the detent values.
|
|
112
|
+
*/
|
|
113
|
+
| 'never';
|
|
114
|
+
|
|
100
115
|
/**
|
|
101
116
|
* Blur style mapped to native values in IOS.
|
|
102
117
|
*
|
|
@@ -298,6 +313,17 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
298
313
|
*/
|
|
299
314
|
edgeToEdgeFullScreen?: boolean;
|
|
300
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Controls how the sheet adjusts its height for system insets (safe area).
|
|
318
|
+
*
|
|
319
|
+
* - `'automatic'`: Adds the bottom safe area inset to the sheet height,
|
|
320
|
+
* ensuring content is properly inset from system UI elements.
|
|
321
|
+
* - `'never'`: Does not adjust for insets; height is calculated purely from detent values.
|
|
322
|
+
*
|
|
323
|
+
* @default 'automatic'
|
|
324
|
+
*/
|
|
325
|
+
insetAdjustment?: InsetAdjustment;
|
|
326
|
+
|
|
301
327
|
/**
|
|
302
328
|
* A component that is fixed at the top of the Sheet content.
|
|
303
329
|
* Useful for search bars, titles, or other header content.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ViewProps } from 'react-native';
|
|
1
|
+
import type { ColorValue, ViewProps } from 'react-native';
|
|
2
2
|
import type {
|
|
3
3
|
DirectEventHandler,
|
|
4
4
|
Double,
|
|
@@ -39,14 +39,17 @@ export interface NativeProps extends ViewProps {
|
|
|
39
39
|
|
|
40
40
|
// Number properties - use 0 as default to avoid nil insertion
|
|
41
41
|
maxHeight?: WithDefault<Double, 0>;
|
|
42
|
-
background?: WithDefault<Int32, 0>;
|
|
43
42
|
cornerRadius?: WithDefault<Double, -1>;
|
|
43
|
+
|
|
44
|
+
// Color properties
|
|
45
|
+
backgroundColor?: ColorValue;
|
|
44
46
|
initialDetentIndex?: WithDefault<Int32, -1>;
|
|
45
47
|
dimmedDetentIndex?: WithDefault<Int32, 0>;
|
|
46
48
|
|
|
47
49
|
// String properties - use empty string as default to avoid nil insertion
|
|
48
50
|
blurTint?: WithDefault<string, ''>;
|
|
49
51
|
keyboardMode?: WithDefault<'resize' | 'pan', 'resize'>;
|
|
52
|
+
insetAdjustment?: WithDefault<'automatic' | 'never', 'automatic'>;
|
|
50
53
|
|
|
51
54
|
// Blur options
|
|
52
55
|
blurOptions?: BlurOptionsType;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
2
|
+
import {
|
|
3
|
+
type CommonActions,
|
|
4
|
+
type ParamListBase,
|
|
5
|
+
type Router,
|
|
6
|
+
StackRouter,
|
|
7
|
+
type StackActionType,
|
|
8
|
+
StackActions,
|
|
9
|
+
type StackRouterOptions,
|
|
10
|
+
} from '@react-navigation/native';
|
|
11
|
+
|
|
12
|
+
import type { TrueSheetNavigationState } from './types';
|
|
13
|
+
|
|
14
|
+
export type TrueSheetRouterOptions = StackRouterOptions;
|
|
15
|
+
|
|
16
|
+
export type TrueSheetActionType =
|
|
17
|
+
| StackActionType
|
|
18
|
+
| ReturnType<typeof CommonActions.goBack>
|
|
19
|
+
| {
|
|
20
|
+
type: 'RESIZE';
|
|
21
|
+
index: number;
|
|
22
|
+
source?: string;
|
|
23
|
+
target?: string;
|
|
24
|
+
}
|
|
25
|
+
| {
|
|
26
|
+
type: 'DISMISS';
|
|
27
|
+
source?: string;
|
|
28
|
+
target?: string;
|
|
29
|
+
}
|
|
30
|
+
| {
|
|
31
|
+
type: 'REMOVE';
|
|
32
|
+
source?: string;
|
|
33
|
+
target?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const TrueSheetActions = {
|
|
37
|
+
...StackActions,
|
|
38
|
+
resize(index: number): TrueSheetActionType {
|
|
39
|
+
return { type: 'RESIZE', index };
|
|
40
|
+
},
|
|
41
|
+
dismiss(): TrueSheetActionType {
|
|
42
|
+
return { type: 'DISMISS' };
|
|
43
|
+
},
|
|
44
|
+
remove(): TrueSheetActionType {
|
|
45
|
+
return { type: 'REMOVE' };
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export function TrueSheetRouter(
|
|
50
|
+
routerOptions: StackRouterOptions
|
|
51
|
+
): Router<TrueSheetNavigationState<ParamListBase>, TrueSheetActionType> {
|
|
52
|
+
const baseRouter = StackRouter(routerOptions) as unknown as Router<
|
|
53
|
+
TrueSheetNavigationState<ParamListBase>,
|
|
54
|
+
TrueSheetActionType
|
|
55
|
+
>;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
...baseRouter,
|
|
59
|
+
type: 'true-sheet',
|
|
60
|
+
|
|
61
|
+
getInitialState(options) {
|
|
62
|
+
const state = baseRouter.getInitialState(options);
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
...state,
|
|
66
|
+
stale: false,
|
|
67
|
+
type: 'true-sheet',
|
|
68
|
+
key: `true-sheet-${nanoid()}`,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
getStateForAction(state, action, options) {
|
|
73
|
+
switch (action.type) {
|
|
74
|
+
case 'RESIZE': {
|
|
75
|
+
const routeIndex =
|
|
76
|
+
action.target === state.key && action.source
|
|
77
|
+
? state.routes.findIndex((r) => r.key === action.source)
|
|
78
|
+
: state.index;
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
...state,
|
|
82
|
+
routes: state.routes.map((route, i) =>
|
|
83
|
+
i === routeIndex
|
|
84
|
+
? {
|
|
85
|
+
...route,
|
|
86
|
+
resizeIndex: action.index,
|
|
87
|
+
resizeKey: (route.resizeKey ?? 0) + 1,
|
|
88
|
+
}
|
|
89
|
+
: route
|
|
90
|
+
),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
case 'GO_BACK':
|
|
95
|
+
case 'POP':
|
|
96
|
+
case 'DISMISS': {
|
|
97
|
+
// Only base screen remains - let parent navigator handle it
|
|
98
|
+
if (state.routes.length <= 1) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Find the route to dismiss
|
|
103
|
+
const routeIndex =
|
|
104
|
+
action.target === state.key && 'source' in action && action.source
|
|
105
|
+
? state.routes.findIndex((r) => r.key === action.source)
|
|
106
|
+
: state.index;
|
|
107
|
+
|
|
108
|
+
// Base screen - let parent navigator handle it
|
|
109
|
+
if (routeIndex === 0) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Mark the route as closing instead of removing it
|
|
114
|
+
return {
|
|
115
|
+
...state,
|
|
116
|
+
routes: state.routes.map((route, i) =>
|
|
117
|
+
i === routeIndex
|
|
118
|
+
? {
|
|
119
|
+
...route,
|
|
120
|
+
closing: true,
|
|
121
|
+
}
|
|
122
|
+
: route
|
|
123
|
+
),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
case 'REMOVE': {
|
|
128
|
+
// Actually remove the closing route
|
|
129
|
+
const routeKey = action.source;
|
|
130
|
+
const routeIndex = routeKey
|
|
131
|
+
? state.routes.findIndex((r) => r.key === routeKey)
|
|
132
|
+
: state.routes.findIndex((r) => r.closing);
|
|
133
|
+
|
|
134
|
+
if (routeIndex === -1) {
|
|
135
|
+
return state;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const routes = state.routes.filter((_, i) => i !== routeIndex);
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
...state,
|
|
142
|
+
index: Math.min(state.index, routes.length - 1),
|
|
143
|
+
routes,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
default:
|
|
148
|
+
return baseRouter.getStateForAction(state, action, options);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
getRehydratedState(partialState, { routeNames, routeParamList, routeGetIdList }) {
|
|
153
|
+
if (partialState.stale === false) {
|
|
154
|
+
return partialState;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const state = baseRouter.getRehydratedState(partialState, {
|
|
158
|
+
routeNames,
|
|
159
|
+
routeParamList,
|
|
160
|
+
routeGetIdList,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
...state,
|
|
165
|
+
type: 'true-sheet',
|
|
166
|
+
key: `true-sheet-${nanoid()}`,
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
actionCreators: TrueSheetActions,
|
|
171
|
+
};
|
|
172
|
+
}
|