@onekeyfe/react-native-native-overlay 3.0.162-alpha.268
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/NativeOverlay.podspec +30 -0
- package/README.md +35 -0
- package/android/build.gradle +82 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayAnimation.kt +176 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayEntryRootView.kt +415 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayEvents.kt +38 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayHost.kt +174 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayPackage.kt +16 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayPageHostView.kt +122 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayPageHostViewManager.kt +40 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayView.kt +465 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayViewManager.kt +156 -0
- package/android/src/main/jni/CMakeLists.txt +44 -0
- package/android/src/main/jni/RNCNativeOverlay.h +19 -0
- package/common/cpp/react/renderer/components/RNCNativeOverlay/NativeOverlayComponentDescriptor.h +12 -0
- package/common/cpp/react/renderer/components/RNCNativeOverlay/NativeOverlayShadowNode.cpp +12 -0
- package/common/cpp/react/renderer/components/RNCNativeOverlay/NativeOverlayShadowNode.h +41 -0
- package/common/cpp/react/renderer/components/RNCNativeOverlay/NativeOverlayState.h +40 -0
- package/docs/SPEC.md +693 -0
- package/ios/NativeOverlayAnimation.swift +160 -0
- package/ios/NativeOverlayContainerView.swift +688 -0
- package/ios/NativeOverlayKeyboard.swift +88 -0
- package/ios/NativeOverlayPageHostView.swift +98 -0
- package/ios/NativeOverlaySheetController.swift +391 -0
- package/ios/NativeOverlayWindowManager.swift +194 -0
- package/ios/RCTNativeOverlayComponentView.h +11 -0
- package/ios/RCTNativeOverlayComponentView.mm +193 -0
- package/ios/RCTNativeOverlayPageHostComponentView.h +11 -0
- package/ios/RCTNativeOverlayPageHostComponentView.mm +64 -0
- package/lib/module/NativeOverlayNativeComponent.ts +61 -0
- package/lib/module/NativeOverlayPageHostNativeComponent.ts +13 -0
- package/lib/module/OverlayErrors.js +6 -0
- package/lib/module/OverlayErrors.js.map +1 -0
- package/lib/module/OverlayLevelContext.js +27 -0
- package/lib/module/OverlayLevelContext.js.map +1 -0
- package/lib/module/OverlayLevels.js +33 -0
- package/lib/module/OverlayLevels.js.map +1 -0
- package/lib/module/OverlayPageHost.js +24 -0
- package/lib/module/OverlayPageHost.js.map +1 -0
- package/lib/module/OverlayPageHost.web.js +49 -0
- package/lib/module/OverlayPageHost.web.js.map +1 -0
- package/lib/module/OverlayPageScope.js +41 -0
- package/lib/module/OverlayPageScope.js.map +1 -0
- package/lib/module/OverlayStore.js +305 -0
- package/lib/module/OverlayStore.js.map +1 -0
- package/lib/module/OverlayView.js +141 -0
- package/lib/module/OverlayView.js.map +1 -0
- package/lib/module/OverlayView.web.js +290 -0
- package/lib/module/OverlayView.web.js.map +1 -0
- package/lib/module/OverlayViewTypes.js +4 -0
- package/lib/module/OverlayViewTypes.js.map +1 -0
- package/lib/module/animation/motionPresets.js +57 -0
- package/lib/module/animation/motionPresets.js.map +1 -0
- package/lib/module/animation/platformMotionPresets.js +4 -0
- package/lib/module/animation/platformMotionPresets.js.map +1 -0
- package/lib/module/animation/platformMotionPresets.web.js +4 -0
- package/lib/module/animation/platformMotionPresets.web.js.map +1 -0
- package/lib/module/animation/resolveAnimation.js +80 -0
- package/lib/module/animation/resolveAnimation.js.map +1 -0
- package/lib/module/animation/spring.js +69 -0
- package/lib/module/animation/spring.js.map +1 -0
- package/lib/module/animation/types.js +2 -0
- package/lib/module/animation/types.js.map +1 -0
- package/lib/module/index.js +16 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useOverlayController.js +127 -0
- package/lib/module/useOverlayController.js.map +1 -0
- package/lib/module/useSuspendedPageOwners.js +16 -0
- package/lib/module/useSuspendedPageOwners.js.map +1 -0
- package/lib/module/web/animateTransition.js +115 -0
- package/lib/module/web/animateTransition.js.map +1 -0
- package/lib/module/web/overlayLayers.js +147 -0
- package/lib/module/web/overlayLayers.js.map +1 -0
- package/lib/module/web/useKeyboardShift.js +110 -0
- package/lib/module/web/useKeyboardShift.js.map +1 -0
- package/lib/module/web/useSheetDrag.js +126 -0
- package/lib/module/web/useSheetDrag.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeOverlayNativeComponent.d.ts +41 -0
- package/lib/typescript/src/NativeOverlayNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/NativeOverlayPageHostNativeComponent.d.ts +9 -0
- package/lib/typescript/src/NativeOverlayPageHostNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/OverlayErrors.d.ts +4 -0
- package/lib/typescript/src/OverlayErrors.d.ts.map +1 -0
- package/lib/typescript/src/OverlayLevelContext.d.ts +12 -0
- package/lib/typescript/src/OverlayLevelContext.d.ts.map +1 -0
- package/lib/typescript/src/OverlayLevels.d.ts +13 -0
- package/lib/typescript/src/OverlayLevels.d.ts.map +1 -0
- package/lib/typescript/src/OverlayPageHost.d.ts +9 -0
- package/lib/typescript/src/OverlayPageHost.d.ts.map +1 -0
- package/lib/typescript/src/OverlayPageHost.web.d.ts +11 -0
- package/lib/typescript/src/OverlayPageHost.web.d.ts.map +1 -0
- package/lib/typescript/src/OverlayPageScope.d.ts +17 -0
- package/lib/typescript/src/OverlayPageScope.d.ts.map +1 -0
- package/lib/typescript/src/OverlayStore.d.ts +72 -0
- package/lib/typescript/src/OverlayStore.d.ts.map +1 -0
- package/lib/typescript/src/OverlayView.d.ts +3 -0
- package/lib/typescript/src/OverlayView.d.ts.map +1 -0
- package/lib/typescript/src/OverlayView.web.d.ts +3 -0
- package/lib/typescript/src/OverlayView.web.d.ts.map +1 -0
- package/lib/typescript/src/OverlayViewTypes.d.ts +68 -0
- package/lib/typescript/src/OverlayViewTypes.d.ts.map +1 -0
- package/lib/typescript/src/animation/motionPresets.d.ts +13 -0
- package/lib/typescript/src/animation/motionPresets.d.ts.map +1 -0
- package/lib/typescript/src/animation/platformMotionPresets.d.ts +2 -0
- package/lib/typescript/src/animation/platformMotionPresets.d.ts.map +1 -0
- package/lib/typescript/src/animation/platformMotionPresets.web.d.ts +2 -0
- package/lib/typescript/src/animation/platformMotionPresets.web.d.ts.map +1 -0
- package/lib/typescript/src/animation/resolveAnimation.d.ts +23 -0
- package/lib/typescript/src/animation/resolveAnimation.d.ts.map +1 -0
- package/lib/typescript/src/animation/spring.d.ts +24 -0
- package/lib/typescript/src/animation/spring.d.ts.map +1 -0
- package/lib/typescript/src/animation/types.d.ts +56 -0
- package/lib/typescript/src/animation/types.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +59 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/useOverlayController.d.ts +29 -0
- package/lib/typescript/src/useOverlayController.d.ts.map +1 -0
- package/lib/typescript/src/useSuspendedPageOwners.d.ts +7 -0
- package/lib/typescript/src/useSuspendedPageOwners.d.ts.map +1 -0
- package/lib/typescript/src/web/animateTransition.d.ts +18 -0
- package/lib/typescript/src/web/animateTransition.d.ts.map +1 -0
- package/lib/typescript/src/web/overlayLayers.d.ts +10 -0
- package/lib/typescript/src/web/overlayLayers.d.ts.map +1 -0
- package/lib/typescript/src/web/useKeyboardShift.d.ts +29 -0
- package/lib/typescript/src/web/useKeyboardShift.d.ts.map +1 -0
- package/lib/typescript/src/web/useSheetDrag.d.ts +13 -0
- package/lib/typescript/src/web/useSheetDrag.d.ts.map +1 -0
- package/package.json +188 -0
- package/react-native.config.js +16 -0
- package/src/NativeOverlayNativeComponent.ts +61 -0
- package/src/NativeOverlayPageHostNativeComponent.ts +13 -0
- package/src/OverlayErrors.ts +3 -0
- package/src/OverlayLevelContext.tsx +32 -0
- package/src/OverlayLevels.ts +40 -0
- package/src/OverlayPageHost.tsx +21 -0
- package/src/OverlayPageHost.web.tsx +53 -0
- package/src/OverlayPageScope.tsx +42 -0
- package/src/OverlayStore.ts +401 -0
- package/src/OverlayView.tsx +165 -0
- package/src/OverlayView.web.tsx +356 -0
- package/src/OverlayViewTypes.ts +81 -0
- package/src/animation/motionPresets.ts +52 -0
- package/src/animation/platformMotionPresets.ts +1 -0
- package/src/animation/platformMotionPresets.web.ts +1 -0
- package/src/animation/resolveAnimation.ts +103 -0
- package/src/animation/spring.ts +80 -0
- package/src/animation/types.ts +71 -0
- package/src/index.ts +55 -0
- package/src/types.ts +79 -0
- package/src/useOverlayController.ts +199 -0
- package/src/useSuspendedPageOwners.ts +26 -0
- package/src/web/animateTransition.ts +137 -0
- package/src/web/overlayLayers.ts +182 -0
- package/src/web/useKeyboardShift.ts +130 -0
- package/src/web/useSheetDrag.ts +143 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
package com.onekey.nativeoverlay
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
6
|
+
import com.facebook.react.uimanager.StateWrapper
|
|
7
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
9
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
10
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
11
|
+
import com.facebook.react.viewmanagers.RNCNativeOverlayManagerDelegate
|
|
12
|
+
import com.facebook.react.viewmanagers.RNCNativeOverlayManagerInterface
|
|
13
|
+
|
|
14
|
+
@ReactModule(name = NativeOverlayViewManager.NAME)
|
|
15
|
+
class NativeOverlayViewManager :
|
|
16
|
+
ViewGroupManager<NativeOverlayView>(),
|
|
17
|
+
RNCNativeOverlayManagerInterface<NativeOverlayView> {
|
|
18
|
+
private val delegate = RNCNativeOverlayManagerDelegate<NativeOverlayView, NativeOverlayViewManager>(this)
|
|
19
|
+
|
|
20
|
+
override fun getName(): String = NAME
|
|
21
|
+
|
|
22
|
+
override fun getDelegate(): ViewManagerDelegate<NativeOverlayView> = delegate
|
|
23
|
+
|
|
24
|
+
override fun createViewInstance(context: ThemedReactContext): NativeOverlayView {
|
|
25
|
+
val view = NativeOverlayView(context)
|
|
26
|
+
fun dispatch(event: (surfaceId: Int) -> com.facebook.react.uimanager.events.Event<*>) {
|
|
27
|
+
val dispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, view.id)
|
|
28
|
+
dispatcher?.dispatchEvent(event(UIManagerHelper.getSurfaceId(context)))
|
|
29
|
+
}
|
|
30
|
+
view.onPresented = { stackOrder ->
|
|
31
|
+
dispatch { NativeOverlayPresentedEvent(it, view.id, stackOrder) }
|
|
32
|
+
}
|
|
33
|
+
view.onDismissed = { reason ->
|
|
34
|
+
dispatch { NativeOverlayReasonEvent(it, view.id, NativeOverlayReasonEvent.DISMISSED, reason) }
|
|
35
|
+
}
|
|
36
|
+
view.onRequestDismiss = { reason ->
|
|
37
|
+
dispatch { NativeOverlayReasonEvent(it, view.id, NativeOverlayReasonEvent.REQUEST_DISMISS, reason) }
|
|
38
|
+
}
|
|
39
|
+
return view
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override fun addEventEmitters(context: ThemedReactContext, view: NativeOverlayView) {
|
|
43
|
+
view.eventDispatcher = UIManagerHelper.getEventDispatcher(context)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun updateState(
|
|
47
|
+
view: NativeOverlayView,
|
|
48
|
+
props: ReactStylesDiffMap,
|
|
49
|
+
stateWrapper: StateWrapper,
|
|
50
|
+
): Any? {
|
|
51
|
+
view.stateWrapper = stateWrapper
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
override fun onAfterUpdateTransaction(view: NativeOverlayView) {
|
|
56
|
+
super.onAfterUpdateTransaction(view)
|
|
57
|
+
view.commitConfiguration()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
override fun onDropViewInstance(view: NativeOverlayView) {
|
|
61
|
+
view.onDropViewInstance()
|
|
62
|
+
super.onDropViewInstance(view)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override fun addView(parent: NativeOverlayView, child: View, index: Int) {
|
|
66
|
+
parent.addReactChild(child)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override fun getChildCount(parent: NativeOverlayView): Int = parent.getReactChildCount()
|
|
70
|
+
|
|
71
|
+
override fun getChildAt(parent: NativeOverlayView, index: Int): View? = parent.getReactChildAt(index)
|
|
72
|
+
|
|
73
|
+
override fun removeView(parent: NativeOverlayView, view: View) {
|
|
74
|
+
parent.removeReactChild(view)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override fun removeAllViews(parent: NativeOverlayView) {
|
|
78
|
+
parent.getReactChildAt(0)?.let(parent::removeReactChild)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
override fun removeViewAt(parent: NativeOverlayView, index: Int) {
|
|
82
|
+
parent.getReactChildAt(index)?.let(parent::removeReactChild)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
override fun setVisible(view: NativeOverlayView, value: Boolean) {
|
|
86
|
+
view.visible = value
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
override fun setLevel(view: NativeOverlayView, value: String?) {
|
|
90
|
+
view.level = value ?: "modal"
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
override fun setScope(view: NativeOverlayView, value: String?) {
|
|
94
|
+
view.scope = value ?: "global"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
override fun setHostKey(view: NativeOverlayView, value: String?) {
|
|
98
|
+
view.hostKey = value.orEmpty()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
override fun setOwnerKey(view: NativeOverlayView, value: String?) {
|
|
102
|
+
view.ownerKey = value.orEmpty()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
override fun setPresentation(view: NativeOverlayView, value: String?) {
|
|
106
|
+
view.presentation = value ?: "center"
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
override fun setStackOrder(view: NativeOverlayView, value: Int) {
|
|
110
|
+
view.stackOrder = value
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
override fun setBlocking(view: NativeOverlayView, value: Boolean) {
|
|
114
|
+
view.blocking = value
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
override fun setDismissOnBackPress(view: NativeOverlayView, value: Boolean) {
|
|
118
|
+
view.dismissOnBackPress = value
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
override fun setDismissOnBackdropPress(view: NativeOverlayView, value: Boolean) {
|
|
122
|
+
view.dismissOnBackdropPress = value
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
override fun setBackdropColor(view: NativeOverlayView, value: Int?) {
|
|
126
|
+
view.backdropColor = value
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
override fun setSheetHeight(view: NativeOverlayView, value: Double) {
|
|
130
|
+
view.sheetHeight = value
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
override fun setSheetCornerRadius(view: NativeOverlayView, value: Double) {
|
|
134
|
+
view.sheetCornerRadius = value
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
override fun setShowHandle(view: NativeOverlayView, value: Boolean) {
|
|
138
|
+
view.showHandle = value
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
override fun setSheetBackgroundColor(view: NativeOverlayView, value: Int?) {
|
|
142
|
+
view.sheetBackgroundColor = value
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
override fun setDismissOnPanDown(view: NativeOverlayView, value: Boolean) {
|
|
146
|
+
view.dismissOnPanDown = value
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
override fun setAnimationConfig(view: NativeOverlayView, value: String?) {
|
|
150
|
+
view.animationConfig = value
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
companion object {
|
|
154
|
+
const val NAME = "RNCNativeOverlay"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
3
|
+
|
|
4
|
+
# Replaces the codegen library so the hand-written overlay shadow node
|
|
5
|
+
# (common/cpp) is compiled and registered. Mirrors react-native-screens.
|
|
6
|
+
set(LIB_LITERAL RNCNativeOverlay)
|
|
7
|
+
set(LIB_TARGET_NAME react_codegen_${LIB_LITERAL})
|
|
8
|
+
|
|
9
|
+
set(LIB_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
|
10
|
+
set(LIB_COMMON_DIR ${LIB_ANDROID_DIR}/../common/cpp)
|
|
11
|
+
set(LIB_COMMON_COMPONENTS_DIR ${LIB_COMMON_DIR}/react/renderer/components/${LIB_LITERAL})
|
|
12
|
+
set(LIB_ANDROID_GENERATED_JNI_DIR ${LIB_ANDROID_DIR}/build/generated/source/codegen/jni)
|
|
13
|
+
set(LIB_ANDROID_GENERATED_COMPONENTS_DIR ${LIB_ANDROID_GENERATED_JNI_DIR}/react/renderer/components/${LIB_LITERAL})
|
|
14
|
+
|
|
15
|
+
file(GLOB LIB_CUSTOM_SRCS CONFIGURE_DEPENDS ${LIB_COMMON_COMPONENTS_DIR}/*.cpp)
|
|
16
|
+
file(GLOB LIB_CODEGEN_SRCS CONFIGURE_DEPENDS
|
|
17
|
+
${LIB_ANDROID_GENERATED_JNI_DIR}/*.cpp
|
|
18
|
+
${LIB_ANDROID_GENERATED_COMPONENTS_DIR}/*.cpp
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
add_library(
|
|
22
|
+
${LIB_TARGET_NAME}
|
|
23
|
+
OBJECT
|
|
24
|
+
${LIB_CUSTOM_SRCS}
|
|
25
|
+
${LIB_CODEGEN_SRCS}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
target_include_directories(
|
|
29
|
+
${LIB_TARGET_NAME}
|
|
30
|
+
PUBLIC
|
|
31
|
+
.
|
|
32
|
+
${LIB_COMMON_DIR}
|
|
33
|
+
${LIB_ANDROID_GENERATED_JNI_DIR}
|
|
34
|
+
${LIB_ANDROID_GENERATED_COMPONENTS_DIR}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
target_link_libraries(
|
|
38
|
+
${LIB_TARGET_NAME}
|
|
39
|
+
fbjni
|
|
40
|
+
jsi
|
|
41
|
+
reactnative
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
target_compile_reactnative_options(${LIB_TARGET_NAME} PRIVATE)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
4
|
+
#include <ReactCommon/TurboModule.h>
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
|
|
7
|
+
// Shadows the codegen header of the same name so autolinking, which
|
|
8
|
+
// includes it before ComponentDescriptors.h, sees the hand-written
|
|
9
|
+
// RNCNativeOverlayComponentDescriptor.
|
|
10
|
+
#include <react/renderer/components/RNCNativeOverlay/NativeOverlayComponentDescriptor.h>
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
JSI_EXPORT
|
|
15
|
+
std::shared_ptr<TurboModule> RNCNativeOverlay_ModuleProvider(
|
|
16
|
+
const std::string &moduleName,
|
|
17
|
+
const JavaTurboModule::InitParams ¶ms);
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
package/common/cpp/react/renderer/components/RNCNativeOverlay/NativeOverlayComponentDescriptor.h
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
4
|
+
|
|
5
|
+
#include "NativeOverlayShadowNode.h"
|
|
6
|
+
|
|
7
|
+
namespace facebook::react {
|
|
8
|
+
|
|
9
|
+
using RNCNativeOverlayComponentDescriptor =
|
|
10
|
+
ConcreteComponentDescriptor<RNCNativeOverlayShadowNode>;
|
|
11
|
+
|
|
12
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#include "NativeOverlayShadowNode.h"
|
|
2
|
+
|
|
3
|
+
namespace facebook::react {
|
|
4
|
+
|
|
5
|
+
extern const char RNCNativeOverlayComponentName[] = "RNCNativeOverlay";
|
|
6
|
+
|
|
7
|
+
Point RNCNativeOverlayShadowNode::getContentOriginOffset(
|
|
8
|
+
bool /*includeTransform*/) const {
|
|
9
|
+
return getStateData().contentOffset;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <react/renderer/components/RNCNativeOverlay/EventEmitters.h>
|
|
5
|
+
#include <react/renderer/components/RNCNativeOverlay/Props.h>
|
|
6
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
7
|
+
|
|
8
|
+
#include "NativeOverlayState.h"
|
|
9
|
+
|
|
10
|
+
namespace facebook::react {
|
|
11
|
+
|
|
12
|
+
JSI_EXPORT extern const char RNCNativeOverlayComponentName[];
|
|
13
|
+
|
|
14
|
+
class JSI_EXPORT RNCNativeOverlayShadowNode final
|
|
15
|
+
: public ConcreteViewShadowNode<
|
|
16
|
+
RNCNativeOverlayComponentName,
|
|
17
|
+
RNCNativeOverlayProps,
|
|
18
|
+
RNCNativeOverlayEventEmitter,
|
|
19
|
+
NativeOverlayState> {
|
|
20
|
+
public:
|
|
21
|
+
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* Like <Modal>: the content is drawn outside the host's tree position, so
|
|
25
|
+
* measurements stop at this node (a root) and the host is never culled.
|
|
26
|
+
*/
|
|
27
|
+
static ShadowNodeTraits BaseTraits() {
|
|
28
|
+
auto traits = ConcreteViewShadowNode::BaseTraits();
|
|
29
|
+
traits.set(ShadowNodeTraits::Trait::RootNodeKind);
|
|
30
|
+
traits.set(ShadowNodeTraits::Trait::Unstable_uncullableView);
|
|
31
|
+
return traits;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Measurements start at this node's origin, which native reports as the
|
|
36
|
+
* window origin of wherever it presented the content.
|
|
37
|
+
*/
|
|
38
|
+
Point getContentOriginOffset(bool includeTransform) const override;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <react/renderer/graphics/Float.h>
|
|
4
|
+
#include <react/renderer/graphics/Point.h>
|
|
5
|
+
|
|
6
|
+
#ifdef RN_SERIALIZABLE_STATE
|
|
7
|
+
#include <folly/dynamic.h>
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
namespace facebook::react {
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Native moves an overlay's content out of the host view into its level
|
|
14
|
+
* window, sheet, or page host. `contentOffset` is the window origin of the
|
|
15
|
+
* view the content now lives in (0,0 for a full-window level; the sheet top
|
|
16
|
+
* for a sheet), so `measure` / `measureInWindow` report on-screen frames.
|
|
17
|
+
*/
|
|
18
|
+
class NativeOverlayState final {
|
|
19
|
+
public:
|
|
20
|
+
NativeOverlayState() = default;
|
|
21
|
+
explicit NativeOverlayState(Point contentOffset)
|
|
22
|
+
: contentOffset(contentOffset) {}
|
|
23
|
+
|
|
24
|
+
Point contentOffset{};
|
|
25
|
+
|
|
26
|
+
#ifdef RN_SERIALIZABLE_STATE
|
|
27
|
+
NativeOverlayState(
|
|
28
|
+
const NativeOverlayState & /*previousState*/,
|
|
29
|
+
folly::dynamic data)
|
|
30
|
+
: contentOffset(
|
|
31
|
+
{static_cast<Float>(data["x"].getDouble()),
|
|
32
|
+
static_cast<Float>(data["y"].getDouble())}) {}
|
|
33
|
+
|
|
34
|
+
folly::dynamic getDynamic() const {
|
|
35
|
+
return folly::dynamic::object("x", contentOffset.x)("y", contentOffset.y);
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
} // namespace facebook::react
|