expo-android-glass-view 0.1.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.
Files changed (140) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +55 -0
  3. package/README.md +260 -0
  4. package/THIRD_PARTY_NOTICES.md +44 -0
  5. package/android/build.gradle +39 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/expo/modules/androidglassview/AndroidGlassBottomTabs.kt +162 -0
  8. package/android/src/main/java/expo/modules/androidglassview/AndroidGlassButton.kt +45 -0
  9. package/android/src/main/java/expo/modules/androidglassview/AndroidGlassSlider.kt +84 -0
  10. package/android/src/main/java/expo/modules/androidglassview/AndroidGlassToggle.kt +59 -0
  11. package/android/src/main/java/expo/modules/androidglassview/AndroidGlassView.kt +21 -0
  12. package/android/src/main/java/expo/modules/androidglassview/ControlledProp.kt +30 -0
  13. package/android/src/main/java/expo/modules/androidglassview/ExpoAndroidGlassViewModule.kt +210 -0
  14. package/android/src/main/java/expo/modules/androidglassview/GlassHostView.kt +346 -0
  15. package/android/src/main/java/expo/modules/androidglassview/GlassRegistry.kt +31 -0
  16. package/android/src/main/java/expo/modules/androidglassview/GlassSurface.kt +96 -0
  17. package/android/src/main/java/expo/modules/androidglassview/ViewBackdrop.kt +151 -0
  18. package/android/src/main/java/expo/modules/androidglassview/backdrop/Backdrop.kt +25 -0
  19. package/android/src/main/java/expo/modules/androidglassview/backdrop/BackdropEffectScope.kt +82 -0
  20. package/android/src/main/java/expo/modules/androidglassview/backdrop/DrawBackdropModifier.kt +397 -0
  21. package/android/src/main/java/expo/modules/androidglassview/backdrop/Platform.kt +18 -0
  22. package/android/src/main/java/expo/modules/androidglassview/backdrop/RuntimeShader.kt +94 -0
  23. package/android/src/main/java/expo/modules/androidglassview/backdrop/RuntimeShaderCache.kt +28 -0
  24. package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/Backdrop.kt +45 -0
  25. package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/CanvasBackdrop.kt +43 -0
  26. package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/CombinedBackdrop.kt +107 -0
  27. package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/EmptyBackdrop.kt +33 -0
  28. package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/LayerBackdrop.kt +82 -0
  29. package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/LayerBackdropModifier.kt +77 -0
  30. package/android/src/main/java/expo/modules/androidglassview/backdrop/effects/Blur.kt +37 -0
  31. package/android/src/main/java/expo/modules/androidglassview/backdrop/effects/ColorFilter.kt +83 -0
  32. package/android/src/main/java/expo/modules/androidglassview/backdrop/effects/Lens.kt +117 -0
  33. package/android/src/main/java/expo/modules/androidglassview/backdrop/effects/RenderEffect.kt +41 -0
  34. package/android/src/main/java/expo/modules/androidglassview/backdrop/highlight/Highlight.kt +36 -0
  35. package/android/src/main/java/expo/modules/androidglassview/backdrop/highlight/HighlightModifier.kt +174 -0
  36. package/android/src/main/java/expo/modules/androidglassview/backdrop/highlight/HighlightStyle.kt +146 -0
  37. package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/InverseLayerScope.kt +138 -0
  38. package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/LayerRecorder.kt +34 -0
  39. package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/Outline.kt +26 -0
  40. package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/Paint.kt +24 -0
  41. package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/RenderEffect.kt +58 -0
  42. package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/Shaders.kt +206 -0
  43. package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/ShapeProvider.kt +52 -0
  44. package/android/src/main/java/expo/modules/androidglassview/backdrop/shadow/InnerShadow.kt +49 -0
  45. package/android/src/main/java/expo/modules/androidglassview/backdrop/shadow/InnerShadowModifier.kt +166 -0
  46. package/android/src/main/java/expo/modules/androidglassview/backdrop/shadow/Shadow.kt +35 -0
  47. package/android/src/main/java/expo/modules/androidglassview/backdrop/shadow/ShadowModifier.kt +145 -0
  48. package/android/src/main/java/expo/modules/androidglassview/capture/ViewBackdropCapture.kt +176 -0
  49. package/android/src/main/java/expo/modules/androidglassview/components/CapsuleShape.kt +10 -0
  50. package/android/src/main/java/expo/modules/androidglassview/components/DampedDragAnimation.kt +152 -0
  51. package/android/src/main/java/expo/modules/androidglassview/components/DragGestureInspector.kt +91 -0
  52. package/android/src/main/java/expo/modules/androidglassview/components/InteractiveHighlight.kt +127 -0
  53. package/android/src/main/java/expo/modules/androidglassview/components/LiquidBottomTabs.kt +471 -0
  54. package/android/src/main/java/expo/modules/androidglassview/components/LiquidButton.kt +111 -0
  55. package/android/src/main/java/expo/modules/androidglassview/components/LiquidSlider.kt +227 -0
  56. package/android/src/main/java/expo/modules/androidglassview/components/LiquidToggle.kt +220 -0
  57. package/android/src/main/java/expo/modules/androidglassview/components/TabsFrame.kt +18 -0
  58. package/build/AndroidGlassBottomTabs.android.d.ts +4 -0
  59. package/build/AndroidGlassBottomTabs.android.d.ts.map +1 -0
  60. package/build/AndroidGlassBottomTabs.android.js +42 -0
  61. package/build/AndroidGlassBottomTabs.android.js.map +1 -0
  62. package/build/AndroidGlassBottomTabs.d.ts +5 -0
  63. package/build/AndroidGlassBottomTabs.d.ts.map +1 -0
  64. package/build/AndroidGlassBottomTabs.js +34 -0
  65. package/build/AndroidGlassBottomTabs.js.map +1 -0
  66. package/build/AndroidGlassButton.android.d.ts +4 -0
  67. package/build/AndroidGlassButton.android.d.ts.map +1 -0
  68. package/build/AndroidGlassButton.android.js +32 -0
  69. package/build/AndroidGlassButton.android.js.map +1 -0
  70. package/build/AndroidGlassButton.d.ts +5 -0
  71. package/build/AndroidGlassButton.d.ts.map +1 -0
  72. package/build/AndroidGlassButton.js +38 -0
  73. package/build/AndroidGlassButton.js.map +1 -0
  74. package/build/AndroidGlassComponents.types.d.ts +71 -0
  75. package/build/AndroidGlassComponents.types.d.ts.map +1 -0
  76. package/build/AndroidGlassComponents.types.js +2 -0
  77. package/build/AndroidGlassComponents.types.js.map +1 -0
  78. package/build/AndroidGlassSlider.android.d.ts +4 -0
  79. package/build/AndroidGlassSlider.android.d.ts.map +1 -0
  80. package/build/AndroidGlassSlider.android.js +27 -0
  81. package/build/AndroidGlassSlider.android.js.map +1 -0
  82. package/build/AndroidGlassSlider.d.ts +5 -0
  83. package/build/AndroidGlassSlider.d.ts.map +1 -0
  84. package/build/AndroidGlassSlider.js +47 -0
  85. package/build/AndroidGlassSlider.js.map +1 -0
  86. package/build/AndroidGlassTab.d.ts +9 -0
  87. package/build/AndroidGlassTab.d.ts.map +1 -0
  88. package/build/AndroidGlassTab.js +22 -0
  89. package/build/AndroidGlassTab.js.map +1 -0
  90. package/build/AndroidGlassToggle.android.d.ts +4 -0
  91. package/build/AndroidGlassToggle.android.d.ts.map +1 -0
  92. package/build/AndroidGlassToggle.android.js +27 -0
  93. package/build/AndroidGlassToggle.android.js.map +1 -0
  94. package/build/AndroidGlassToggle.d.ts +5 -0
  95. package/build/AndroidGlassToggle.d.ts.map +1 -0
  96. package/build/AndroidGlassToggle.js +7 -0
  97. package/build/AndroidGlassToggle.js.map +1 -0
  98. package/build/AndroidGlassView.android.d.ts +4 -0
  99. package/build/AndroidGlassView.android.d.ts.map +1 -0
  100. package/build/AndroidGlassView.android.js +10 -0
  101. package/build/AndroidGlassView.android.js.map +1 -0
  102. package/build/AndroidGlassView.d.ts +8 -0
  103. package/build/AndroidGlassView.d.ts.map +1 -0
  104. package/build/AndroidGlassView.js +18 -0
  105. package/build/AndroidGlassView.js.map +1 -0
  106. package/build/AndroidGlassView.types.d.ts +34 -0
  107. package/build/AndroidGlassView.types.d.ts.map +1 -0
  108. package/build/AndroidGlassView.types.js +2 -0
  109. package/build/AndroidGlassView.types.js.map +1 -0
  110. package/build/index.d.ts +10 -0
  111. package/build/index.d.ts.map +1 -0
  112. package/build/index.js +12 -0
  113. package/build/index.js.map +1 -0
  114. package/build/useMinimizeOnScroll.d.ts +17 -0
  115. package/build/useMinimizeOnScroll.d.ts.map +1 -0
  116. package/build/useMinimizeOnScroll.js +39 -0
  117. package/build/useMinimizeOnScroll.js.map +1 -0
  118. package/build/utils.d.ts +5 -0
  119. package/build/utils.d.ts.map +1 -0
  120. package/build/utils.js +9 -0
  121. package/build/utils.js.map +1 -0
  122. package/expo-module.config.json +6 -0
  123. package/package.json +58 -0
  124. package/src/AndroidGlassBottomTabs.android.tsx +93 -0
  125. package/src/AndroidGlassBottomTabs.tsx +59 -0
  126. package/src/AndroidGlassButton.android.tsx +70 -0
  127. package/src/AndroidGlassButton.tsx +70 -0
  128. package/src/AndroidGlassComponents.types.ts +76 -0
  129. package/src/AndroidGlassSlider.android.tsx +70 -0
  130. package/src/AndroidGlassSlider.tsx +78 -0
  131. package/src/AndroidGlassTab.tsx +29 -0
  132. package/src/AndroidGlassToggle.android.tsx +64 -0
  133. package/src/AndroidGlassToggle.tsx +22 -0
  134. package/src/AndroidGlassView.android.tsx +41 -0
  135. package/src/AndroidGlassView.tsx +41 -0
  136. package/src/AndroidGlassView.types.ts +34 -0
  137. package/src/index.ts +11 -0
  138. package/src/useMinimizeOnScroll.ts +53 -0
  139. package/src/utils.ts +10 -0
  140. package/tsconfig.json +28 -0
@@ -0,0 +1,227 @@
1
+ /*
2
+ * Copyright 2025 Kyant (https://github.com/Kyant0/AndroidLiquidGlass)
3
+ * Licensed under the Apache License, Version 2.0. See THIRD_PARTY_NOTICES.md.
4
+ *
5
+ * From the Backdrop Catalog sample app. Changes from upstream: package relocated, made internal,
6
+ * configurable colours, an onValueChangeFinished callback, and the whole slider takes drags
7
+ * (pressing anywhere moves the thumb under the finger) instead of only the thumb, with taps
8
+ * on the track handled by the same gesture.
9
+ */
10
+ package expo.modules.androidglassview.components
11
+
12
+ import androidx.compose.foundation.background
13
+ import androidx.compose.foundation.isSystemInDarkTheme
14
+ import androidx.compose.foundation.layout.Box
15
+ import androidx.compose.foundation.layout.BoxWithConstraints
16
+ import androidx.compose.foundation.layout.fillMaxSize
17
+ import androidx.compose.foundation.layout.fillMaxWidth
18
+ import androidx.compose.foundation.layout.height
19
+ import androidx.compose.foundation.layout.size
20
+ import androidx.compose.runtime.Composable
21
+ import androidx.compose.runtime.LaunchedEffect
22
+ import androidx.compose.runtime.remember
23
+ import androidx.compose.runtime.rememberCoroutineScope
24
+ import androidx.compose.runtime.snapshotFlow
25
+ import androidx.compose.ui.Alignment
26
+ import androidx.compose.ui.Modifier
27
+ import androidx.compose.ui.draw.clip
28
+ import androidx.compose.ui.graphics.Color
29
+ import androidx.compose.ui.graphics.drawscope.scale
30
+ import androidx.compose.ui.graphics.graphicsLayer
31
+ import androidx.compose.ui.input.pointer.pointerInput
32
+ import androidx.compose.ui.layout.layout
33
+ import androidx.compose.ui.platform.LocalLayoutDirection
34
+ import androidx.compose.ui.unit.LayoutDirection
35
+ import androidx.compose.ui.unit.dp
36
+ import androidx.compose.ui.util.fastCoerceIn
37
+ import androidx.compose.ui.util.fastRoundToInt
38
+ import androidx.compose.ui.util.lerp
39
+ import expo.modules.androidglassview.backdrop.Backdrop
40
+ import expo.modules.androidglassview.backdrop.backdrops.layerBackdrop
41
+ import expo.modules.androidglassview.backdrop.backdrops.rememberBackdrop
42
+ import expo.modules.androidglassview.backdrop.backdrops.rememberCombinedBackdrop
43
+ import expo.modules.androidglassview.backdrop.backdrops.rememberLayerBackdrop
44
+ import expo.modules.androidglassview.backdrop.drawBackdrop
45
+ import expo.modules.androidglassview.backdrop.effects.blur
46
+ import expo.modules.androidglassview.backdrop.effects.lens
47
+ import expo.modules.androidglassview.backdrop.highlight.Highlight
48
+ import expo.modules.androidglassview.backdrop.shadow.InnerShadow
49
+ import expo.modules.androidglassview.backdrop.shadow.Shadow
50
+ import kotlinx.coroutines.flow.collectLatest
51
+
52
+ @Composable
53
+ internal fun LiquidSlider(
54
+ value: () -> Float,
55
+ onValueChange: (Float) -> Unit,
56
+ onValueChangeFinished: () -> Unit,
57
+ onDragStarted: () -> Unit,
58
+ valueRange: ClosedFloatingPointRange<Float>,
59
+ visibilityThreshold: Float,
60
+ backdrop: Backdrop,
61
+ modifier: Modifier = Modifier,
62
+ accentColor: Color? = null,
63
+ trackColor: Color? = null
64
+ ) {
65
+ val isLightTheme = !isSystemInDarkTheme()
66
+ val accent = accentColor
67
+ ?: if (isLightTheme) Color(0xFF0088FF)
68
+ else Color(0xFF0091FF)
69
+ val track = trackColor
70
+ ?: if (isLightTheme) Color(0xFF787878).copy(0.2f)
71
+ else Color(0xFF787880).copy(0.36f)
72
+
73
+ val trackBackdrop = rememberLayerBackdrop()
74
+
75
+ BoxWithConstraints(
76
+ modifier.fillMaxWidth(),
77
+ contentAlignment = Alignment.CenterStart
78
+ ) {
79
+ val trackWidth = constraints.maxWidth
80
+
81
+ val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
82
+ val animationScope = rememberCoroutineScope()
83
+ val dampedDragAnimation = remember(animationScope) {
84
+ DampedDragAnimation(
85
+ animationScope = animationScope,
86
+ initialValue = value(),
87
+ valueRange = valueRange,
88
+ visibilityThreshold = visibilityThreshold,
89
+ initialScale = 1f,
90
+ pressedScale = 1.5f,
91
+ onDragStarted = {},
92
+ onDragStopped = {},
93
+ onDrag = { _, _ -> }
94
+ )
95
+ }
96
+ LaunchedEffect(dampedDragAnimation) {
97
+ snapshotFlow { value() }
98
+ .collectLatest { value ->
99
+ if (dampedDragAnimation.targetValue != value) {
100
+ dampedDragAnimation.updateValue(value)
101
+ }
102
+ }
103
+ }
104
+
105
+ val valueAt: (Float) -> Float = { x ->
106
+ val fraction = (x / trackWidth).fastCoerceIn(0f, 1f)
107
+ val position = if (isLtr) fraction else 1f - fraction
108
+ valueRange.start + (valueRange.endInclusive - valueRange.start) * position
109
+ }
110
+
111
+ Box(
112
+ Modifier
113
+ .fillMaxSize()
114
+ .pointerInput(dampedDragAnimation, trackWidth, isLtr) {
115
+ inspectDragGestures(
116
+ onDragStart = { down ->
117
+ onDragStarted()
118
+ dampedDragAnimation.press()
119
+ onValueChange(valueAt(down.position.x))
120
+ },
121
+ onDragEnd = { up ->
122
+ // On a busy frame the last move can lag behind; the lift point wins.
123
+ onValueChange(valueAt(up.position.x))
124
+ dampedDragAnimation.release()
125
+ onValueChangeFinished()
126
+ },
127
+ onDragCancel = {
128
+ dampedDragAnimation.release()
129
+ onValueChangeFinished()
130
+ }
131
+ ) { change, _ ->
132
+ onValueChange(valueAt(change.position.x))
133
+ }
134
+ },
135
+ contentAlignment = Alignment.CenterStart
136
+ ) {
137
+ Box(Modifier.layerBackdrop(trackBackdrop)) {
138
+ Box(
139
+ Modifier
140
+ .clip(CapsuleShape)
141
+ .background(track)
142
+ .height(6f.dp)
143
+ .fillMaxWidth()
144
+ )
145
+
146
+ Box(
147
+ Modifier
148
+ .clip(CapsuleShape)
149
+ .background(accent)
150
+ .height(6f.dp)
151
+ .layout { measurable, constraints ->
152
+ val placeable = measurable.measure(constraints)
153
+ val width = (constraints.maxWidth * dampedDragAnimation.progress).fastRoundToInt()
154
+ layout(width, placeable.height) {
155
+ placeable.place(0, 0)
156
+ }
157
+ }
158
+ )
159
+ }
160
+
161
+ Box(
162
+ Modifier
163
+ .graphicsLayer {
164
+ translationX =
165
+ (-size.width / 2f + trackWidth * dampedDragAnimation.progress)
166
+ .fastCoerceIn(-size.width / 4f, trackWidth - size.width * 3f / 4f) * if (isLtr) 1f else -1f
167
+ }
168
+ .drawBackdrop(
169
+ backdrop = rememberCombinedBackdrop(
170
+ backdrop,
171
+ rememberBackdrop(trackBackdrop) { drawBackdrop ->
172
+ val progress = dampedDragAnimation.pressProgress
173
+ val scaleX = lerp(2f / 3f, 1f, progress)
174
+ val scaleY = lerp(0f, 1f, progress)
175
+ scale(scaleX, scaleY) {
176
+ drawBackdrop()
177
+ }
178
+ }
179
+ ),
180
+ shape = { CapsuleShape },
181
+ effects = {
182
+ val progress = dampedDragAnimation.pressProgress
183
+ blur(8f.dp.toPx() * (1f - progress))
184
+ lens(
185
+ 10f.dp.toPx() * progress,
186
+ 14f.dp.toPx() * progress,
187
+ chromaticAberration = true
188
+ )
189
+ },
190
+ highlight = {
191
+ val progress = dampedDragAnimation.pressProgress
192
+ Highlight.Ambient.copy(
193
+ width = Highlight.Ambient.width / 1.5f,
194
+ blurRadius = Highlight.Ambient.blurRadius / 1.5f,
195
+ alpha = progress
196
+ )
197
+ },
198
+ shadow = {
199
+ Shadow(
200
+ radius = 4f.dp,
201
+ color = Color.Black.copy(alpha = 0.05f)
202
+ )
203
+ },
204
+ innerShadow = {
205
+ val progress = dampedDragAnimation.pressProgress
206
+ InnerShadow(
207
+ radius = 4f.dp * progress,
208
+ alpha = progress
209
+ )
210
+ },
211
+ layerBlock = {
212
+ scaleX = dampedDragAnimation.scaleX
213
+ scaleY = dampedDragAnimation.scaleY
214
+ val velocity = dampedDragAnimation.velocity / 10f
215
+ scaleX /= 1f - (velocity * 0.75f).fastCoerceIn(-0.2f, 0.2f)
216
+ scaleY *= 1f - (velocity * 0.25f).fastCoerceIn(-0.2f, 0.2f)
217
+ },
218
+ onDrawSurface = {
219
+ val progress = dampedDragAnimation.pressProgress
220
+ drawRect(Color.White.copy(alpha = 1f - progress))
221
+ }
222
+ )
223
+ .size(40f.dp, 24f.dp)
224
+ )
225
+ }
226
+ }
227
+ }
@@ -0,0 +1,220 @@
1
+ /*
2
+ * Copyright 2025 Kyant (https://github.com/Kyant0/AndroidLiquidGlass)
3
+ * Licensed under the Apache License, Version 2.0. See THIRD_PARTY_NOTICES.md.
4
+ *
5
+ * From the Backdrop Catalog sample app. Changes from upstream: package relocated, made internal,
6
+ * configurable colours, a cancelled drag (e.g. taken over by a scrolling parent) no longer
7
+ * toggles the switch, and the whole switch (not only the thumb) takes taps and drags.
8
+ */
9
+ package expo.modules.androidglassview.components
10
+
11
+ import androidx.compose.foundation.isSystemInDarkTheme
12
+ import androidx.compose.foundation.layout.Box
13
+ import androidx.compose.foundation.layout.size
14
+ import androidx.compose.runtime.Composable
15
+ import androidx.compose.runtime.LaunchedEffect
16
+ import androidx.compose.runtime.getValue
17
+ import androidx.compose.runtime.mutableFloatStateOf
18
+ import androidx.compose.runtime.mutableStateOf
19
+ import androidx.compose.runtime.remember
20
+ import androidx.compose.runtime.rememberCoroutineScope
21
+ import androidx.compose.runtime.setValue
22
+ import androidx.compose.runtime.snapshotFlow
23
+ import androidx.compose.ui.Alignment
24
+ import androidx.compose.ui.Modifier
25
+ import androidx.compose.ui.draw.clip
26
+ import androidx.compose.ui.draw.drawBehind
27
+ import androidx.compose.ui.graphics.Color
28
+ import androidx.compose.ui.graphics.drawscope.scale
29
+ import androidx.compose.ui.graphics.graphicsLayer
30
+ import androidx.compose.ui.graphics.lerp
31
+ import androidx.compose.ui.platform.LocalDensity
32
+ import androidx.compose.ui.platform.LocalLayoutDirection
33
+ import androidx.compose.ui.semantics.Role
34
+ import androidx.compose.ui.semantics.role
35
+ import androidx.compose.ui.semantics.semantics
36
+ import androidx.compose.ui.unit.LayoutDirection
37
+ import androidx.compose.ui.unit.dp
38
+ import androidx.compose.ui.util.fastCoerceIn
39
+ import androidx.compose.ui.util.lerp
40
+ import expo.modules.androidglassview.backdrop.Backdrop
41
+ import expo.modules.androidglassview.backdrop.backdrops.layerBackdrop
42
+ import expo.modules.androidglassview.backdrop.backdrops.rememberBackdrop
43
+ import expo.modules.androidglassview.backdrop.backdrops.rememberCombinedBackdrop
44
+ import expo.modules.androidglassview.backdrop.backdrops.rememberLayerBackdrop
45
+ import expo.modules.androidglassview.backdrop.drawBackdrop
46
+ import expo.modules.androidglassview.backdrop.effects.blur
47
+ import expo.modules.androidglassview.backdrop.effects.lens
48
+ import expo.modules.androidglassview.backdrop.highlight.Highlight
49
+ import expo.modules.androidglassview.backdrop.shadow.InnerShadow
50
+ import expo.modules.androidglassview.backdrop.shadow.Shadow
51
+ import kotlinx.coroutines.flow.collectLatest
52
+
53
+ @Composable
54
+ internal fun LiquidToggle(
55
+ selected: () -> Boolean,
56
+ onSelect: (Boolean) -> Unit,
57
+ backdrop: Backdrop,
58
+ modifier: Modifier = Modifier,
59
+ accentColor: Color? = null,
60
+ trackColor: Color? = null
61
+ ) {
62
+ val isLightTheme = !isSystemInDarkTheme()
63
+ val accent = accentColor
64
+ ?: if (isLightTheme) Color(0xFF34C759)
65
+ else Color(0xFF30D158)
66
+ val track = trackColor
67
+ ?: if (isLightTheme) Color(0xFF787878).copy(0.2f)
68
+ else Color(0xFF787880).copy(0.36f)
69
+
70
+ val density = LocalDensity.current
71
+ val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
72
+ val dragWidth = with(density) { 20f.dp.toPx() }
73
+ val animationScope = rememberCoroutineScope()
74
+ var didDrag by remember { mutableStateOf(false) }
75
+ var fraction by remember { mutableFloatStateOf(if (selected()) 1f else 0f) }
76
+ val dampedDragAnimation = remember(animationScope) {
77
+ DampedDragAnimation(
78
+ animationScope = animationScope,
79
+ initialValue = fraction,
80
+ valueRange = 0f..1f,
81
+ visibilityThreshold = 0.001f,
82
+ initialScale = 1f,
83
+ pressedScale = 1.5f,
84
+ onDragStarted = {},
85
+ onDragStopped = { cancelled ->
86
+ when {
87
+ cancelled -> {
88
+ didDrag = false
89
+ fraction = if (selected()) 1f else 0f
90
+ }
91
+
92
+ didDrag -> {
93
+ fraction = if (targetValue >= 0.5f) 1f else 0f
94
+ onSelect(fraction == 1f)
95
+ didDrag = false
96
+ }
97
+
98
+ else -> {
99
+ fraction = if (selected()) 0f else 1f
100
+ onSelect(fraction == 1f)
101
+ }
102
+ }
103
+ },
104
+ onDrag = { _, dragAmount ->
105
+ if (!didDrag) {
106
+ didDrag = dragAmount.x != 0f
107
+ }
108
+ val delta = dragAmount.x / dragWidth
109
+ fraction =
110
+ if (isLtr) (fraction + delta).fastCoerceIn(0f, 1f)
111
+ else (fraction - delta).fastCoerceIn(0f, 1f)
112
+ }
113
+ )
114
+ }
115
+ LaunchedEffect(dampedDragAnimation) {
116
+ snapshotFlow { fraction }
117
+ .collectLatest { fraction ->
118
+ dampedDragAnimation.updateValue(fraction)
119
+ }
120
+ }
121
+ LaunchedEffect(selected) {
122
+ snapshotFlow { selected() }
123
+ .collectLatest { isSelected ->
124
+ val target = if (isSelected) 1f else 0f
125
+ if (target != fraction) {
126
+ fraction = target
127
+ dampedDragAnimation.animateToValue(target)
128
+ }
129
+ }
130
+ }
131
+
132
+ val trackBackdrop = rememberLayerBackdrop()
133
+
134
+ // Unlike upstream (thumb only), the whole switch takes taps and drags.
135
+ Box(
136
+ modifier.then(dampedDragAnimation.modifier),
137
+ contentAlignment = Alignment.CenterStart
138
+ ) {
139
+ Box(
140
+ Modifier
141
+ .layerBackdrop(trackBackdrop)
142
+ .clip(CapsuleShape)
143
+ .drawBehind {
144
+ val fraction = dampedDragAnimation.value
145
+ drawRect(lerp(track, accent, fraction))
146
+ }
147
+ .size(64f.dp, 28f.dp)
148
+ )
149
+
150
+ Box(
151
+ Modifier
152
+ .graphicsLayer {
153
+ val fraction = dampedDragAnimation.value
154
+ val padding = 2f.dp.toPx()
155
+ translationX =
156
+ if (isLtr) lerp(padding, padding + dragWidth, fraction)
157
+ else lerp(-padding, -(padding + dragWidth), fraction)
158
+ }
159
+ .semantics {
160
+ role = Role.Switch
161
+ }
162
+ .drawBackdrop(
163
+ backdrop = rememberCombinedBackdrop(
164
+ backdrop,
165
+ rememberBackdrop(trackBackdrop) { drawBackdrop ->
166
+ val progress = dampedDragAnimation.pressProgress
167
+ val scaleX = lerp(2f / 3f, 0.75f, progress)
168
+ val scaleY = lerp(0f, 0.75f, progress)
169
+ scale(scaleX, scaleY) {
170
+ drawBackdrop()
171
+ }
172
+ }
173
+ ),
174
+ shape = { CapsuleShape },
175
+ effects = {
176
+ val progress = dampedDragAnimation.pressProgress
177
+ blur(8f.dp.toPx() * (1f - progress))
178
+ lens(
179
+ 5f.dp.toPx() * progress,
180
+ 10f.dp.toPx() * progress,
181
+ chromaticAberration = true
182
+ )
183
+ },
184
+ highlight = {
185
+ val progress = dampedDragAnimation.pressProgress
186
+ Highlight.Ambient.copy(
187
+ width = Highlight.Ambient.width / 1.5f,
188
+ blurRadius = Highlight.Ambient.blurRadius / 1.5f,
189
+ alpha = progress
190
+ )
191
+ },
192
+ shadow = {
193
+ Shadow(
194
+ radius = 4f.dp,
195
+ color = Color.Black.copy(alpha = 0.05f)
196
+ )
197
+ },
198
+ innerShadow = {
199
+ val progress = dampedDragAnimation.pressProgress
200
+ InnerShadow(
201
+ radius = 4f.dp * progress,
202
+ alpha = progress
203
+ )
204
+ },
205
+ layerBlock = {
206
+ scaleX = dampedDragAnimation.scaleX
207
+ scaleY = dampedDragAnimation.scaleY
208
+ val velocity = dampedDragAnimation.velocity / 50f
209
+ scaleX /= 1f - (velocity * 0.75f).fastCoerceIn(-0.2f, 0.2f)
210
+ scaleY *= 1f - (velocity * 0.25f).fastCoerceIn(-0.2f, 0.2f)
211
+ },
212
+ onDrawSurface = {
213
+ val progress = dampedDragAnimation.pressProgress
214
+ drawRect(Color.White.copy(alpha = 1f - progress))
215
+ }
216
+ )
217
+ .size(40f.dp, 24f.dp)
218
+ )
219
+ }
220
+ }
@@ -0,0 +1,18 @@
1
+ package expo.modules.androidglassview.components
2
+
3
+ /**
4
+ * Where the tabs are drawn right now, in the host's coordinates. React Native lays the tabs out
5
+ * for the expanded bar; while the bar minimizes, [mapX] moves a point from those slots to the
6
+ * current, narrower ones.
7
+ */
8
+ internal class TabsFrame(
9
+ /** 0 = expanded, 1 = minimized. */
10
+ val minimizeProgress: Float,
11
+ private val expandedSlotsLeft: Float,
12
+ private val slotsLeft: Float,
13
+ private val slotsScale: Float,
14
+ /** Vertical centre of the bar. */
15
+ val centerY: Float
16
+ ) {
17
+ fun mapX(x: Float): Float = slotsLeft + (x - expandedSlotsLeft) * slotsScale
18
+ }
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';
3
+ export default function AndroidGlassBottomTabs({ selectedIndex, onTabSelected, minimized, onMinimizedChange, accentColor, containerColor, children, style, ...rest }: AndroidGlassBottomTabsProps): React.JSX.Element;
4
+ //# sourceMappingURL=AndroidGlassBottomTabs.android.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AndroidGlassBottomTabs.android.d.ts","sourceRoot":"","sources":["../src/AndroidGlassBottomTabs.android.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAsBlF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,aAAa,EACb,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,KAAK,EACL,GAAG,IAAI,EACR,EAAE,2BAA2B,qBAyC7B"}
@@ -0,0 +1,42 @@
1
+ import { requireNativeView } from 'expo';
2
+ import * as React from 'react';
3
+ import { StyleSheet, View } from 'react-native';
4
+ import { toNativeColor } from './utils';
5
+ const NativeAndroidGlassBottomTabs = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassBottomTabs');
6
+ export default function AndroidGlassBottomTabs({ selectedIndex, onTabSelected, minimized, onMinimizedChange, accentColor, containerColor, children, style, ...rest }) {
7
+ const tabs = React.Children.toArray(children).filter(React.isValidElement);
8
+ // Without a `selectedIndex` prop, the bar keeps the user's selection.
9
+ const [ownIndex, setOwnIndex] = React.useState(0);
10
+ // Sent back with `selectedIndex`, so the native side can tell a stale index (JS still catching
11
+ // up with earlier selections) from a current one.
12
+ const [eventCount, setEventCount] = React.useState(0);
13
+ const selected = selectedIndex ?? ownIndex;
14
+ return (<NativeAndroidGlassBottomTabs accessibilityRole="tablist" {...rest} style={[styles.bar, style]} selectedIndex={selected} tabsCount={tabs.length} mostRecentEventCount={eventCount} minimized={minimized ?? false} accentColor={toNativeColor(accentColor)} containerColor={toNativeColor(containerColor)} onTabSelected={(event) => {
15
+ const { index, eventCount: count } = event.nativeEvent;
16
+ setEventCount((current) => Math.max(current, count));
17
+ setOwnIndex(index);
18
+ onTabSelected?.(index);
19
+ }} onMinimizedChange={(event) => onMinimizedChange?.(event.nativeEvent.minimized)}>
20
+ {tabs.map((tab, index) => (
21
+ // The native bar handles taps and drags, and draws these views itself (inside the glass
22
+ // and, tinted, under the droplet), so they must stay real views and not take touches.
23
+ <View key={tab.key ?? index} collapsable={false} pointerEvents="none" accessibilityRole="tab" accessibilityState={{ selected: index === selected }} style={styles.tab}>
24
+ {tab}
25
+ </View>))}
26
+ </NativeAndroidGlassBottomTabs>);
27
+ }
28
+ const styles = StyleSheet.create({
29
+ // 4 dp side padding keeps the tabs aligned with the droplet: (width - 8 dp) / count each.
30
+ bar: {
31
+ height: 64,
32
+ flexDirection: 'row',
33
+ paddingHorizontal: 4,
34
+ },
35
+ tab: {
36
+ flex: 1,
37
+ alignItems: 'center',
38
+ justifyContent: 'center',
39
+ gap: 2,
40
+ },
41
+ });
42
+ //# sourceMappingURL=AndroidGlassBottomTabs.android.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AndroidGlassBottomTabs.android.js","sourceRoot":"","sources":["../src/AndroidGlassBottomTabs.android.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAkB1D,MAAM,4BAA4B,GAChC,iBAAiB,CAAC,sBAAsB,EAAE,wBAAwB,CAAC,CAAC;AAEtE,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,aAAa,EACb,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,KAAK,EACL,GAAG,IAAI,EACqB;IAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC3E,sEAAsE;IACtE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClD,+FAA+F;IAC/F,kDAAkD;IAClD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,aAAa,IAAI,QAAQ,CAAC;IAC3C,OAAO,CACL,CAAC,4BAA4B,CAC3B,iBAAiB,CAAC,SAAS,CAC3B,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAC3B,aAAa,CAAC,CAAC,QAAQ,CAAC,CACxB,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CACvB,oBAAoB,CAAC,CAAC,UAAU,CAAC,CACjC,SAAS,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,CAC9B,WAAW,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CACxC,cAAc,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAC9C,aAAa,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACvB,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC;YACvD,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YACrD,WAAW,CAAC,KAAK,CAAC,CAAC;YACnB,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC,CACF,iBAAiB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAC/E;MAAA,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;QACxB,wFAAwF;QACxF,sFAAsF;QACtF,CAAC,IAAI,CACH,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,KAAK,CAAC,CACtB,WAAW,CAAC,CAAC,KAAK,CAAC,CACnB,aAAa,CAAC,MAAM,CACpB,iBAAiB,CAAC,KAAK,CACvB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,KAAK,QAAQ,EAAE,CAAC,CACrD,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAClB;UAAA,CAAC,GAAG,CACN;QAAA,EAAE,IAAI,CAAC,CACR,CAAC,CACJ;IAAA,EAAE,4BAA4B,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,0FAA0F;IAC1F,GAAG,EAAE;QACH,MAAM,EAAE,EAAE;QACV,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,CAAC;KACrB;IACD,GAAG,EAAE;QACH,IAAI,EAAE,CAAC;QACP,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,GAAG,EAAE,CAAC;KACP;CACF,CAAC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { StyleSheet, View } from 'react-native';\n\nimport type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';\nimport { type NativeColor, toNativeColor } from './utils';\n\ntype IndexEvent = { nativeEvent: { index: number; eventCount: number } };\ntype MinimizedEvent = { nativeEvent: { minimized: boolean } };\n\ntype NativeAndroidGlassBottomTabsProps = Omit<\n AndroidGlassBottomTabsProps,\n 'onTabSelected' | 'onMinimizedChange' | 'accentColor' | 'containerColor'\n> & {\n tabsCount: number;\n /** Count of the last selection event handled here (see ControlledProp on the native side). */\n mostRecentEventCount: number;\n onTabSelected: (event: IndexEvent) => void;\n onMinimizedChange: (event: MinimizedEvent) => void;\n accentColor?: NativeColor;\n containerColor?: NativeColor;\n};\n\nconst NativeAndroidGlassBottomTabs: React.ComponentType<NativeAndroidGlassBottomTabsProps> =\n requireNativeView('ExpoAndroidGlassView', 'AndroidGlassBottomTabs');\n\nexport default function AndroidGlassBottomTabs({\n selectedIndex,\n onTabSelected,\n minimized,\n onMinimizedChange,\n accentColor,\n containerColor,\n children,\n style,\n ...rest\n}: AndroidGlassBottomTabsProps) {\n const tabs = React.Children.toArray(children).filter(React.isValidElement);\n // Without a `selectedIndex` prop, the bar keeps the user's selection.\n const [ownIndex, setOwnIndex] = React.useState(0);\n // Sent back with `selectedIndex`, so the native side can tell a stale index (JS still catching\n // up with earlier selections) from a current one.\n const [eventCount, setEventCount] = React.useState(0);\n const selected = selectedIndex ?? ownIndex;\n return (\n <NativeAndroidGlassBottomTabs\n accessibilityRole=\"tablist\"\n {...rest}\n style={[styles.bar, style]}\n selectedIndex={selected}\n tabsCount={tabs.length}\n mostRecentEventCount={eventCount}\n minimized={minimized ?? false}\n accentColor={toNativeColor(accentColor)}\n containerColor={toNativeColor(containerColor)}\n onTabSelected={(event) => {\n const { index, eventCount: count } = event.nativeEvent;\n setEventCount((current) => Math.max(current, count));\n setOwnIndex(index);\n onTabSelected?.(index);\n }}\n onMinimizedChange={(event) => onMinimizedChange?.(event.nativeEvent.minimized)}>\n {tabs.map((tab, index) => (\n // The native bar handles taps and drags, and draws these views itself (inside the glass\n // and, tinted, under the droplet), so they must stay real views and not take touches.\n <View\n key={tab.key ?? index}\n collapsable={false}\n pointerEvents=\"none\"\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: index === selected }}\n style={styles.tab}>\n {tab}\n </View>\n ))}\n </NativeAndroidGlassBottomTabs>\n );\n}\n\nconst styles = StyleSheet.create({\n // 4 dp side padding keeps the tabs aligned with the droplet: (width - 8 dp) / count each.\n bar: {\n height: 64,\n flexDirection: 'row',\n paddingHorizontal: 4,\n },\n tab: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n },\n});\n"]}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';
3
+ /** iOS and web fallback: a plain tab bar with the same API (it does not minimize). */
4
+ export default function AndroidGlassBottomTabs({ selectedIndex, onTabSelected, minimized: _minimized, onMinimizedChange: _onMinimizedChange, accentColor: _accentColor, containerColor, children, style, ...rest }: AndroidGlassBottomTabsProps): React.JSX.Element;
5
+ //# sourceMappingURL=AndroidGlassBottomTabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AndroidGlassBottomTabs.d.ts","sourceRoot":"","sources":["../src/AndroidGlassBottomTabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAElF,sFAAsF;AACtF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,aAAiB,EACjB,aAAa,EACb,SAAS,EAAE,UAAU,EACrB,iBAAiB,EAAE,kBAAkB,EACrC,WAAW,EAAE,YAAY,EACzB,cAAc,EACd,QAAQ,EACR,KAAK,EACL,GAAG,IAAI,EACR,EAAE,2BAA2B,qBAuB7B"}
@@ -0,0 +1,34 @@
1
+ import * as React from 'react';
2
+ import { Pressable, StyleSheet, View } from 'react-native';
3
+ /** iOS and web fallback: a plain tab bar with the same API (it does not minimize). */
4
+ export default function AndroidGlassBottomTabs({ selectedIndex = 0, onTabSelected, minimized: _minimized, onMinimizedChange: _onMinimizedChange, accentColor: _accentColor, containerColor, children, style, ...rest }) {
5
+ const tabs = React.Children.toArray(children).filter(React.isValidElement);
6
+ return (<View accessibilityRole="tablist" {...rest} style={[
7
+ styles.bar,
8
+ { backgroundColor: containerColor ?? 'rgba(250, 250, 250, 0.9)' },
9
+ style,
10
+ ]}>
11
+ {tabs.map((tab, index) => (<Pressable key={tab.key ?? index} accessibilityRole="tab" accessibilityState={{ selected: index === selectedIndex }} onPress={() => onTabSelected?.(index)} style={[styles.tab, index === selectedIndex && styles.selected]}>
12
+ {tab}
13
+ </Pressable>))}
14
+ </View>);
15
+ }
16
+ const styles = StyleSheet.create({
17
+ bar: {
18
+ height: 64,
19
+ flexDirection: 'row',
20
+ padding: 4,
21
+ borderRadius: 32,
22
+ },
23
+ tab: {
24
+ flex: 1,
25
+ alignItems: 'center',
26
+ justifyContent: 'center',
27
+ gap: 2,
28
+ borderRadius: 28,
29
+ },
30
+ selected: {
31
+ backgroundColor: 'rgba(0, 0, 0, 0.08)',
32
+ },
33
+ });
34
+ //# sourceMappingURL=AndroidGlassBottomTabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AndroidGlassBottomTabs.js","sourceRoot":"","sources":["../src/AndroidGlassBottomTabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAI3D,sFAAsF;AACtF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,aAAa,GAAG,CAAC,EACjB,aAAa,EACb,SAAS,EAAE,UAAU,EACrB,iBAAiB,EAAE,kBAAkB,EACrC,WAAW,EAAE,YAAY,EACzB,cAAc,EACd,QAAQ,EACR,KAAK,EACL,GAAG,IAAI,EACqB;IAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC3E,OAAO,CACL,CAAC,IAAI,CACH,iBAAiB,CAAC,SAAS,CAC3B,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC;YACL,MAAM,CAAC,GAAG;YACV,EAAE,eAAe,EAAE,cAAc,IAAI,0BAA0B,EAAE;YACjE,KAAK;SACN,CAAC,CACF;MAAA,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CACxB,CAAC,SAAS,CACR,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,KAAK,CAAC,CACtB,iBAAiB,CAAC,KAAK,CACvB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,KAAK,aAAa,EAAE,CAAC,CAC1D,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC,CACtC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,KAAK,aAAa,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAChE;UAAA,CAAC,GAAG,CACN;QAAA,EAAE,SAAS,CAAC,CACb,CAAC,CACJ;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,GAAG,EAAE;QACH,MAAM,EAAE,EAAE;QACV,aAAa,EAAE,KAAK;QACpB,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,EAAE;KACjB;IACD,GAAG,EAAE;QACH,IAAI,EAAE,CAAC;QACP,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,GAAG,EAAE,CAAC;QACN,YAAY,EAAE,EAAE;KACjB;IACD,QAAQ,EAAE;QACR,eAAe,EAAE,qBAAqB;KACvC;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { Pressable, StyleSheet, View } from 'react-native';\n\nimport type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';\n\n/** iOS and web fallback: a plain tab bar with the same API (it does not minimize). */\nexport default function AndroidGlassBottomTabs({\n selectedIndex = 0,\n onTabSelected,\n minimized: _minimized,\n onMinimizedChange: _onMinimizedChange,\n accentColor: _accentColor,\n containerColor,\n children,\n style,\n ...rest\n}: AndroidGlassBottomTabsProps) {\n const tabs = React.Children.toArray(children).filter(React.isValidElement);\n return (\n <View\n accessibilityRole=\"tablist\"\n {...rest}\n style={[\n styles.bar,\n { backgroundColor: containerColor ?? 'rgba(250, 250, 250, 0.9)' },\n style,\n ]}>\n {tabs.map((tab, index) => (\n <Pressable\n key={tab.key ?? index}\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: index === selectedIndex }}\n onPress={() => onTabSelected?.(index)}\n style={[styles.tab, index === selectedIndex && styles.selected]}>\n {tab}\n </Pressable>\n ))}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n bar: {\n height: 64,\n flexDirection: 'row',\n padding: 4,\n borderRadius: 32,\n },\n tab: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n borderRadius: 28,\n },\n selected: {\n backgroundColor: 'rgba(0, 0, 0, 0.08)',\n },\n});\n"]}
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import type { AndroidGlassButtonProps } from './AndroidGlassComponents.types';
3
+ export default function AndroidGlassButton({ onPress, title, titleStyle, cornerRadius, tintColor, surfaceColor, fallbackColor, style, children, ...rest }: AndroidGlassButtonProps): React.JSX.Element;
4
+ //# sourceMappingURL=AndroidGlassButton.android.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AndroidGlassButton.android.d.ts","sourceRoot":"","sources":["../src/AndroidGlassButton.android.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAgB9E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,OAAO,EACP,KAAK,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,aAAa,EACb,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,uBAAuB,qBAoBzB"}
@@ -0,0 +1,32 @@
1
+ import { requireNativeView } from 'expo';
2
+ import * as React from 'react';
3
+ import { StyleSheet, Text } from 'react-native';
4
+ import { toNativeColor } from './utils';
5
+ const NativeAndroidGlassButton = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassButton');
6
+ export default function AndroidGlassButton({ onPress, title, titleStyle, cornerRadius, tintColor, surfaceColor, fallbackColor, style, children, ...rest }) {
7
+ const borderRadius = StyleSheet.flatten(style)?.borderRadius;
8
+ return (<NativeAndroidGlassButton accessibilityRole="button" {...rest} style={[styles.button, style]} cornerRadius={cornerRadius ?? (typeof borderRadius === 'number' ? borderRadius : undefined)} tintColor={toNativeColor(tintColor)} surfaceColor={toNativeColor(surfaceColor)} fallbackColor={toNativeColor(fallbackColor)} onPress={onPress ? () => onPress() : undefined}>
9
+ {title != null ? (<Text style={[styles.title, tintColor != null && styles.titleOnTint, titleStyle]}>
10
+ {title}
11
+ </Text>) : null}
12
+ {children}
13
+ </NativeAndroidGlassButton>);
14
+ }
15
+ const styles = StyleSheet.create({
16
+ button: {
17
+ height: 48,
18
+ paddingHorizontal: 16,
19
+ flexDirection: 'row',
20
+ alignItems: 'center',
21
+ justifyContent: 'center',
22
+ gap: 8,
23
+ },
24
+ title: {
25
+ fontSize: 15,
26
+ color: '#000000',
27
+ },
28
+ titleOnTint: {
29
+ color: '#ffffff',
30
+ },
31
+ });
32
+ //# sourceMappingURL=AndroidGlassButton.android.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AndroidGlassButton.android.js","sourceRoot":"","sources":["../src/AndroidGlassButton.android.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAY1D,MAAM,wBAAwB,GAC5B,iBAAiB,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;AAElE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,OAAO,EACP,KAAK,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,aAAa,EACb,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACiB;IACxB,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC7D,OAAO,CACL,CAAC,wBAAwB,CACvB,iBAAiB,CAAC,QAAQ,CAC1B,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAC9B,YAAY,CAAC,CAAC,YAAY,IAAI,CAAC,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5F,SAAS,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CACpC,YAAY,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAC1C,aAAa,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAC5C,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAC/C;MAAA,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CACf,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,IAAI,IAAI,IAAI,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAC/E;UAAA,CAAC,KAAK,CACR;QAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,IAAI,CACR;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,wBAAwB,CAAC,CAC5B,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE;QACN,MAAM,EAAE,EAAE;QACV,iBAAiB,EAAE,EAAE;QACrB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,GAAG,EAAE,CAAC;KACP;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,SAAS;KACjB;IACD,WAAW,EAAE;QACX,KAAK,EAAE,SAAS;KACjB;CACF,CAAC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { StyleSheet, Text } from 'react-native';\n\nimport type { AndroidGlassButtonProps } from './AndroidGlassComponents.types';\nimport { type NativeColor, toNativeColor } from './utils';\n\ntype NativeAndroidGlassButtonProps = Omit<\n AndroidGlassButtonProps,\n 'tintColor' | 'surfaceColor' | 'fallbackColor' | 'onPress' | 'title' | 'titleStyle'\n> & {\n tintColor?: NativeColor;\n surfaceColor?: NativeColor;\n fallbackColor?: NativeColor;\n onPress?: () => void;\n};\n\nconst NativeAndroidGlassButton: React.ComponentType<NativeAndroidGlassButtonProps> =\n requireNativeView('ExpoAndroidGlassView', 'AndroidGlassButton');\n\nexport default function AndroidGlassButton({\n onPress,\n title,\n titleStyle,\n cornerRadius,\n tintColor,\n surfaceColor,\n fallbackColor,\n style,\n children,\n ...rest\n}: AndroidGlassButtonProps) {\n const borderRadius = StyleSheet.flatten(style)?.borderRadius;\n return (\n <NativeAndroidGlassButton\n accessibilityRole=\"button\"\n {...rest}\n style={[styles.button, style]}\n cornerRadius={cornerRadius ?? (typeof borderRadius === 'number' ? borderRadius : undefined)}\n tintColor={toNativeColor(tintColor)}\n surfaceColor={toNativeColor(surfaceColor)}\n fallbackColor={toNativeColor(fallbackColor)}\n onPress={onPress ? () => onPress() : undefined}>\n {title != null ? (\n <Text style={[styles.title, tintColor != null && styles.titleOnTint, titleStyle]}>\n {title}\n </Text>\n ) : null}\n {children}\n </NativeAndroidGlassButton>\n );\n}\n\nconst styles = StyleSheet.create({\n button: {\n height: 48,\n paddingHorizontal: 16,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 8,\n },\n title: {\n fontSize: 15,\n color: '#000000',\n },\n titleOnTint: {\n color: '#ffffff',\n },\n});\n"]}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { AndroidGlassButtonProps } from './AndroidGlassComponents.types';
3
+ /** iOS and web fallback: a translucent capsule button with the same API. */
4
+ export default function AndroidGlassButton({ onPress, title, titleStyle, cornerRadius, tintColor, surfaceColor, fallbackColor, style, children, blurRadius: _blurRadius, refractionHeight: _refractionHeight, refractionAmount: _refractionAmount, chromaticAberration: _chromaticAberration, depthEffect: _depthEffect, vibrancy: _vibrancy, highlight: _highlight, shadow: _shadow, interactive: _interactive, ...rest }: AndroidGlassButtonProps): React.JSX.Element;
5
+ //# sourceMappingURL=AndroidGlassButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AndroidGlassButton.d.ts","sourceRoot":"","sources":["../src/AndroidGlassButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAI9E,4EAA4E;AAC5E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,OAAO,EACP,KAAK,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,aAAa,EACb,KAAK,EACL,QAAQ,EACR,UAAU,EAAE,WAAW,EACvB,gBAAgB,EAAE,iBAAiB,EACnC,gBAAgB,EAAE,iBAAiB,EACnC,mBAAmB,EAAE,oBAAoB,EACzC,WAAW,EAAE,YAAY,EACzB,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,YAAY,EACzB,GAAG,IAAI,EACR,EAAE,uBAAuB,qBAuBzB"}