@onekeyfe/react-native-native-overlay 6.8.0-4 → 6.8.0-5
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/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayHost.kt +37 -5
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayPackage.kt +1 -1
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToastCardView.kt +871 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToastSpec.kt +327 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToasterView.kt +574 -0
- package/android/src/main/java/com/onekey/nativeoverlay/NativeOverlayToasterViewManager.kt +54 -0
- package/android/src/test/java/com/onekey/nativeoverlay/NativeOverlayAccessibilityIsolationTest.kt +172 -0
- package/docs/SPEC.md +120 -9
- package/ios/NativeOverlayToastCardView.swift +572 -0
- package/ios/NativeOverlayToastSpec.swift +356 -0
- package/ios/NativeOverlayToasterView.swift +519 -0
- package/ios/RCTNativeOverlayToasterComponentView.h +11 -0
- package/ios/RCTNativeOverlayToasterComponentView.mm +85 -0
- package/lib/module/NativeOverlayToasterNativeComponent.ts +24 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/toast/OverlayToastHost.js +42 -0
- package/lib/module/toast/OverlayToastHost.js.map +1 -0
- package/lib/module/toast/OverlayToastHost.web.js +32 -0
- package/lib/module/toast/OverlayToastHost.web.js.map +1 -0
- package/lib/module/toast/OverlayToastStore.js +217 -0
- package/lib/module/toast/OverlayToastStore.js.map +1 -0
- package/lib/module/toast/toastBridge.js +65 -0
- package/lib/module/toast/toastBridge.js.map +1 -0
- package/lib/module/toast/toastDomContent.web.js +298 -0
- package/lib/module/toast/toastDomContent.web.js.map +1 -0
- package/lib/module/toast/toastDomRenderer.web.js +629 -0
- package/lib/module/toast/toastDomRenderer.web.js.map +1 -0
- package/lib/module/toast/toastStyles.web.js +97 -0
- package/lib/module/toast/toastStyles.web.js.map +1 -0
- package/lib/module/toast/types.js +2 -0
- package/lib/module/toast/types.js.map +1 -0
- package/lib/module/web/overlayLayers.js +5 -0
- package/lib/module/web/overlayLayers.js.map +1 -1
- package/lib/typescript/src/NativeOverlayToasterNativeComponent.d.ts +19 -0
- package/lib/typescript/src/NativeOverlayToasterNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/toast/OverlayToastHost.d.ts +6 -0
- package/lib/typescript/src/toast/OverlayToastHost.d.ts.map +1 -0
- package/lib/typescript/src/toast/OverlayToastHost.web.d.ts +6 -0
- package/lib/typescript/src/toast/OverlayToastHost.web.d.ts.map +1 -0
- package/lib/typescript/src/toast/OverlayToastStore.d.ts +47 -0
- package/lib/typescript/src/toast/OverlayToastStore.d.ts.map +1 -0
- package/lib/typescript/src/toast/toastBridge.d.ts +11 -0
- package/lib/typescript/src/toast/toastBridge.d.ts.map +1 -0
- package/lib/typescript/src/toast/toastDomContent.web.d.ts +15 -0
- package/lib/typescript/src/toast/toastDomContent.web.d.ts.map +1 -0
- package/lib/typescript/src/toast/toastDomRenderer.web.d.ts +8 -0
- package/lib/typescript/src/toast/toastDomRenderer.web.d.ts.map +1 -0
- package/lib/typescript/src/toast/toastStyles.web.d.ts +2 -0
- package/lib/typescript/src/toast/toastStyles.web.d.ts.map +1 -0
- package/lib/typescript/src/toast/types.d.ts +240 -0
- package/lib/typescript/src/toast/types.d.ts.map +1 -0
- package/lib/typescript/src/web/overlayLayers.d.ts.map +1 -1
- package/package.json +3 -2
- package/react-native.config.js +1 -0
- package/src/NativeOverlayToasterNativeComponent.ts +24 -0
- package/src/index.ts +23 -0
- package/src/toast/OverlayToastHost.tsx +62 -0
- package/src/toast/OverlayToastHost.web.tsx +29 -0
- package/src/toast/OverlayToastStore.ts +254 -0
- package/src/toast/toastBridge.ts +62 -0
- package/src/toast/toastDomContent.web.ts +351 -0
- package/src/toast/toastDomRenderer.web.ts +748 -0
- package/src/toast/toastStyles.web.ts +97 -0
- package/src/toast/types.ts +251 -0
- package/src/web/overlayLayers.ts +7 -0
|
@@ -2,6 +2,7 @@ package com.onekey.nativeoverlay
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.view.KeyEvent
|
|
5
|
+
import android.view.View
|
|
5
6
|
import android.view.ViewGroup
|
|
6
7
|
import android.view.Window
|
|
7
8
|
import android.widget.FrameLayout
|
|
@@ -103,6 +104,32 @@ internal class NativeOverlayHost private constructor(
|
|
|
103
104
|
onEntriesChanged()
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Adds the message-toast layer under every entry of the `toast` level: the
|
|
109
|
+
* cards are plain views, drawn by the platform rather than hosted React
|
|
110
|
+
* content, and custom toast entries stay above them.
|
|
111
|
+
*/
|
|
112
|
+
fun attachToastLayer(layer: View) {
|
|
113
|
+
val content = activity.findViewById<ViewGroup>(android.R.id.content) ?: return
|
|
114
|
+
if (parent !== content) {
|
|
115
|
+
(parent as? ViewGroup)?.removeView(this)
|
|
116
|
+
content.addView(this, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
117
|
+
} else if (content.getChildAt(content.childCount - 1) !== this) {
|
|
118
|
+
bringToFront()
|
|
119
|
+
}
|
|
120
|
+
val container = levelContainer(NativeOverlayLevel.TOAST)
|
|
121
|
+
if (layer.parent !== container) {
|
|
122
|
+
(layer.parent as? ViewGroup)?.removeView(layer)
|
|
123
|
+
container.addView(layer, 0, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
124
|
+
}
|
|
125
|
+
updateAccessibility()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
fun detachToastLayer(layer: View) {
|
|
129
|
+
(layer.parent as? ViewGroup)?.removeView(layer)
|
|
130
|
+
updateAccessibility()
|
|
131
|
+
}
|
|
132
|
+
|
|
106
133
|
fun detach(entry: NativeOverlayEntryRootView) {
|
|
107
134
|
(entry.parent as? ViewGroup)?.removeView(entry)
|
|
108
135
|
onEntriesChanged()
|
|
@@ -128,11 +155,14 @@ internal class NativeOverlayHost private constructor(
|
|
|
128
155
|
container
|
|
129
156
|
}
|
|
130
157
|
|
|
131
|
-
private fun
|
|
158
|
+
private fun orderedViews(): List<View> =
|
|
132
159
|
levelContainers.values.flatMap { container ->
|
|
133
|
-
(0 until container.childCount).
|
|
160
|
+
(0 until container.childCount).map { container.getChildAt(it) }
|
|
134
161
|
}
|
|
135
162
|
|
|
163
|
+
private fun orderedEntries(): List<NativeOverlayEntryRootView> =
|
|
164
|
+
orderedViews().filterIsInstance<NativeOverlayEntryRootView>()
|
|
165
|
+
|
|
136
166
|
/** Global overlays win; otherwise the topmost visible page overlay. */
|
|
137
167
|
private fun topBackEntry(): NativeOverlayEntryRootView? =
|
|
138
168
|
orderedEntries().lastOrNull {
|
|
@@ -149,11 +179,13 @@ internal class NativeOverlayHost private constructor(
|
|
|
149
179
|
|
|
150
180
|
/** TalkBack only reads the topmost blocking overlay and what is above it. */
|
|
151
181
|
private fun updateAccessibility() {
|
|
152
|
-
val
|
|
153
|
-
val topIndex =
|
|
182
|
+
val views = orderedViews()
|
|
183
|
+
val topIndex = views.indexOfLast {
|
|
184
|
+
it is NativeOverlayEntryRootView && it.blocking && it.isShownForInput
|
|
185
|
+
}
|
|
154
186
|
val content = activity.findViewById<ViewGroup>(android.R.id.content) ?: return
|
|
155
187
|
if (topIndex >= 0) {
|
|
156
|
-
accessibilityIsolation.update(content, this,
|
|
188
|
+
accessibilityIsolation.update(content, this, views.take(topIndex), this)
|
|
157
189
|
return
|
|
158
190
|
}
|
|
159
191
|
val pageEntry = shownPageHosts().flatMap { it.shownEntries() }.lastOrNull { it.blocking }
|
|
@@ -8,7 +8,7 @@ import com.facebook.react.uimanager.ViewManager
|
|
|
8
8
|
class NativeOverlayPackage : ReactPackage {
|
|
9
9
|
override fun createViewManagers(
|
|
10
10
|
reactContext: ReactApplicationContext,
|
|
11
|
-
): List<ViewManager<*, *>> = listOf(NativeOverlayViewManager(), NativeOverlayPageHostViewManager())
|
|
11
|
+
): List<ViewManager<*, *>> = listOf(NativeOverlayViewManager(), NativeOverlayPageHostViewManager(), NativeOverlayToasterViewManager())
|
|
12
12
|
|
|
13
13
|
override fun createNativeModules(
|
|
14
14
|
reactContext: ReactApplicationContext,
|