expo-android-glass-view 1.0.2 → 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,24 @@
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
+
3
22
  ## 1.0.2 — 2026-10-18
4
23
 
5
24
  ### Fixed
@@ -141,8 +141,12 @@ internal fun LiquidBottomTabs(
141
141
  initialScale = 1f,
142
142
  pressedScale = 78f / 56f,
143
143
  onDragStarted = { currentOnExpand() },
144
- onDragStopped = {
145
- val targetIndex = targetValue.fastRoundToInt().fastCoerceIn(0, tabsCount - 1)
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
- if (scrubbing) settle()
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 (abs(change.position.x - startX) > viewConfiguration.touchSlop) {
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.2",
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",