react-native-screenshot-aware 0.0.1
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 +20 -0
- package/README.md +101 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeScreenshotAwareSpec.java +38 -0
- package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +49 -0
- package/android/app/build/generated/source/codegen/jni/RNScreenshotAwareSpec-generated.cpp +32 -0
- package/android/app/build/generated/source/codegen/jni/RNScreenshotAwareSpec.h +31 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNScreenshotAwareSpec/RNScreenshotAwareSpecJSI-generated.cpp +28 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNScreenshotAwareSpec/RNScreenshotAwareSpecJSI.h +67 -0
- package/android/build.gradle +90 -0
- package/android/generated/java/com/screenshotaware/NativeScreenshotAwareSpec.java +41 -0
- package/android/generated/jni/CMakeLists.txt +49 -0
- package/android/generated/jni/RNScreenshotAwareSpec-generated.cpp +38 -0
- package/android/generated/jni/RNScreenshotAwareSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/EventEmitters.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/EventEmitters.h +17 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/Props.cpp +19 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/Props.h +18 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/RNScreenshotAwareSpecJSI-generated.cpp +36 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/RNScreenshotAwareSpecJSI.h +76 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/States.h +19 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/screenshotaware/ScreenshotAwareModule.kt +54 -0
- package/android/src/main/java/com/screenshotaware/ScreenshotAwarePackage.kt +34 -0
- package/android/src/newarch/ScreenshotAwareSpec.kt +7 -0
- package/android/src/oldarch/ScreenshotAwareSpec.kt +11 -0
- package/ios/ScreenshotAware.h +13 -0
- package/ios/ScreenshotAware.mm +52 -0
- package/ios/ScreenshotAwareImpl.h +13 -0
- package/ios/ScreenshotAwareImpl.mm +35 -0
- package/ios/generated/RNScreenshotAwareSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/RNScreenshotAwareSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/RNScreenshotAwareSpec/EventEmitters.cpp +16 -0
- package/ios/generated/RNScreenshotAwareSpec/EventEmitters.h +17 -0
- package/ios/generated/RNScreenshotAwareSpec/Props.cpp +19 -0
- package/ios/generated/RNScreenshotAwareSpec/Props.h +18 -0
- package/ios/generated/RNScreenshotAwareSpec/RCTComponentViewHelpers.h +18 -0
- package/ios/generated/RNScreenshotAwareSpec/RNScreenshotAwareSpec-generated.mm +36 -0
- package/ios/generated/RNScreenshotAwareSpec/RNScreenshotAwareSpec.h +50 -0
- package/ios/generated/RNScreenshotAwareSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/RNScreenshotAwareSpec/ShadowNodes.h +23 -0
- package/ios/generated/RNScreenshotAwareSpec/States.cpp +16 -0
- package/ios/generated/RNScreenshotAwareSpec/States.h +19 -0
- package/ios/generated/RNScreenshotAwareSpecJSI-generated.cpp +36 -0
- package/ios/generated/RNScreenshotAwareSpecJSI.h +76 -0
- package/lib/commonjs/NativeScreenshotAware.js +9 -0
- package/lib/commonjs/NativeScreenshotAware.js.map +1 -0
- package/lib/commonjs/index.js +25 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/NativeScreenshotAware.js +5 -0
- package/lib/module/NativeScreenshotAware.js.map +1 -0
- package/lib/module/index.js +19 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/NativeScreenshotAware.d.ts +8 -0
- package/lib/typescript/NativeScreenshotAware.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +133 -0
- package/react-native-screenshot-aware.podspec +23 -0
- package/src/NativeScreenshotAware.ts +9 -0
- package/src/index.tsx +23 -0
package/android/generated/jni/react/renderer/components/RNScreenshotAwareSpec/EventEmitters.cpp
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "EventEmitters.h"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "Props.h"
|
|
12
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
13
|
+
#include <react/renderer/core/propsConversions.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNScreenshotAwareSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeScreenshotAwareCxxSpecJSI_addListener(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
static_cast<NativeScreenshotAwareCxxSpecJSI *>(&turboModule)->addListener(
|
|
16
|
+
rt,
|
|
17
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
18
|
+
);
|
|
19
|
+
return jsi::Value::undefined();
|
|
20
|
+
}
|
|
21
|
+
static jsi::Value __hostFunction_NativeScreenshotAwareCxxSpecJSI_removeListeners(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
22
|
+
static_cast<NativeScreenshotAwareCxxSpecJSI *>(&turboModule)->removeListeners(
|
|
23
|
+
rt,
|
|
24
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
|
|
25
|
+
);
|
|
26
|
+
return jsi::Value::undefined();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
NativeScreenshotAwareCxxSpecJSI::NativeScreenshotAwareCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
30
|
+
: TurboModule("ScreenshotAware", jsInvoker) {
|
|
31
|
+
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeScreenshotAwareCxxSpecJSI_addListener};
|
|
32
|
+
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeScreenshotAwareCxxSpecJSI_removeListeners};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeScreenshotAwareCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeScreenshotAwareCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual void addListener(jsi::Runtime &rt, jsi::String eventName) = 0;
|
|
24
|
+
virtual void removeListeners(jsi::Runtime &rt, double count) = 0;
|
|
25
|
+
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
template <typename T>
|
|
29
|
+
class JSI_EXPORT NativeScreenshotAwareCxxSpec : public TurboModule {
|
|
30
|
+
public:
|
|
31
|
+
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
32
|
+
return delegate_.get(rt, propName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static constexpr std::string_view kModuleName = "ScreenshotAware";
|
|
36
|
+
|
|
37
|
+
protected:
|
|
38
|
+
NativeScreenshotAwareCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
39
|
+
: TurboModule(std::string{NativeScreenshotAwareCxxSpec::kModuleName}, jsInvoker),
|
|
40
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
private:
|
|
44
|
+
class Delegate : public NativeScreenshotAwareCxxSpecJSI {
|
|
45
|
+
public:
|
|
46
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
47
|
+
NativeScreenshotAwareCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void addListener(jsi::Runtime &rt, jsi::String eventName) override {
|
|
52
|
+
static_assert(
|
|
53
|
+
bridging::getParameterCount(&T::addListener) == 2,
|
|
54
|
+
"Expected addListener(...) to have 2 parameters");
|
|
55
|
+
|
|
56
|
+
return bridging::callFromJs<void>(
|
|
57
|
+
rt, &T::addListener, jsInvoker_, instance_, std::move(eventName));
|
|
58
|
+
}
|
|
59
|
+
void removeListeners(jsi::Runtime &rt, double count) override {
|
|
60
|
+
static_assert(
|
|
61
|
+
bridging::getParameterCount(&T::removeListeners) == 2,
|
|
62
|
+
"Expected removeListeners(...) to have 2 parameters");
|
|
63
|
+
|
|
64
|
+
return bridging::callFromJs<void>(
|
|
65
|
+
rt, &T::removeListeners, jsInvoker_, instance_, std::move(count));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private:
|
|
69
|
+
friend class NativeScreenshotAwareCxxSpec;
|
|
70
|
+
T *instance_;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
Delegate delegate_;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ShadowNodes.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "EventEmitters.h"
|
|
14
|
+
#include "Props.h"
|
|
15
|
+
#include "States.h"
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <jsi/jsi.h>
|
|
18
|
+
|
|
19
|
+
namespace facebook::react {
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateStateCpp.js
|
|
9
|
+
*/
|
|
10
|
+
#include "States.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateStateH.js
|
|
8
|
+
*/
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#ifdef ANDROID
|
|
12
|
+
#include <folly/dynamic.h>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package com.screenshotaware
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.os.Build
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
8
|
+
|
|
9
|
+
class ScreenshotAwareModule internal constructor(context: ReactApplicationContext) :
|
|
10
|
+
ScreenshotAwareSpec(context) {
|
|
11
|
+
|
|
12
|
+
private var screenCaptureCallback = Activity.ScreenCaptureCallback {
|
|
13
|
+
sendEvent()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override fun getName(): String {
|
|
17
|
+
return NAME
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun initialize() {
|
|
21
|
+
super.initialize()
|
|
22
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
|
23
|
+
reactApplicationContext.currentActivity?.let {
|
|
24
|
+
currentActivity?.registerScreenCaptureCallback(it.mainExecutor, screenCaptureCallback)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun invalidate() {
|
|
30
|
+
super.invalidate()
|
|
31
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
|
32
|
+
currentActivity?.unregisterScreenCaptureCallback(screenCaptureCallback)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private fun sendEvent() {
|
|
37
|
+
reactApplicationContext
|
|
38
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
39
|
+
.emit(EVENT_NAME, null)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ReactMethod
|
|
43
|
+
override fun addListener(eventName: String?) {
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@ReactMethod
|
|
47
|
+
override fun removeListeners(count: Double) {
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
companion object {
|
|
51
|
+
const val NAME = "ScreenshotAware"
|
|
52
|
+
const val EVENT_NAME: String = "ScreenshotEvent"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package com.screenshotaware
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.TurboReactPackage
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class ScreenshotAwarePackage : TurboReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == ScreenshotAwareModule.NAME) {
|
|
13
|
+
ScreenshotAwareModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[ScreenshotAwareModule.NAME] = ReactModuleInfo(
|
|
23
|
+
ScreenshotAwareModule.NAME,
|
|
24
|
+
ScreenshotAwareModule.NAME,
|
|
25
|
+
false, // canOverrideExistingModule
|
|
26
|
+
false, // needsEagerInit
|
|
27
|
+
true, // hasConstants
|
|
28
|
+
false, // isCxxModule
|
|
29
|
+
true // isTurboModule
|
|
30
|
+
)
|
|
31
|
+
moduleInfos
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package com.screenshotaware
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
|
|
6
|
+
abstract class ScreenshotAwareSpec internal constructor(context: ReactApplicationContext) :
|
|
7
|
+
ReactContextBaseJavaModule(context) {
|
|
8
|
+
|
|
9
|
+
abstract fun addListener(eventName: String?)
|
|
10
|
+
abstract fun removeListeners(count: Double)
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#import <React/RCTEventEmitter.h>
|
|
2
|
+
|
|
3
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
+
#import "RNScreenshotAwareSpec.h"
|
|
5
|
+
|
|
6
|
+
@interface ScreenshotAware : RCTEventEmitter <RCTBridgeModule>
|
|
7
|
+
#else
|
|
8
|
+
#import <React/RCTBridgeModule.h>
|
|
9
|
+
|
|
10
|
+
@interface ScreenshotAware : RCTEventEmitter <RCTBridgeModule>
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
@end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#import "ScreenshotAware.h"
|
|
2
|
+
#import "ScreenshotAwareImpl.h"
|
|
3
|
+
|
|
4
|
+
@interface ScreenshotAware () <ScreenshotAwareImplDelegate>
|
|
5
|
+
@end
|
|
6
|
+
|
|
7
|
+
@implementation ScreenshotAware {
|
|
8
|
+
ScreenshotAwareImpl *moduleImpl;
|
|
9
|
+
BOOL hasListeners;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_MODULE()
|
|
13
|
+
|
|
14
|
+
- (instancetype)init {
|
|
15
|
+
self = [super init];
|
|
16
|
+
if (self) {
|
|
17
|
+
moduleImpl = [ScreenshotAwareImpl new];
|
|
18
|
+
moduleImpl.delegate = self;
|
|
19
|
+
}
|
|
20
|
+
return self;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
- (void)handleEventWithName:(NSString * _Nonnull)name {
|
|
24
|
+
if (hasListeners) {
|
|
25
|
+
[self sendEventWithName:name body:nil];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
30
|
+
return [ScreenshotAwareImpl supportedEvents];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (void)startObserving
|
|
34
|
+
{
|
|
35
|
+
hasListeners = YES;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
-(void)stopObserving
|
|
39
|
+
{
|
|
40
|
+
hasListeners = NO;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Don't compile this code when we build for the old architecture.
|
|
44
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
45
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
46
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
47
|
+
{
|
|
48
|
+
return std::make_shared<facebook::react::NativeScreenshotAwareSpecJSI>(params);
|
|
49
|
+
}
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
@end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@protocol ScreenshotAwareImplDelegate
|
|
2
|
+
|
|
3
|
+
- (void)handleEventWithName:(NSString *_Nonnull)name;
|
|
4
|
+
|
|
5
|
+
@end
|
|
6
|
+
|
|
7
|
+
@interface ScreenshotAwareImpl : NSObject
|
|
8
|
+
|
|
9
|
+
+ (NSArray<NSString *> *_Nonnull)supportedEvents;
|
|
10
|
+
|
|
11
|
+
@property(nonatomic, weak) id<ScreenshotAwareImplDelegate> _Nullable delegate;
|
|
12
|
+
|
|
13
|
+
@end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#import "ScreenshotAwareImpl.h"
|
|
2
|
+
#import <React/RCTUtils.h>
|
|
3
|
+
|
|
4
|
+
static NSString *const kRNScreenshotEventName = @"ScreenshotEvent";
|
|
5
|
+
|
|
6
|
+
@implementation ScreenshotAwareImpl
|
|
7
|
+
|
|
8
|
+
+ (NSArray<NSString *> *)supportedEvents
|
|
9
|
+
{
|
|
10
|
+
return @[kRNScreenshotEventName];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
- (instancetype)init
|
|
14
|
+
{
|
|
15
|
+
self = [super init];
|
|
16
|
+
if (self) {
|
|
17
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
18
|
+
selector:@selector(screenshotDetected:)
|
|
19
|
+
name:UIApplicationUserDidTakeScreenshotNotification
|
|
20
|
+
object:nil];
|
|
21
|
+
}
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (void)dealloc
|
|
26
|
+
{
|
|
27
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
- (void)screenshotDetected:(NSNotification *)notification
|
|
31
|
+
{
|
|
32
|
+
[self.delegate handleEventWithName:kRNScreenshotEventName];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ComponentDescriptors.h"
|
|
12
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
13
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
void RNScreenshotAwareSpec_registerComponentDescriptorsFromCodegen(
|
|
18
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "ShadowNodes.h"
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
void RNScreenshotAwareSpec_registerComponentDescriptorsFromCodegen(
|
|
22
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
23
|
+
|
|
24
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "EventEmitters.h"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "Props.h"
|
|
12
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
13
|
+
#include <react/renderer/core/propsConversions.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateComponentHObjCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#import <Foundation/Foundation.h>
|
|
11
|
+
#import <React/RCTDefines.h>
|
|
12
|
+
#import <React/RCTLog.h>
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
NS_ASSUME_NONNULL_END
|