expo-android-glass-view 0.1.2 → 0.1.3
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
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.3 — 2026-09-11
|
|
4
|
+
|
|
5
|
+
- Fix a crash when navigating to or from a screen that has a glass view (Expo Router and React
|
|
6
|
+
Navigation on react-native-screens): `IllegalStateException: Cannot locate windowRecomposer … is
|
|
7
|
+
not attached to a window`. React Native measures views that are not attached to the window —
|
|
8
|
+
a pushed screen or a tab opened for the first time, before react-native-screens attaches it, or
|
|
9
|
+
a screen it has detached — and measuring the glass layer there made Compose look for the
|
|
10
|
+
window. The glass layer is now skipped while detached and sized when it attaches.
|
|
11
|
+
- `captureRevision` is now 3.
|
|
12
|
+
|
|
3
13
|
## 0.1.2 — 2026-09-10
|
|
4
14
|
|
|
5
15
|
- Fix a crash when a glass view sits inside a react-native-screens stack (Expo Router and React
|
|
@@ -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") { 3 }
|
|
17
17
|
|
|
18
18
|
View(AndroidGlassView::class) {
|
|
19
19
|
Name("AndroidGlassView")
|
|
@@ -120,6 +120,12 @@ abstract class GlassHostView(context: Context, appContext: AppContext) : ExpoVie
|
|
|
120
120
|
clipToPadding = false
|
|
121
121
|
composeView.clipChildren = false
|
|
122
122
|
super.addView(composeView, 0, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
123
|
+
// The Compose layer is not sized while it is detached (see onMeasure); size it on attach.
|
|
124
|
+
// Listeners run after the view's own onAttachedToWindow, so it is attached by then.
|
|
125
|
+
composeView.addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
|
|
126
|
+
override fun onViewAttachedToWindow(v: View) = layoutComposeLayer()
|
|
127
|
+
override fun onViewDetachedFromWindow(v: View) = Unit
|
|
128
|
+
})
|
|
123
129
|
}
|
|
124
130
|
|
|
125
131
|
@Composable
|
|
@@ -199,6 +205,12 @@ abstract class GlassHostView(context: Context, appContext: AppContext) : ExpoVie
|
|
|
199
205
|
val width = MeasureSpec.getSize(widthMeasureSpec)
|
|
200
206
|
val height = MeasureSpec.getSize(heightMeasureSpec)
|
|
201
207
|
setMeasuredDimension(width, height)
|
|
208
|
+
// ComposeView creates its composition on its first measure, and that needs the window's
|
|
209
|
+
// recomposer: measured off-window it throws "Cannot locate windowRecomposer". Fabric does
|
|
210
|
+
// measure off-window views — a screen react-native-screens has not attached yet (a pushed
|
|
211
|
+
// screen, a tab opened for the first time) or has detached — so skip the Compose layer until
|
|
212
|
+
// it is attached. The attach listener in init sizes it then.
|
|
213
|
+
if (!composeView.isAttachedToWindow) return
|
|
202
214
|
composeView.measure(
|
|
203
215
|
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
204
216
|
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
|
|
@@ -207,9 +219,19 @@ abstract class GlassHostView(context: Context, appContext: AppContext) : ExpoVie
|
|
|
207
219
|
|
|
208
220
|
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
|
209
221
|
// React Native lays out the React children; only the glass layer is ours.
|
|
222
|
+
if (!composeView.isAttachedToWindow) return
|
|
210
223
|
composeView.layout(0, 0, right - left, bottom - top)
|
|
211
224
|
}
|
|
212
225
|
|
|
226
|
+
/** Sizes the Compose layer to this view outside a layout pass (see [onMeasure]). */
|
|
227
|
+
private fun layoutComposeLayer() {
|
|
228
|
+
composeView.measure(
|
|
229
|
+
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
230
|
+
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
|
|
231
|
+
)
|
|
232
|
+
composeView.layout(0, 0, width, height)
|
|
233
|
+
}
|
|
234
|
+
|
|
213
235
|
override fun requestLayout() {
|
|
214
236
|
super.requestLayout()
|
|
215
237
|
// React Native does not run Android layout passes, so honour the Compose layer's
|
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.3",
|
|
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",
|