@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,160 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
/// Mirrors `IOverlayMotion` from `src/animation/types.ts`.
|
|
4
|
+
enum NativeOverlayMotion {
|
|
5
|
+
case spring(mass: CGFloat, stiffness: CGFloat, damping: CGFloat)
|
|
6
|
+
case timing(duration: TimeInterval, controlPoint1: CGPoint, controlPoint2: CGPoint)
|
|
7
|
+
|
|
8
|
+
/// Tamagui `quick` on native.
|
|
9
|
+
static let quick = NativeOverlayMotion.spring(mass: 0.1, stiffness: 100, damping: 20)
|
|
10
|
+
|
|
11
|
+
init(json: Any?) {
|
|
12
|
+
guard let dict = json as? [String: Any], let type = dict["type"] as? String else {
|
|
13
|
+
self = .quick
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
if type == "timing",
|
|
17
|
+
let timing = dict["timing"] as? [String: Any],
|
|
18
|
+
let durationMs = (timing["durationMs"] as? NSNumber)?.doubleValue {
|
|
19
|
+
let easing = (timing["easing"] as? [NSNumber])?.map { CGFloat($0.doubleValue) } ?? []
|
|
20
|
+
let points = easing.count == 4 ? easing : [0.25, 0.1, 0.25, 1]
|
|
21
|
+
self = .timing(
|
|
22
|
+
duration: durationMs / 1000,
|
|
23
|
+
controlPoint1: CGPoint(x: points[0], y: points[1]),
|
|
24
|
+
controlPoint2: CGPoint(x: points[2], y: points[3])
|
|
25
|
+
)
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
if type == "spring", let spring = dict["spring"] as? [String: Any] {
|
|
29
|
+
self = .spring(
|
|
30
|
+
mass: CGFloat((spring["mass"] as? NSNumber)?.doubleValue ?? 1),
|
|
31
|
+
stiffness: CGFloat((spring["stiffness"] as? NSNumber)?.doubleValue ?? 100),
|
|
32
|
+
damping: CGFloat((spring["damping"] as? NSNumber)?.doubleValue ?? 20)
|
|
33
|
+
)
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
self = .quick
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
func makeAnimator() -> UIViewPropertyAnimator {
|
|
40
|
+
switch self {
|
|
41
|
+
case let .spring(mass, stiffness, damping):
|
|
42
|
+
// (mass:stiffness:damping:) maps 1:1 to Reanimated and, unlike the
|
|
43
|
+
// dampingRatio initializer, accepts ratios above 1 (`quick` is ~3.16).
|
|
44
|
+
let parameters = UISpringTimingParameters(
|
|
45
|
+
mass: mass,
|
|
46
|
+
stiffness: stiffness,
|
|
47
|
+
damping: damping,
|
|
48
|
+
initialVelocity: .zero
|
|
49
|
+
)
|
|
50
|
+
return UIViewPropertyAnimator(duration: 0, timingParameters: parameters)
|
|
51
|
+
case let .timing(duration, controlPoint1, controlPoint2):
|
|
52
|
+
let parameters = UICubicTimingParameters(
|
|
53
|
+
controlPoint1: controlPoint1,
|
|
54
|
+
controlPoint2: controlPoint2
|
|
55
|
+
)
|
|
56
|
+
return UIViewPropertyAnimator(duration: duration, timingParameters: parameters)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Mirrors `IResolvedOverlayTransition`.
|
|
62
|
+
struct NativeOverlayTransition {
|
|
63
|
+
enum Kind: String {
|
|
64
|
+
case none
|
|
65
|
+
case fade
|
|
66
|
+
case slide
|
|
67
|
+
case scale
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
enum Edge: String {
|
|
71
|
+
case top
|
|
72
|
+
case bottom
|
|
73
|
+
case left
|
|
74
|
+
case right
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var kind: Kind = .fade
|
|
78
|
+
var edge: Edge = .bottom
|
|
79
|
+
var distance: CGFloat?
|
|
80
|
+
var scale: CGFloat = 0.95
|
|
81
|
+
var offsetY: CGFloat = 0
|
|
82
|
+
var fade = true
|
|
83
|
+
var motion: NativeOverlayMotion = .quick
|
|
84
|
+
|
|
85
|
+
init() {}
|
|
86
|
+
|
|
87
|
+
init(json: Any?) {
|
|
88
|
+
guard let dict = json as? [String: Any] else { return }
|
|
89
|
+
kind = Kind(rawValue: dict["type"] as? String ?? "") ?? .fade
|
|
90
|
+
edge = Edge(rawValue: dict["edge"] as? String ?? "") ?? .bottom
|
|
91
|
+
distance = (dict["distance"] as? NSNumber).map { CGFloat($0.doubleValue) }
|
|
92
|
+
scale = CGFloat((dict["scale"] as? NSNumber)?.doubleValue ?? 0.95)
|
|
93
|
+
offsetY = CGFloat((dict["offsetY"] as? NSNumber)?.doubleValue ?? 0)
|
|
94
|
+
fade = (dict["fade"] as? NSNumber)?.boolValue ?? (kind == .fade || kind == .scale)
|
|
95
|
+
motion = NativeOverlayMotion(json: dict["motion"])
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/// Reduce Motion keeps the timing but drops movement.
|
|
99
|
+
var accessibilityAdjusted: NativeOverlayTransition {
|
|
100
|
+
guard UIAccessibility.isReduceMotionEnabled, kind != .none else { return self }
|
|
101
|
+
var copy = self
|
|
102
|
+
copy.kind = .fade
|
|
103
|
+
copy.fade = true
|
|
104
|
+
return copy
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var hidesOpacity: Bool { kind == .fade || fade }
|
|
108
|
+
|
|
109
|
+
/// The off-stage transform: where enter starts and exit ends.
|
|
110
|
+
func hiddenTransform(contentExtent: CGRect, bounds: CGRect) -> CGAffineTransform {
|
|
111
|
+
switch kind {
|
|
112
|
+
case .none, .fade:
|
|
113
|
+
return .identity
|
|
114
|
+
case .slide:
|
|
115
|
+
let travel: CGFloat
|
|
116
|
+
if let distance {
|
|
117
|
+
travel = distance
|
|
118
|
+
} else {
|
|
119
|
+
switch edge {
|
|
120
|
+
case .top: travel = contentExtent.maxY
|
|
121
|
+
case .bottom: travel = bounds.height - contentExtent.minY
|
|
122
|
+
case .left: travel = contentExtent.maxX
|
|
123
|
+
case .right: travel = bounds.width - contentExtent.minX
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
switch edge {
|
|
127
|
+
case .top: return CGAffineTransform(translationX: 0, y: -travel)
|
|
128
|
+
case .bottom: return CGAffineTransform(translationX: 0, y: travel)
|
|
129
|
+
case .left: return CGAffineTransform(translationX: -travel, y: 0)
|
|
130
|
+
case .right: return CGAffineTransform(translationX: travel, y: 0)
|
|
131
|
+
}
|
|
132
|
+
case .scale:
|
|
133
|
+
// Scale around the content's center, not the full-window wrapper's.
|
|
134
|
+
let dx = contentExtent.midX - bounds.midX
|
|
135
|
+
let dy = contentExtent.midY - bounds.midY
|
|
136
|
+
return CGAffineTransform(translationX: dx, y: dy + offsetY)
|
|
137
|
+
.scaledBy(x: scale, y: scale)
|
|
138
|
+
.translatedBy(x: -dx, y: -dy)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// Mirrors `IResolvedOverlayAnimation`.
|
|
144
|
+
struct NativeOverlayAnimationConfig {
|
|
145
|
+
var enter = NativeOverlayTransition()
|
|
146
|
+
var exit = NativeOverlayTransition()
|
|
147
|
+
var backdropMotion: NativeOverlayMotion = .quick
|
|
148
|
+
|
|
149
|
+
init() {}
|
|
150
|
+
|
|
151
|
+
init(jsonString: String) {
|
|
152
|
+
guard !jsonString.isEmpty,
|
|
153
|
+
let data = jsonString.data(using: .utf8),
|
|
154
|
+
let object = try? JSONSerialization.jsonObject(with: data),
|
|
155
|
+
let dict = object as? [String: Any] else { return }
|
|
156
|
+
enter = NativeOverlayTransition(json: dict["enter"])
|
|
157
|
+
exit = dict["exit"] == nil ? enter : NativeOverlayTransition(json: dict["exit"])
|
|
158
|
+
backdropMotion = NativeOverlayMotion(json: (dict["backdrop"] as? [String: Any])?["motion"])
|
|
159
|
+
}
|
|
160
|
+
}
|