@sdcx/overlay 0.4.0 → 1.0.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/LICENSE +1 -1
- package/README.md +10 -1
- package/RNOverlay.podspec +4 -4
- package/android/build.gradle +47 -25
- package/android/src/main/java/com/reactnative/overlay/Overlay.java +66 -80
- package/android/src/main/java/com/reactnative/overlay/OverlayModule.java +116 -95
- package/android/src/main/java/com/reactnative/overlay/OverlayPackage.java +14 -15
- package/android/src/main/java/com/reactnative/overlay/OverlayRootView.java +95 -113
- package/dist/NativeOverlay.d.ts +11 -0
- package/dist/NativeOverlay.js +2 -0
- package/{lib → dist}/index.d.ts +4 -3
- package/dist/index.js +9 -0
- package/ios/Overlay/RNOverlay.h +3 -2
- package/ios/Overlay/RNOverlay.mm +58 -0
- package/ios/Overlay/RNOverlayHostingView.h +24 -0
- package/ios/Overlay/RNOverlayHostingView.mm +194 -0
- package/ios/Overlay/RNOverlayModule.h +8 -3
- package/ios/Overlay/RNOverlayModule.mm +101 -0
- package/package.json +50 -64
- package/src/NativeOverlay.ts +14 -0
- package/src/index.ts +8 -15
- package/ios/Overlay/RNOverlay.m +0 -60
- package/ios/Overlay/RNOverlayModule.m +0 -78
- package/lib/index.js +0 -10
package/package.json
CHANGED
|
@@ -1,66 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"eslint": "^7.32.0",
|
|
53
|
-
"typescript": "^4.6.4"
|
|
54
|
-
},
|
|
55
|
-
"jest": {
|
|
56
|
-
"preset": "react-native",
|
|
57
|
-
"moduleFileExtensions": [
|
|
58
|
-
"ts",
|
|
59
|
-
"tsx",
|
|
60
|
-
"js",
|
|
61
|
-
"jsx",
|
|
62
|
-
"json",
|
|
63
|
-
"node"
|
|
64
|
-
]
|
|
65
|
-
}
|
|
2
|
+
"name": "@sdcx/overlay",
|
|
3
|
+
"description": "A react-native Overlay component.",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"typings": "./dist/index.d.ts",
|
|
7
|
+
"react-native": "src/index",
|
|
8
|
+
"nativePackage": true,
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"dist",
|
|
12
|
+
"android",
|
|
13
|
+
"ios",
|
|
14
|
+
"RNOverlay.podspec",
|
|
15
|
+
"!android/build",
|
|
16
|
+
"!ios/build",
|
|
17
|
+
"!**/__tests__"
|
|
18
|
+
],
|
|
19
|
+
"repository": "https://github.com/sdcxtech/react-native-troika",
|
|
20
|
+
"homepage": "https://github.com/sdcxtech/react-native-troika/tree/master/packages/overlay#readme",
|
|
21
|
+
"author": "sdcx",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"react-native",
|
|
25
|
+
"overlay"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "rm -rf ./dist && tsc -p tsconfig.json",
|
|
29
|
+
"prepare": "npm run build",
|
|
30
|
+
"tsc": "tsc",
|
|
31
|
+
"test": "jest",
|
|
32
|
+
"lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx"
|
|
33
|
+
},
|
|
34
|
+
"codegenConfig": {
|
|
35
|
+
"name": "overlay",
|
|
36
|
+
"type": "modules",
|
|
37
|
+
"jsSrcsDir": "src",
|
|
38
|
+
"android": {
|
|
39
|
+
"javaPackageName": "com.reactnative.overlay"
|
|
40
|
+
},
|
|
41
|
+
"ios": {
|
|
42
|
+
"modulesProvider": {
|
|
43
|
+
"OverlayHost": "RNOverlayModule"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": ">=16.8",
|
|
49
|
+
"react-native": ">=0.60"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {}
|
|
66
52
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TurboModule, CodegenTypes } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface OverlayOptions {
|
|
5
|
+
overlayId: CodegenTypes.Int32;
|
|
6
|
+
passThroughTouches?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Spec extends TurboModule {
|
|
10
|
+
show(moduleName: string, options: OverlayOptions): void;
|
|
11
|
+
hide(moduleName: string, overlayId: CodegenTypes.Int32): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('OverlayHost');
|
package/src/index.ts
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Insets } from 'react-native';
|
|
2
|
+
import NativeOverlay, { type OverlayOptions } from './NativeOverlay';
|
|
2
3
|
|
|
3
|
-
export interface OverlayOptions {
|
|
4
|
-
|
|
5
|
-
passThroughTouches?: boolean
|
|
4
|
+
export interface OverlayProps extends OverlayOptions {
|
|
5
|
+
insets: Insets;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
interface OverlayInterface extends NativeModule {
|
|
9
|
-
show(moduleName: string, options: OverlayOptions): void
|
|
10
|
-
hide(moduleName: string, id: number): void
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const OverlayHost: OverlayInterface = NativeModules.OverlayHost
|
|
14
|
-
|
|
15
8
|
function show(moduleName: string, options: OverlayOptions) {
|
|
16
|
-
|
|
9
|
+
NativeOverlay.show(moduleName, options);
|
|
17
10
|
}
|
|
18
11
|
|
|
19
12
|
function hide(moduleName: string, id: number) {
|
|
20
|
-
|
|
13
|
+
NativeOverlay.hide(moduleName, id);
|
|
21
14
|
}
|
|
22
15
|
|
|
23
|
-
const Overlay = { show, hide }
|
|
16
|
+
const Overlay = { show, hide };
|
|
24
17
|
|
|
25
|
-
export { Overlay }
|
|
18
|
+
export { Overlay };
|
package/ios/Overlay/RNOverlay.m
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
#import "RNOverlay.h"
|
|
2
|
-
|
|
3
|
-
#import <React/RCTRootView.h>
|
|
4
|
-
|
|
5
|
-
@interface RNOverlay ()
|
|
6
|
-
|
|
7
|
-
@property(nonatomic, weak) UIWindow *keyWindow;
|
|
8
|
-
@property(nonatomic, strong) RCTRootView *rootView;
|
|
9
|
-
@property(nonatomic, copy) NSString *moduleName;
|
|
10
|
-
@property(nonatomic, weak) RCTBridge *bridge;
|
|
11
|
-
|
|
12
|
-
@end
|
|
13
|
-
|
|
14
|
-
@implementation RNOverlay
|
|
15
|
-
|
|
16
|
-
- (instancetype)initWithModuleName:(NSString *)moduleName bridge:(RCTBridge *)bridge {
|
|
17
|
-
if (self = [super init]) {
|
|
18
|
-
_moduleName = moduleName;
|
|
19
|
-
_bridge = bridge;
|
|
20
|
-
}
|
|
21
|
-
return self;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
- (void)show:(NSDictionary *)props options:(NSDictionary *)options {
|
|
25
|
-
BOOL passThroughTouches = [options[@"passThroughTouches"] boolValue];
|
|
26
|
-
|
|
27
|
-
RCTRootView *rctView = [self createReactRootView:props];
|
|
28
|
-
rctView.passThroughTouches = passThroughTouches;
|
|
29
|
-
rctView.frame = [UIScreen mainScreen].bounds;
|
|
30
|
-
|
|
31
|
-
self.rootView = rctView;
|
|
32
|
-
|
|
33
|
-
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
|
34
|
-
[keyWindow addSubview:rctView];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
- (void)hide {
|
|
38
|
-
if (self.rootView) {
|
|
39
|
-
[self.rootView removeFromSuperview];
|
|
40
|
-
self.rootView = nil;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
- (void)update {
|
|
45
|
-
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
|
46
|
-
if (keyWindow != self.keyWindow) {
|
|
47
|
-
[self.rootView removeFromSuperview];
|
|
48
|
-
[keyWindow addSubview:self.rootView];
|
|
49
|
-
self.keyWindow = keyWindow;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
- (RCTRootView *)createReactRootView:(NSDictionary *)props {
|
|
54
|
-
RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:self.bridge moduleName:self.moduleName initialProperties:props];
|
|
55
|
-
reactView.backgroundColor = UIColor.clearColor;
|
|
56
|
-
|
|
57
|
-
return reactView;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@end
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
#import "RNOverlayModule.h"
|
|
2
|
-
#import "RNOverlay.h"
|
|
3
|
-
|
|
4
|
-
#import <React/RCTLog.h>
|
|
5
|
-
#import <React/RCTBridge.h>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
NSString* genKey(NSString* moduleName, NSNumber* id) {
|
|
9
|
-
return [NSString stringWithFormat:@"%@-%@", moduleName, id];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@interface RNOverlayModule ()
|
|
14
|
-
|
|
15
|
-
@property(nonatomic, strong) NSMutableDictionary *overlays;
|
|
16
|
-
|
|
17
|
-
@end
|
|
18
|
-
|
|
19
|
-
@implementation RNOverlayModule
|
|
20
|
-
|
|
21
|
-
@synthesize bridge;
|
|
22
|
-
|
|
23
|
-
- (instancetype)init {
|
|
24
|
-
if (self = [super init]) {
|
|
25
|
-
_overlays = [[NSMutableDictionary alloc] init];
|
|
26
|
-
}
|
|
27
|
-
return self;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
- (void)handleReload {
|
|
31
|
-
for (NSString *key in self.overlays) {
|
|
32
|
-
RNOverlay *overlay = self.overlays[key];
|
|
33
|
-
[overlay hide];
|
|
34
|
-
}
|
|
35
|
-
[self.overlays removeAllObjects];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
- (void)invalidate {
|
|
39
|
-
[self handleReload];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
43
|
-
return YES;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
- (dispatch_queue_t)methodQueue {
|
|
47
|
-
return dispatch_get_main_queue();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
RCT_EXPORT_MODULE(OverlayHost)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
RCT_EXPORT_METHOD(show:(NSString *)moduleName options:(NSDictionary *)options) {
|
|
54
|
-
NSString* key = genKey(moduleName, options[@"id"]);
|
|
55
|
-
RNOverlay *overlay = self.overlays[key];
|
|
56
|
-
if (overlay != nil) {
|
|
57
|
-
[overlay update];
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
overlay = [[RNOverlay alloc] initWithModuleName:moduleName bridge:self.bridge];
|
|
62
|
-
self.overlays[key] = overlay;
|
|
63
|
-
|
|
64
|
-
[overlay show:@{@"id": options[@"id"]} options:options];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
RCT_EXPORT_METHOD(hide:(NSString *)moduleName id:(nonnull NSNumber *)id) {
|
|
68
|
-
NSString* key = genKey(moduleName, id);
|
|
69
|
-
RNOverlay *overlay = self.overlays[key];
|
|
70
|
-
if (!overlay) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
[self.overlays removeObjectForKey:key];
|
|
74
|
-
[overlay hide];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
@end
|
package/lib/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
const OverlayHost = NativeModules.OverlayHost;
|
|
3
|
-
function show(moduleName, options) {
|
|
4
|
-
OverlayHost.show(moduleName, options);
|
|
5
|
-
}
|
|
6
|
-
function hide(moduleName, id) {
|
|
7
|
-
OverlayHost.hide(moduleName, id);
|
|
8
|
-
}
|
|
9
|
-
const Overlay = { show, hide };
|
|
10
|
-
export { Overlay };
|