@onekeyfe/react-native-native-sheet 3.0.125
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/LICENSE +21 -0
- package/NativeSheet.podspec +22 -0
- package/README.md +56 -0
- package/android/build.gradle +82 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/onekey/nativesheet/NativeSheetEvents.kt +37 -0
- package/android/src/main/java/com/onekey/nativesheet/NativeSheetPackage.kt +16 -0
- package/android/src/main/java/com/onekey/nativesheet/NativeSheetView.kt +354 -0
- package/android/src/main/java/com/onekey/nativesheet/NativeSheetViewManager.kt +118 -0
- package/ios/NativeSheetContainerView.swift +441 -0
- package/ios/RCTNativeSheetComponentView.h +11 -0
- package/ios/RCTNativeSheetComponentView.mm +156 -0
- package/lib/module/NativeSheetNativeComponent.ts +35 -0
- package/lib/module/codegen-types.d.js +2 -0
- package/lib/module/codegen-types.d.js.map +1 -0
- package/lib/module/index.js +92 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeSheetNativeComponent.d.ts +25 -0
- package/lib/typescript/src/NativeSheetNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +40 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +171 -0
- package/react-native.config.js +12 -0
- package/src/NativeSheetNativeComponent.ts +35 -0
- package/src/codegen-types.d.ts +9 -0
- package/src/index.tsx +145 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#import "RCTNativeSheetComponentView.h"
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/RNCNativeSheet/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/RNCNativeSheet/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/RNCNativeSheet/Props.h>
|
|
6
|
+
#import <react/renderer/components/RNCNativeSheet/RCTComponentViewHelpers.h>
|
|
7
|
+
|
|
8
|
+
#import <React/RCTConversions.h>
|
|
9
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
10
|
+
#import <React/RCTSurfaceTouchHandler.h>
|
|
11
|
+
|
|
12
|
+
#if __has_include(<NativeSheet/NativeSheet-Swift.h>)
|
|
13
|
+
#import <NativeSheet/NativeSheet-Swift.h>
|
|
14
|
+
#elif __has_include("NativeSheet/NativeSheet-Swift.h")
|
|
15
|
+
#import "NativeSheet/NativeSheet-Swift.h"
|
|
16
|
+
#elif __has_include("NativeSheet-Swift.h")
|
|
17
|
+
#import "NativeSheet-Swift.h"
|
|
18
|
+
#else
|
|
19
|
+
#import "react_native_native_sheet-Swift.h"
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
using namespace facebook::react;
|
|
23
|
+
|
|
24
|
+
static void RNCNativeSheetInvokeVoidSelector(id target, SEL selector)
|
|
25
|
+
{
|
|
26
|
+
if (![target respondsToSelector:selector]) return;
|
|
27
|
+
auto implementation = (void (*)(id, SEL))[target methodForSelector:selector];
|
|
28
|
+
implementation(target, selector);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@implementation RCTNativeSheetComponentView {
|
|
32
|
+
UIView *_nativeSheetView;
|
|
33
|
+
RCTSurfaceTouchHandler *_touchHandler;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
37
|
+
{
|
|
38
|
+
return concreteComponentDescriptorProvider<RNCNativeSheetComponentDescriptor>();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
42
|
+
{
|
|
43
|
+
if (self = [super initWithFrame:frame]) {
|
|
44
|
+
static const auto defaultProps = std::make_shared<const RNCNativeSheetProps>();
|
|
45
|
+
_props = defaultProps;
|
|
46
|
+
|
|
47
|
+
Class containerClass = NSClassFromString(@"NativeSheet.NativeSheetContainerView");
|
|
48
|
+
if (!containerClass) {
|
|
49
|
+
containerClass = NSClassFromString(@"NativeSheetContainerView");
|
|
50
|
+
}
|
|
51
|
+
_nativeSheetView = [[containerClass alloc] init];
|
|
52
|
+
_touchHandler = [RCTSurfaceTouchHandler new];
|
|
53
|
+
self.contentView = _nativeSheetView;
|
|
54
|
+
[_nativeSheetView setValue:_touchHandler forKey:@"touchHandler"];
|
|
55
|
+
|
|
56
|
+
typedef void (^EventBlock)(NSDictionary *);
|
|
57
|
+
__weak auto weakSelf = self;
|
|
58
|
+
EventBlock onDismiss = ^(NSDictionary *body) {
|
|
59
|
+
auto strongSelf = weakSelf;
|
|
60
|
+
if (!strongSelf) return;
|
|
61
|
+
auto emitter = std::static_pointer_cast<const RNCNativeSheetEventEmitter>(strongSelf->_eventEmitter);
|
|
62
|
+
if (!emitter) return;
|
|
63
|
+
NSString *reason = [body objectForKey:@"reason"] ?: @"system";
|
|
64
|
+
emitter->onDismiss({.reason = std::string(reason.UTF8String)});
|
|
65
|
+
};
|
|
66
|
+
EventBlock onPresented = ^(NSDictionary *body) {
|
|
67
|
+
auto strongSelf = weakSelf;
|
|
68
|
+
if (!strongSelf) return;
|
|
69
|
+
auto emitter = std::static_pointer_cast<const RNCNativeSheetEventEmitter>(strongSelf->_eventEmitter);
|
|
70
|
+
if (!emitter) return;
|
|
71
|
+
NSNumber *height = [body objectForKey:@"height"] ?: @0;
|
|
72
|
+
emitter->onPresented({.height = height.doubleValue});
|
|
73
|
+
};
|
|
74
|
+
[_nativeSheetView setValue:onDismiss forKey:@"onDismiss"];
|
|
75
|
+
[_nativeSheetView setValue:onPresented forKey:@"onPresented"];
|
|
76
|
+
}
|
|
77
|
+
return self;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
+ (BOOL)shouldBeRecycled
|
|
81
|
+
{
|
|
82
|
+
return NO;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
|
|
86
|
+
index:(NSInteger)index
|
|
87
|
+
{
|
|
88
|
+
SEL selector = NSSelectorFromString(@"insertChild:atIndex:");
|
|
89
|
+
if (![_nativeSheetView respondsToSelector:selector]) return;
|
|
90
|
+
NSMethodSignature *signature = [_nativeSheetView methodSignatureForSelector:selector];
|
|
91
|
+
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
|
92
|
+
UIView *child = childComponentView;
|
|
93
|
+
[invocation setSelector:selector];
|
|
94
|
+
[invocation setTarget:_nativeSheetView];
|
|
95
|
+
[invocation setArgument:&child atIndex:2];
|
|
96
|
+
[invocation setArgument:&index atIndex:3];
|
|
97
|
+
[invocation invoke];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
|
|
101
|
+
index:(NSInteger)index
|
|
102
|
+
{
|
|
103
|
+
SEL selector = NSSelectorFromString(@"removeChild:");
|
|
104
|
+
if ([_nativeSheetView respondsToSelector:selector]) {
|
|
105
|
+
NSMethodSignature *signature = [_nativeSheetView methodSignatureForSelector:selector];
|
|
106
|
+
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
|
107
|
+
UIView *child = childComponentView;
|
|
108
|
+
[invocation setSelector:selector];
|
|
109
|
+
[invocation setTarget:_nativeSheetView];
|
|
110
|
+
[invocation setArgument:&child atIndex:2];
|
|
111
|
+
[invocation invoke];
|
|
112
|
+
}
|
|
113
|
+
[childComponentView removeFromSuperview];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
117
|
+
{
|
|
118
|
+
const auto &newProps = *std::static_pointer_cast<RNCNativeSheetProps const>(props);
|
|
119
|
+
|
|
120
|
+
[_nativeSheetView setValue:@(newProps.sheetHeight) forKey:@"sheetHeight"];
|
|
121
|
+
[_nativeSheetView setValue:@(newProps.securityBlocked) forKey:@"securityBlocked"];
|
|
122
|
+
[_nativeSheetView setValue:@(newProps.dismissOnPanDown) forKey:@"dismissOnPanDown"];
|
|
123
|
+
[_nativeSheetView setValue:@(newProps.dismissOnBackdropPress) forKey:@"dismissOnBackdropPress"];
|
|
124
|
+
[_nativeSheetView setValue:@(newProps.dismissOnBackPress) forKey:@"dismissOnBackPress"];
|
|
125
|
+
[_nativeSheetView setValue:@(newProps.showHandle) forKey:@"showHandle"];
|
|
126
|
+
[_nativeSheetView setValue:@(newProps.cornerRadius) forKey:@"cornerRadius"];
|
|
127
|
+
[_nativeSheetView setValue:@(newProps.dimAmount) forKey:@"dimAmount"];
|
|
128
|
+
[_nativeSheetView setValue:RCTUIColorFromSharedColor(newProps.sheetBackgroundColor)
|
|
129
|
+
forKey:@"sheetBackgroundColor"];
|
|
130
|
+
[_nativeSheetView setValue:@(newProps.open) forKey:@"open"];
|
|
131
|
+
SEL commitSelector = NSSelectorFromString(@"commitConfiguration");
|
|
132
|
+
RNCNativeSheetInvokeVoidSelector(_nativeSheetView, commitSelector);
|
|
133
|
+
|
|
134
|
+
[super updateProps:props oldProps:oldProps];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
- (void)prepareForRecycle
|
|
138
|
+
{
|
|
139
|
+
SEL invalidateSelector = NSSelectorFromString(@"invalidate");
|
|
140
|
+
RNCNativeSheetInvokeVoidSelector(_nativeSheetView, invalidateSelector);
|
|
141
|
+
[super prepareForRecycle];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
- (void)invalidate
|
|
145
|
+
{
|
|
146
|
+
SEL invalidateSelector = NSSelectorFromString(@"invalidate");
|
|
147
|
+
RNCNativeSheetInvokeVoidSelector(_nativeSheetView, invalidateSelector);
|
|
148
|
+
[super invalidate];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@end
|
|
152
|
+
|
|
153
|
+
Class<RCTComponentViewProtocol> RNCNativeSheetCls(void)
|
|
154
|
+
{
|
|
155
|
+
return RCTNativeSheetComponentView.class;
|
|
156
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type ColorValue,
|
|
4
|
+
type ViewProps,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
import type {
|
|
7
|
+
DirectEventHandler,
|
|
8
|
+
Double,
|
|
9
|
+
WithDefault,
|
|
10
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
11
|
+
|
|
12
|
+
export type NativeSheetDismissEvent = Readonly<{
|
|
13
|
+
reason: string;
|
|
14
|
+
}>;
|
|
15
|
+
|
|
16
|
+
export type NativeSheetPresentedEvent = Readonly<{
|
|
17
|
+
height: Double;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
export interface NativeSheetNativeProps extends ViewProps {
|
|
21
|
+
open: boolean;
|
|
22
|
+
sheetHeight: Double;
|
|
23
|
+
securityBlocked?: WithDefault<boolean, false>;
|
|
24
|
+
dismissOnPanDown?: WithDefault<boolean, true>;
|
|
25
|
+
dismissOnBackdropPress?: WithDefault<boolean, false>;
|
|
26
|
+
dismissOnBackPress?: WithDefault<boolean, true>;
|
|
27
|
+
showHandle?: WithDefault<boolean, true>;
|
|
28
|
+
cornerRadius?: WithDefault<Double, 32>;
|
|
29
|
+
dimAmount?: WithDefault<Double, 0.4>;
|
|
30
|
+
sheetBackgroundColor?: ColorValue;
|
|
31
|
+
onDismiss?: DirectEventHandler<NativeSheetDismissEvent>;
|
|
32
|
+
onPresented?: DirectEventHandler<NativeSheetPresentedEvent>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default codegenNativeComponent<NativeSheetNativeProps>('RNCNativeSheet');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["codegen-types.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createContext, useCallback, useContext } from 'react';
|
|
4
|
+
import { StyleSheet, useWindowDimensions, View } from 'react-native';
|
|
5
|
+
import RNCNativeSheet from './NativeSheetNativeComponent';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const NativeSheetSecurityContext = /*#__PURE__*/createContext(false);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Blocks every descendant sheet while security UI is visible. Consumers must
|
|
11
|
+
* place this provider above all NativeSheet instances and bind `blocked` to the
|
|
12
|
+
* app-lock state. A blocked transition is dismissed natively without animation.
|
|
13
|
+
*/
|
|
14
|
+
export function NativeSheetSecurityProvider({
|
|
15
|
+
blocked,
|
|
16
|
+
children
|
|
17
|
+
}) {
|
|
18
|
+
return /*#__PURE__*/_jsx(NativeSheetSecurityContext.Provider, {
|
|
19
|
+
value: blocked,
|
|
20
|
+
children: children
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Presents arbitrary React Native children inside a native sheet container.
|
|
26
|
+
* The native component is staged off-screen before presentation; once opened,
|
|
27
|
+
* Fabric mounts the same child view into the platform sheet without serializing
|
|
28
|
+
* business content through the native bridge.
|
|
29
|
+
*/
|
|
30
|
+
export function NativeSheet({
|
|
31
|
+
open,
|
|
32
|
+
height,
|
|
33
|
+
children,
|
|
34
|
+
onDismiss,
|
|
35
|
+
onPresented,
|
|
36
|
+
dismissOnPanDown = true,
|
|
37
|
+
dismissOnBackdropPress = false,
|
|
38
|
+
dismissOnBackPress = true,
|
|
39
|
+
showHandle = true,
|
|
40
|
+
cornerRadius = 32,
|
|
41
|
+
dimAmount = 0.4,
|
|
42
|
+
backgroundColor,
|
|
43
|
+
testID
|
|
44
|
+
}) {
|
|
45
|
+
const securityBlocked = useContext(NativeSheetSecurityContext);
|
|
46
|
+
const {
|
|
47
|
+
width
|
|
48
|
+
} = useWindowDimensions();
|
|
49
|
+
const handleDismiss = useCallback(event => {
|
|
50
|
+
onDismiss?.(event.nativeEvent.reason);
|
|
51
|
+
}, [onDismiss]);
|
|
52
|
+
const handlePresented = useCallback(event => {
|
|
53
|
+
onPresented?.(event.nativeEvent.height);
|
|
54
|
+
}, [onPresented]);
|
|
55
|
+
return /*#__PURE__*/_jsx(RNCNativeSheet, {
|
|
56
|
+
testID: testID,
|
|
57
|
+
open: open,
|
|
58
|
+
sheetHeight: height,
|
|
59
|
+
securityBlocked: securityBlocked,
|
|
60
|
+
dismissOnPanDown: dismissOnPanDown,
|
|
61
|
+
dismissOnBackdropPress: dismissOnBackdropPress,
|
|
62
|
+
dismissOnBackPress: dismissOnBackPress,
|
|
63
|
+
showHandle: showHandle,
|
|
64
|
+
cornerRadius: cornerRadius,
|
|
65
|
+
dimAmount: dimAmount,
|
|
66
|
+
sheetBackgroundColor: backgroundColor,
|
|
67
|
+
onDismiss: handleDismiss,
|
|
68
|
+
onPresented: handlePresented,
|
|
69
|
+
style: [styles.stagingHost, {
|
|
70
|
+
width,
|
|
71
|
+
height
|
|
72
|
+
}],
|
|
73
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
74
|
+
pointerEvents: "auto",
|
|
75
|
+
style: styles.content,
|
|
76
|
+
collapsable: false,
|
|
77
|
+
children: children
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
stagingHost: {
|
|
83
|
+
position: 'absolute',
|
|
84
|
+
left: -100_000,
|
|
85
|
+
bottom: 0,
|
|
86
|
+
opacity: 0
|
|
87
|
+
},
|
|
88
|
+
content: {
|
|
89
|
+
flex: 1
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useCallback","useContext","StyleSheet","useWindowDimensions","View","RNCNativeSheet","jsx","_jsx","NativeSheetSecurityContext","NativeSheetSecurityProvider","blocked","children","Provider","value","NativeSheet","open","height","onDismiss","onPresented","dismissOnPanDown","dismissOnBackdropPress","dismissOnBackPress","showHandle","cornerRadius","dimAmount","backgroundColor","testID","securityBlocked","width","handleDismiss","event","nativeEvent","reason","handlePresented","sheetHeight","sheetBackgroundColor","style","styles","stagingHost","pointerEvents","content","collapsable","create","position","left","bottom","opacity","flex"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SACEA,aAAa,EAEbC,WAAW,EACXC,UAAU,QACL,OAAO;AAEd,SAGEC,UAAU,EACVC,mBAAmB,EACnBC,IAAI,QACC,cAAc;AAErB,OAAOC,cAAc,MAGd,8BAA8B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA+BtC,MAAMC,0BAA0B,gBAAGT,aAAa,CAAC,KAAK,CAAC;;AAEvD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASU,2BAA2BA,CAAC;EAC1CC,OAAO;EACPC;AACuC,CAAC,EAAE;EAC1C,oBACEJ,IAAA,CAACC,0BAA0B,CAACI,QAAQ;IAACC,KAAK,EAAEH,OAAQ;IAAAC,QAAA,EACjDA;EAAQ,CAC0B,CAAC;AAE1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,WAAWA,CAAC;EAC1BC,IAAI;EACJC,MAAM;EACNL,QAAQ;EACRM,SAAS;EACTC,WAAW;EACXC,gBAAgB,GAAG,IAAI;EACvBC,sBAAsB,GAAG,KAAK;EAC9BC,kBAAkB,GAAG,IAAI;EACzBC,UAAU,GAAG,IAAI;EACjBC,YAAY,GAAG,EAAE;EACjBC,SAAS,GAAG,GAAG;EACfC,eAAe;EACfC;AACgB,CAAC,EAAE;EACnB,MAAMC,eAAe,GAAG1B,UAAU,CAACO,0BAA0B,CAAC;EAC9D,MAAM;IAAEoB;EAAM,CAAC,GAAGzB,mBAAmB,CAAC,CAAC;EAEvC,MAAM0B,aAAa,GAAG7B,WAAW,CAC9B8B,KAAoD,IAAK;IACxDb,SAAS,GAAGa,KAAK,CAACC,WAAW,CAACC,MAAkC,CAAC;EACnE,CAAC,EACD,CAACf,SAAS,CACZ,CAAC;EACD,MAAMgB,eAAe,GAAGjC,WAAW,CAChC8B,KAAsD,IAAK;IAC1DZ,WAAW,GAAGY,KAAK,CAACC,WAAW,CAACf,MAAM,CAAC;EACzC,CAAC,EACD,CAACE,WAAW,CACd,CAAC;EAED,oBACEX,IAAA,CAACF,cAAc;IACbqB,MAAM,EAAEA,MAAO;IACfX,IAAI,EAAEA,IAAK;IACXmB,WAAW,EAAElB,MAAO;IACpBW,eAAe,EAAEA,eAAgB;IACjCR,gBAAgB,EAAEA,gBAAiB;IACnCC,sBAAsB,EAAEA,sBAAuB;IAC/CC,kBAAkB,EAAEA,kBAAmB;IACvCC,UAAU,EAAEA,UAAW;IACvBC,YAAY,EAAEA,YAAa;IAC3BC,SAAS,EAAEA,SAAU;IACrBW,oBAAoB,EAAEV,eAAgB;IACtCR,SAAS,EAAEY,aAAc;IACzBX,WAAW,EAAEe,eAAgB;IAC7BG,KAAK,EAAE,CAACC,MAAM,CAACC,WAAW,EAAE;MAAEV,KAAK;MAAEZ;IAAO,CAAC,CAAE;IAAAL,QAAA,eAE/CJ,IAAA,CAACH,IAAI;MAACmC,aAAa,EAAC,MAAM;MAACH,KAAK,EAAEC,MAAM,CAACG,OAAQ;MAACC,WAAW,EAAE,KAAM;MAAA9B,QAAA,EAClEA;IAAQ,CACL;EAAC,CACO,CAAC;AAErB;AAEA,MAAM0B,MAAM,GAAGnC,UAAU,CAACwC,MAAM,CAAC;EAC/BJ,WAAW,EAAE;IACXK,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC,OAAO;IACdC,MAAM,EAAE,CAAC;IACTC,OAAO,EAAE;EACX,CAAC;EACDN,OAAO,EAAE;IACPO,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ColorValue, type ViewProps } from 'react-native';
|
|
2
|
+
import type { DirectEventHandler, Double, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export type NativeSheetDismissEvent = Readonly<{
|
|
4
|
+
reason: string;
|
|
5
|
+
}>;
|
|
6
|
+
export type NativeSheetPresentedEvent = Readonly<{
|
|
7
|
+
height: Double;
|
|
8
|
+
}>;
|
|
9
|
+
export interface NativeSheetNativeProps extends ViewProps {
|
|
10
|
+
open: boolean;
|
|
11
|
+
sheetHeight: Double;
|
|
12
|
+
securityBlocked?: WithDefault<boolean, false>;
|
|
13
|
+
dismissOnPanDown?: WithDefault<boolean, true>;
|
|
14
|
+
dismissOnBackdropPress?: WithDefault<boolean, false>;
|
|
15
|
+
dismissOnBackPress?: WithDefault<boolean, true>;
|
|
16
|
+
showHandle?: WithDefault<boolean, true>;
|
|
17
|
+
cornerRadius?: WithDefault<Double, 32>;
|
|
18
|
+
dimAmount?: WithDefault<Double, 0.4>;
|
|
19
|
+
sheetBackgroundColor?: ColorValue;
|
|
20
|
+
onDismiss?: DirectEventHandler<NativeSheetDismissEvent>;
|
|
21
|
+
onPresented?: DirectEventHandler<NativeSheetPresentedEvent>;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: import("react-native/types_generated/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeSheetNativeProps>;
|
|
24
|
+
export default _default;
|
|
25
|
+
//# sourceMappingURL=NativeSheetNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeSheetNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/NativeSheetNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACN,WAAW,EACZ,MAAM,2CAA2C,CAAC;AAEnD,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,WAAW,sBAAuB,SAAQ,SAAS;IACvD,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9C,sBAAsB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrD,kBAAkB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAChD,UAAU,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,oBAAoB,CAAC,EAAE,UAAU,CAAC;IAClC,SAAS,CAAC,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;IACxD,WAAW,CAAC,EAAE,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;CAC7D;;AAED,wBAAgF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type PropsWithChildren } from 'react';
|
|
2
|
+
import { type ColorValue } from 'react-native';
|
|
3
|
+
export type NativeSheetDismissReason = 'back' | 'backdrop' | 'pan' | 'programmatic' | 'security' | 'system';
|
|
4
|
+
export interface NativeSheetProps extends PropsWithChildren {
|
|
5
|
+
/** Controls whether the sheet is presented. */
|
|
6
|
+
open: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Fixed outer height for this presentation, in points/dp. Content updates do
|
|
9
|
+
* not change this value, so asynchronously loaded children cannot resize the
|
|
10
|
+
* native sheet mid-transition.
|
|
11
|
+
*/
|
|
12
|
+
height: number;
|
|
13
|
+
onDismiss?: (reason: NativeSheetDismissReason) => void;
|
|
14
|
+
onPresented?: (height: number) => void;
|
|
15
|
+
dismissOnPanDown?: boolean;
|
|
16
|
+
dismissOnBackdropPress?: boolean;
|
|
17
|
+
dismissOnBackPress?: boolean;
|
|
18
|
+
showHandle?: boolean;
|
|
19
|
+
cornerRadius?: number;
|
|
20
|
+
dimAmount?: number;
|
|
21
|
+
backgroundColor?: ColorValue;
|
|
22
|
+
testID?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Blocks every descendant sheet while security UI is visible. Consumers must
|
|
26
|
+
* place this provider above all NativeSheet instances and bind `blocked` to the
|
|
27
|
+
* app-lock state. A blocked transition is dismissed natively without animation.
|
|
28
|
+
*/
|
|
29
|
+
export declare function NativeSheetSecurityProvider({ blocked, children, }: PropsWithChildren<{
|
|
30
|
+
blocked: boolean;
|
|
31
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* Presents arbitrary React Native children inside a native sheet container.
|
|
34
|
+
* The native component is staged off-screen before presentation; once opened,
|
|
35
|
+
* Fabric mounts the same child view into the platform sheet without serializing
|
|
36
|
+
* business content through the native bridge.
|
|
37
|
+
*/
|
|
38
|
+
export declare function NativeSheet({ open, height, children, onDismiss, onPresented, dismissOnPanDown, dismissOnBackdropPress, dismissOnBackPress, showHandle, cornerRadius, dimAmount, backgroundColor, testID, }: NativeSheetProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export type { NativeSheetDismissEvent, NativeSheetNativeProps, NativeSheetPresentedEvent, } from './NativeSheetNativeComponent';
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EAGvB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,KAAK,UAAU,EAKhB,MAAM,cAAc,CAAC;AAOtB,MAAM,MAAM,wBAAwB,GAChC,MAAM,GACN,UAAU,GACV,KAAK,GACL,cAAc,GACd,UAAU,GACV,QAAQ,CAAC;AAEb,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,+CAA+C;IAC/C,IAAI,EAAE,OAAO,CAAC;IACd;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACvD,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,OAAO,EACP,QAAQ,GACT,EAAE,iBAAiB,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,2CAMzC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,EACX,gBAAuB,EACvB,sBAA8B,EAC9B,kBAAyB,EACzB,UAAiB,EACjB,YAAiB,EACjB,SAAe,EACf,eAAe,EACf,MAAM,GACP,EAAE,gBAAgB,2CAuClB;AAcD,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,8BAA8B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onekeyfe/react-native-native-sheet",
|
|
3
|
+
"version": "3.0.125",
|
|
4
|
+
"description": "Native bottom sheet host for arbitrary React Native content",
|
|
5
|
+
"source": "./src/index.tsx",
|
|
6
|
+
"main": "./lib/module/index.js",
|
|
7
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"source": "./src/index.tsx",
|
|
11
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
12
|
+
"default": "./lib/module/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"lib",
|
|
19
|
+
"android",
|
|
20
|
+
"ios",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
36
|
+
"prepare": "bob build",
|
|
37
|
+
"typecheck": "tsc",
|
|
38
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
39
|
+
"test": "jest",
|
|
40
|
+
"release": "yarn prepare && npm whoami && npm publish --access public"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"react-native",
|
|
44
|
+
"ios",
|
|
45
|
+
"android"
|
|
46
|
+
],
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/OneKeyHQ/app-modules.git",
|
|
50
|
+
"directory": "native-views/react-native-native-sheet"
|
|
51
|
+
},
|
|
52
|
+
"author": "@onekeyfe <huanming@onekey.so> (https://github.com/OneKeyHQ/app-modules)",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/OneKeyHQ/app-modules/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/OneKeyHQ/app-modules/tree/main/native-views/react-native-native-sheet#readme",
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
63
|
+
"@eslint/compat": "^1.3.2",
|
|
64
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
65
|
+
"@eslint/js": "^9.35.0",
|
|
66
|
+
"@react-native/babel-preset": "0.86.2",
|
|
67
|
+
"@react-native/eslint-config": "0.86.2",
|
|
68
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
69
|
+
"@types/jest": "^29.5.14",
|
|
70
|
+
"@types/react": "^19.2.0",
|
|
71
|
+
"commitlint": "^19.8.1",
|
|
72
|
+
"del-cli": "^6.0.0",
|
|
73
|
+
"eslint": "^9.35.0",
|
|
74
|
+
"eslint-config-prettier": "^10.1.8",
|
|
75
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
76
|
+
"jest": "^29.7.0",
|
|
77
|
+
"lefthook": "^2.0.3",
|
|
78
|
+
"prettier": "^2.8.8",
|
|
79
|
+
"react": "19.2.3",
|
|
80
|
+
"react-native": "0.86.2",
|
|
81
|
+
"react-native-builder-bob": "^0.40.13",
|
|
82
|
+
"release-it": "^19.0.4",
|
|
83
|
+
"turbo": "^2.5.6",
|
|
84
|
+
"typescript": "^5.9.2"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"react": "*",
|
|
88
|
+
"react-native": "*"
|
|
89
|
+
},
|
|
90
|
+
"packageManager": "yarn@4.11.0",
|
|
91
|
+
"react-native-builder-bob": {
|
|
92
|
+
"source": "src",
|
|
93
|
+
"output": "lib",
|
|
94
|
+
"targets": [
|
|
95
|
+
[
|
|
96
|
+
"module",
|
|
97
|
+
{
|
|
98
|
+
"esm": true
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
"typescript",
|
|
103
|
+
{
|
|
104
|
+
"project": "tsconfig.build.json"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"prettier": {
|
|
110
|
+
"quoteProps": "consistent",
|
|
111
|
+
"singleQuote": true,
|
|
112
|
+
"tabWidth": 2,
|
|
113
|
+
"trailingComma": "es5",
|
|
114
|
+
"useTabs": false
|
|
115
|
+
},
|
|
116
|
+
"jest": {
|
|
117
|
+
"preset": "react-native",
|
|
118
|
+
"modulePathIgnorePatterns": [
|
|
119
|
+
"<rootDir>/example/node_modules",
|
|
120
|
+
"<rootDir>/lib/"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"commitlint": {
|
|
124
|
+
"extends": [
|
|
125
|
+
"@commitlint/config-conventional"
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
"release-it": {
|
|
129
|
+
"git": {
|
|
130
|
+
"commitMessage": "chore: release ${version}",
|
|
131
|
+
"tagName": "v${version}"
|
|
132
|
+
},
|
|
133
|
+
"npm": {
|
|
134
|
+
"publish": true
|
|
135
|
+
},
|
|
136
|
+
"github": {
|
|
137
|
+
"release": true
|
|
138
|
+
},
|
|
139
|
+
"plugins": {
|
|
140
|
+
"@release-it/conventional-changelog": {
|
|
141
|
+
"preset": {
|
|
142
|
+
"name": "angular"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"codegenConfig": {
|
|
148
|
+
"name": "RNCNativeSheet",
|
|
149
|
+
"type": "components",
|
|
150
|
+
"jsSrcsDir": "./src",
|
|
151
|
+
"android": {
|
|
152
|
+
"javaPackageName": "com.onekey.nativesheet"
|
|
153
|
+
},
|
|
154
|
+
"ios": {
|
|
155
|
+
"componentProvider": {
|
|
156
|
+
"RNCNativeSheet": "RCTNativeSheetComponentView"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"create-react-native-library": {
|
|
161
|
+
"type": "fabric-view",
|
|
162
|
+
"languages": "kotlin-swift",
|
|
163
|
+
"tools": [
|
|
164
|
+
"eslint",
|
|
165
|
+
"jest",
|
|
166
|
+
"lefthook",
|
|
167
|
+
"release-it"
|
|
168
|
+
],
|
|
169
|
+
"version": "0.56.0"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dependency: {
|
|
3
|
+
platforms: {
|
|
4
|
+
android: {
|
|
5
|
+
componentDescriptors: ['RNCNativeSheetComponentDescriptor'],
|
|
6
|
+
cmakeListsPath: undefined,
|
|
7
|
+
packageImportPath: 'import com.onekey.nativesheet.NativeSheetPackage;',
|
|
8
|
+
packageInstance: 'new NativeSheetPackage()',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codegenNativeComponent,
|
|
3
|
+
type ColorValue,
|
|
4
|
+
type ViewProps,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
import type {
|
|
7
|
+
DirectEventHandler,
|
|
8
|
+
Double,
|
|
9
|
+
WithDefault,
|
|
10
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
11
|
+
|
|
12
|
+
export type NativeSheetDismissEvent = Readonly<{
|
|
13
|
+
reason: string;
|
|
14
|
+
}>;
|
|
15
|
+
|
|
16
|
+
export type NativeSheetPresentedEvent = Readonly<{
|
|
17
|
+
height: Double;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
export interface NativeSheetNativeProps extends ViewProps {
|
|
21
|
+
open: boolean;
|
|
22
|
+
sheetHeight: Double;
|
|
23
|
+
securityBlocked?: WithDefault<boolean, false>;
|
|
24
|
+
dismissOnPanDown?: WithDefault<boolean, true>;
|
|
25
|
+
dismissOnBackdropPress?: WithDefault<boolean, false>;
|
|
26
|
+
dismissOnBackPress?: WithDefault<boolean, true>;
|
|
27
|
+
showHandle?: WithDefault<boolean, true>;
|
|
28
|
+
cornerRadius?: WithDefault<Double, 32>;
|
|
29
|
+
dimAmount?: WithDefault<Double, 0.4>;
|
|
30
|
+
sheetBackgroundColor?: ColorValue;
|
|
31
|
+
onDismiss?: DirectEventHandler<NativeSheetDismissEvent>;
|
|
32
|
+
onPresented?: DirectEventHandler<NativeSheetPresentedEvent>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default codegenNativeComponent<NativeSheetNativeProps>('RNCNativeSheet');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module 'react-native/Libraries/Types/CodegenTypes' {
|
|
2
|
+
import type { NativeSyntheticEvent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export type Double = number;
|
|
5
|
+
export type WithDefault<T, V> = [V] extends [never] ? T : T;
|
|
6
|
+
export type DirectEventHandler<T> = (
|
|
7
|
+
event: NativeSyntheticEvent<T>
|
|
8
|
+
) => void | Promise<void>;
|
|
9
|
+
}
|