@sdcx/overlay 0.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/LICENSE +21 -0
- package/README.md +15 -0
- package/RNOverlay.podspec +18 -0
- package/android/build.gradle +35 -0
- package/android/proguard-rules.pro +0 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnative/overlay/Overlay.java +100 -0
- package/android/src/main/java/com/reactnative/overlay/OverlayModule.java +103 -0
- package/android/src/main/java/com/reactnative/overlay/OverlayPackage.java +34 -0
- package/android/src/main/java/com/reactnative/overlay/OverlayRootView.java +119 -0
- package/ios/Overlay/RNOverlay.h +14 -0
- package/ios/Overlay/RNOverlay.m +60 -0
- package/ios/Overlay/RNOverlayModule.h +10 -0
- package/ios/Overlay/RNOverlayModule.m +71 -0
- package/ios/Overlay.xcodeproj/project.pbxproj +283 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +10 -0
- package/package.json +66 -0
- package/src/index.ts +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 http://www.sdcx.tech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Overlay
|
|
2
|
+
|
|
3
|
+
`Overlay` 是一个 React Native 原生 UI 基础设施,它漂浮在你的 React Native 应用之上,可用于实现 Modal, Alert, Toast, Popover, Notification, Hoverball 等顶层 UI。
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @sdcx/overlay
|
|
9
|
+
# &
|
|
10
|
+
pod install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
请查看 Hoverball 示例代码
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "RNOverlay"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
s.platforms = { :ios => "10.0" }
|
|
14
|
+
s.source = { :git => "https://github.com/github-account/overlay.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/Overlay/**/*.{h,m,mm}"
|
|
17
|
+
s.dependency "React-Core"
|
|
18
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// android/build.gradle
|
|
2
|
+
|
|
3
|
+
def safeExtGet(prop, fallback) {
|
|
4
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
apply plugin: 'com.android.library'
|
|
8
|
+
|
|
9
|
+
android {
|
|
10
|
+
compileOptions {
|
|
11
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
12
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 30)
|
|
16
|
+
buildToolsVersion safeExtGet('buildToolsVersion', '30.0.2')
|
|
17
|
+
|
|
18
|
+
defaultConfig {
|
|
19
|
+
minSdkVersion safeExtGet('minSdkVersion', 21)
|
|
20
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 30)
|
|
21
|
+
versionCode 1
|
|
22
|
+
versionName "1.0.0"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
buildTypes {
|
|
26
|
+
release {
|
|
27
|
+
consumerProguardFiles 'proguard-rules.pro'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
dependencies {
|
|
33
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
34
|
+
implementation 'com.facebook.react:react-native:+'
|
|
35
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
package com.reactnative.overlay;
|
|
2
|
+
|
|
3
|
+
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
4
|
+
|
|
5
|
+
import android.app.Activity;
|
|
6
|
+
import android.os.Bundle;
|
|
7
|
+
import android.view.Gravity;
|
|
8
|
+
import android.view.ViewGroup;
|
|
9
|
+
import android.view.Window;
|
|
10
|
+
import android.widget.FrameLayout;
|
|
11
|
+
|
|
12
|
+
import androidx.annotation.NonNull;
|
|
13
|
+
import androidx.annotation.UiThread;
|
|
14
|
+
|
|
15
|
+
import com.facebook.react.ReactInstanceManager;
|
|
16
|
+
import com.facebook.react.bridge.Arguments;
|
|
17
|
+
import com.facebook.react.bridge.ReactContext;
|
|
18
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
19
|
+
|
|
20
|
+
@UiThread
|
|
21
|
+
public class Overlay {
|
|
22
|
+
|
|
23
|
+
final Activity activity;
|
|
24
|
+
final String moduleName;
|
|
25
|
+
|
|
26
|
+
final ReactInstanceManager reactInstanceManager;
|
|
27
|
+
|
|
28
|
+
OverlayRootView rootView;
|
|
29
|
+
ViewGroup decorView;
|
|
30
|
+
|
|
31
|
+
public Overlay(@NonNull Activity activity, String moduleName, ReactInstanceManager reactInstanceManager) {
|
|
32
|
+
this.activity = activity;
|
|
33
|
+
this.moduleName = moduleName;
|
|
34
|
+
this.reactInstanceManager = reactInstanceManager;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public void show(ReadableMap props, ReadableMap options) {
|
|
38
|
+
OverlayRootView reactRootView = createReactRootView();
|
|
39
|
+
|
|
40
|
+
if (options.hasKey("passThroughTouches")) {
|
|
41
|
+
reactRootView.setShouldConsumeTouchEvent(!options.getBoolean("passThroughTouches"));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.rootView = reactRootView;
|
|
45
|
+
startReactApplication(reactRootView, Arguments.toBundle(props));
|
|
46
|
+
decorView = getDecorView();
|
|
47
|
+
if (decorView != null) {
|
|
48
|
+
decorView.addView(reactRootView);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public void hide() {
|
|
53
|
+
if (decorView != null) {
|
|
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;
|
|
96
|
+
}
|
|
97
|
+
return (ViewGroup) window.getDecorView();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
package com.reactnative.overlay;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
|
|
7
|
+
import com.facebook.common.logging.FLog;
|
|
8
|
+
import com.facebook.react.ReactNativeHost;
|
|
9
|
+
import com.facebook.react.bridge.LifecycleEventListener;
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
12
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
13
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
14
|
+
import com.facebook.react.bridge.UiThreadUtil;
|
|
15
|
+
|
|
16
|
+
import java.util.HashMap;
|
|
17
|
+
|
|
18
|
+
public class OverlayModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
|
|
19
|
+
|
|
20
|
+
private final HashMap<String, Overlay> overlays = new HashMap<>();
|
|
21
|
+
private final ReactApplicationContext reactContext;
|
|
22
|
+
|
|
23
|
+
private final ReactNativeHost reactNativeHost;
|
|
24
|
+
|
|
25
|
+
public OverlayModule(ReactApplicationContext reactContext, ReactNativeHost reactNativeHost) {
|
|
26
|
+
super(reactContext);
|
|
27
|
+
this.reactContext = reactContext;
|
|
28
|
+
this.reactNativeHost = reactNativeHost;
|
|
29
|
+
reactContext.addLifecycleEventListener(this);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Override
|
|
33
|
+
public void invalidate() {
|
|
34
|
+
reactContext.removeLifecycleEventListener(this);
|
|
35
|
+
final Activity activity = getCurrentActivity();
|
|
36
|
+
if (activity == null || activity.isFinishing()) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
UiThreadUtil.runOnUiThread(this::handleDestroy);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private void handleDestroy() {
|
|
43
|
+
for (String key : overlays.keySet()) {
|
|
44
|
+
Overlay overlay = overlays.get(key);
|
|
45
|
+
overlay.hide();
|
|
46
|
+
}
|
|
47
|
+
overlays.clear();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@NonNull
|
|
51
|
+
@Override
|
|
52
|
+
public String getName() {
|
|
53
|
+
return "OverlayHost";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@ReactMethod
|
|
57
|
+
public void show(final String moduleName, final ReadableMap props, final ReadableMap options) {
|
|
58
|
+
UiThreadUtil.runOnUiThread(() -> {
|
|
59
|
+
final Activity activity = getCurrentActivity();
|
|
60
|
+
if (activity == null || activity.isFinishing()) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
Overlay overlay = overlays.get(moduleName);
|
|
65
|
+
if (overlay != null) {
|
|
66
|
+
overlay.update();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
overlay = new Overlay(activity, moduleName, reactNativeHost.getReactInstanceManager());
|
|
71
|
+
overlay.show(props, options);
|
|
72
|
+
overlays.put(moduleName, overlay);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@ReactMethod
|
|
77
|
+
public void hide(String moduleName) {
|
|
78
|
+
UiThreadUtil.runOnUiThread(() -> {
|
|
79
|
+
Overlay overlay = overlays.get(moduleName);
|
|
80
|
+
if (overlay == null) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
overlays.remove(moduleName);
|
|
84
|
+
overlay.hide();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Override
|
|
89
|
+
public void onHostResume() {
|
|
90
|
+
UiThreadUtil.assertOnUiThread();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Override
|
|
94
|
+
public void onHostPause() {
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Override
|
|
99
|
+
public void onHostDestroy() {
|
|
100
|
+
FLog.i("OverlayModule", "onHostDestroy");
|
|
101
|
+
handleDestroy();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package com.reactnative.overlay;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.ReactInstanceManager;
|
|
6
|
+
import com.facebook.react.ReactNativeHost;
|
|
7
|
+
import com.facebook.react.ReactPackage;
|
|
8
|
+
import com.facebook.react.bridge.NativeModule;
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
11
|
+
|
|
12
|
+
import java.util.Collections;
|
|
13
|
+
import java.util.List;
|
|
14
|
+
|
|
15
|
+
public class OverlayPackage implements ReactPackage {
|
|
16
|
+
|
|
17
|
+
private final ReactNativeHost reactNativeHost;
|
|
18
|
+
|
|
19
|
+
public OverlayPackage(ReactNativeHost reactNativeHost) {
|
|
20
|
+
this.reactNativeHost = reactNativeHost;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@NonNull
|
|
24
|
+
@Override
|
|
25
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
26
|
+
return Collections.singletonList(new OverlayModule(reactContext, reactNativeHost));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@NonNull
|
|
30
|
+
@Override
|
|
31
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
32
|
+
return Collections.emptyList();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
package com.reactnative.overlay;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.os.Bundle;
|
|
5
|
+
import android.util.AttributeSet;
|
|
6
|
+
import android.view.MotionEvent;
|
|
7
|
+
import android.view.ViewTreeObserver;
|
|
8
|
+
|
|
9
|
+
import androidx.annotation.Nullable;
|
|
10
|
+
|
|
11
|
+
import com.facebook.react.ReactInstanceManager;
|
|
12
|
+
import com.facebook.react.ReactRootView;
|
|
13
|
+
|
|
14
|
+
import java.lang.reflect.Method;
|
|
15
|
+
|
|
16
|
+
public class OverlayRootView extends ReactRootView {
|
|
17
|
+
|
|
18
|
+
public OverlayRootView(Context context) {
|
|
19
|
+
super(context);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public OverlayRootView(Context context, AttributeSet attrs) {
|
|
23
|
+
super(context, attrs);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public OverlayRootView(Context context, AttributeSet attrs, int defStyle) {
|
|
27
|
+
super(context, attrs, defStyle);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private boolean shouldConsumeTouchEvent = true;
|
|
31
|
+
|
|
32
|
+
public void setShouldConsumeTouchEvent(boolean consume) {
|
|
33
|
+
this.shouldConsumeTouchEvent = consume;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Override
|
|
37
|
+
public boolean onTouchEvent(MotionEvent ev) {
|
|
38
|
+
int action = ev.getAction() & MotionEvent.ACTION_MASK;
|
|
39
|
+
if (action == MotionEvent.ACTION_DOWN) {
|
|
40
|
+
onChildStartedNativeGesture(ev);
|
|
41
|
+
}
|
|
42
|
+
return shouldConsumeTouchEvent;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Override
|
|
46
|
+
protected void onAttachedToWindow() {
|
|
47
|
+
super.onAttachedToWindow();
|
|
48
|
+
removeOnGlobalLayoutListener();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
protected void onDetachedFromWindow() {
|
|
53
|
+
super.onDetachedFromWindow();
|
|
54
|
+
removeOnGlobalLayoutListener();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
public void startReactApplication(ReactInstanceManager reactInstanceManager, String moduleName, @Nullable Bundle initialProperties) {
|
|
59
|
+
super.startReactApplication(reactInstanceManager, moduleName, initialProperties);
|
|
60
|
+
removeOnGlobalLayoutListener();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 避免 reload 时,重复 run 的问题
|
|
64
|
+
private boolean shouldRunApplication = true;
|
|
65
|
+
|
|
66
|
+
@Override
|
|
67
|
+
public void runApplication() {
|
|
68
|
+
if (shouldRunApplication) {
|
|
69
|
+
shouldRunApplication = false;
|
|
70
|
+
super.runApplication();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private boolean hbd_isAttachedToReactInstance;
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
public void onAttachedToReactInstance() {
|
|
78
|
+
super.onAttachedToReactInstance();
|
|
79
|
+
hbd_isAttachedToReactInstance = true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Override
|
|
83
|
+
public void setAppProperties(@Nullable Bundle appProperties) {
|
|
84
|
+
if (hbd_isAttachedToReactInstance) {
|
|
85
|
+
shouldRunApplication = true;
|
|
86
|
+
super.setAppProperties(appProperties);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Override
|
|
91
|
+
public void unmountReactApplication() {
|
|
92
|
+
super.unmountReactApplication();
|
|
93
|
+
removeOnGlobalLayoutListener();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private ViewTreeObserver.OnGlobalLayoutListener mGlobalLayoutListener;
|
|
97
|
+
|
|
98
|
+
private ViewTreeObserver.OnGlobalLayoutListener getGlobalLayoutListener() {
|
|
99
|
+
if (mGlobalLayoutListener == null) {
|
|
100
|
+
try {
|
|
101
|
+
Method method = ReactRootView.class.getDeclaredMethod("getCustomGlobalLayoutListener");
|
|
102
|
+
method.setAccessible(true);
|
|
103
|
+
mGlobalLayoutListener = (ViewTreeObserver.OnGlobalLayoutListener) method.invoke(this);
|
|
104
|
+
} catch (Exception e) {
|
|
105
|
+
e.printStackTrace();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return mGlobalLayoutListener;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void addOnGlobalLayoutListener() {
|
|
112
|
+
removeOnGlobalLayoutListener();
|
|
113
|
+
getViewTreeObserver().addOnGlobalLayoutListener(getGlobalLayoutListener());
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void removeOnGlobalLayoutListener() {
|
|
117
|
+
getViewTreeObserver().removeOnGlobalLayoutListener(getGlobalLayoutListener());
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
#import <React/RCTBridge.h>
|
|
3
|
+
|
|
4
|
+
@interface RNOverlay : NSObject
|
|
5
|
+
|
|
6
|
+
- (instancetype)initWithModuleName:(NSString *)moduleName bridge:(RCTBridge *)bridge;
|
|
7
|
+
|
|
8
|
+
- (void)show:(NSDictionary *)props options:(NSDictionary *)options;
|
|
9
|
+
|
|
10
|
+
- (void)hide;
|
|
11
|
+
|
|
12
|
+
- (void)update;
|
|
13
|
+
|
|
14
|
+
@end
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#import "RNOverlayModule.h"
|
|
2
|
+
#import "RNOverlay.h"
|
|
3
|
+
|
|
4
|
+
#import <React/RCTLog.h>
|
|
5
|
+
#import <React/RCTBridge.h>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@interface RNOverlayModule ()
|
|
9
|
+
|
|
10
|
+
@property(nonatomic, strong) NSMutableDictionary *overlays;
|
|
11
|
+
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
@implementation RNOverlayModule
|
|
15
|
+
|
|
16
|
+
@synthesize bridge;
|
|
17
|
+
|
|
18
|
+
- (instancetype)init {
|
|
19
|
+
if (self = [super init]) {
|
|
20
|
+
_overlays = [[NSMutableDictionary alloc] init];
|
|
21
|
+
}
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (void)handleReload {
|
|
26
|
+
for (NSString *key in self.overlays) {
|
|
27
|
+
RNOverlay *overlay = self.overlays[key];
|
|
28
|
+
[overlay hide];
|
|
29
|
+
}
|
|
30
|
+
[self.overlays removeAllObjects];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (void)invalidate {
|
|
34
|
+
[self handleReload];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
38
|
+
return YES;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
- (dispatch_queue_t)methodQueue {
|
|
42
|
+
return dispatch_get_main_queue();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
RCT_EXPORT_MODULE(OverlayHost)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
RCT_EXPORT_METHOD(show:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options) {
|
|
49
|
+
RNOverlay *overlay = self.overlays[moduleName];
|
|
50
|
+
if (overlay != nil) {
|
|
51
|
+
[overlay update];
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
overlay = [[RNOverlay alloc] initWithModuleName:moduleName bridge:self.bridge];
|
|
56
|
+
self.overlays[moduleName] = overlay;
|
|
57
|
+
|
|
58
|
+
[overlay show:props options:options];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
RCT_EXPORT_METHOD(hide:(NSString *)moduleName) {
|
|
62
|
+
RNOverlay *overlay = self.overlays[moduleName];
|
|
63
|
+
if (!overlay) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
[self.overlays removeObjectForKey:moduleName];
|
|
67
|
+
[overlay hide];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@end
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// !$*UTF8*$!
|
|
2
|
+
{
|
|
3
|
+
archiveVersion = 1;
|
|
4
|
+
classes = {
|
|
5
|
+
};
|
|
6
|
+
objectVersion = 48;
|
|
7
|
+
objects = {
|
|
8
|
+
|
|
9
|
+
/* Begin PBXBuildFile section */
|
|
10
|
+
91C884A6202C3E8600EC0A20 /* undefined.m in Sources */ = {isa = PBXBuildFile; fileRef = 91C884A1202C3E8600EC0A20 /* undefined.m */; };
|
|
11
|
+
/* End PBXBuildFile section */
|
|
12
|
+
|
|
13
|
+
/* Begin PBXCopyFilesBuildPhase section */
|
|
14
|
+
910362D01FE9318600F4DA8E /* CopyFiles */ = {
|
|
15
|
+
isa = PBXCopyFilesBuildPhase;
|
|
16
|
+
buildActionMask = 2147483647;
|
|
17
|
+
dstPath = "include/$(PRODUCT_NAME)";
|
|
18
|
+
dstSubfolderSpec = 16;
|
|
19
|
+
files = (
|
|
20
|
+
);
|
|
21
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
22
|
+
};
|
|
23
|
+
/* End PBXCopyFilesBuildPhase section */
|
|
24
|
+
|
|
25
|
+
/* Begin PBXFileReference section */
|
|
26
|
+
910362D21FE9318600F4DA8E /* libOverlay.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOverlay.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
27
|
+
91C884A1202C3E8600EC0A20 /* undefined.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = undefined.m; sourceTree = "<group>"; };
|
|
28
|
+
91C884A2202C3E8600EC0A20 /* undefined.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = undefined.h; sourceTree = "<group>"; };
|
|
29
|
+
/* End PBXFileReference section */
|
|
30
|
+
|
|
31
|
+
/* Begin PBXFrameworksBuildPhase section */
|
|
32
|
+
910362CF1FE9318600F4DA8E /* Frameworks */ = {
|
|
33
|
+
isa = PBXFrameworksBuildPhase;
|
|
34
|
+
buildActionMask = 2147483647;
|
|
35
|
+
files = (
|
|
36
|
+
);
|
|
37
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
38
|
+
};
|
|
39
|
+
/* End PBXFrameworksBuildPhase section */
|
|
40
|
+
|
|
41
|
+
/* Begin PBXGroup section */
|
|
42
|
+
910362C91FE9318600F4DA8E = {
|
|
43
|
+
isa = PBXGroup;
|
|
44
|
+
children = (
|
|
45
|
+
910362D41FE9318600F4DA8E /* Overlay */,
|
|
46
|
+
910362D31FE9318600F4DA8E /* Products */,
|
|
47
|
+
);
|
|
48
|
+
sourceTree = "<group>";
|
|
49
|
+
};
|
|
50
|
+
910362D31FE9318600F4DA8E /* Products */ = {
|
|
51
|
+
isa = PBXGroup;
|
|
52
|
+
children = (
|
|
53
|
+
910362D21FE9318600F4DA8E /* libOverlay.a */,
|
|
54
|
+
);
|
|
55
|
+
name = Products;
|
|
56
|
+
sourceTree = "<group>";
|
|
57
|
+
};
|
|
58
|
+
910362D41FE9318600F4DA8E /* Overlay */ = {
|
|
59
|
+
isa = PBXGroup;
|
|
60
|
+
children = (
|
|
61
|
+
91C884A2202C3E8600EC0A20 /* undefined.h */,
|
|
62
|
+
91C884A1202C3E8600EC0A20 /* undefined.m */,
|
|
63
|
+
);
|
|
64
|
+
path = Overlay;
|
|
65
|
+
sourceTree = "<group>";
|
|
66
|
+
};
|
|
67
|
+
/* End PBXGroup section */
|
|
68
|
+
|
|
69
|
+
/* Begin PBXNativeTarget section */
|
|
70
|
+
910362D11FE9318600F4DA8E /* Overlay */ = {
|
|
71
|
+
isa = PBXNativeTarget;
|
|
72
|
+
buildConfigurationList = 910362DB1FE9318600F4DA8E /* Build configuration list for PBXNativeTarget "Overlay" */;
|
|
73
|
+
buildPhases = (
|
|
74
|
+
910362CE1FE9318600F4DA8E /* Sources */,
|
|
75
|
+
910362CF1FE9318600F4DA8E /* Frameworks */,
|
|
76
|
+
910362D01FE9318600F4DA8E /* CopyFiles */,
|
|
77
|
+
);
|
|
78
|
+
buildRules = (
|
|
79
|
+
);
|
|
80
|
+
dependencies = (
|
|
81
|
+
);
|
|
82
|
+
name = Overlay;
|
|
83
|
+
productName = Overlay;
|
|
84
|
+
productReference = 910362D21FE9318600F4DA8E /* libOverlay.a */;
|
|
85
|
+
productType = "com.apple.product-type.library.static";
|
|
86
|
+
};
|
|
87
|
+
/* End PBXNativeTarget section */
|
|
88
|
+
|
|
89
|
+
/* Begin PBXProject section */
|
|
90
|
+
910362CA1FE9318600F4DA8E /* Project object */ = {
|
|
91
|
+
isa = PBXProject;
|
|
92
|
+
attributes = {
|
|
93
|
+
LastUpgradeCheck = 0920;
|
|
94
|
+
ORGANIZATIONNAME = Listen;
|
|
95
|
+
TargetAttributes = {
|
|
96
|
+
910362D11FE9318600F4DA8E = {
|
|
97
|
+
CreatedOnToolsVersion = 9.2;
|
|
98
|
+
ProvisioningStyle = Automatic;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
buildConfigurationList = 910362CD1FE9318600F4DA8E /* Build configuration list for PBXProject "Overlay" */;
|
|
103
|
+
compatibilityVersion = "Xcode 8.0";
|
|
104
|
+
developmentRegion = en;
|
|
105
|
+
hasScannedForEncodings = 0;
|
|
106
|
+
knownRegions = (
|
|
107
|
+
en,
|
|
108
|
+
);
|
|
109
|
+
mainGroup = 910362C91FE9318600F4DA8E;
|
|
110
|
+
productRefGroup = 910362D31FE9318600F4DA8E /* Products */;
|
|
111
|
+
projectDirPath = "";
|
|
112
|
+
projectRoot = "";
|
|
113
|
+
targets = (
|
|
114
|
+
910362D11FE9318600F4DA8E /* Overlay */,
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
/* End PBXProject section */
|
|
118
|
+
|
|
119
|
+
/* Begin PBXSourcesBuildPhase section */
|
|
120
|
+
910362CE1FE9318600F4DA8E /* Sources */ = {
|
|
121
|
+
isa = PBXSourcesBuildPhase;
|
|
122
|
+
buildActionMask = 2147483647;
|
|
123
|
+
files = (
|
|
124
|
+
91C884A6202C3E8600EC0A20 /* undefined.m in Sources */,
|
|
125
|
+
);
|
|
126
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
127
|
+
};
|
|
128
|
+
/* End PBXSourcesBuildPhase section */
|
|
129
|
+
|
|
130
|
+
/* Begin XCBuildConfiguration section */
|
|
131
|
+
910362D91FE9318600F4DA8E /* Debug */ = {
|
|
132
|
+
isa = XCBuildConfiguration;
|
|
133
|
+
buildSettings = {
|
|
134
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
135
|
+
CLANG_ANALYZER_NONNULL = YES;
|
|
136
|
+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
|
137
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
|
138
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
139
|
+
CLANG_ENABLE_MODULES = YES;
|
|
140
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
141
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
142
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
143
|
+
CLANG_WARN_COMMA = YES;
|
|
144
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
145
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
146
|
+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
|
147
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
148
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
149
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
150
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
151
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
152
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
153
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
154
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
155
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
156
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
157
|
+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
|
158
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
159
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
160
|
+
CODE_SIGN_IDENTITY = "iPhone Developer";
|
|
161
|
+
COPY_PHASE_STRIP = NO;
|
|
162
|
+
DEBUG_INFORMATION_FORMAT = dwarf;
|
|
163
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
164
|
+
ENABLE_TESTABILITY = YES;
|
|
165
|
+
GCC_C_LANGUAGE_STANDARD = gnu11;
|
|
166
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
|
167
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
168
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
|
169
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
170
|
+
"DEBUG=1",
|
|
171
|
+
"$(inherited)",
|
|
172
|
+
);
|
|
173
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
174
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
175
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
176
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
177
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
178
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
179
|
+
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
|
180
|
+
MTL_ENABLE_DEBUG_INFO = YES;
|
|
181
|
+
ONLY_ACTIVE_ARCH = YES;
|
|
182
|
+
SDKROOT = iphoneos;
|
|
183
|
+
};
|
|
184
|
+
name = Debug;
|
|
185
|
+
};
|
|
186
|
+
910362DA1FE9318600F4DA8E /* Release */ = {
|
|
187
|
+
isa = XCBuildConfiguration;
|
|
188
|
+
buildSettings = {
|
|
189
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
190
|
+
CLANG_ANALYZER_NONNULL = YES;
|
|
191
|
+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
|
192
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
|
193
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
194
|
+
CLANG_ENABLE_MODULES = YES;
|
|
195
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
196
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
197
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
198
|
+
CLANG_WARN_COMMA = YES;
|
|
199
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
200
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
201
|
+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
|
202
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
203
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
204
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
205
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
206
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
207
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
208
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
209
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
210
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
211
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
212
|
+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
|
213
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
214
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
215
|
+
CODE_SIGN_IDENTITY = "iPhone Developer";
|
|
216
|
+
COPY_PHASE_STRIP = NO;
|
|
217
|
+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
|
218
|
+
ENABLE_NS_ASSERTIONS = NO;
|
|
219
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
220
|
+
GCC_C_LANGUAGE_STANDARD = gnu11;
|
|
221
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
222
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
223
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
224
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
225
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
226
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
227
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
228
|
+
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
|
229
|
+
MTL_ENABLE_DEBUG_INFO = NO;
|
|
230
|
+
SDKROOT = iphoneos;
|
|
231
|
+
VALIDATE_PRODUCT = YES;
|
|
232
|
+
};
|
|
233
|
+
name = Release;
|
|
234
|
+
};
|
|
235
|
+
910362DC1FE9318600F4DA8E /* Debug */ = {
|
|
236
|
+
isa = XCBuildConfiguration;
|
|
237
|
+
buildSettings = {
|
|
238
|
+
CODE_SIGN_STYLE = Automatic;
|
|
239
|
+
DEVELOPMENT_TEAM = 9H9696K6NL;
|
|
240
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
241
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
242
|
+
SKIP_INSTALL = YES;
|
|
243
|
+
TARGETED_DEVICE_FAMILY = "1,2";
|
|
244
|
+
};
|
|
245
|
+
name = Debug;
|
|
246
|
+
};
|
|
247
|
+
910362DD1FE9318600F4DA8E /* Release */ = {
|
|
248
|
+
isa = XCBuildConfiguration;
|
|
249
|
+
buildSettings = {
|
|
250
|
+
CODE_SIGN_STYLE = Automatic;
|
|
251
|
+
DEVELOPMENT_TEAM = 9H9696K6NL;
|
|
252
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
253
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
254
|
+
SKIP_INSTALL = YES;
|
|
255
|
+
TARGETED_DEVICE_FAMILY = "1,2";
|
|
256
|
+
};
|
|
257
|
+
name = Release;
|
|
258
|
+
};
|
|
259
|
+
/* End XCBuildConfiguration section */
|
|
260
|
+
|
|
261
|
+
/* Begin XCConfigurationList section */
|
|
262
|
+
910362CD1FE9318600F4DA8E /* Build configuration list for PBXProject "Overlay" */ = {
|
|
263
|
+
isa = XCConfigurationList;
|
|
264
|
+
buildConfigurations = (
|
|
265
|
+
910362D91FE9318600F4DA8E /* Debug */,
|
|
266
|
+
910362DA1FE9318600F4DA8E /* Release */,
|
|
267
|
+
);
|
|
268
|
+
defaultConfigurationIsVisible = 0;
|
|
269
|
+
defaultConfigurationName = Release;
|
|
270
|
+
};
|
|
271
|
+
910362DB1FE9318600F4DA8E /* Build configuration list for PBXNativeTarget "Overlay" */ = {
|
|
272
|
+
isa = XCConfigurationList;
|
|
273
|
+
buildConfigurations = (
|
|
274
|
+
910362DC1FE9318600F4DA8E /* Debug */,
|
|
275
|
+
910362DD1FE9318600F4DA8E /* Release */,
|
|
276
|
+
);
|
|
277
|
+
defaultConfigurationIsVisible = 0;
|
|
278
|
+
defaultConfigurationName = Release;
|
|
279
|
+
};
|
|
280
|
+
/* End XCConfigurationList section */
|
|
281
|
+
};
|
|
282
|
+
rootObject = 910362CA1FE9318600F4DA8E /* Project object */;
|
|
283
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface OverlayOptions {
|
|
2
|
+
passThroughTouches?: boolean;
|
|
3
|
+
}
|
|
4
|
+
interface PropsType {
|
|
5
|
+
[index: string]: any;
|
|
6
|
+
}
|
|
7
|
+
declare function show<P extends PropsType = {}>(moduleName: string, props?: P, options?: OverlayOptions): void;
|
|
8
|
+
declare function hide(moduleName: string): void;
|
|
9
|
+
declare const Overlay: {
|
|
10
|
+
show: typeof show;
|
|
11
|
+
hide: typeof hide;
|
|
12
|
+
};
|
|
13
|
+
export { Overlay };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
const OverlayHost = NativeModules.OverlayHost;
|
|
3
|
+
function show(moduleName, props, options = {}) {
|
|
4
|
+
OverlayHost.show(moduleName, props, options);
|
|
5
|
+
}
|
|
6
|
+
function hide(moduleName) {
|
|
7
|
+
OverlayHost.hide(moduleName);
|
|
8
|
+
}
|
|
9
|
+
const Overlay = { show, hide };
|
|
10
|
+
export { Overlay };
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sdcx/overlay",
|
|
3
|
+
"description": "A react-native Overlay component.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"typings": "./lib/index.d.ts",
|
|
7
|
+
"react-native": "src/index",
|
|
8
|
+
"nativePackage": true,
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"lib",
|
|
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 ./lib && tsc -p tsconfig.build.json",
|
|
29
|
+
"prepare": "npm run build",
|
|
30
|
+
"tsc": "tsc",
|
|
31
|
+
"test": "jest",
|
|
32
|
+
"lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": ">=16.8",
|
|
36
|
+
"react-native": ">=0.60"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@babel/core": "^7.13.10",
|
|
40
|
+
"@babel/runtime": "^7.13.10",
|
|
41
|
+
"@react-native-community/eslint-config": "^3.0.0",
|
|
42
|
+
"@types/jest": "^26.0.21",
|
|
43
|
+
"@types/react": "^17.0.2",
|
|
44
|
+
"@types/react-native": "^0.67.0",
|
|
45
|
+
"@types/react-test-renderer": "17.0.2",
|
|
46
|
+
"babel-jest": "^26.6.3",
|
|
47
|
+
"jest": "^26.6.3",
|
|
48
|
+
"metro-react-native-babel-preset": "^0.66.2",
|
|
49
|
+
"react": "17.0.2",
|
|
50
|
+
"react-native": "^0.67.4",
|
|
51
|
+
"react-test-renderer": "17.0.2",
|
|
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
|
+
}
|
|
66
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NativeModule, NativeModules } from 'react-native'
|
|
2
|
+
|
|
3
|
+
interface OverlayOptions {
|
|
4
|
+
passThroughTouches?: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface PropsType {
|
|
8
|
+
[index: string]: any
|
|
9
|
+
}
|
|
10
|
+
interface OverlayInterface extends NativeModule {
|
|
11
|
+
show<P extends PropsType = {}>(moduleName: string, props?: P, options?: OverlayOptions): void
|
|
12
|
+
hide(moduleName: string): void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const OverlayHost: OverlayInterface = NativeModules.OverlayHost
|
|
16
|
+
|
|
17
|
+
function show<P extends PropsType = {}>(moduleName: string, props?: P, options: OverlayOptions = {}) {
|
|
18
|
+
OverlayHost.show(moduleName, props, options)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function hide(moduleName: string) {
|
|
22
|
+
OverlayHost.hide(moduleName)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Overlay = { show, hide }
|
|
26
|
+
|
|
27
|
+
export { Overlay }
|