expo-android-glass-view 0.1.6 → 0.1.8
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/CHANGELOG.md +8 -0
- package/README.md +12 -6
- package/android/build.gradle +5 -2
- package/android/src/main/java/expo/modules/androidglassview/ExpoAndroidGlassViewModule.kt +1 -1
- package/android/src/main/java/expo/modules/androidglassview/GlassHostView.kt +2 -2
- package/android/src/main/java/expo/modules/androidglassview/ViewBackdrop.kt +2 -1
- package/android/src/main/java/expo/modules/androidglassview/capture/ViewBackdropCapture.kt +83 -26
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.7 — 2026-09-13
|
|
4
|
+
|
|
5
|
+
- Fix: refresh glass backdrops when navigation replaces children in an inline-drawn container,
|
|
6
|
+
or changes their visibility or drawing order. Tab bars no longer keep references to detached
|
|
7
|
+
screens. Manually applied transforms and alpha are tracked too, including drawer movement.
|
|
8
|
+
All glass components share this fix; referenced lists still scroll without re-capturing.
|
|
9
|
+
- `captureRevision` is now 4. Consumer apps need a native rebuild to receive this fix.
|
|
10
|
+
|
|
3
11
|
## 0.1.6 — 2026-09-12
|
|
4
12
|
|
|
5
13
|
- Fix: 0.1.4 and 0.1.5 were published without their compiled JavaScript (`build/`), so Metro
|
package/README.md
CHANGED
|
@@ -13,7 +13,11 @@ The glass effects and the components come from
|
|
|
13
13
|
the glass see the React Native screen behind it is adapted from
|
|
14
14
|
[QWEA0/Liquid-Glass-Android](https://github.com/QWEA0/Liquid-Glass-Android).
|
|
15
15
|
|
|
16
|
-
>
|
|
16
|
+
> [!WARNING]
|
|
17
|
+
> **⚠️ EXPERIMENTAL — NOT PRODUCTION READY**
|
|
18
|
+
>
|
|
19
|
+
> This is an early **0.1 release**. APIs, behavior and native implementation may change before `1.0`.
|
|
20
|
+
> **Use it for experiments and prototypes, not production apps yet.**
|
|
17
21
|
|
|
18
22
|
```tsx
|
|
19
23
|
import {
|
|
@@ -362,6 +366,8 @@ The capture is cached in one RenderNode with its own GPU layer, and every glass
|
|
|
362
366
|
- a container it draws inline scrolls: one of its own ancestors, one of their direct children,
|
|
363
367
|
or a container that holds other glass views. A list that is simply behind the glass (deeper in
|
|
364
368
|
another branch, with no glass inside) is referenced, so it scrolls live without a new capture,
|
|
369
|
+
- an inline container's direct children change (including screen replacement, visibility and
|
|
370
|
+
drawing order), or a child whose transform is drawn inline moves, resizes or changes alpha,
|
|
365
371
|
- a view it left out because it was too far away moves, resizes or scrolls,
|
|
366
372
|
- a glass view is added or removed.
|
|
367
373
|
|
|
@@ -390,11 +396,11 @@ React Native screen behind it_).
|
|
|
390
396
|
Measured with `adb shell dumpsys gfxinfo` and `atrace` on a release build, on a mid-range phone:
|
|
391
397
|
Xiaomi 24117RN76E, MediaTek Helio G99, Android 16, 120 Hz.
|
|
392
398
|
|
|
393
|
-
| Screen
|
|
394
|
-
|
|
|
395
|
-
| Static screen, nothing moving
|
|
396
|
-
| Scrolling a list under a glass header, a glass button and the tab bar
|
|
397
|
-
| 6 glass tiles over an animated backdrop, plus glass panels and controls
|
|
399
|
+
| Screen | Glass views | Result |
|
|
400
|
+
| ----------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------------- |
|
|
401
|
+
| Static screen, nothing moving | 3 | 0 frames rendered while idle |
|
|
402
|
+
| Scrolling a list under a glass header, a glass button and the tab bar | 3 | no missed frames; 90% of frames within 14 ms |
|
|
403
|
+
| 6 glass tiles over an animated backdrop, plus glass panels and controls | 17 | about 70 fps, no missed frames; the RenderThread needs ~14 ms per frame |
|
|
398
404
|
|
|
399
405
|
In practice:
|
|
400
406
|
|
package/android/build.gradle
CHANGED
|
@@ -14,13 +14,14 @@ plugins {
|
|
|
14
14
|
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
|
|
15
15
|
|
|
16
16
|
group = 'expo.modules.androidglassview'
|
|
17
|
-
version = '0.1.
|
|
17
|
+
version = '0.1.7'
|
|
18
18
|
|
|
19
19
|
android {
|
|
20
20
|
namespace "expo.modules.androidglassview"
|
|
21
21
|
defaultConfig {
|
|
22
22
|
versionCode 1
|
|
23
|
-
versionName "0.1.
|
|
23
|
+
versionName "0.1.7"
|
|
24
|
+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
|
24
25
|
}
|
|
25
26
|
buildFeatures {
|
|
26
27
|
compose true
|
|
@@ -36,4 +37,6 @@ dependencies {
|
|
|
36
37
|
// Same Compose version as @expo/ui for this Expo SDK, so apps using both resolve one runtime.
|
|
37
38
|
implementation 'androidx.compose.foundation:foundation-android:1.10.6'
|
|
38
39
|
implementation 'androidx.compose.ui:ui-android:1.10.6'
|
|
40
|
+
androidTestImplementation 'androidx.test:runner:1.6.2'
|
|
41
|
+
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
|
39
42
|
}
|
|
@@ -13,7 +13,7 @@ class ExpoAndroidGlassViewModule : Module() {
|
|
|
13
13
|
// Bumped when the backdrop capture changes in a way JS may need to know about.
|
|
14
14
|
// 2: ancestors of a sampling glass view are never drawn again through their own draw()
|
|
15
15
|
// (0.1.1 crashed inside react-native-screens stacks).
|
|
16
|
-
Constant("captureRevision") {
|
|
16
|
+
Constant("captureRevision") { 4 }
|
|
17
17
|
|
|
18
18
|
View(AndroidGlassView::class) {
|
|
19
19
|
Name("AndroidGlassView")
|
|
@@ -83,8 +83,8 @@ abstract class GlassHostView(context: Context, appContext: AppContext) : ExpoVie
|
|
|
83
83
|
private var dragClaimed = false
|
|
84
84
|
|
|
85
85
|
// Re-sample when the glass moves on screen (layout, an ancestor scrolling, transforms), when a
|
|
86
|
-
// container the capture drew inline
|
|
87
|
-
//
|
|
86
|
+
// container the capture drew inline changed its children, scroll or baked child transforms,
|
|
87
|
+
// or when a view the capture left out (too far away to be seen through the glass)
|
|
88
88
|
// moved and may now be. A list that is only referenced scrolls live, so scrolling it costs no
|
|
89
89
|
// capture. There is deliberately no global-layout listener: React Native lays out on every
|
|
90
90
|
// state change (e.g. each slider tick updating a label), and re-sampling every glass view each
|
|
@@ -68,7 +68,8 @@ internal class ViewBackdrop(private val host: GlassHostView) : Backdrop {
|
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Whether the capture is out of date although the host didn't move: something it drew inline
|
|
71
|
-
* (not by reference)
|
|
71
|
+
* (not by reference) changed its children or baked geometry, or a view it left out moved
|
|
72
|
+
* (see ViewBackdropCapture).
|
|
72
73
|
*/
|
|
73
74
|
fun changedSinceCapture(): Boolean = capture?.changedSinceCapture() ?: false
|
|
74
75
|
|
|
@@ -17,6 +17,7 @@ import android.graphics.RectF
|
|
|
17
17
|
import android.os.Build
|
|
18
18
|
import android.view.View
|
|
19
19
|
import android.view.ViewGroup
|
|
20
|
+
import android.view.animation.Animation
|
|
20
21
|
import androidx.annotation.RequiresApi
|
|
21
22
|
import kotlin.math.max
|
|
22
23
|
|
|
@@ -100,12 +101,16 @@ internal class ViewBackdropCapture {
|
|
|
100
101
|
private var bakedScroll = IntArray(32)
|
|
101
102
|
|
|
102
103
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
104
|
+
* Child lists dispatched inline, rather than through the group's own RenderNode. A screen
|
|
105
|
+
* replacement can discard a referenced child's display list without moving any views.
|
|
105
106
|
*/
|
|
106
|
-
private val
|
|
107
|
+
private val inlineGroups = ArrayList<InlineGroup>()
|
|
108
|
+
|
|
109
|
+
/** Culled children, and children whose transform/clip/alpha we applied ourselves. */
|
|
110
|
+
private val geometryViews = ArrayList<View>()
|
|
111
|
+
private var geometry = FloatArray(GEOMETRY_FIELDS * 16)
|
|
112
|
+
private var geometryTracksAlpha = BooleanArray(16)
|
|
107
113
|
private val culledSet = HashSet<View>()
|
|
108
|
-
private var culledGeometry = FloatArray(GEOMETRY_FIELDS * 16)
|
|
109
114
|
|
|
110
115
|
/** Margin around a view's bounds that its drawing may still reach (shadows, borders), in px. */
|
|
111
116
|
private var cullPadding = 0f
|
|
@@ -113,24 +118,34 @@ internal class ViewBackdropCapture {
|
|
|
113
118
|
|
|
114
119
|
/**
|
|
115
120
|
* Whether the last capture is out of date although the glass itself didn't move: a view whose
|
|
116
|
-
* scroll offset it baked in
|
|
117
|
-
* (and may now reach the glass).
|
|
121
|
+
* scroll offset or transform it baked in changed, an inline group changed its children, or a
|
|
122
|
+
* view it left out moved (and may now reach the glass). RenderNode subtrees stay live without
|
|
123
|
+
* being traversed here. This check allocates nothing.
|
|
118
124
|
*/
|
|
119
125
|
fun changedSinceCapture(): Boolean {
|
|
120
126
|
for (i in bakedViews.indices) {
|
|
121
127
|
val view = bakedViews[i]
|
|
122
128
|
if (view.scrollX != bakedScroll[i * 2] || view.scrollY != bakedScroll[i * 2 + 1]) return true
|
|
123
129
|
}
|
|
124
|
-
for (i in
|
|
125
|
-
if (!hasGeometry(
|
|
130
|
+
for (i in geometryViews.indices) {
|
|
131
|
+
if (!hasGeometry(geometryViews[i], i)) return true
|
|
132
|
+
}
|
|
133
|
+
for (i in inlineGroups.indices) {
|
|
134
|
+
if (inlineGroups[i].hasChanged()) return true
|
|
126
135
|
}
|
|
127
136
|
return false
|
|
128
137
|
}
|
|
129
138
|
|
|
130
139
|
/** Forgets the views of the last capture (they may belong to a window that is going away). */
|
|
131
140
|
fun clear() {
|
|
141
|
+
expanded.clear()
|
|
142
|
+
excluded.clear()
|
|
143
|
+
selfPath.clear()
|
|
144
|
+
path.clear()
|
|
145
|
+
hidden.clear()
|
|
132
146
|
bakedViews.clear()
|
|
133
|
-
|
|
147
|
+
inlineGroups.clear()
|
|
148
|
+
geometryViews.clear()
|
|
134
149
|
culledSet.clear()
|
|
135
150
|
}
|
|
136
151
|
|
|
@@ -143,13 +158,21 @@ internal class ViewBackdropCapture {
|
|
|
143
158
|
}
|
|
144
159
|
|
|
145
160
|
private fun cull(view: View) {
|
|
146
|
-
val offset = culledViews.size * GEOMETRY_FIELDS
|
|
147
|
-
if (culledGeometry.size < offset + GEOMETRY_FIELDS) {
|
|
148
|
-
culledGeometry = culledGeometry.copyOf(culledGeometry.size * 2)
|
|
149
|
-
}
|
|
150
|
-
culledViews.add(view)
|
|
151
161
|
culledSet.add(view)
|
|
152
|
-
|
|
162
|
+
// A fade outside the capture cannot bring any content into it.
|
|
163
|
+
bakeGeometry(view, trackAlpha = false)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private fun bakeGeometry(view: View, trackAlpha: Boolean = true) {
|
|
167
|
+
val index = geometryViews.size
|
|
168
|
+
val offset = index * GEOMETRY_FIELDS
|
|
169
|
+
if (geometry.size < offset + GEOMETRY_FIELDS) {
|
|
170
|
+
geometry = geometry.copyOf(geometry.size * 2)
|
|
171
|
+
geometryTracksAlpha = geometryTracksAlpha.copyOf(geometryTracksAlpha.size * 2)
|
|
172
|
+
}
|
|
173
|
+
geometryTracksAlpha[index] = trackAlpha
|
|
174
|
+
geometryViews.add(view)
|
|
175
|
+
val g = geometry
|
|
153
176
|
g[offset] = view.left.toFloat()
|
|
154
177
|
g[offset + 1] = view.top.toFloat()
|
|
155
178
|
g[offset + 2] = view.right.toFloat()
|
|
@@ -164,10 +187,15 @@ internal class ViewBackdropCapture {
|
|
|
164
187
|
g[offset + 11] = view.scrollX.toFloat()
|
|
165
188
|
g[offset + 12] = view.scrollY.toFloat()
|
|
166
189
|
g[offset + 13] = view.z
|
|
190
|
+
g[offset + 14] = view.pivotX
|
|
191
|
+
g[offset + 15] = view.pivotY
|
|
192
|
+
g[offset + 16] = view.alpha
|
|
193
|
+
g[offset + 17] = view.cameraDistance
|
|
167
194
|
}
|
|
168
195
|
|
|
169
|
-
private fun hasGeometry(view: View,
|
|
170
|
-
val
|
|
196
|
+
private fun hasGeometry(view: View, index: Int): Boolean {
|
|
197
|
+
val offset = index * GEOMETRY_FIELDS
|
|
198
|
+
val g = geometry
|
|
171
199
|
return g[offset] == view.left.toFloat() &&
|
|
172
200
|
g[offset + 1] == view.top.toFloat() &&
|
|
173
201
|
g[offset + 2] == view.right.toFloat() &&
|
|
@@ -181,7 +209,11 @@ internal class ViewBackdropCapture {
|
|
|
181
209
|
g[offset + 10] == view.rotationY &&
|
|
182
210
|
g[offset + 11] == view.scrollX.toFloat() &&
|
|
183
211
|
g[offset + 12] == view.scrollY.toFloat() &&
|
|
184
|
-
g[offset + 13] == view.z
|
|
212
|
+
g[offset + 13] == view.z &&
|
|
213
|
+
g[offset + 14] == view.pivotX &&
|
|
214
|
+
g[offset + 15] == view.pivotY &&
|
|
215
|
+
(!geometryTracksAlpha[index] || g[offset + 16] == view.alpha) &&
|
|
216
|
+
g[offset + 17] == view.cameraDistance
|
|
185
217
|
}
|
|
186
218
|
|
|
187
219
|
/**
|
|
@@ -191,12 +223,7 @@ internal class ViewBackdropCapture {
|
|
|
191
223
|
* @param glassViews every glass view; the ones outside [source] are ignored.
|
|
192
224
|
*/
|
|
193
225
|
fun draw(canvas: Canvas, source: View, self: View, glassViews: Collection<View>) {
|
|
194
|
-
|
|
195
|
-
excluded.clear()
|
|
196
|
-
selfPath.clear()
|
|
197
|
-
bakedViews.clear()
|
|
198
|
-
culledViews.clear()
|
|
199
|
-
culledSet.clear()
|
|
226
|
+
clear()
|
|
200
227
|
cullPadding = CULL_PADDING_DP * source.resources.displayMetrics.density
|
|
201
228
|
|
|
202
229
|
var ancestor = self.parent
|
|
@@ -239,6 +266,8 @@ internal class ViewBackdropCapture {
|
|
|
239
266
|
}
|
|
240
267
|
|
|
241
268
|
private fun drawLevel(canvas: Canvas, host: View) {
|
|
269
|
+
// Snapshot before temporarily hiding children; otherwise every pre-draw sees a change.
|
|
270
|
+
if (host is ViewGroup) inlineGroups.add(InlineGroup(host))
|
|
242
271
|
if (host is ViewGroup && host in selfPath) {
|
|
243
272
|
drawAncestor(canvas, host)
|
|
244
273
|
return
|
|
@@ -321,6 +350,7 @@ internal class ViewBackdropCapture {
|
|
|
321
350
|
if (child in expanded) {
|
|
322
351
|
drawLevel(canvas, child)
|
|
323
352
|
} else {
|
|
353
|
+
if (child is ViewGroup) inlineGroups.add(InlineGroup(child))
|
|
324
354
|
bakeScroll(child)
|
|
325
355
|
canvas.translate(-child.scrollX.toFloat(), -child.scrollY.toFloat())
|
|
326
356
|
child.draw(canvas)
|
|
@@ -365,6 +395,7 @@ internal class ViewBackdropCapture {
|
|
|
365
395
|
|
|
366
396
|
/** The child's matrix, clip and alpha, as its parent applies them; the canvas is at its left/top. */
|
|
367
397
|
private fun applyChildTransform(canvas: Canvas, child: View, clipChildren: Boolean) {
|
|
398
|
+
bakeGeometry(child)
|
|
368
399
|
val matrix = child.matrix
|
|
369
400
|
if (!matrix.isIdentity) canvas.concat(matrix)
|
|
370
401
|
if (clipChildren) canvas.clipRect(0f, 0f, child.width.toFloat(), child.height.toFloat())
|
|
@@ -389,11 +420,37 @@ internal class ViewBackdropCapture {
|
|
|
389
420
|
return children
|
|
390
421
|
}
|
|
391
422
|
|
|
423
|
+
/** Only the direct dispatch boundary is frozen; descendants keep their live RenderNodes. */
|
|
424
|
+
private class InlineGroup(private val group: ViewGroup) {
|
|
425
|
+
private val count = group.childCount
|
|
426
|
+
private val children = Array(count) { group.getChildAt(it) }
|
|
427
|
+
private val visibility = IntArray(count) { children[it].visibility }
|
|
428
|
+
private val order = IntArray(count) { group.getChildDrawingOrder(it) }
|
|
429
|
+
private val z = FloatArray(count) { children[it].z }
|
|
430
|
+
private val animations = arrayOfNulls<Animation>(count).also { values ->
|
|
431
|
+
for (i in 0 until count) values[i] = children[i].animation
|
|
432
|
+
}
|
|
433
|
+
private val clipChildren = group.clipChildren
|
|
434
|
+
private val clipToPadding = group.clipToPadding
|
|
435
|
+
|
|
436
|
+
fun hasChanged(): Boolean {
|
|
437
|
+
if (group.childCount != count || group.clipChildren != clipChildren ||
|
|
438
|
+
group.clipToPadding != clipToPadding) return true
|
|
439
|
+
for (i in 0 until count) {
|
|
440
|
+
val child = group.getChildAt(i)
|
|
441
|
+
if (child !== children[i] || child.visibility != visibility[i] ||
|
|
442
|
+
group.getChildDrawingOrder(i) != order[i] || child.z != z[i] ||
|
|
443
|
+
child.animation !== animations[i]) return true
|
|
444
|
+
}
|
|
445
|
+
return false
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
392
449
|
companion object {
|
|
393
450
|
private var depth = 0
|
|
394
451
|
|
|
395
|
-
/** Geometry values stored per culled
|
|
396
|
-
private const val GEOMETRY_FIELDS =
|
|
452
|
+
/** Geometry values stored per culled or manually transformed view. */
|
|
453
|
+
private const val GEOMETRY_FIELDS = 18
|
|
397
454
|
|
|
398
455
|
/** How far outside its bounds a view's drawing is assumed to reach (shadows, borders). */
|
|
399
456
|
private const val CULL_PADDING_DP = 8f
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-android-glass-view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Liquid Glass views, buttons, sliders and toggles for React Native on Android (Jetpack Compose, powered by Kyant0/AndroidLiquidGlass)",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|