@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/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
`Overlay` 是一个 React Native 原生 UI 基础设施,它漂浮在你的 React Native 应用之上,可用于实现 Modal, Alert, Toast, Popover, Notification, Hoverball 等顶层 UI。
|
|
4
4
|
|
|
5
|
+
> 这个库属于实验性质,请谨慎使用
|
|
6
|
+
|
|
7
|
+
## 版本兼容
|
|
8
|
+
|
|
9
|
+
| 版本 | RN 版本 | RN 架构 |
|
|
10
|
+
| ---- | ------- | ------- |
|
|
11
|
+
| 0.x | < 0.82 | 旧架构 |
|
|
12
|
+
| 1.x | >= 0.82 | 新架构 |
|
|
13
|
+
|
|
5
14
|
## Installation
|
|
6
15
|
|
|
7
16
|
```bash
|
|
@@ -24,7 +33,7 @@ module.exports = {
|
|
|
24
33
|
},
|
|
25
34
|
},
|
|
26
35
|
},
|
|
27
|
-
}
|
|
36
|
+
};
|
|
28
37
|
```
|
|
29
38
|
|
|
30
39
|
## Usage
|
package/RNOverlay.podspec
CHANGED
|
@@ -6,13 +6,13 @@ Pod::Spec.new do |s|
|
|
|
6
6
|
s.name = "RNOverlay"
|
|
7
7
|
s.version = package["version"]
|
|
8
8
|
s.summary = package["description"]
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
s.homepage = package["homepage"]
|
|
11
11
|
s.license = package["license"]
|
|
12
12
|
s.authors = package["author"]
|
|
13
|
-
s.platforms = { :ios =>
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
14
|
s.source = { :git => "https://github.com/github-account/overlay.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/Overlay/**/*.{h,m,mm}"
|
|
17
|
-
s
|
|
18
|
-
end
|
|
17
|
+
install_modules_dependencies(s)
|
|
18
|
+
end
|
package/android/build.gradle
CHANGED
|
@@ -1,35 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
mavenCentral()
|
|
4
|
+
google()
|
|
5
|
+
}
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
9
|
+
}
|
|
5
10
|
}
|
|
6
11
|
|
|
7
12
|
apply plugin: 'com.android.library'
|
|
13
|
+
apply plugin: 'com.facebook.react'
|
|
14
|
+
|
|
15
|
+
def safeExtGet(prop, fallback) {
|
|
16
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
17
|
+
}
|
|
8
18
|
|
|
9
19
|
android {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
|
|
21
|
+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
22
|
+
// Check AGP version for backward compatibility w/react-native versions still on gradle plugin 6
|
|
23
|
+
def major = agpVersion[0].toInteger()
|
|
24
|
+
def minor = agpVersion[1].toInteger()
|
|
25
|
+
if ((major == 7 && minor >= 3) || major >= 8) {
|
|
26
|
+
namespace "com.reactnative.overlay"
|
|
27
|
+
buildFeatures {
|
|
28
|
+
buildConfig true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 35)
|
|
33
|
+
buildToolsVersion safeExtGet('buildToolsVersion', '35.0.0')
|
|
34
|
+
|
|
35
|
+
defaultConfig {
|
|
36
|
+
minSdkVersion safeExtGet('minSdkVersion', 24)
|
|
37
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 35)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
sourceSets {
|
|
41
|
+
main {
|
|
42
|
+
java.srcDirs += [
|
|
43
|
+
"generated/java",
|
|
44
|
+
"generated/jni"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
repositories {
|
|
51
|
+
google()
|
|
52
|
+
mavenCentral()
|
|
30
53
|
}
|
|
31
54
|
|
|
32
55
|
dependencies {
|
|
33
|
-
|
|
34
|
-
implementation 'com.facebook.react:react-native:+'
|
|
56
|
+
api 'com.facebook.react:react-native:+'
|
|
35
57
|
}
|
|
@@ -3,98 +3,84 @@ package com.reactnative.overlay;
|
|
|
3
3
|
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
4
4
|
|
|
5
5
|
import android.app.Activity;
|
|
6
|
-
import android.os.Bundle;
|
|
7
|
-
import android.view.Gravity;
|
|
8
6
|
import android.view.ViewGroup;
|
|
9
7
|
import android.view.Window;
|
|
10
|
-
import android.widget.FrameLayout;
|
|
11
8
|
|
|
12
9
|
import androidx.annotation.NonNull;
|
|
13
10
|
import androidx.annotation.UiThread;
|
|
14
11
|
|
|
15
|
-
import com.facebook.react.
|
|
12
|
+
import com.facebook.react.ReactHost;
|
|
16
13
|
import com.facebook.react.bridge.Arguments;
|
|
17
|
-
import com.facebook.react.bridge.ReactContext;
|
|
18
14
|
import com.facebook.react.bridge.ReadableMap;
|
|
15
|
+
import com.facebook.react.interfaces.fabric.ReactSurface;
|
|
19
16
|
|
|
20
17
|
@UiThread
|
|
21
18
|
public class Overlay {
|
|
22
19
|
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
decorView.removeView(rootView);
|
|
55
|
-
decorView = null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
unmountReactView();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public void update() {
|
|
62
|
-
ViewGroup decorView = getDecorView();
|
|
63
|
-
if (decorView != null && decorView != this.decorView) {
|
|
64
|
-
this.decorView.removeView(rootView);
|
|
65
|
-
this.decorView = decorView;
|
|
66
|
-
decorView.addView(rootView);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private void unmountReactView() {
|
|
71
|
-
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
|
|
72
|
-
if (reactContext == null || !reactContext.hasActiveCatalystInstance()) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (rootView != null) {
|
|
77
|
-
rootView.unmountReactApplication();
|
|
78
|
-
rootView = null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private void startReactApplication(OverlayRootView reactRootView, Bundle props) {
|
|
83
|
-
reactRootView.startReactApplication(reactInstanceManager, moduleName, props);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private OverlayRootView createReactRootView() {
|
|
87
|
-
OverlayRootView reactRootView = new OverlayRootView(activity);
|
|
88
|
-
reactRootView.setLayoutParams(new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, Gravity.CENTER));
|
|
89
|
-
return reactRootView;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private ViewGroup getDecorView() {
|
|
93
|
-
Window window = activity.getWindow();
|
|
94
|
-
if (window == null) {
|
|
95
|
-
return null;
|
|
20
|
+
final Activity activity;
|
|
21
|
+
final String moduleName;
|
|
22
|
+
final ReactHost reactHost;
|
|
23
|
+
|
|
24
|
+
ViewGroup rootView;
|
|
25
|
+
ViewGroup decorView;
|
|
26
|
+
ReactSurface reactSurface;
|
|
27
|
+
|
|
28
|
+
public Overlay(@NonNull Activity activity, String moduleName, ReactHost reactHost) {
|
|
29
|
+
this.activity = activity;
|
|
30
|
+
this.moduleName = moduleName;
|
|
31
|
+
this.reactHost = reactHost;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public void show(ReadableMap props, ReadableMap options) {
|
|
35
|
+
|
|
36
|
+
decorView = getDecorView();
|
|
37
|
+
if (decorView == null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ReactSurface reactSurface = reactHost.createSurface(activity, moduleName, Arguments.toBundle(props));
|
|
42
|
+
this.reactSurface = reactSurface;
|
|
43
|
+
ViewGroup view = reactSurface.getView();
|
|
44
|
+
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
|
|
45
|
+
OverlayRootView root = new OverlayRootView(activity);
|
|
46
|
+
root.addView(view, layoutParams);
|
|
47
|
+
this.rootView = root;
|
|
48
|
+
decorView.addView(root, layoutParams);
|
|
49
|
+
if (options.hasKey("passThroughTouches")) {
|
|
50
|
+
root.setPassThroughTouches(options.getBoolean("passThroughTouches"));
|
|
96
51
|
}
|
|
97
|
-
|
|
98
|
-
|
|
52
|
+
reactSurface.start();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public void hide() {
|
|
56
|
+
if (decorView != null) {
|
|
57
|
+
decorView.removeView(rootView);
|
|
58
|
+
decorView = null;
|
|
59
|
+
}
|
|
60
|
+
unmountReactView();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public void update() {
|
|
64
|
+
ViewGroup decorView = getDecorView();
|
|
65
|
+
if (decorView != null && decorView != this.decorView) {
|
|
66
|
+
this.decorView.removeView(rootView);
|
|
67
|
+
this.decorView = decorView;
|
|
68
|
+
decorView.addView(rootView);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private void unmountReactView() {
|
|
73
|
+
if (reactSurface != null) {
|
|
74
|
+
reactSurface.stop();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private ViewGroup getDecorView() {
|
|
79
|
+
Window window = activity.getWindow();
|
|
80
|
+
if (window == null) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return (ViewGroup) window.getDecorView();
|
|
84
|
+
}
|
|
99
85
|
|
|
100
86
|
}
|
|
@@ -3,109 +3,130 @@ package com.reactnative.overlay;
|
|
|
3
3
|
import android.app.Activity;
|
|
4
4
|
|
|
5
5
|
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.core.graphics.Insets;
|
|
7
|
+
import androidx.core.view.ViewCompat;
|
|
8
|
+
import androidx.core.view.WindowInsetsCompat;
|
|
6
9
|
|
|
7
10
|
import com.facebook.common.logging.FLog;
|
|
11
|
+
import com.facebook.react.ReactHost;
|
|
8
12
|
import com.facebook.react.ReactNativeHost;
|
|
9
|
-
import com.facebook.react.bridge.
|
|
13
|
+
import com.facebook.react.bridge.JavaOnlyMap;
|
|
10
14
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
11
15
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
13
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
14
16
|
import com.facebook.react.bridge.ReadableMap;
|
|
15
17
|
import com.facebook.react.bridge.UiThreadUtil;
|
|
16
18
|
import com.facebook.react.bridge.WritableMap;
|
|
19
|
+
import com.facebook.react.defaults.DefaultReactHost;
|
|
20
|
+
import com.facebook.react.uimanager.PixelUtil;
|
|
17
21
|
|
|
18
22
|
import java.util.HashMap;
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
23
|
+
|
|
24
|
+
public class OverlayModule extends NativeOverlaySpec implements LifecycleEventListener {
|
|
25
|
+
|
|
26
|
+
private final HashMap<String, Overlay> overlays = new HashMap<>();
|
|
27
|
+
private final ReactApplicationContext reactContext;
|
|
28
|
+
private final ReactHost reactHost;
|
|
29
|
+
|
|
30
|
+
public OverlayModule(ReactApplicationContext reactContext, ReactNativeHost reactNativeHost) {
|
|
31
|
+
super(reactContext);
|
|
32
|
+
this.reactContext = reactContext;
|
|
33
|
+
this.reactHost = DefaultReactHost.getDefaultReactHost(reactContext, reactNativeHost, null);
|
|
34
|
+
reactContext.addLifecycleEventListener(this);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@NonNull
|
|
38
|
+
@Override
|
|
39
|
+
public String getName() {
|
|
40
|
+
return "OverlayHost";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Override
|
|
44
|
+
public void invalidate() {
|
|
45
|
+
reactContext.removeLifecycleEventListener(this);
|
|
46
|
+
final Activity activity = getCurrentActivity();
|
|
47
|
+
if (activity == null || activity.isFinishing()) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
UiThreadUtil.runOnUiThread(this::handleDestroy);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private void handleDestroy() {
|
|
54
|
+
for (String key : overlays.keySet()) {
|
|
55
|
+
Overlay overlay = overlays.get(key);
|
|
56
|
+
overlay.hide();
|
|
57
|
+
}
|
|
58
|
+
overlays.clear();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public void show(final String moduleName, final ReadableMap options) {
|
|
62
|
+
UiThreadUtil.runOnUiThread(() -> {
|
|
63
|
+
final Activity activity = getCurrentActivity();
|
|
64
|
+
if (activity == null || activity.isFinishing()) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Overlay overlay = overlays.get(moduleName);
|
|
69
|
+
if (overlay != null) {
|
|
70
|
+
overlay.update();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
int id = (int) options.getDouble("overlayId");
|
|
75
|
+
WritableMap props = JavaOnlyMap.deepClone(options);
|
|
76
|
+
props.putMap("insets", getInsets(activity));
|
|
77
|
+
overlay = new Overlay(activity, moduleName, reactHost);
|
|
78
|
+
overlay.show(props, options);
|
|
79
|
+
overlays.put(genOverlayKey(moduleName, id), overlay);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Override
|
|
84
|
+
public void hide(String moduleName, double overlayId) {
|
|
85
|
+
hide(moduleName, (int) overlayId);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public void hide(String moduleName, int id) {
|
|
89
|
+
UiThreadUtil.runOnUiThread(() -> {
|
|
90
|
+
Overlay overlay = overlays.get(genOverlayKey(moduleName, id));
|
|
91
|
+
if (overlay == null) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
overlays.remove(genOverlayKey(moduleName, id));
|
|
95
|
+
overlay.hide();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Override
|
|
100
|
+
public void onHostResume() {
|
|
101
|
+
//
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@Override
|
|
105
|
+
public void onHostPause() {
|
|
106
|
+
//
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@Override
|
|
110
|
+
public void onHostDestroy() {
|
|
111
|
+
FLog.i("OverlayModule", "onHostDestroy");
|
|
112
|
+
handleDestroy();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private String genOverlayKey(String moduleName, int id) {
|
|
116
|
+
return moduleName + "-" + id;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private ReadableMap getInsets(Activity activity) {
|
|
120
|
+
WindowInsetsCompat windowInsets = ViewCompat.getRootWindowInsets(activity.getWindow().getDecorView());
|
|
121
|
+
assert windowInsets != null;
|
|
122
|
+
Insets navigationBarInsets = windowInsets.getInsetsIgnoringVisibility(WindowInsetsCompat.Type.navigationBars());
|
|
123
|
+
Insets statusBarInsets = windowInsets.getInsetsIgnoringVisibility(WindowInsetsCompat.Type.statusBars());
|
|
124
|
+
Insets displayCutoutInsets = windowInsets.getInsetsIgnoringVisibility(WindowInsetsCompat.Type.displayCutout());
|
|
125
|
+
WritableMap insets = new JavaOnlyMap();
|
|
126
|
+
insets.putDouble("left", Math.floor(PixelUtil.toDIPFromPixel(Math.max(navigationBarInsets.left, displayCutoutInsets.left) + 0.5f)));
|
|
127
|
+
insets.putDouble("top", Math.floor(PixelUtil.toDIPFromPixel(statusBarInsets.top + 0.5f)));
|
|
128
|
+
insets.putDouble("right", Math.floor(PixelUtil.toDIPFromPixel(Math.max(navigationBarInsets.right, displayCutoutInsets.right) + 0.5f)));
|
|
129
|
+
insets.putDouble("bottom", Math.floor(PixelUtil.toDIPFromPixel(navigationBarInsets.bottom) + 0.5f));
|
|
130
|
+
return insets;
|
|
131
|
+
}
|
|
111
132
|
}
|
|
@@ -2,7 +2,6 @@ package com.reactnative.overlay;
|
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
|
|
5
|
-
import com.facebook.react.ReactInstanceManager;
|
|
6
5
|
import com.facebook.react.ReactNativeHost;
|
|
7
6
|
import com.facebook.react.ReactPackage;
|
|
8
7
|
import com.facebook.react.bridge.NativeModule;
|
|
@@ -14,21 +13,21 @@ import java.util.List;
|
|
|
14
13
|
|
|
15
14
|
public class OverlayPackage implements ReactPackage {
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
private final ReactNativeHost reactNativeHost;
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
public OverlayPackage(ReactNativeHost reactNativeHost) {
|
|
19
|
+
this.reactNativeHost = reactNativeHost;
|
|
20
|
+
}
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
@NonNull
|
|
23
|
+
@Override
|
|
24
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
25
|
+
return Collections.singletonList(new OverlayModule(reactContext, reactNativeHost));
|
|
26
|
+
}
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
@NonNull
|
|
29
|
+
@Override
|
|
30
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
31
|
+
return Collections.emptyList();
|
|
32
|
+
}
|
|
34
33
|
}
|