expo-android-glass-view 1.0.1 → 1.0.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,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.3 — 2026-11-19
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **`AndroidGlassBottomTabs`: a vertical swipe that started on the bar selected the tab under
|
|
8
|
+
the finger** ([#1](https://github.com/kagantemizkan/expo-android-glass-view/issues/1)). The bar
|
|
9
|
+
now tells the direction apart once the finger passes touch slop: a mostly horizontal move
|
|
10
|
+
scrubs between tabs as before, a mostly vertical one is ignored and selects nothing on
|
|
11
|
+
release.
|
|
12
|
+
- **A cancelled tab gesture committed the tab it was passing over**
|
|
13
|
+
([#2](https://github.com/kagantemizkan/expo-android-glass-view/issues/2)). When the system or
|
|
14
|
+
another touch handler cancels a scrub on the bar or a drag of the droplet, the droplet now
|
|
15
|
+
slides back to the selected tab and `onTabSelected` is not called.
|
|
16
|
+
|
|
17
|
+
### Compatibility
|
|
18
|
+
|
|
19
|
+
- Rebuild the Android app or development client; this is a native change. iOS and web are
|
|
20
|
+
unchanged.
|
|
21
|
+
|
|
22
|
+
## 1.0.2 — 2026-10-18
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **1.0.1 crashed on Android when a menu opened or closed** (`UnsupportedOperationException:
|
|
27
|
+
Only CornerBasedShape is supported in lens effects`): it handed the menu's drop-shaped
|
|
28
|
+
silhouette to the glass lens, which only accepts rounded rectangles. The glass is drawn
|
|
29
|
+
exactly as in 1.0.0 again. The drop shadow is now a separate layer behind it, with the
|
|
30
|
+
same position, size, scale and fade, so it stays visible without touching the glass.
|
|
31
|
+
Do not use 1.0.1.
|
|
32
|
+
|
|
33
|
+
### Compatibility
|
|
34
|
+
|
|
35
|
+
- Rebuild the Android app or development client; this is a native change.
|
|
36
|
+
|
|
3
37
|
## 1.0.1 — 2026-10-18
|
|
4
38
|
|
|
5
39
|
### Fixed
|
|
@@ -36,7 +36,9 @@ import expo.modules.androidglassview.backdrop.effects.lens
|
|
|
36
36
|
import expo.modules.androidglassview.backdrop.effects.vibrancy
|
|
37
37
|
import expo.modules.androidglassview.backdrop.highlight.Highlight
|
|
38
38
|
import expo.modules.androidglassview.backdrop.isRenderEffectSupported
|
|
39
|
+
import expo.modules.androidglassview.backdrop.internal.ShapeProvider
|
|
39
40
|
import expo.modules.androidglassview.backdrop.shadow.Shadow
|
|
41
|
+
import expo.modules.androidglassview.backdrop.shadow.ShadowElement
|
|
40
42
|
import expo.modules.kotlin.AppContext
|
|
41
43
|
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
42
44
|
import org.json.JSONArray
|
|
@@ -334,27 +336,35 @@ class AndroidGlassMenuPanel(context: Context, appContext: AppContext) : GlassHos
|
|
|
334
336
|
val localRadius = radius / effectScale
|
|
335
337
|
val shape = RoundedCornerShape(localRadius.coerceAtLeast(0f).dp)
|
|
336
338
|
val silhouette = if (neck > .001f) MenuDropShape(localRadius.dp, neck) else shape
|
|
337
|
-
|
|
339
|
+
val placement = Modifier.offset {
|
|
338
340
|
IntOffset(with(density) { (x + width * (1f - stretchX) + dragX * 7f * (1f - verticalPull).coerceAtLeast(0f)).dp.toPx() }.roundToInt(),
|
|
339
341
|
with(density) { (y + dragY * 8f).dp.toPx() }.roundToInt())
|
|
340
342
|
}
|
|
341
343
|
.requiredSize((if(fixedLayer) layoutWidth else width).coerceAtLeast(1f).dp,
|
|
342
344
|
(if(fixedLayer) layoutHeight else height).coerceAtLeast(1f).dp)
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
val dropShadow: () -> Shadow? = {
|
|
346
|
+
if (!shadowEnabled) null else menuGlass.dropShadow.let { base ->
|
|
347
|
+
shadowOpacity?.let { base.copy(color = base.color.copy(alpha = it)) } ?: base
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// The drop shadow is its own layer behind the glass. The glass layer below is
|
|
351
|
+
// clipped to the menu silhouette, so a shadow drawn inside it was cut off and
|
|
352
|
+
// never visible. This layer takes the same position, size, scale and fade, and
|
|
353
|
+
// ShadowNode masks the shape's interior, so only the outside is shaded.
|
|
354
|
+
Box(placement.graphicsLayer {
|
|
355
|
+
transformOrigin = TransformOrigin(0f,0f)
|
|
356
|
+
this.scaleX = surfaceScaleX; this.scaleY = surfaceScaleY
|
|
357
|
+
this.alpha = overallAlpha
|
|
358
|
+
}.then(ShadowElement(ShapeProvider { silhouette }, dropShadow)))
|
|
359
|
+
Box(placement
|
|
360
|
+
.drawBackdrop(backdrop = backdrop, shape = { shape }, clipToShape = false, layerBlock = {
|
|
347
361
|
transformOrigin = TransformOrigin(0f,0f)
|
|
348
362
|
this.scaleX = surfaceScaleX; this.scaleY = surfaceScaleY
|
|
349
|
-
this.alpha = overallAlpha
|
|
363
|
+
this.alpha = overallAlpha; this.shape = silhouette; clip = true
|
|
350
364
|
}, effects = {
|
|
351
365
|
glassEffects(menuGlass, effectScale, material, press)
|
|
352
366
|
}, highlight = { menuGlass.rim.copy(alpha = menuGlass.rim.alpha + press * .25f) },
|
|
353
|
-
shadow =
|
|
354
|
-
if (!shadowEnabled) null else menuGlass.dropShadow.let { base ->
|
|
355
|
-
shadowOpacity?.let { base.copy(color = base.color.copy(alpha = it)) } ?: base
|
|
356
|
-
}
|
|
357
|
-
},
|
|
367
|
+
shadow = null,
|
|
358
368
|
onDrawSurface = { glassSurface(menuGlass, effectsSupported) }
|
|
359
369
|
)
|
|
360
370
|
.then(scrubbing)
|
|
@@ -141,8 +141,12 @@ internal fun LiquidBottomTabs(
|
|
|
141
141
|
initialScale = 1f,
|
|
142
142
|
pressedScale = 78f / 56f,
|
|
143
143
|
onDragStarted = { currentOnExpand() },
|
|
144
|
-
onDragStopped = {
|
|
145
|
-
|
|
144
|
+
onDragStopped = { cancelled ->
|
|
145
|
+
// A cancelled drag never confirmed its target: slide back to the selected tab
|
|
146
|
+
// and emit nothing.
|
|
147
|
+
val targetIndex =
|
|
148
|
+
if (cancelled) currentIndex
|
|
149
|
+
else targetValue.fastRoundToInt().fastCoerceIn(0, tabsCount - 1)
|
|
146
150
|
currentIndex = targetIndex
|
|
147
151
|
animateToValue(targetIndex.toFloat())
|
|
148
152
|
animationScope.launch {
|
|
@@ -232,7 +236,8 @@ internal fun LiquidBottomTabs(
|
|
|
232
236
|
// A tap selects the tab under the finger, exactly like upstream's tab click. Unlike
|
|
233
237
|
// upstream (where only the droplet can be dragged), a horizontal drag that starts
|
|
234
238
|
// anywhere on the bar pulls the droplet under the finger and scrubs between tabs;
|
|
235
|
-
// releasing selects the nearest one.
|
|
239
|
+
// releasing selects the nearest one. A mostly vertical drag is not a tab gesture
|
|
240
|
+
// and selects nothing; a cancelled one returns to the selected tab.
|
|
236
241
|
.pointerInput(dampedDragAnimation, tabsCount, isLtr, geometry) {
|
|
237
242
|
val lastIndex = (tabsCount - 1).toFloat()
|
|
238
243
|
// x is in the bar's own coordinates, which follow the minimize animation.
|
|
@@ -244,7 +249,11 @@ internal fun LiquidBottomTabs(
|
|
|
244
249
|
if (isLtr) slot else lastIndex - slot
|
|
245
250
|
}
|
|
246
251
|
var startX = 0f
|
|
252
|
+
var startY = 0f
|
|
247
253
|
var scrubbing = false
|
|
254
|
+
// Set once the finger moved past touch slop mostly vertically: the gesture
|
|
255
|
+
// is not about the tabs, so it neither scrubs nor selects on release.
|
|
256
|
+
var vertical = false
|
|
248
257
|
var scrubValue = 0f
|
|
249
258
|
val settle: () -> Unit = {
|
|
250
259
|
val target = scrubValue.fastRoundToInt().fastCoerceIn(0, tabsCount - 1)
|
|
@@ -257,27 +266,40 @@ internal fun LiquidBottomTabs(
|
|
|
257
266
|
inspectDragGestures(
|
|
258
267
|
onDragStart = { down ->
|
|
259
268
|
startX = down.position.x
|
|
269
|
+
startY = down.position.y
|
|
260
270
|
scrubbing = false
|
|
271
|
+
vertical = false
|
|
261
272
|
},
|
|
262
273
|
onDragEnd = { up ->
|
|
263
274
|
if (scrubbing) {
|
|
264
275
|
settle()
|
|
265
|
-
} else {
|
|
276
|
+
} else if (!vertical) {
|
|
266
277
|
currentIndex = valueAt(up.position.x).fastRoundToInt()
|
|
267
278
|
.fastCoerceIn(0, tabsCount - 1)
|
|
268
279
|
currentOnExpand()
|
|
269
280
|
}
|
|
270
281
|
scrubbing = false
|
|
282
|
+
vertical = false
|
|
271
283
|
},
|
|
272
284
|
onDragCancel = {
|
|
273
|
-
|
|
285
|
+
// Nothing was confirmed by a release: go back to the selected tab
|
|
286
|
+
// instead of committing the scrub position.
|
|
287
|
+
if (scrubbing) dampedDragAnimation.animateToValue(currentIndex.toFloat())
|
|
274
288
|
scrubbing = false
|
|
289
|
+
vertical = false
|
|
275
290
|
}
|
|
276
291
|
) { change, _ ->
|
|
292
|
+
val dx = abs(change.position.x - startX)
|
|
293
|
+
val dy = abs(change.position.y - startY)
|
|
294
|
+
val slop = viewConfiguration.touchSlop
|
|
277
295
|
if (scrubbing) {
|
|
278
296
|
scrubValue = valueAt(change.position.x)
|
|
279
297
|
dampedDragAnimation.updateValue(scrubValue)
|
|
280
|
-
} else if (
|
|
298
|
+
} else if (vertical) {
|
|
299
|
+
// Decided: not a tab gesture.
|
|
300
|
+
} else if (dy > slop && dy >= dx) {
|
|
301
|
+
vertical = true
|
|
302
|
+
} else if (dx > slop && dx > dy) {
|
|
281
303
|
scrubbing = true
|
|
282
304
|
currentOnExpand()
|
|
283
305
|
scrubValue = valueAt(change.position.x)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-android-glass-view",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.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",
|