react-native-smooth-clip-view 0.2.8 → 0.3.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/README.md +86 -21
- package/android/CMakeLists.txt +7 -0
- package/android/build.gradle +14 -2
- package/android/proguard-rules.pro +3 -3
- package/android/src/main/cpp/SmoothClipAndroid.h +10 -0
- package/android/src/main/cpp/SmoothClipBindings.cpp +896 -6
- package/android/src/main/cpp/SmoothClipRegistry.cpp +1067 -46
- package/android/src/main/cpp/SmoothClipTrace.h +25 -0
- package/android/src/main/java/com/smoothclipview/ClipGeometryNormalizer.kt +265 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipBindings.kt +21 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipModule.kt +283 -0
- package/android/src/main/java/com/smoothclipview/SmoothClipView.kt +385 -24
- package/android/src/main/java/com/smoothclipview/SmoothClipViewManager.kt +138 -24
- package/cpp/SmoothClipAnimationCurve.h +151 -122
- package/cpp/SmoothClipRegistry.h +102 -4
- package/cpp/SmoothClipSharedGeometry.h +146 -7
- package/cpp/SmoothClipVelocityTracker.h +13 -9
- package/ios/SmoothClipGeometry.h +184 -6
- package/ios/SmoothClipRegistry.mm +1033 -25
- package/ios/SmoothClipRegistrySnapshot.h +13 -0
- package/ios/SmoothClipTurboModule.cpp +857 -2
- package/ios/SmoothClipTurboModule.h +310 -0
- package/ios/SmoothClipView.mm +714 -183
- package/ios/SmoothClipViewRegistry.h +1 -0
- package/ios/reactnativesmoothclipview.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/reactnativesmoothclipview.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/lib/module/NativeSmoothClipModule.js.map +1 -1
- package/lib/module/SmoothClipView.ios.js +22 -6
- package/lib/module/SmoothClipView.ios.js.map +1 -1
- package/lib/module/SmoothClipView.js +1 -46
- package/lib/module/SmoothClipView.js.map +1 -1
- package/lib/module/SmoothClipViewNativeComponent.ts +27 -1
- package/lib/module/capabilities.js +4 -0
- package/lib/module/capabilities.js.map +1 -0
- package/lib/module/capabilities.native.js +36 -0
- package/lib/module/capabilities.native.js.map +1 -0
- package/lib/module/capabilityTypes.js +11 -0
- package/lib/module/capabilityTypes.js.map +1 -0
- package/lib/module/driverState.js +0 -28
- package/lib/module/driverState.js.map +1 -1
- package/lib/module/drivers.js +1 -281
- package/lib/module/drivers.js.map +1 -1
- package/lib/module/drivers.native.js +340 -75
- package/lib/module/drivers.native.js.map +1 -1
- package/lib/module/geometry.js +147 -17
- package/lib/module/geometry.js.map +1 -1
- package/lib/module/groupDriverTypes.js +4 -0
- package/lib/module/groupDriverTypes.js.map +1 -0
- package/lib/module/groupDrivers.android.js +4 -0
- package/lib/module/groupDrivers.android.js.map +1 -0
- package/lib/module/groupDrivers.ios.js +4 -0
- package/lib/module/groupDrivers.ios.js.map +1 -0
- package/lib/module/groupDrivers.js +4 -0
- package/lib/module/groupDrivers.js.map +1 -0
- package/lib/module/groupDrivers.native.js +799 -0
- package/lib/module/groupDrivers.native.js.map +1 -0
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/presentationProtocol.js +15 -0
- package/lib/module/presentationProtocol.js.map +1 -0
- package/lib/typescript/src/NativeSmoothClipModule.d.ts +25 -0
- package/lib/typescript/src/NativeSmoothClipModule.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipView.d.ts +2 -10
- package/lib/typescript/src/SmoothClipView.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipView.ios.d.ts +133 -2
- package/lib/typescript/src/SmoothClipView.ios.d.ts.map +1 -1
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts +8 -0
- package/lib/typescript/src/SmoothClipViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/capabilities.d.ts +3 -0
- package/lib/typescript/src/capabilities.d.ts.map +1 -0
- package/lib/typescript/src/capabilities.native.d.ts +3 -0
- package/lib/typescript/src/capabilities.native.d.ts.map +1 -0
- package/lib/typescript/src/capabilityTypes.d.ts +10 -0
- package/lib/typescript/src/capabilityTypes.d.ts.map +1 -0
- package/lib/typescript/src/driverState.d.ts +1 -6
- package/lib/typescript/src/driverState.d.ts.map +1 -1
- package/lib/typescript/src/driverTypes.d.ts +39 -11
- package/lib/typescript/src/driverTypes.d.ts.map +1 -1
- package/lib/typescript/src/drivers.d.ts +2 -4
- package/lib/typescript/src/drivers.d.ts.map +1 -1
- package/lib/typescript/src/drivers.native.d.ts.map +1 -1
- package/lib/typescript/src/geometry.d.ts +36 -2
- package/lib/typescript/src/geometry.d.ts.map +1 -1
- package/lib/typescript/src/groupDriverTypes.d.ts +66 -0
- package/lib/typescript/src/groupDriverTypes.d.ts.map +1 -0
- package/lib/typescript/src/groupDrivers.android.d.ts +2 -0
- package/lib/typescript/src/groupDrivers.android.d.ts.map +1 -0
- package/lib/typescript/src/groupDrivers.d.ts +2 -0
- package/lib/typescript/src/groupDrivers.d.ts.map +1 -0
- package/lib/typescript/src/groupDrivers.ios.d.ts +2 -0
- package/lib/typescript/src/groupDrivers.ios.d.ts.map +1 -0
- package/lib/typescript/src/groupDrivers.native.d.ts +4 -0
- package/lib/typescript/src/groupDrivers.native.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/presentationProtocol.d.ts +4 -0
- package/lib/typescript/src/presentationProtocol.d.ts.map +1 -0
- package/package.json +10 -11
- package/src/NativeSmoothClipModule.ts +275 -0
- package/src/SmoothClipView.ios.tsx +30 -11
- package/src/SmoothClipView.tsx +2 -76
- package/src/SmoothClipViewNativeComponent.ts +27 -1
- package/src/capabilities.native.ts +69 -0
- package/src/capabilities.ts +2 -0
- package/src/capabilityTypes.ts +17 -0
- package/src/driverState.ts +1 -41
- package/src/driverTypes.ts +56 -11
- package/src/drivers.native.ts +921 -151
- package/src/drivers.ts +2 -423
- package/src/geometry.ts +231 -27
- package/src/groupDriverTypes.ts +117 -0
- package/src/groupDrivers.android.ts +1 -0
- package/src/groupDrivers.ios.ts +1 -0
- package/src/groupDrivers.native.ts +1189 -0
- package/src/groupDrivers.ts +1 -0
- package/src/index.ts +30 -2
- package/src/presentationProtocol.ts +28 -0
- package/lib/module/SmoothClipView.web.js +0 -54
- package/lib/module/SmoothClipView.web.js.map +0 -1
- package/lib/module/index.web.js +0 -8
- package/lib/module/index.web.js.map +0 -1
- package/lib/module/webClipPath.js +0 -25
- package/lib/module/webClipPath.js.map +0 -1
- package/lib/typescript/src/SmoothClipView.web.d.ts +0 -10
- package/lib/typescript/src/SmoothClipView.web.d.ts.map +0 -1
- package/lib/typescript/src/index.web.d.ts +0 -9
- package/lib/typescript/src/index.web.d.ts.map +0 -1
- package/lib/typescript/src/webClipPath.d.ts +0 -7
- package/lib/typescript/src/webClipPath.d.ts.map +0 -1
- package/src/SmoothClipView.web.tsx +0 -66
- package/src/index.web.ts +0 -23
- package/src/webClipPath.ts +0 -30
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#if defined(SMOOTH_CLIP_ENABLE_ATRACE)
|
|
4
|
+
|
|
5
|
+
#include <android/trace.h>
|
|
6
|
+
|
|
7
|
+
namespace smoothclip::trace {
|
|
8
|
+
|
|
9
|
+
class ScopedSection {
|
|
10
|
+
public:
|
|
11
|
+
explicit ScopedSection(const char *name) { ATrace_beginSection(name); }
|
|
12
|
+
|
|
13
|
+
~ScopedSection() { ATrace_endSection(); }
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
} // namespace smoothclip::trace
|
|
17
|
+
|
|
18
|
+
#define SMOOTH_CLIP_TRACE(name) \
|
|
19
|
+
::smoothclip::trace::ScopedSection smoothClipTraceSection{name}
|
|
20
|
+
|
|
21
|
+
#else
|
|
22
|
+
|
|
23
|
+
#define SMOOTH_CLIP_TRACE(name)
|
|
24
|
+
|
|
25
|
+
#endif
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
package com.smoothclipview
|
|
2
2
|
|
|
3
|
+
import android.graphics.Path
|
|
3
4
|
import android.view.View
|
|
4
5
|
import kotlin.math.max
|
|
5
6
|
import kotlin.math.min
|
|
6
7
|
import kotlin.math.roundToInt
|
|
7
8
|
|
|
9
|
+
internal const val CLIP_CURVE_CIRCULAR = 0
|
|
10
|
+
internal const val CLIP_CURVE_CONTINUOUS = 1
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* Normalizes clip geometry without allocating a result object. The callback is
|
|
10
14
|
* inlined into the view's command path so per-frame updates stay allocation-free.
|
|
@@ -51,6 +55,267 @@ internal inline fun normalizeClipGeometryPx(
|
|
|
51
55
|
return true
|
|
52
56
|
}
|
|
53
57
|
|
|
58
|
+
/**
|
|
59
|
+
* V2 normalization with independent radii. Radii use the CSS overlap rule:
|
|
60
|
+
* one shared factor keeps all four corners proportional when any opposing pair
|
|
61
|
+
* exceeds the visible width or height. This mirrors SmoothClipNormalizeV2 in
|
|
62
|
+
* the shared C++ delivery path.
|
|
63
|
+
*/
|
|
64
|
+
internal inline fun normalizeClipGeometryV2Px(
|
|
65
|
+
x: Float,
|
|
66
|
+
y: Float,
|
|
67
|
+
width: Float,
|
|
68
|
+
height: Float,
|
|
69
|
+
topLeftRadius: Float,
|
|
70
|
+
topRightRadius: Float,
|
|
71
|
+
bottomRightRadius: Float,
|
|
72
|
+
bottomLeftRadius: Float,
|
|
73
|
+
curveCode: Int,
|
|
74
|
+
hostWidth: Float,
|
|
75
|
+
hostHeight: Float,
|
|
76
|
+
apply: (
|
|
77
|
+
left: Float,
|
|
78
|
+
top: Float,
|
|
79
|
+
right: Float,
|
|
80
|
+
bottom: Float,
|
|
81
|
+
normalizedTopLeftRadius: Float,
|
|
82
|
+
normalizedTopRightRadius: Float,
|
|
83
|
+
normalizedBottomRightRadius: Float,
|
|
84
|
+
normalizedBottomLeftRadius: Float,
|
|
85
|
+
normalizedCurveCode: Int,
|
|
86
|
+
) -> Unit,
|
|
87
|
+
): Boolean {
|
|
88
|
+
if (!x.isFinite() || !y.isFinite() || !width.isFinite() ||
|
|
89
|
+
!height.isFinite() || !topLeftRadius.isFinite() ||
|
|
90
|
+
!topRightRadius.isFinite() || !bottomRightRadius.isFinite() ||
|
|
91
|
+
!bottomLeftRadius.isFinite() || !hostWidth.isFinite() ||
|
|
92
|
+
!hostHeight.isFinite() ||
|
|
93
|
+
(curveCode != CLIP_CURVE_CIRCULAR && curveCode != CLIP_CURVE_CONTINUOUS)
|
|
94
|
+
) {
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
val boundedHostWidth = hostWidth.coerceAtLeast(0f)
|
|
99
|
+
val boundedHostHeight = hostHeight.coerceAtLeast(0f)
|
|
100
|
+
val requestedRight = x + width.coerceAtLeast(0f)
|
|
101
|
+
val requestedBottom = y + height.coerceAtLeast(0f)
|
|
102
|
+
val left = x.coerceIn(0f, boundedHostWidth)
|
|
103
|
+
val top = y.coerceIn(0f, boundedHostHeight)
|
|
104
|
+
val right = requestedRight.coerceIn(0f, boundedHostWidth)
|
|
105
|
+
val bottom = requestedBottom.coerceIn(0f, boundedHostHeight)
|
|
106
|
+
val visibleWidth = max(0f, right - left)
|
|
107
|
+
val visibleHeight = max(0f, bottom - top)
|
|
108
|
+
val topLeft = topLeftRadius.coerceAtLeast(0f)
|
|
109
|
+
val topRight = topRightRadius.coerceAtLeast(0f)
|
|
110
|
+
val bottomRight = bottomRightRadius.coerceAtLeast(0f)
|
|
111
|
+
val bottomLeft = bottomLeftRadius.coerceAtLeast(0f)
|
|
112
|
+
|
|
113
|
+
var radiusScale = 1f
|
|
114
|
+
val topWidth = topLeft + topRight
|
|
115
|
+
val bottomWidth = bottomLeft + bottomRight
|
|
116
|
+
val leftHeight = topLeft + bottomLeft
|
|
117
|
+
val rightHeight = topRight + bottomRight
|
|
118
|
+
if (topWidth > 0f) radiusScale = min(radiusScale, visibleWidth / topWidth)
|
|
119
|
+
if (bottomWidth > 0f) radiusScale = min(radiusScale, visibleWidth / bottomWidth)
|
|
120
|
+
if (leftHeight > 0f) radiusScale = min(radiusScale, visibleHeight / leftHeight)
|
|
121
|
+
if (rightHeight > 0f) radiusScale = min(radiusScale, visibleHeight / rightHeight)
|
|
122
|
+
radiusScale = radiusScale.coerceIn(0f, 1f)
|
|
123
|
+
|
|
124
|
+
apply(
|
|
125
|
+
left,
|
|
126
|
+
top,
|
|
127
|
+
right,
|
|
128
|
+
bottom,
|
|
129
|
+
topLeft * radiusScale,
|
|
130
|
+
topRight * radiusScale,
|
|
131
|
+
bottomRight * radiusScale,
|
|
132
|
+
bottomLeft * radiusScale,
|
|
133
|
+
curveCode,
|
|
134
|
+
)
|
|
135
|
+
return true
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Emits one fixed-topology rounded rectangle for both V2 curve families.
|
|
140
|
+
* Circular uses the standard quarter-circle cubic coefficient; continuous
|
|
141
|
+
* keeps both control points at the rectangle corner (coefficient 1), yielding
|
|
142
|
+
* zero endpoint curvature and a visibly smoother shoulder. "Continuous" is a
|
|
143
|
+
* library-defined cross-platform curve, not a claim of pixel identity with
|
|
144
|
+
* Apple's private continuous-corner implementation.
|
|
145
|
+
*/
|
|
146
|
+
internal fun appendRoundedRectPath(
|
|
147
|
+
path: Path,
|
|
148
|
+
left: Float,
|
|
149
|
+
top: Float,
|
|
150
|
+
right: Float,
|
|
151
|
+
bottom: Float,
|
|
152
|
+
topLeftRadius: Float,
|
|
153
|
+
topRightRadius: Float,
|
|
154
|
+
bottomRightRadius: Float,
|
|
155
|
+
bottomLeftRadius: Float,
|
|
156
|
+
curveCode: Int,
|
|
157
|
+
) {
|
|
158
|
+
val coefficient = if (curveCode == CLIP_CURVE_CONTINUOUS) {
|
|
159
|
+
1f
|
|
160
|
+
} else {
|
|
161
|
+
0.5522848f
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
path.moveTo(left + topLeftRadius, top)
|
|
165
|
+
path.lineTo(right - topRightRadius, top)
|
|
166
|
+
path.cubicTo(
|
|
167
|
+
right - topRightRadius + coefficient * topRightRadius,
|
|
168
|
+
top,
|
|
169
|
+
right,
|
|
170
|
+
top + topRightRadius - coefficient * topRightRadius,
|
|
171
|
+
right,
|
|
172
|
+
top + topRightRadius,
|
|
173
|
+
)
|
|
174
|
+
path.lineTo(right, bottom - bottomRightRadius)
|
|
175
|
+
path.cubicTo(
|
|
176
|
+
right,
|
|
177
|
+
bottom - bottomRightRadius + coefficient * bottomRightRadius,
|
|
178
|
+
right - bottomRightRadius + coefficient * bottomRightRadius,
|
|
179
|
+
bottom,
|
|
180
|
+
right - bottomRightRadius,
|
|
181
|
+
bottom,
|
|
182
|
+
)
|
|
183
|
+
path.lineTo(left + bottomLeftRadius, bottom)
|
|
184
|
+
path.cubicTo(
|
|
185
|
+
left + bottomLeftRadius - coefficient * bottomLeftRadius,
|
|
186
|
+
bottom,
|
|
187
|
+
left,
|
|
188
|
+
bottom - bottomLeftRadius + coefficient * bottomLeftRadius,
|
|
189
|
+
left,
|
|
190
|
+
bottom - bottomLeftRadius,
|
|
191
|
+
)
|
|
192
|
+
path.lineTo(left, top + topLeftRadius)
|
|
193
|
+
path.cubicTo(
|
|
194
|
+
left,
|
|
195
|
+
top + topLeftRadius - coefficient * topLeftRadius,
|
|
196
|
+
left + topLeftRadius - coefficient * topLeftRadius,
|
|
197
|
+
top,
|
|
198
|
+
left + topLeftRadius,
|
|
199
|
+
top,
|
|
200
|
+
)
|
|
201
|
+
path.close()
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Hit-tests the actual rendered path. Path has no float `contains` API, so we
|
|
206
|
+
* flatten that same instance to sub-pixel line segments for ACTION_DOWN. This
|
|
207
|
+
* is deliberately off the render/animation hot path and avoids maintaining a
|
|
208
|
+
* second analytical curve that can drift from clipping geometry.
|
|
209
|
+
*/
|
|
210
|
+
internal fun containsPathPoint(path: Path, x: Float, y: Float): Boolean {
|
|
211
|
+
if (!x.isFinite() || !y.isFinite() || path.isEmpty) return false
|
|
212
|
+
val points = path.approximate(0.1f)
|
|
213
|
+
if (points.size < 6) return false
|
|
214
|
+
|
|
215
|
+
var inside = false
|
|
216
|
+
var previousX = points[1]
|
|
217
|
+
var previousY = points[2]
|
|
218
|
+
var index = 3
|
|
219
|
+
while (index + 2 < points.size) {
|
|
220
|
+
val currentX = points[index + 1]
|
|
221
|
+
val currentY = points[index + 2]
|
|
222
|
+
val dx = currentX - previousX
|
|
223
|
+
val dy = currentY - previousY
|
|
224
|
+
val segmentLengthSquared = dx * dx + dy * dy
|
|
225
|
+
if (segmentLengthSquared > 0f) {
|
|
226
|
+
val projection = (((x - previousX) * dx + (y - previousY) * dy) /
|
|
227
|
+
segmentLengthSquared).coerceIn(0f, 1f)
|
|
228
|
+
val projectedX = previousX + projection * dx
|
|
229
|
+
val projectedY = previousY + projection * dy
|
|
230
|
+
val distanceX = x - projectedX
|
|
231
|
+
val distanceY = y - projectedY
|
|
232
|
+
if (distanceX * distanceX + distanceY * distanceY <= 0.01f) {
|
|
233
|
+
return true
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if ((currentY > y) != (previousY > y)) {
|
|
237
|
+
val crossingX = (previousX - currentX) * (y - currentY) /
|
|
238
|
+
(previousY - currentY) + currentX
|
|
239
|
+
if (x < crossingX) inside = !inside
|
|
240
|
+
}
|
|
241
|
+
previousX = currentX
|
|
242
|
+
previousY = currentY
|
|
243
|
+
index += 3
|
|
244
|
+
}
|
|
245
|
+
return inside
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
internal fun containsRoundedPointV2Px(
|
|
249
|
+
x: Float,
|
|
250
|
+
y: Float,
|
|
251
|
+
left: Float,
|
|
252
|
+
top: Float,
|
|
253
|
+
right: Float,
|
|
254
|
+
bottom: Float,
|
|
255
|
+
topLeftRadius: Float,
|
|
256
|
+
topRightRadius: Float,
|
|
257
|
+
bottomRightRadius: Float,
|
|
258
|
+
bottomLeftRadius: Float,
|
|
259
|
+
curveCode: Int,
|
|
260
|
+
isEmpty: Boolean,
|
|
261
|
+
): Boolean {
|
|
262
|
+
if (isEmpty || x < left || x > right || y < top || y > bottom) return false
|
|
263
|
+
|
|
264
|
+
fun containsCorner(inwardX: Float, inwardY: Float): Boolean {
|
|
265
|
+
if (curveCode == CLIP_CURVE_CIRCULAR) {
|
|
266
|
+
val dx = inwardX - 1f
|
|
267
|
+
val dy = inwardY - 1f
|
|
268
|
+
return dx * dx + dy * dy <= 1f
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Invert the rendered cubic's inward-x component. This runs only for
|
|
272
|
+
// ACTION_DOWN hit testing, never on the animation/render hot path.
|
|
273
|
+
var low = 0f
|
|
274
|
+
var high = 1f
|
|
275
|
+
repeat(12) {
|
|
276
|
+
val t = (low + high) / 2f
|
|
277
|
+
val inverse = 1f - t
|
|
278
|
+
val boundaryInwardX = inverse * inverse * inverse
|
|
279
|
+
if (boundaryInwardX > inwardX) {
|
|
280
|
+
low = t
|
|
281
|
+
} else {
|
|
282
|
+
high = t
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
val t = (low + high) / 2f
|
|
286
|
+
val boundaryInwardY = t * t * t
|
|
287
|
+
return inwardY >= boundaryInwardY
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (topLeftRadius > 0f && x < left + topLeftRadius && y < top + topLeftRadius) {
|
|
291
|
+
return containsCorner(
|
|
292
|
+
(x - left) / topLeftRadius,
|
|
293
|
+
(y - top) / topLeftRadius,
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
if (topRightRadius > 0f && x > right - topRightRadius && y < top + topRightRadius) {
|
|
297
|
+
return containsCorner(
|
|
298
|
+
(right - x) / topRightRadius,
|
|
299
|
+
(y - top) / topRightRadius,
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
if (bottomRightRadius > 0f &&
|
|
303
|
+
x > right - bottomRightRadius && y > bottom - bottomRightRadius
|
|
304
|
+
) {
|
|
305
|
+
return containsCorner(
|
|
306
|
+
(right - x) / bottomRightRadius,
|
|
307
|
+
(bottom - y) / bottomRightRadius,
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
if (bottomLeftRadius > 0f && x < left + bottomLeftRadius && y > bottom - bottomLeftRadius) {
|
|
311
|
+
return containsCorner(
|
|
312
|
+
(x - left) / bottomLeftRadius,
|
|
313
|
+
(bottom - y) / bottomLeftRadius,
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
return true
|
|
317
|
+
}
|
|
318
|
+
|
|
54
319
|
internal fun clipVisibility(isEmpty: Boolean): Int =
|
|
55
320
|
if (isEmpty) View.INVISIBLE else View.VISIBLE
|
|
56
321
|
|
|
@@ -35,6 +35,27 @@ internal object SmoothClipBindings {
|
|
|
35
35
|
lifecycleVisible: Boolean,
|
|
36
36
|
)
|
|
37
37
|
|
|
38
|
+
external fun nativeRegisterViewV2(
|
|
39
|
+
driverId: Double,
|
|
40
|
+
view: SmoothClipView,
|
|
41
|
+
x: Double,
|
|
42
|
+
y: Double,
|
|
43
|
+
width: Double,
|
|
44
|
+
height: Double,
|
|
45
|
+
topLeftRadius: Double,
|
|
46
|
+
topRightRadius: Double,
|
|
47
|
+
bottomRightRadius: Double,
|
|
48
|
+
bottomLeftRadius: Double,
|
|
49
|
+
curveCode: Int,
|
|
50
|
+
contentTranslateX: Double,
|
|
51
|
+
contentTranslateY: Double,
|
|
52
|
+
contentScale: Double,
|
|
53
|
+
density: Double,
|
|
54
|
+
widthPx: Double,
|
|
55
|
+
heightPx: Double,
|
|
56
|
+
lifecycleVisible: Boolean,
|
|
57
|
+
)
|
|
58
|
+
|
|
38
59
|
/**
|
|
39
60
|
* Pushes a registered view's density and pixel host size so driver
|
|
40
61
|
* deliveries are pre-normalized in C++; redelivers the visible value.
|
|
@@ -29,6 +29,58 @@ class SmoothClipModule(context: ReactApplicationContext) :
|
|
|
29
29
|
SmoothClipBindings.nativeInvalidate()
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
override fun getPresentationProtocolVersion(): Double = 2.0
|
|
33
|
+
|
|
34
|
+
// Static complex paths are supported, but autonomous animation remains a
|
|
35
|
+
// measured capability. Keep it disabled until the physical-device path
|
|
36
|
+
// sampling and frame-time gates are run for this release.
|
|
37
|
+
override fun supportsAutonomousComplexPathAnimation(): Boolean = false
|
|
38
|
+
|
|
39
|
+
override fun beginGroupInteractionV2(driverIds: ReadableArray): WritableArray =
|
|
40
|
+
Arguments.createArray()
|
|
41
|
+
|
|
42
|
+
override fun snapshotGroupV2(driverIds: ReadableArray): WritableArray =
|
|
43
|
+
Arguments.createArray()
|
|
44
|
+
|
|
45
|
+
override fun setClipPresentationBatchV2(entries: ReadableArray): Boolean = false
|
|
46
|
+
|
|
47
|
+
override fun animateTimingGroupV2(
|
|
48
|
+
controllerId: Double,
|
|
49
|
+
entries: ReadableArray,
|
|
50
|
+
durationMs: Double,
|
|
51
|
+
controlPoint1X: Double,
|
|
52
|
+
controlPoint1Y: Double,
|
|
53
|
+
controlPoint2X: Double,
|
|
54
|
+
controlPoint2Y: Double,
|
|
55
|
+
reduceMotion: Double,
|
|
56
|
+
suspensionPolicy: Double,
|
|
57
|
+
): Double = 0.0
|
|
58
|
+
|
|
59
|
+
override fun animateSpringGroupV2(
|
|
60
|
+
controllerId: Double,
|
|
61
|
+
entries: ReadableArray,
|
|
62
|
+
mass: Double,
|
|
63
|
+
stiffness: Double,
|
|
64
|
+
damping: Double,
|
|
65
|
+
initialVelocity: Double,
|
|
66
|
+
inheritVelocity: Boolean,
|
|
67
|
+
reduceMotion: Double,
|
|
68
|
+
suspensionPolicy: Double,
|
|
69
|
+
): Double = 0.0
|
|
70
|
+
|
|
71
|
+
override fun animateKeyframesGroupV2(
|
|
72
|
+
controllerId: Double,
|
|
73
|
+
entries: ReadableArray,
|
|
74
|
+
durationMs: Double,
|
|
75
|
+
reduceMotion: Double,
|
|
76
|
+
suspensionPolicy: Double,
|
|
77
|
+
): Double = 0.0
|
|
78
|
+
|
|
79
|
+
override fun cancelAnimationGroupV2(
|
|
80
|
+
groupId: Double,
|
|
81
|
+
behavior: Double,
|
|
82
|
+
): WritableArray = Arguments.createArray()
|
|
83
|
+
|
|
32
84
|
override fun setClipPresentation(
|
|
33
85
|
driverId: Double,
|
|
34
86
|
x: Double,
|
|
@@ -42,9 +94,33 @@ class SmoothClipModule(context: ReactApplicationContext) :
|
|
|
42
94
|
overridePendingAnimation: Boolean,
|
|
43
95
|
) = Unit
|
|
44
96
|
|
|
97
|
+
override fun setClipPresentationV2(
|
|
98
|
+
driverId: Double,
|
|
99
|
+
x: Double,
|
|
100
|
+
y: Double,
|
|
101
|
+
width: Double,
|
|
102
|
+
height: Double,
|
|
103
|
+
topLeftRadius: Double,
|
|
104
|
+
topRightRadius: Double,
|
|
105
|
+
bottomRightRadius: Double,
|
|
106
|
+
bottomLeftRadius: Double,
|
|
107
|
+
curveCode: Double,
|
|
108
|
+
contentTranslateX: Double,
|
|
109
|
+
contentTranslateY: Double,
|
|
110
|
+
contentScale: Double,
|
|
111
|
+
takeOwnership: Boolean,
|
|
112
|
+
overridePendingAnimation: Boolean,
|
|
113
|
+
) = Unit
|
|
114
|
+
|
|
45
115
|
override fun beginInteraction(driverId: Double): WritableArray =
|
|
46
116
|
Arguments.createArray()
|
|
47
117
|
|
|
118
|
+
override fun beginInteractionV2(driverId: Double): WritableArray =
|
|
119
|
+
Arguments.createArray()
|
|
120
|
+
|
|
121
|
+
override fun snapshotCurrentV2(driverId: Double): WritableArray =
|
|
122
|
+
Arguments.createArray()
|
|
123
|
+
|
|
48
124
|
override fun animateTiming(
|
|
49
125
|
driverId: Double,
|
|
50
126
|
hasInteractiveStart: Boolean,
|
|
@@ -70,6 +146,41 @@ class SmoothClipModule(context: ReactApplicationContext) :
|
|
|
70
146
|
reduceMotion: Double,
|
|
71
147
|
): Double = 0.0
|
|
72
148
|
|
|
149
|
+
override fun animateTimingV2(
|
|
150
|
+
driverId: Double,
|
|
151
|
+
hasInteractiveStart: Boolean,
|
|
152
|
+
startX: Double,
|
|
153
|
+
startY: Double,
|
|
154
|
+
startWidth: Double,
|
|
155
|
+
startHeight: Double,
|
|
156
|
+
startTopLeftRadius: Double,
|
|
157
|
+
startTopRightRadius: Double,
|
|
158
|
+
startBottomRightRadius: Double,
|
|
159
|
+
startBottomLeftRadius: Double,
|
|
160
|
+
startCurveCode: Double,
|
|
161
|
+
startContentTranslateX: Double,
|
|
162
|
+
startContentTranslateY: Double,
|
|
163
|
+
startContentScale: Double,
|
|
164
|
+
x: Double,
|
|
165
|
+
y: Double,
|
|
166
|
+
width: Double,
|
|
167
|
+
height: Double,
|
|
168
|
+
topLeftRadius: Double,
|
|
169
|
+
topRightRadius: Double,
|
|
170
|
+
bottomRightRadius: Double,
|
|
171
|
+
bottomLeftRadius: Double,
|
|
172
|
+
curveCode: Double,
|
|
173
|
+
contentTranslateX: Double,
|
|
174
|
+
contentTranslateY: Double,
|
|
175
|
+
contentScale: Double,
|
|
176
|
+
durationMs: Double,
|
|
177
|
+
controlPoint1X: Double,
|
|
178
|
+
controlPoint1Y: Double,
|
|
179
|
+
controlPoint2X: Double,
|
|
180
|
+
controlPoint2Y: Double,
|
|
181
|
+
reduceMotion: Double,
|
|
182
|
+
): Double = 0.0
|
|
183
|
+
|
|
73
184
|
override fun animateSpring(
|
|
74
185
|
driverId: Double,
|
|
75
186
|
hasInteractiveStart: Boolean,
|
|
@@ -95,6 +206,41 @@ class SmoothClipModule(context: ReactApplicationContext) :
|
|
|
95
206
|
reduceMotion: Double,
|
|
96
207
|
): Double = 0.0
|
|
97
208
|
|
|
209
|
+
override fun animateSpringV2(
|
|
210
|
+
driverId: Double,
|
|
211
|
+
hasInteractiveStart: Boolean,
|
|
212
|
+
startX: Double,
|
|
213
|
+
startY: Double,
|
|
214
|
+
startWidth: Double,
|
|
215
|
+
startHeight: Double,
|
|
216
|
+
startTopLeftRadius: Double,
|
|
217
|
+
startTopRightRadius: Double,
|
|
218
|
+
startBottomRightRadius: Double,
|
|
219
|
+
startBottomLeftRadius: Double,
|
|
220
|
+
startCurveCode: Double,
|
|
221
|
+
startContentTranslateX: Double,
|
|
222
|
+
startContentTranslateY: Double,
|
|
223
|
+
startContentScale: Double,
|
|
224
|
+
x: Double,
|
|
225
|
+
y: Double,
|
|
226
|
+
width: Double,
|
|
227
|
+
height: Double,
|
|
228
|
+
topLeftRadius: Double,
|
|
229
|
+
topRightRadius: Double,
|
|
230
|
+
bottomRightRadius: Double,
|
|
231
|
+
bottomLeftRadius: Double,
|
|
232
|
+
curveCode: Double,
|
|
233
|
+
contentTranslateX: Double,
|
|
234
|
+
contentTranslateY: Double,
|
|
235
|
+
contentScale: Double,
|
|
236
|
+
mass: Double,
|
|
237
|
+
stiffness: Double,
|
|
238
|
+
damping: Double,
|
|
239
|
+
initialVelocity: Double,
|
|
240
|
+
inheritVelocity: Boolean,
|
|
241
|
+
reduceMotion: Double,
|
|
242
|
+
): Double = 0.0
|
|
243
|
+
|
|
98
244
|
override fun animateKeyframes(
|
|
99
245
|
driverId: Double,
|
|
100
246
|
hasInteractiveStart: Boolean,
|
|
@@ -117,6 +263,137 @@ class SmoothClipModule(context: ReactApplicationContext) :
|
|
|
117
263
|
reduceMotion: Double,
|
|
118
264
|
): Double = 0.0
|
|
119
265
|
|
|
266
|
+
override fun animateKeyframesV2(
|
|
267
|
+
driverId: Double,
|
|
268
|
+
hasInteractiveStart: Boolean,
|
|
269
|
+
startX: Double,
|
|
270
|
+
startY: Double,
|
|
271
|
+
startWidth: Double,
|
|
272
|
+
startHeight: Double,
|
|
273
|
+
startTopLeftRadius: Double,
|
|
274
|
+
startTopRightRadius: Double,
|
|
275
|
+
startBottomRightRadius: Double,
|
|
276
|
+
startBottomLeftRadius: Double,
|
|
277
|
+
startCurveCode: Double,
|
|
278
|
+
startContentTranslateX: Double,
|
|
279
|
+
startContentTranslateY: Double,
|
|
280
|
+
startContentScale: Double,
|
|
281
|
+
x: Double,
|
|
282
|
+
y: Double,
|
|
283
|
+
width: Double,
|
|
284
|
+
height: Double,
|
|
285
|
+
topLeftRadius: Double,
|
|
286
|
+
topRightRadius: Double,
|
|
287
|
+
bottomRightRadius: Double,
|
|
288
|
+
bottomLeftRadius: Double,
|
|
289
|
+
curveCode: Double,
|
|
290
|
+
contentTranslateX: Double,
|
|
291
|
+
contentTranslateY: Double,
|
|
292
|
+
contentScale: Double,
|
|
293
|
+
durationMs: Double,
|
|
294
|
+
frames: ReadableArray,
|
|
295
|
+
reduceMotion: Double,
|
|
296
|
+
): Double = 0.0
|
|
297
|
+
|
|
298
|
+
override fun animateTimingFromV2(
|
|
299
|
+
driverId: Double,
|
|
300
|
+
startX: Double,
|
|
301
|
+
startY: Double,
|
|
302
|
+
startWidth: Double,
|
|
303
|
+
startHeight: Double,
|
|
304
|
+
startTopLeftRadius: Double,
|
|
305
|
+
startTopRightRadius: Double,
|
|
306
|
+
startBottomRightRadius: Double,
|
|
307
|
+
startBottomLeftRadius: Double,
|
|
308
|
+
startCurveCode: Double,
|
|
309
|
+
startContentTranslateX: Double,
|
|
310
|
+
startContentTranslateY: Double,
|
|
311
|
+
startContentScale: Double,
|
|
312
|
+
x: Double,
|
|
313
|
+
y: Double,
|
|
314
|
+
width: Double,
|
|
315
|
+
height: Double,
|
|
316
|
+
topLeftRadius: Double,
|
|
317
|
+
topRightRadius: Double,
|
|
318
|
+
bottomRightRadius: Double,
|
|
319
|
+
bottomLeftRadius: Double,
|
|
320
|
+
curveCode: Double,
|
|
321
|
+
contentTranslateX: Double,
|
|
322
|
+
contentTranslateY: Double,
|
|
323
|
+
contentScale: Double,
|
|
324
|
+
durationMs: Double,
|
|
325
|
+
controlPoint1X: Double,
|
|
326
|
+
controlPoint1Y: Double,
|
|
327
|
+
controlPoint2X: Double,
|
|
328
|
+
controlPoint2Y: Double,
|
|
329
|
+
reduceMotion: Double,
|
|
330
|
+
): Double = 0.0
|
|
331
|
+
|
|
332
|
+
override fun animateSpringFromV2(
|
|
333
|
+
driverId: Double,
|
|
334
|
+
startX: Double,
|
|
335
|
+
startY: Double,
|
|
336
|
+
startWidth: Double,
|
|
337
|
+
startHeight: Double,
|
|
338
|
+
startTopLeftRadius: Double,
|
|
339
|
+
startTopRightRadius: Double,
|
|
340
|
+
startBottomRightRadius: Double,
|
|
341
|
+
startBottomLeftRadius: Double,
|
|
342
|
+
startCurveCode: Double,
|
|
343
|
+
startContentTranslateX: Double,
|
|
344
|
+
startContentTranslateY: Double,
|
|
345
|
+
startContentScale: Double,
|
|
346
|
+
x: Double,
|
|
347
|
+
y: Double,
|
|
348
|
+
width: Double,
|
|
349
|
+
height: Double,
|
|
350
|
+
topLeftRadius: Double,
|
|
351
|
+
topRightRadius: Double,
|
|
352
|
+
bottomRightRadius: Double,
|
|
353
|
+
bottomLeftRadius: Double,
|
|
354
|
+
curveCode: Double,
|
|
355
|
+
contentTranslateX: Double,
|
|
356
|
+
contentTranslateY: Double,
|
|
357
|
+
contentScale: Double,
|
|
358
|
+
mass: Double,
|
|
359
|
+
stiffness: Double,
|
|
360
|
+
damping: Double,
|
|
361
|
+
initialVelocity: Double,
|
|
362
|
+
inheritVelocity: Boolean,
|
|
363
|
+
reduceMotion: Double,
|
|
364
|
+
): Double = 0.0
|
|
365
|
+
|
|
366
|
+
override fun animateKeyframesFromV2(
|
|
367
|
+
driverId: Double,
|
|
368
|
+
startX: Double,
|
|
369
|
+
startY: Double,
|
|
370
|
+
startWidth: Double,
|
|
371
|
+
startHeight: Double,
|
|
372
|
+
startTopLeftRadius: Double,
|
|
373
|
+
startTopRightRadius: Double,
|
|
374
|
+
startBottomRightRadius: Double,
|
|
375
|
+
startBottomLeftRadius: Double,
|
|
376
|
+
startCurveCode: Double,
|
|
377
|
+
startContentTranslateX: Double,
|
|
378
|
+
startContentTranslateY: Double,
|
|
379
|
+
startContentScale: Double,
|
|
380
|
+
x: Double,
|
|
381
|
+
y: Double,
|
|
382
|
+
width: Double,
|
|
383
|
+
height: Double,
|
|
384
|
+
topLeftRadius: Double,
|
|
385
|
+
topRightRadius: Double,
|
|
386
|
+
bottomRightRadius: Double,
|
|
387
|
+
bottomLeftRadius: Double,
|
|
388
|
+
curveCode: Double,
|
|
389
|
+
contentTranslateX: Double,
|
|
390
|
+
contentTranslateY: Double,
|
|
391
|
+
contentScale: Double,
|
|
392
|
+
durationMs: Double,
|
|
393
|
+
frames: ReadableArray,
|
|
394
|
+
reduceMotion: Double,
|
|
395
|
+
): Double = 0.0
|
|
396
|
+
|
|
120
397
|
override fun rejectAnimation(driverId: Double): Double = 0.0
|
|
121
398
|
|
|
122
399
|
override fun cancelAnimation(
|
|
@@ -125,5 +402,11 @@ class SmoothClipModule(context: ReactApplicationContext) :
|
|
|
125
402
|
behavior: Double,
|
|
126
403
|
): WritableArray = Arguments.createArray()
|
|
127
404
|
|
|
405
|
+
override fun cancelAnimationV2(
|
|
406
|
+
driverId: Double,
|
|
407
|
+
animationId: Double,
|
|
408
|
+
behavior: Double,
|
|
409
|
+
): WritableArray = Arguments.createArray()
|
|
410
|
+
|
|
128
411
|
override fun destroyDriver(driverId: Double) = Unit
|
|
129
412
|
}
|