@lodev09/react-native-true-sheet 3.1.0-beta.9 → 3.1.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/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +8 -2
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +13 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +0 -3
- package/ios/TrueSheetModule.mm +17 -2
- package/ios/TrueSheetView.h +2 -0
- package/ios/TrueSheetView.mm +12 -0
- package/ios/TrueSheetViewController.mm +9 -0
- 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/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/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
|
@@ -85,8 +85,14 @@ class TrueSheetModule(reactContext: ReactApplicationContext) :
|
|
|
85
85
|
*/
|
|
86
86
|
@ReactMethod
|
|
87
87
|
fun resizeByRef(viewTag: Double, index: Double, promise: Promise) {
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
val tag = viewTag.toInt()
|
|
89
|
+
val detentIndex = index.toInt()
|
|
90
|
+
|
|
91
|
+
withTrueSheetView(tag, promise) { view ->
|
|
92
|
+
view.resize(detentIndex) {
|
|
93
|
+
promise.resolve(null)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.lodev09.truesheet
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
|
+
import android.util.Log
|
|
4
5
|
import android.view.View
|
|
5
6
|
import android.view.ViewStructure
|
|
6
7
|
import android.view.accessibility.AccessibilityEvent
|
|
@@ -12,6 +13,7 @@ import com.facebook.react.uimanager.StateWrapper
|
|
|
12
13
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
13
14
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
14
15
|
import com.facebook.react.uimanager.events.EventDispatcher
|
|
16
|
+
import com.facebook.react.util.RNLog
|
|
15
17
|
import com.facebook.react.views.view.ReactViewGroup
|
|
16
18
|
import com.lodev09.truesheet.core.GrabberOptions
|
|
17
19
|
import com.lodev09.truesheet.core.TrueSheetDialogObserver
|
|
@@ -92,7 +94,6 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
92
94
|
viewController.setupBackground()
|
|
93
95
|
viewController.setupGrabber()
|
|
94
96
|
updateSheetIfNeeded()
|
|
95
|
-
viewController.setStateForDetentIndex(viewController.currentDetentIndex)
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
@@ -331,6 +332,17 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
331
332
|
viewController.dismiss(animated)
|
|
332
333
|
}
|
|
333
334
|
|
|
335
|
+
@UiThread
|
|
336
|
+
fun resize(detentIndex: Int, promiseCallback: () -> Unit) {
|
|
337
|
+
if (!viewController.isPresented) {
|
|
338
|
+
RNLog.w(reactContext, "TrueSheet: Cannot resize. Sheet is not presented.")
|
|
339
|
+
promiseCallback()
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
present(detentIndex, true, promiseCallback)
|
|
344
|
+
}
|
|
345
|
+
|
|
334
346
|
/**
|
|
335
347
|
* Debounced sheet update to handle rapid content/header size changes.
|
|
336
348
|
* Uses post to ensure all layout passes complete before reconfiguring.
|
|
@@ -448,15 +448,12 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
|
|
|
448
448
|
fun hideDialog() {
|
|
449
449
|
isDialogVisible = false
|
|
450
450
|
dialog?.window?.decorView?.visibility = INVISIBLE
|
|
451
|
-
emitChangePositionDelegate(screenHeight, realtime = false)
|
|
452
451
|
}
|
|
453
452
|
|
|
454
453
|
/** Shows a previously hidden dialog. */
|
|
455
454
|
fun showDialog() {
|
|
456
455
|
isDialogVisible = true
|
|
457
456
|
dialog?.window?.decorView?.visibility = VISIBLE
|
|
458
|
-
val positionPx = bottomSheetView?.let { ScreenUtils.getScreenY(it) } ?: screenHeight
|
|
459
|
-
emitChangePositionDelegate(positionPx, realtime = false)
|
|
460
457
|
}
|
|
461
458
|
|
|
462
459
|
// ====================================================================
|
package/ios/TrueSheetModule.mm
CHANGED
|
@@ -96,8 +96,23 @@ RCT_EXPORT_MODULE(TrueSheetModule)
|
|
|
96
96
|
index:(double)index
|
|
97
97
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
98
98
|
reject:(RCTPromiseRejectBlock)reject {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
RCTExecuteOnMainQueue(^{
|
|
100
|
+
TrueSheetView *trueSheetView = [TrueSheetModule getTrueSheetViewByTag:@((NSInteger)viewTag)];
|
|
101
|
+
|
|
102
|
+
if (!trueSheetView) {
|
|
103
|
+
reject(@"SHEET_NOT_FOUND", [NSString stringWithFormat:@"No sheet found with tag %d", (int)viewTag], nil);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
[trueSheetView resizeToIndex:(NSInteger)index
|
|
108
|
+
completion:^(BOOL success, NSError *_Nullable error) {
|
|
109
|
+
if (success) {
|
|
110
|
+
resolve(nil);
|
|
111
|
+
} else {
|
|
112
|
+
reject(@"RESIZE_FAILED", error.localizedDescription ?: @"Failed to resize sheet", error);
|
|
113
|
+
}
|
|
114
|
+
}];
|
|
115
|
+
});
|
|
101
116
|
}
|
|
102
117
|
|
|
103
118
|
#pragma mark - Helper Methods
|
package/ios/TrueSheetView.h
CHANGED
|
@@ -30,6 +30,8 @@ typedef void (^TrueSheetCompletionBlock)(BOOL success, NSError *_Nullable error)
|
|
|
30
30
|
|
|
31
31
|
- (void)dismissAnimated:(BOOL)animated completion:(nullable TrueSheetCompletionBlock)completion;
|
|
32
32
|
|
|
33
|
+
- (void)resizeToIndex:(NSInteger)index completion:(nullable TrueSheetCompletionBlock)completion;
|
|
34
|
+
|
|
33
35
|
@end
|
|
34
36
|
|
|
35
37
|
NS_ASSUME_NONNULL_END
|
package/ios/TrueSheetView.mm
CHANGED
|
@@ -356,6 +356,18 @@ using namespace facebook::react;
|
|
|
356
356
|
}];
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
+
- (void)resizeToIndex:(NSInteger)index completion:(nullable TrueSheetCompletionBlock)completion {
|
|
360
|
+
if (!_controller.isPresented) {
|
|
361
|
+
RCTLogWarn(@"TrueSheet: Cannot resize. Sheet is not presented.");
|
|
362
|
+
if (completion) {
|
|
363
|
+
completion(YES, nil);
|
|
364
|
+
}
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
[self presentAtIndex:index animated:YES completion:completion];
|
|
369
|
+
}
|
|
370
|
+
|
|
359
371
|
#pragma mark - TrueSheetContainerViewDelegate
|
|
360
372
|
|
|
361
373
|
/**
|
|
@@ -489,6 +489,15 @@
|
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
- (void)emitChangePositionDelegateWithPosition:(CGFloat)position realtime:(BOOL)realtime debug:(NSString *)debug {
|
|
492
|
+
UIViewController *presented = self.presentedViewController;
|
|
493
|
+
if (presented) {
|
|
494
|
+
UIModalPresentationStyle style = presented.modalPresentationStyle;
|
|
495
|
+
if (style == UIModalPresentationFullScreen || style == UIModalPresentationOverFullScreen ||
|
|
496
|
+
style == UIModalPresentationCurrentContext || style == UIModalPresentationOverCurrentContext) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
492
501
|
if (fabs(_lastPosition - position) > 0.01) {
|
|
493
502
|
_lastPosition = position;
|
|
494
503
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
4
|
+
import { StackRouter, StackActions } from '@react-navigation/native';
|
|
5
|
+
export const TrueSheetActions = {
|
|
6
|
+
...StackActions,
|
|
7
|
+
resize(index) {
|
|
8
|
+
return {
|
|
9
|
+
type: 'RESIZE',
|
|
10
|
+
index
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
dismiss() {
|
|
14
|
+
return {
|
|
15
|
+
type: 'DISMISS'
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
remove() {
|
|
19
|
+
return {
|
|
20
|
+
type: 'REMOVE'
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export function TrueSheetRouter(routerOptions) {
|
|
25
|
+
const baseRouter = StackRouter(routerOptions);
|
|
26
|
+
return {
|
|
27
|
+
...baseRouter,
|
|
28
|
+
type: 'true-sheet',
|
|
29
|
+
getInitialState(options) {
|
|
30
|
+
const state = baseRouter.getInitialState(options);
|
|
31
|
+
return {
|
|
32
|
+
...state,
|
|
33
|
+
stale: false,
|
|
34
|
+
type: 'true-sheet',
|
|
35
|
+
key: `true-sheet-${nanoid()}`
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
getStateForAction(state, action, options) {
|
|
39
|
+
switch (action.type) {
|
|
40
|
+
case 'RESIZE':
|
|
41
|
+
{
|
|
42
|
+
const routeIndex = action.target === state.key && action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
|
|
43
|
+
return {
|
|
44
|
+
...state,
|
|
45
|
+
routes: state.routes.map((route, i) => i === routeIndex ? {
|
|
46
|
+
...route,
|
|
47
|
+
resizeIndex: action.index,
|
|
48
|
+
resizeKey: (route.resizeKey ?? 0) + 1
|
|
49
|
+
} : route)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
case 'GO_BACK':
|
|
53
|
+
case 'POP':
|
|
54
|
+
case 'DISMISS':
|
|
55
|
+
{
|
|
56
|
+
// Only base screen remains - let parent navigator handle it
|
|
57
|
+
if (state.routes.length <= 1) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Find the route to dismiss
|
|
62
|
+
const routeIndex = action.target === state.key && 'source' in action && action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
|
|
63
|
+
|
|
64
|
+
// Base screen - let parent navigator handle it
|
|
65
|
+
if (routeIndex === 0) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Mark the route as closing instead of removing it
|
|
70
|
+
return {
|
|
71
|
+
...state,
|
|
72
|
+
routes: state.routes.map((route, i) => i === routeIndex ? {
|
|
73
|
+
...route,
|
|
74
|
+
closing: true
|
|
75
|
+
} : route)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
case 'REMOVE':
|
|
79
|
+
{
|
|
80
|
+
// Actually remove the closing route
|
|
81
|
+
const routeKey = action.source;
|
|
82
|
+
const routeIndex = routeKey ? state.routes.findIndex(r => r.key === routeKey) : state.routes.findIndex(r => r.closing);
|
|
83
|
+
if (routeIndex === -1) {
|
|
84
|
+
return state;
|
|
85
|
+
}
|
|
86
|
+
const routes = state.routes.filter((_, i) => i !== routeIndex);
|
|
87
|
+
return {
|
|
88
|
+
...state,
|
|
89
|
+
index: Math.min(state.index, routes.length - 1),
|
|
90
|
+
routes
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
default:
|
|
94
|
+
return baseRouter.getStateForAction(state, action, options);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
getRehydratedState(partialState, {
|
|
98
|
+
routeNames,
|
|
99
|
+
routeParamList,
|
|
100
|
+
routeGetIdList
|
|
101
|
+
}) {
|
|
102
|
+
if (partialState.stale === false) {
|
|
103
|
+
return partialState;
|
|
104
|
+
}
|
|
105
|
+
const state = baseRouter.getRehydratedState(partialState, {
|
|
106
|
+
routeNames,
|
|
107
|
+
routeParamList,
|
|
108
|
+
routeGetIdList
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
...state,
|
|
112
|
+
type: 'true-sheet',
|
|
113
|
+
key: `true-sheet-${nanoid()}`
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
actionCreators: TrueSheetActions
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=TrueSheetRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["nanoid","StackRouter","StackActions","TrueSheetActions","resize","index","type","dismiss","remove","TrueSheetRouter","routerOptions","baseRouter","getInitialState","options","state","stale","key","getStateForAction","action","routeIndex","target","source","routes","findIndex","r","map","route","i","resizeIndex","resizeKey","length","closing","routeKey","filter","_","Math","min","getRehydratedState","partialState","routeNames","routeParamList","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,MAAMA,CAACC,KAAa,EAAuB;IACzC,OAAO;MAAEC,IAAI,EAAE,QAAQ;MAAED;IAAM,CAAC;EAClC,CAAC;EACDE,OAAOA,CAAA,EAAwB;IAC7B,OAAO;MAAED,IAAI,EAAE;IAAU,CAAC;EAC5B,CAAC;EACDE,MAAMA,CAAA,EAAwB;IAC5B,OAAO;MAAEF,IAAI,EAAE;IAAS,CAAC;EAC3B;AACF,CAAC;AAED,OAAO,SAASG,eAAeA,CAC7BC,aAAiC,EACqC;EACtE,MAAMC,UAAU,GAAGV,WAAW,CAACS,aAAa,CAG3C;EAED,OAAO;IACL,GAAGC,UAAU;IACbL,IAAI,EAAE,YAAY;IAElBM,eAAeA,CAACC,OAAO,EAAE;MACvB,MAAMC,KAAK,GAAGH,UAAU,CAACC,eAAe,CAACC,OAAO,CAAC;MAEjD,OAAO;QACL,GAAGC,KAAK;QACRC,KAAK,EAAE,KAAK;QACZT,IAAI,EAAE,YAAY;QAClBU,GAAG,EAAE,cAAchB,MAAM,CAAC,CAAC;MAC7B,CAAC;IACH,CAAC;IAEDiB,iBAAiBA,CAACH,KAAK,EAAEI,MAAM,EAAEL,OAAO,EAAE;MACxC,QAAQK,MAAM,CAACZ,IAAI;QACjB,KAAK,QAAQ;UAAE;YACb,MAAMa,UAAU,GACdD,MAAM,CAACE,MAAM,KAAKN,KAAK,CAACE,GAAG,IAAIE,MAAM,CAACG,MAAM,GACxCP,KAAK,CAACQ,MAAM,CAACC,SAAS,CAAEC,CAAC,IAAKA,CAAC,CAACR,GAAG,KAAKE,MAAM,CAAC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GAAG,KAAKgB,QAAQ,CAAC,GACjDlB,KAAK,CAACQ,MAAM,CAACC,SAAS,CAAEC,CAAC,IAAKA,CAAC,CAACO,OAAO,CAAC;YAE5C,IAAIZ,UAAU,KAAK,CAAC,CAAC,EAAE;cACrB,OAAOL,KAAK;YACd;YAEA,MAAMQ,MAAM,GAAGR,KAAK,CAACQ,MAAM,CAACW,MAAM,CAAC,CAACC,CAAC,EAAEP,CAAC,KAAKA,CAAC,KAAKR,UAAU,CAAC;YAE9D,OAAO;cACL,GAAGL,KAAK;cACRT,KAAK,EAAE8B,IAAI,CAACC,GAAG,CAACtB,KAAK,CAACT,KAAK,EAAEiB,MAAM,CAACQ,MAAM,GAAG,CAAC,CAAC;cAC/CR;YACF,CAAC;UACH;QAEA;UACE,OAAOX,UAAU,CAACM,iBAAiB,CAACH,KAAK,EAAEI,MAAM,EAAEL,OAAO,CAAC;MAC/D;IACF,CAAC;IAEDwB,kBAAkBA,CAACC,YAAY,EAAE;MAAEC,UAAU;MAAEC,cAAc;MAAEC;IAAe,CAAC,EAAE;MAC/E,IAAIH,YAAY,CAACvB,KAAK,KAAK,KAAK,EAAE;QAChC,OAAOuB,YAAY;MACrB;MAEA,MAAMxB,KAAK,GAAGH,UAAU,CAAC0B,kBAAkB,CAACC,YAAY,EAAE;QACxDC,UAAU;QACVC,cAAc;QACdC;MACF,CAAC,CAAC;MAEF,OAAO;QACL,GAAG3B,KAAK;QACRR,IAAI,EAAE,YAAY;QAClBU,GAAG,EAAE,cAAchB,MAAM,CAAC,CAAC;MAC7B,CAAC;IACH,CAAC;IAED0C,cAAc,EAAEvC;EAClB,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import { TrueSheet } from "../TrueSheet.js";
|
|
5
|
+
import { TrueSheetActions } from "./TrueSheetRouter.js";
|
|
6
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
function TrueSheetScreen({
|
|
8
|
+
detentIndex,
|
|
9
|
+
resizeKey,
|
|
10
|
+
navigation,
|
|
11
|
+
emit,
|
|
12
|
+
routeKey,
|
|
13
|
+
closing,
|
|
14
|
+
detents,
|
|
15
|
+
children,
|
|
16
|
+
...sheetProps
|
|
17
|
+
}) {
|
|
18
|
+
const ref = useRef(null);
|
|
19
|
+
const isDismissedRef = useRef(false);
|
|
20
|
+
const isFirstRenderRef = useRef(true);
|
|
21
|
+
// Capture initial detent index only once
|
|
22
|
+
const initialDetentIndexRef = useRef(detentIndex);
|
|
23
|
+
|
|
24
|
+
// Handle closing state change - dismiss the sheet and wait for animation
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (closing && !isDismissedRef.current) {
|
|
27
|
+
isDismissedRef.current = true;
|
|
28
|
+
(async () => {
|
|
29
|
+
await ref.current?.dismiss();
|
|
30
|
+
navigation.dispatch({
|
|
31
|
+
...TrueSheetActions.remove(),
|
|
32
|
+
source: routeKey
|
|
33
|
+
});
|
|
34
|
+
})();
|
|
35
|
+
} else if (closing && isDismissedRef.current) {
|
|
36
|
+
// Sheet was already dismissed by user swipe, just remove
|
|
37
|
+
navigation.dispatch({
|
|
38
|
+
...TrueSheetActions.remove(),
|
|
39
|
+
source: routeKey
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, [closing, navigation, routeKey]);
|
|
43
|
+
|
|
44
|
+
// Handle resize - resizeKey ensures effect runs even when resizing to same index
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
// Skip first render - initialDetentIndex handles initial presentation
|
|
47
|
+
if (isFirstRenderRef.current) {
|
|
48
|
+
isFirstRenderRef.current = false;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
ref.current?.resize(detentIndex);
|
|
52
|
+
}, [detentIndex, resizeKey]);
|
|
53
|
+
const emitEvent = useCallback((type, data) => {
|
|
54
|
+
emit({
|
|
55
|
+
type,
|
|
56
|
+
target: routeKey,
|
|
57
|
+
data
|
|
58
|
+
});
|
|
59
|
+
}, [emit, routeKey]);
|
|
60
|
+
const onWillPresent = useCallback(e => {
|
|
61
|
+
emitEvent('sheetWillPresent', e.nativeEvent);
|
|
62
|
+
}, [emitEvent]);
|
|
63
|
+
const onDidPresent = useCallback(e => {
|
|
64
|
+
emitEvent('sheetDidPresent', e.nativeEvent);
|
|
65
|
+
}, [emitEvent]);
|
|
66
|
+
const onWillDismiss = useCallback(_e => {
|
|
67
|
+
emitEvent('sheetWillDismiss', undefined);
|
|
68
|
+
}, [emitEvent]);
|
|
69
|
+
const onDidDismiss = useCallback(() => {
|
|
70
|
+
emitEvent('sheetDidDismiss', undefined);
|
|
71
|
+
// User dismissed the sheet by swiping down
|
|
72
|
+
if (!isDismissedRef.current) {
|
|
73
|
+
isDismissedRef.current = true;
|
|
74
|
+
navigation.goBack();
|
|
75
|
+
}
|
|
76
|
+
}, [emitEvent, navigation]);
|
|
77
|
+
const onDetentChange = useCallback(e => {
|
|
78
|
+
emitEvent('sheetDetentChange', e.nativeEvent);
|
|
79
|
+
}, [emitEvent]);
|
|
80
|
+
const onDragBegin = useCallback(e => {
|
|
81
|
+
emitEvent('sheetDragBegin', e.nativeEvent);
|
|
82
|
+
}, [emitEvent]);
|
|
83
|
+
const onDragChange = useCallback(e => {
|
|
84
|
+
emitEvent('sheetDragChange', e.nativeEvent);
|
|
85
|
+
}, [emitEvent]);
|
|
86
|
+
const onDragEnd = useCallback(e => {
|
|
87
|
+
emitEvent('sheetDragEnd', e.nativeEvent);
|
|
88
|
+
}, [emitEvent]);
|
|
89
|
+
const onPositionChange = useCallback(e => {
|
|
90
|
+
emitEvent('sheetPositionChange', e.nativeEvent);
|
|
91
|
+
}, [emitEvent]);
|
|
92
|
+
const onWillFocus = useCallback(_e => {
|
|
93
|
+
emitEvent('sheetWillFocus', undefined);
|
|
94
|
+
}, [emitEvent]);
|
|
95
|
+
const onDidFocus = useCallback(_e => {
|
|
96
|
+
emitEvent('sheetDidFocus', undefined);
|
|
97
|
+
}, [emitEvent]);
|
|
98
|
+
const onWillBlur = useCallback(_e => {
|
|
99
|
+
emitEvent('sheetWillBlur', undefined);
|
|
100
|
+
}, [emitEvent]);
|
|
101
|
+
const onDidBlur = useCallback(_e => {
|
|
102
|
+
emitEvent('sheetDidBlur', undefined);
|
|
103
|
+
}, [emitEvent]);
|
|
104
|
+
return /*#__PURE__*/_jsx(TrueSheet, {
|
|
105
|
+
ref: ref,
|
|
106
|
+
name: `navigation-sheet-${routeKey}`,
|
|
107
|
+
initialDetentIndex: initialDetentIndexRef.current,
|
|
108
|
+
detents: detents,
|
|
109
|
+
onWillPresent: onWillPresent,
|
|
110
|
+
onDidPresent: onDidPresent,
|
|
111
|
+
onWillDismiss: onWillDismiss,
|
|
112
|
+
onDidDismiss: onDidDismiss,
|
|
113
|
+
onDetentChange: onDetentChange,
|
|
114
|
+
onDragBegin: onDragBegin,
|
|
115
|
+
onDragChange: onDragChange,
|
|
116
|
+
onDragEnd: onDragEnd,
|
|
117
|
+
onPositionChange: onPositionChange,
|
|
118
|
+
onWillFocus: onWillFocus,
|
|
119
|
+
onDidFocus: onDidFocus,
|
|
120
|
+
onWillBlur: onWillBlur,
|
|
121
|
+
onDidBlur: onDidBlur,
|
|
122
|
+
...sheetProps,
|
|
123
|
+
children: children
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const DEFAULT_DETENTS = ['auto'];
|
|
127
|
+
function clampDetentIndex(index, detentsLength) {
|
|
128
|
+
return Math.min(index, Math.max(detentsLength - 1, 0));
|
|
129
|
+
}
|
|
130
|
+
export function TrueSheetView({
|
|
131
|
+
state,
|
|
132
|
+
navigation,
|
|
133
|
+
descriptors
|
|
134
|
+
}) {
|
|
135
|
+
// First route is the base screen, rest are sheets
|
|
136
|
+
const [baseRoute, ...sheetRoutes] = state.routes;
|
|
137
|
+
const baseDescriptor = baseRoute ? descriptors[baseRoute.key] : null;
|
|
138
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
139
|
+
children: [baseDescriptor?.render(), sheetRoutes.map(route => {
|
|
140
|
+
const descriptor = descriptors[route.key];
|
|
141
|
+
if (!descriptor) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const {
|
|
145
|
+
options,
|
|
146
|
+
navigation: screenNavigation,
|
|
147
|
+
render
|
|
148
|
+
} = descriptor;
|
|
149
|
+
const {
|
|
150
|
+
detentIndex = 0,
|
|
151
|
+
detents = DEFAULT_DETENTS,
|
|
152
|
+
...sheetProps
|
|
153
|
+
} = options;
|
|
154
|
+
const resolvedIndex = clampDetentIndex(route.resizeIndex ?? detentIndex, detents.length);
|
|
155
|
+
return /*#__PURE__*/_jsx(TrueSheetScreen, {
|
|
156
|
+
routeKey: route.key,
|
|
157
|
+
closing: route.closing,
|
|
158
|
+
detentIndex: resolvedIndex,
|
|
159
|
+
resizeKey: route.resizeKey,
|
|
160
|
+
detents: detents,
|
|
161
|
+
navigation: screenNavigation,
|
|
162
|
+
emit: navigation.emit,
|
|
163
|
+
...sheetProps,
|
|
164
|
+
children: render()
|
|
165
|
+
}, route.key);
|
|
166
|
+
})]
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=TrueSheetView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useRef","TrueSheet","TrueSheetActions","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","TrueSheetScreen","detentIndex","resizeKey","navigation","emit","routeKey","closing","detents","children","sheetProps","ref","isDismissedRef","isFirstRenderRef","initialDetentIndexRef","current","dismiss","dispatch","remove","source","resize","emitEvent","type","data","target","onWillPresent","e","nativeEvent","onDidPresent","onWillDismiss","_e","undefined","onDidDismiss","goBack","onDetentChange","onDragBegin","onDragChange","onDragEnd","onPositionChange","onWillFocus","onDidFocus","onWillBlur","onDidBlur","name","initialDetentIndex","DEFAULT_DETENTS","clampDetentIndex","index","detentsLength","Math","min","max","TrueSheetView","state","descriptors","baseRoute","sheetRoutes","routes","baseDescriptor","key","render","map","route","descriptor","options","screenNavigation","resolvedIndex","resizeIndex","length"],"sourceRoot":"../../../src","sources":["navigation/TrueSheetView.tsx"],"mappings":";;AACA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAE7D,SAASC,SAAS,QAAQ,iBAAc;AAyBxC,SAASC,gBAAgB,QAAQ,sBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAcrD,SAASC,eAAeA,CAAC;EACvBC,WAAW;EACXC,SAAS;EACTC,UAAU;EACVC,IAAI;EACJC,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACR,GAAGC;AACiB,CAAC,EAAE;EACvB,MAAMC,GAAG,GAAGnB,MAAM,CAAY,IAAI,CAAC;EACnC,MAAMoB,cAAc,GAAGpB,MAAM,CAAC,KAAK,CAAC;EACpC,MAAMqB,gBAAgB,GAAGrB,MAAM,CAAC,IAAI,CAAC;EACrC;EACA,MAAMsB,qBAAqB,GAAGtB,MAAM,CAACU,WAAW,CAAC;;EAEjD;EACAX,SAAS,CAAC,MAAM;IACd,IAAIgB,OAAO,IAAI,CAACK,cAAc,CAACG,OAAO,EAAE;MACtCH,cAAc,CAACG,OAAO,GAAG,IAAI;MAC7B,CAAC,YAAY;QACX,MAAMJ,GAAG,CAACI,OAAO,EAAEC,OAAO,CAAC,CAAC;QAC5BZ,UAAU,CAACa,QAAQ,CAAC;UAAE,GAAGvB,gBAAgB,CAACwB,MAAM,CAAC,CAAC;UAAEC,MAAM,EAAEb;QAAS,CAAC,CAAC;MACzE,CAAC,EAAE,CAAC;IACN,CAAC,MAAM,IAAIC,OAAO,IAAIK,cAAc,CAACG,OAAO,EAAE;MAC5C;MACAX,UAAU,CAACa,QAAQ,CAAC;Q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K,CAACI,MAAM;EAEhD,MAAMC,cAAc,GAAGH,SAAS,GAAGD,WAAW,CAACC,SAAS,CAACI,GAAG,CAAC,GAAG,IAAI;EAEpE,oBACE3D,KAAA,CAAAF,SAAA;IAAAW,QAAA,GAEGiD,cAAc,EAAEE,MAAM,CAAC,CAAC,EAGxBJ,WAAW,CAACK,GAAG,CAAEC,KAAK,IAAK;MAC1B,MAAMC,UAAU,GAAGT,WAAW,CAACQ,KAAK,CAACH,GAAG,CAAC;MAEzC,IAAI,CAACI,UAAU,EAAE;QACf,OAAO,IAAI;MACb;MAEA,MAAM;QAAEC,OAAO;QAAE5D,UAAU,EAAE6D,gBAAgB;QAAEL;MAAO,CAAC,GAAGG,UAAU;MACpE,MAAM;QAAE7D,WAAW,GAAG,CAAC;QAAEM,OAAO,GAAGqC,eAAe;QAAE,GAAGnC;MAAW,CAAC,GAAGsD,OAAO;MAC7E,MAAME,aAAa,GAAGpB,gBAAgB,CAACgB,KAAK,CAACK,WAAW,IAAIjE,WAAW,EAAEM,OAAO,CAAC4D,MAAM,CAAC;MAExF,oBACExE,IAAA,CAACK,eAAe;QAEdK,QAAQ,EAAEwD,KAAK,CAACH,GAAI;QACpBpD,OAAO,EAAEuD,KAAK,CAACvD,OAAQ;QACvBL,WAAW,EAAEgE,aAAc;QAC3B/D,SAAS,EAAE2D,KAAK,CAAC3D,SAAU;QAC3BK,OAAO,EAAEA,OAAQ;QACjBJ,UAAU,EAAE6D,gBAAiB;QAC7B5D,IAAI,EAAED,UAAU,CAACC,IAAK;QAAA,GAClBK,UAAU;QAAAD,QAAA,EAEbmD,MAAM,CAAC;MAAC,GAVJE,KAAK,CAACH,GAWI,CAAC;IAEtB,CAAC,CAAC;EAAA,CACF,CAAC;AAEP","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createNavigatorFactory, useNavigationBuilder } from '@react-navigation/native';
|
|
4
|
+
import { TrueSheetRouter } from "./TrueSheetRouter.js";
|
|
5
|
+
import { TrueSheetView } from "./TrueSheetView.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
function TrueSheetNavigator({
|
|
8
|
+
id,
|
|
9
|
+
initialRouteName,
|
|
10
|
+
children,
|
|
11
|
+
screenListeners,
|
|
12
|
+
screenOptions
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
state,
|
|
16
|
+
descriptors,
|
|
17
|
+
navigation,
|
|
18
|
+
NavigationContent
|
|
19
|
+
} = useNavigationBuilder(TrueSheetRouter, {
|
|
20
|
+
id,
|
|
21
|
+
initialRouteName,
|
|
22
|
+
children,
|
|
23
|
+
screenListeners,
|
|
24
|
+
screenOptions
|
|
25
|
+
});
|
|
26
|
+
return /*#__PURE__*/_jsx(NavigationContent, {
|
|
27
|
+
children: /*#__PURE__*/_jsx(TrueSheetView, {
|
|
28
|
+
state: state,
|
|
29
|
+
navigation: navigation,
|
|
30
|
+
descriptors: descriptors
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a TrueSheet navigator.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const Sheet = createTrueSheetNavigator();
|
|
41
|
+
*
|
|
42
|
+
* function App() {
|
|
43
|
+
* return (
|
|
44
|
+
* <Sheet.Navigator>
|
|
45
|
+
* <Sheet.Screen name="Home" component={HomeScreen} />
|
|
46
|
+
* <Sheet.Screen
|
|
47
|
+
* name="Details"
|
|
48
|
+
* component={DetailsSheet}
|
|
49
|
+
* options={{ detents: [0.5, 1] }}
|
|
50
|
+
* />
|
|
51
|
+
* </Sheet.Navigator>
|
|
52
|
+
* );
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export const createTrueSheetNavigator = config => {
|
|
57
|
+
return createNavigatorFactory(TrueSheetNavigator)(config);
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=createTrueSheetNavigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createNavigatorFactory","useNavigationBuilder","TrueSheetRouter","TrueSheetView","jsx","_jsx","TrueSheetNavigator","id","initialRouteName","children","screenListeners","screenOptions","state","descriptors","navigation","NavigationContent","createTrueSheetNavigator","config"],"sourceRoot":"../../../src","sources":["navigation/createTrueSheetNavigator.tsx"],"mappings":";;AAAA,SACEA,sBAAsB,EAKtBC,oBAAoB,QACf,0BAA0B;AAEjC,SAASC,eAAe,QAAqC,sBAAmB;AAChF,SAASC,aAAa,QAAQ,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAUhD,SAASC,kBAAkBA,CAAC;EAC1BC,EAAE;EACFC,gBAAgB;EAChBC,QAAQ;EACRC,eAAe;EACfC;AACuB,CAAC,EAAE;EAC1B,MAAM;IAAEC,KAAK;IAAEC,WAAW;IAAEC,UAAU;IAAEC;EAAkB,CAAC,GAAGd,oBAAoB,CAMhFC,eAAe,EAAE;IACjBK,EAAE;IACFC,gBAAgB;IAChBC,QAAQ;IACRC,eAAe;IACfC;EACF,CAAC,CAAC;EAEF,oBACEN,IAAA,CAACU,iBAAiB;IAAAN,QAAA,eAChBJ,IAAA,CAACF,aAAa;MAACS,KAAK,EAAEA,KAAM;MAACE,UAAU,EAAEA,UAAW;MAACD,WAAW,EAAEA;IAAY,CAAE;EAAC,CAChE,CAAC;AAExB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,wBAAwB,GAgBnCC,MAAe,IACqB;EACpC,OAAOjB,sBAAsB,CAACM,kBAAkB,CAAC,CAACW,MAAM,CAAC;AAC3D,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createTrueSheetNavigator","TrueSheetActions","useTrueSheetNavigation"],"sourceRoot":"../../../src","sources":["navigation/index.ts"],"mappings":";;AAAA,SAASA,wBAAwB,QAAQ,+BAA4B;AACrE,SAASC,gBAAgB,QAAkC,sBAAmB;AAC9E,SAASC,sBAAsB,QAAQ,6BAA0B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["navigation/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useNavigation } from '@react-navigation/native';
|
|
4
|
+
/**
|
|
5
|
+
* Hook to access TrueSheet navigation with the resize helper.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* function MySheet() {
|
|
10
|
+
* const navigation = useTrueSheetNavigation();
|
|
11
|
+
*
|
|
12
|
+
* // Resize to a specific detent
|
|
13
|
+
* const handleExpand = () => {
|
|
14
|
+
* navigation.resize(1); // Resize to second detent
|
|
15
|
+
* };
|
|
16
|
+
*
|
|
17
|
+
* return (
|
|
18
|
+
* <Button title="Expand" onPress={handleExpand} />
|
|
19
|
+
* );
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function useTrueSheetNavigation() {
|
|
24
|
+
return useNavigation();
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=useTrueSheetNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useNavigation","useTrueSheetNavigation"],"sourceRoot":"../../../src","sources":["navigation/useTrueSheetNavigation.ts"],"mappings":";;AAAA,SAASA,aAAa,QAA4B,0BAA0B;AAI5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAAA,EAEN;EAC9B,OAAOD,aAAa,CAA6B,CAAC;AACpD","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type CommonActions, type ParamListBase, type Router, type StackActionType, type StackRouterOptions } from '@react-navigation/native';
|
|
2
|
+
import type { TrueSheetNavigationState } from './types';
|
|
3
|
+
export type TrueSheetRouterOptions = StackRouterOptions;
|
|
4
|
+
export type TrueSheetActionType = StackActionType | ReturnType<typeof CommonActions.goBack> | {
|
|
5
|
+
type: 'RESIZE';
|
|
6
|
+
index: number;
|
|
7
|
+
source?: string;
|
|
8
|
+
target?: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'DISMISS';
|
|
11
|
+
source?: string;
|
|
12
|
+
target?: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'REMOVE';
|
|
15
|
+
source?: string;
|
|
16
|
+
target?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const TrueSheetActions: {
|
|
19
|
+
resize(index: number): TrueSheetActionType;
|
|
20
|
+
dismiss(): TrueSheetActionType;
|
|
21
|
+
remove(): TrueSheetActionType;
|
|
22
|
+
replace(name: string, params?: object): {
|
|
23
|
+
readonly type: "REPLACE";
|
|
24
|
+
readonly payload: {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly params: object | undefined;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
push(name: string, params?: object): {
|
|
30
|
+
readonly type: "PUSH";
|
|
31
|
+
readonly payload: {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly params: object | undefined;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
pop(count?: number): {
|
|
37
|
+
readonly type: "POP";
|
|
38
|
+
readonly payload: {
|
|
39
|
+
readonly count: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
popToTop(): {
|
|
43
|
+
readonly type: "POP_TO_TOP";
|
|
44
|
+
};
|
|
45
|
+
popTo(name: string, params?: object, options?: {
|
|
46
|
+
merge?: boolean;
|
|
47
|
+
}): {
|
|
48
|
+
readonly type: "POP_TO";
|
|
49
|
+
readonly payload: {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly params: object | undefined;
|
|
52
|
+
readonly merge: boolean | undefined;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export declare function TrueSheetRouter(routerOptions: StackRouterOptions): Router<TrueSheetNavigationState<ParamListBase>, TrueSheetActionType>;
|
|
57
|
+
//# sourceMappingURL=TrueSheetRouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;kBAEb,MAAM,GAAG,mBAAmB;eAG/B,mBAAmB;cAGpB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;aAwGR,CAAC;;;;;;;;;CArGvB,CAAC;AAEF,wBAAgB,eAAe,CAC7B,aAAa,EAAE,kBAAkB,GAChC,MAAM,CAAC,wBAAwB,CAAC,aAAa,CAAC,EAAE,mBAAmB,CAAC,CAyHtE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ParamListBase } from '@react-navigation/native';
|
|
2
|
+
import type { TrueSheetDescriptorMap, TrueSheetNavigationHelpers, TrueSheetNavigationState } from './types';
|
|
3
|
+
interface TrueSheetViewProps {
|
|
4
|
+
state: TrueSheetNavigationState<ParamListBase>;
|
|
5
|
+
navigation: TrueSheetNavigationHelpers;
|
|
6
|
+
descriptors: TrueSheetDescriptorMap;
|
|
7
|
+
}
|
|
8
|
+
export declare function TrueSheetView({ state, navigation, descriptors }: TrueSheetViewProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=TrueSheetView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrueSheetView.d.ts","sourceRoot":"","sources":["../../../../src/navigation/TrueSheetView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAoB9D,OAAO,KAAK,EACV,sBAAsB,EAEtB,0BAA0B,EAG1B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAoMjB,UAAU,kBAAkB;IAC1B,KAAK,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;IAC/C,UAAU,EAAE,0BAA0B,CAAC;IACvC,WAAW,EAAE,sBAAsB,CAAC;CACrC;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,kBAAkB,2CAyCnF"}
|