@lodev09/react-native-true-sheet 3.3.2 → 3.3.3
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 +11 -8
- package/ios/TrueSheetContainerView.mm +0 -12
- package/ios/utils/WindowUtil.mm +17 -1
- package/lib/module/navigation/TrueSheetRouter.js +25 -2
- package/lib/module/navigation/TrueSheetRouter.js.map +1 -1
- package/lib/typescript/src/navigation/TrueSheetRouter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/navigation/TrueSheetRouter.ts +35 -2
package/README.md
CHANGED
|
@@ -8,16 +8,18 @@
|
|
|
8
8
|
|
|
9
9
|
The true native bottom sheet experience for your React Native Apps. 💩
|
|
10
10
|
|
|
11
|
-
<img alt="React Native True Sheet - IOS" src="docs/static/img/preview-ios.gif"
|
|
11
|
+
<img alt="React Native True Sheet - IOS" src="docs/static/img/preview-ios.gif" height="500" /><img alt="React Native True Sheet - Android" src="docs/static/img/preview-android.gif" height="500" /><img alt="React Native True Sheet - Web" src="docs/static/img/preview-web.gif" height="500" />
|
|
12
12
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
15
|
* ⚡ **Powered by Fabric** - Built on React Native's new architecture for maximum performance
|
|
16
|
-
* 🚀 **Native** - Implemented in the native realm
|
|
17
|
-
* 🎯 **Type-safe** - Full TypeScript support with Codegen-generated native interfaces
|
|
16
|
+
* 🚀 **Fully Native** - Implemented in the native realm, zero JS hacks
|
|
18
17
|
* ♿ **Accessible** - Native accessibility and screen reader support out of the box
|
|
19
|
-
* 🔄 **Flexible API** - Use [imperative methods](https://sheet.lodev09.com/reference/methods#ref-methods) or [lifecycle events](https://sheet.lodev09.com/reference/
|
|
20
|
-
* 🪟 **Liquid Glass** - iOS 26+ Liquid Glass support out of the box
|
|
18
|
+
* 🔄 **Flexible API** - Use [imperative methods](https://sheet.lodev09.com/reference/methods#ref-methods) or [lifecycle events](https://sheet.lodev09.com/reference/events)
|
|
19
|
+
* 🪟 **Liquid Glass** - [iOS 26+ Liquid Glass](https://sheet.lodev09.com/guides/liquid-glass) support out of the box, featured in [Expo Blog](https://expo.dev/blog/how-to-create-apple-maps-style-liquid-glass-sheets)
|
|
20
|
+
* 🐎 **Reanimated** - First-class support for [react-native-reanimated](https://sheet.lodev09.com/guides/reanimated)
|
|
21
|
+
* 🧭 **React Navigation** - Built-in [sheet navigator](https://sheet.lodev09.com/guides/navigation) for seamless navigation integration
|
|
22
|
+
* 🌐 **Web Support** - Full [web support](https://sheet.lodev09.com/guides/web) out of the box
|
|
21
23
|
|
|
22
24
|
## Installation
|
|
23
25
|
|
|
@@ -46,11 +48,12 @@ cd ios && pod install
|
|
|
46
48
|
## Documentation
|
|
47
49
|
|
|
48
50
|
- [Example](example)
|
|
49
|
-
- [
|
|
50
|
-
- [
|
|
51
|
-
- [
|
|
51
|
+
- [Configuration](https://sheet.lodev09.com/reference/configuration)
|
|
52
|
+
- [Lifecycle Events](https://sheet.lodev09.com/reference/events)
|
|
53
|
+
- [React Navigation](https://sheet.lodev09.com/guides/navigation)
|
|
52
54
|
- [Troubleshooting](https://sheet.lodev09.com/troubleshooting)
|
|
53
55
|
- [Testing with Jest](https://sheet.lodev09.com/guides/jest)
|
|
56
|
+
- [Migrating to v3](https://sheet.lodev09.com/migration)
|
|
54
57
|
|
|
55
58
|
## Usage
|
|
56
59
|
|
|
@@ -55,18 +55,6 @@ using namespace facebook::react;
|
|
|
55
55
|
|
|
56
56
|
#pragma mark - Layout
|
|
57
57
|
|
|
58
|
-
- (void)layoutSubviews {
|
|
59
|
-
[super layoutSubviews];
|
|
60
|
-
|
|
61
|
-
// Override Yoga layout to fill parent (controller's view)
|
|
62
|
-
if (self.superview) {
|
|
63
|
-
CGRect parentBounds = self.superview.bounds;
|
|
64
|
-
if (!CGRectEqualToRect(self.frame, parentBounds)) {
|
|
65
|
-
self.frame = parentBounds;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
58
|
- (CGFloat)contentHeight {
|
|
71
59
|
return _contentView ? _contentView.frame.size.height : 0;
|
|
72
60
|
}
|
package/ios/utils/WindowUtil.mm
CHANGED
|
@@ -15,10 +15,13 @@
|
|
|
15
15
|
+ (nullable UIWindow *)keyWindow {
|
|
16
16
|
NSSet<UIScene *> *connectedScenes = [UIApplication sharedApplication].connectedScenes;
|
|
17
17
|
|
|
18
|
+
UIWindow *fallbackWindow = nil;
|
|
19
|
+
|
|
18
20
|
for (UIScene *scene in connectedScenes) {
|
|
19
21
|
if ([scene isKindOfClass:[UIWindowScene class]]) {
|
|
20
22
|
UIWindowScene *windowScene = (UIWindowScene *)scene;
|
|
21
23
|
|
|
24
|
+
// Check for foreground active first (preferred)
|
|
22
25
|
if (windowScene.activationState == UISceneActivationStateForegroundActive) {
|
|
23
26
|
for (UIWindow *window in windowScene.windows) {
|
|
24
27
|
if (window.isKeyWindow) {
|
|
@@ -31,10 +34,23 @@
|
|
|
31
34
|
return windowScene.windows.firstObject;
|
|
32
35
|
}
|
|
33
36
|
}
|
|
37
|
+
|
|
38
|
+
// Store a fallback window for transitional states (e.g., deep link handling from background or cold start)
|
|
39
|
+
if (fallbackWindow == nil && windowScene.windows.count > 0) {
|
|
40
|
+
for (UIWindow *window in windowScene.windows) {
|
|
41
|
+
if (window.isKeyWindow) {
|
|
42
|
+
fallbackWindow = window;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (fallbackWindow == nil) {
|
|
47
|
+
fallbackWindow = windowScene.windows.firstObject;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
34
50
|
}
|
|
35
51
|
}
|
|
36
52
|
|
|
37
|
-
return
|
|
53
|
+
return fallbackWindow;
|
|
38
54
|
}
|
|
39
55
|
|
|
40
56
|
@end
|
|
@@ -15,6 +15,25 @@ export const TrueSheetActions = {
|
|
|
15
15
|
type: 'REMOVE'
|
|
16
16
|
})
|
|
17
17
|
};
|
|
18
|
+
const ensureBaseRoute = (state, baseRouteName, routeParamList) => {
|
|
19
|
+
if (!baseRouteName) {
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
const hasBaseRoute = state.routes.some(r => r.name === baseRouteName);
|
|
23
|
+
if (!hasBaseRoute) {
|
|
24
|
+
const baseRoute = {
|
|
25
|
+
key: `${baseRouteName}-${nanoid()}`,
|
|
26
|
+
name: baseRouteName,
|
|
27
|
+
params: routeParamList?.[baseRouteName]
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
index: state.routes.length,
|
|
32
|
+
routes: [baseRoute, ...state.routes]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return state;
|
|
36
|
+
};
|
|
18
37
|
export const TrueSheetRouter = routerOptions => {
|
|
19
38
|
const baseRouter = StackRouter(routerOptions);
|
|
20
39
|
return {
|
|
@@ -22,8 +41,10 @@ export const TrueSheetRouter = routerOptions => {
|
|
|
22
41
|
type: 'true-sheet',
|
|
23
42
|
getInitialState(options) {
|
|
24
43
|
const state = baseRouter.getInitialState(options);
|
|
44
|
+
const baseRouteName = routerOptions.initialRouteName ?? options.routeNames[0];
|
|
45
|
+
const stateWithBaseRoute = ensureBaseRoute(state, baseRouteName, options.routeParamList);
|
|
25
46
|
return {
|
|
26
|
-
...
|
|
47
|
+
...stateWithBaseRoute,
|
|
27
48
|
stale: false,
|
|
28
49
|
type: 'true-sheet',
|
|
29
50
|
key: `true-sheet-${nanoid()}`
|
|
@@ -101,8 +122,10 @@ export const TrueSheetRouter = routerOptions => {
|
|
|
101
122
|
routeParamList,
|
|
102
123
|
routeGetIdList
|
|
103
124
|
});
|
|
125
|
+
const baseRouteName = routerOptions.initialRouteName ?? routeNames[0];
|
|
126
|
+
const stateWithBaseRoute = ensureBaseRoute(state, baseRouteName, routeParamList);
|
|
104
127
|
return {
|
|
105
|
-
...
|
|
128
|
+
...stateWithBaseRoute,
|
|
106
129
|
type: 'true-sheet',
|
|
107
130
|
key: `true-sheet-${nanoid()}`
|
|
108
131
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["nanoid","StackRouter","StackActions","TrueSheetActions","resize","index","type","dismiss","remove","TrueSheetRouter","routerOptions","baseRouter","getInitialState","options","
|
|
1
|
+
{"version":3,"names":["nanoid","StackRouter","StackActions","TrueSheetActions","resize","index","type","dismiss","remove","ensureBaseRoute","state","baseRouteName","routeParamList","hasBaseRoute","routes","some","r","name","baseRoute","key","params","length","TrueSheetRouter","routerOptions","baseRouter","getInitialState","options","initialRouteName","routeNames","stateWithBaseRoute","stale","getStateForAction","action","routeIndex","target","source","findIndex","map","route","i","resizeIndex","resizeKey","closing","routeKey","filter","_","Math","min","getRehydratedState","partialState","routeGetIdList","actionCreators"],"sourceRoot":"../../../src","sources":["navigation/TrueSheetRouter.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,SAIEC,WAAW,EAEXC,YAAY,QAEP,0BAA0B;AA0BjC,OAAO,MAAMC,gBAAgB,GAAG;EAC9B,GAAGD,YAAY;EACfE,MAAM,EAAGC,KAAa,KAA2B;IAAEC,IAAI,EAAE,QAAQ;IAAED;EAAM,CAAC,CAAC;EAC3EE,OAAO,EAAEA,CAAA,MAA4B;IAAED,IAAI,EAAE;EAAU,CAAC,CAAC;EACzDE,MAAM,EAAEA,CAAA,MAA4B;IAAEF,IAAI,EAAE;EAAS,CAAC;AACxD,CAAC;AAED,MAAMG,eAAe,GAAGA,CACtBC,KAAQ,EACRC,aAAiC,EACjCC,cAA8D,KACf;EAC/C,IAAI,CAACD,aAAa,EAAE;IAClB,OAAOD,KAAK;EACd;EAEA,MAAMG,YAAY,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,KAAKN,aAAa,CAAC;EAEvE,IAAI,CAACE,YAAY,EAAE;IACjB,MAAMK,SAAS,GAAG;MAChBC,GAAG,EAAE,GAAGR,aAAa,IAAIX,MA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heetRouter.d.ts","sourceRoot":"","sources":["../../../../src/navigation/TrueSheetRouter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,MAAM,EAEX,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAExD,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,UAAU,CAAC,OAAO,aAAa,CAAC,MAAM,CAAC,GACvC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,eAAO,MAAM,gBAAgB;oBAEX,MAAM,KAAG,mBAAmB;mBAC/B,mBAAmB;kBACpB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"TrueSheetRouter.d.ts","sourceRoot":"","sources":["../../../../src/navigation/TrueSheetRouter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,MAAM,EAEX,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAExD,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,UAAU,CAAC,OAAO,aAAa,CAAC,MAAM,CAAC,GACvC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,eAAO,MAAM,gBAAgB;oBAEX,MAAM,KAAG,mBAAmB;mBAC/B,mBAAmB;kBACpB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;aA+FvB,CAAJ;;;;;;;;;CA9FL,CAAC;AA8BF,eAAO,MAAM,eAAe,GAC1B,eAAe,kBAAkB,KAChC,MAAM,CAAC,wBAAwB,CAAC,aAAa,CAAC,EAAE,mBAAmB,CA8HrE,CAAC"}
|
package/package.json
CHANGED
|
@@ -40,6 +40,34 @@ export const TrueSheetActions = {
|
|
|
40
40
|
remove: (): TrueSheetActionType => ({ type: 'REMOVE' }),
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
const ensureBaseRoute = <T extends { routes: { name: string }[] }>(
|
|
44
|
+
state: T,
|
|
45
|
+
baseRouteName: string | undefined,
|
|
46
|
+
routeParamList: Record<string, object | undefined> | undefined
|
|
47
|
+
): T & { index: number; routes: T['routes'] } => {
|
|
48
|
+
if (!baseRouteName) {
|
|
49
|
+
return state as T & { index: number; routes: T['routes'] };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const hasBaseRoute = state.routes.some((r) => r.name === baseRouteName);
|
|
53
|
+
|
|
54
|
+
if (!hasBaseRoute) {
|
|
55
|
+
const baseRoute = {
|
|
56
|
+
key: `${baseRouteName}-${nanoid()}`,
|
|
57
|
+
name: baseRouteName,
|
|
58
|
+
params: routeParamList?.[baseRouteName],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
...state,
|
|
63
|
+
index: state.routes.length,
|
|
64
|
+
routes: [baseRoute, ...state.routes],
|
|
65
|
+
} as T & { index: number; routes: T['routes'] };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return state as T & { index: number; routes: T['routes'] };
|
|
69
|
+
};
|
|
70
|
+
|
|
43
71
|
export const TrueSheetRouter = (
|
|
44
72
|
routerOptions: StackRouterOptions
|
|
45
73
|
): Router<TrueSheetNavigationState<ParamListBase>, TrueSheetActionType> => {
|
|
@@ -54,9 +82,11 @@ export const TrueSheetRouter = (
|
|
|
54
82
|
|
|
55
83
|
getInitialState(options) {
|
|
56
84
|
const state = baseRouter.getInitialState(options);
|
|
85
|
+
const baseRouteName = routerOptions.initialRouteName ?? options.routeNames[0];
|
|
86
|
+
const stateWithBaseRoute = ensureBaseRoute(state, baseRouteName, options.routeParamList);
|
|
57
87
|
|
|
58
88
|
return {
|
|
59
|
-
...
|
|
89
|
+
...stateWithBaseRoute,
|
|
60
90
|
stale: false,
|
|
61
91
|
type: 'true-sheet',
|
|
62
92
|
key: `true-sheet-${nanoid()}`,
|
|
@@ -154,8 +184,11 @@ export const TrueSheetRouter = (
|
|
|
154
184
|
routeGetIdList,
|
|
155
185
|
});
|
|
156
186
|
|
|
187
|
+
const baseRouteName = routerOptions.initialRouteName ?? routeNames[0];
|
|
188
|
+
const stateWithBaseRoute = ensureBaseRoute(state, baseRouteName, routeParamList);
|
|
189
|
+
|
|
157
190
|
return {
|
|
158
|
-
...
|
|
191
|
+
...stateWithBaseRoute,
|
|
159
192
|
type: 'true-sheet',
|
|
160
193
|
key: `true-sheet-${nanoid()}`,
|
|
161
194
|
};
|