expo-android-glass-view 0.1.9 → 0.1.11
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 +64 -1
- package/README.md +234 -39
- package/android/src/main/java/expo/modules/androidglassview/AndroidGlassBottomTabs.kt +3 -0
- package/android/src/main/java/expo/modules/androidglassview/AndroidGlassMenuPanel.kt +428 -0
- package/android/src/main/java/expo/modules/androidglassview/AndroidGlassView.kt +1 -1
- package/android/src/main/java/expo/modules/androidglassview/ExpoAndroidGlassViewModule.kt +78 -10
- package/android/src/main/java/expo/modules/androidglassview/GlassHostView.kt +13 -0
- package/android/src/main/java/expo/modules/androidglassview/GlassSurface.kt +68 -24
- package/android/src/main/java/expo/modules/androidglassview/MenuDropShape.kt +51 -0
- package/android/src/main/java/expo/modules/androidglassview/MenuIcons.kt +58 -0
- package/android/src/main/java/expo/modules/androidglassview/MenuLens.kt +36 -0
- package/android/src/main/java/expo/modules/androidglassview/MenuMotion.kt +72 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/DrawBackdropModifier.kt +21 -9
- package/android/src/main/java/expo/modules/androidglassview/backdrop/effects/LinearBlur.kt +47 -0
- package/android/src/main/java/expo/modules/androidglassview/components/LiquidBottomTabs.kt +23 -28
- package/android/src/main/java/expo/modules/androidglassview/components/LiquidButton.kt +2 -2
- package/build/AndroidGlassBottomTabs.android.d.ts +1 -1
- package/build/AndroidGlassBottomTabs.android.d.ts.map +1 -1
- package/build/AndroidGlassBottomTabs.android.js +6 -2
- package/build/AndroidGlassBottomTabs.android.js.map +1 -1
- package/build/AndroidGlassBottomTabs.d.ts +1 -1
- package/build/AndroidGlassBottomTabs.d.ts.map +1 -1
- package/build/AndroidGlassBottomTabs.js +16 -3
- package/build/AndroidGlassBottomTabs.js.map +1 -1
- package/build/AndroidGlassButton.android.d.ts +1 -1
- package/build/AndroidGlassButton.android.d.ts.map +1 -1
- package/build/AndroidGlassButton.android.js +7 -3
- package/build/AndroidGlassButton.android.js.map +1 -1
- package/build/AndroidGlassButton.d.ts +1 -1
- package/build/AndroidGlassButton.d.ts.map +1 -1
- package/build/AndroidGlassButton.js +10 -3
- package/build/AndroidGlassButton.js.map +1 -1
- package/build/AndroidGlassComponents.types.d.ts +9 -2
- package/build/AndroidGlassComponents.types.d.ts.map +1 -1
- package/build/AndroidGlassComponents.types.js.map +1 -1
- package/build/AndroidGlassMenu.d.ts +9 -0
- package/build/AndroidGlassMenu.d.ts.map +1 -0
- package/build/AndroidGlassMenu.js +190 -0
- package/build/AndroidGlassMenu.js.map +1 -0
- package/build/AndroidGlassMenu.types.d.ts +76 -0
- package/build/AndroidGlassMenu.types.d.ts.map +1 -0
- package/build/AndroidGlassMenu.types.js +2 -0
- package/build/AndroidGlassMenu.types.js.map +1 -0
- package/build/AndroidGlassView.d.ts +1 -1
- package/build/AndroidGlassView.d.ts.map +1 -1
- package/build/AndroidGlassView.js +2 -2
- package/build/AndroidGlassView.js.map +1 -1
- package/build/AndroidGlassView.types.d.ts +11 -4
- package/build/AndroidGlassView.types.d.ts.map +1 -1
- package/build/AndroidGlassView.types.js.map +1 -1
- package/build/GlassMenuPanel.android.d.ts +3 -0
- package/build/GlassMenuPanel.android.d.ts.map +1 -0
- package/build/GlassMenuPanel.android.js +30 -0
- package/build/GlassMenuPanel.android.js.map +1 -0
- package/build/GlassMenuPanel.d.ts +3 -0
- package/build/GlassMenuPanel.d.ts.map +1 -0
- package/build/GlassMenuPanel.js +73 -0
- package/build/GlassMenuPanel.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/menuItemSerialization.d.ts +8 -0
- package/build/menuItemSerialization.d.ts.map +1 -0
- package/build/menuItemSerialization.js +15 -0
- package/build/menuItemSerialization.js.map +1 -0
- package/build/menuLayout.d.ts +19 -0
- package/build/menuLayout.d.ts.map +1 -0
- package/build/menuLayout.js +28 -0
- package/build/menuLayout.js.map +1 -0
- package/internal/jest-unit.config.cjs +10 -0
- package/package.json +3 -2
- package/src/AndroidGlassBottomTabs.android.tsx +22 -2
- package/src/AndroidGlassBottomTabs.tsx +31 -2
- package/src/AndroidGlassButton.android.tsx +8 -1
- package/src/AndroidGlassButton.tsx +13 -2
- package/src/AndroidGlassComponents.types.ts +9 -2
- package/src/AndroidGlassMenu.tsx +280 -0
- package/src/AndroidGlassMenu.types.ts +85 -0
- package/src/AndroidGlassView.tsx +3 -1
- package/src/AndroidGlassView.types.ts +12 -4
- package/src/GlassMenuPanel.android.tsx +88 -0
- package/src/GlassMenuPanel.tsx +109 -0
- package/src/index.ts +2 -0
- package/src/menuItemSerialization.ts +19 -0
- package/src/menuLayout.ts +59 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.11 — 2026-09-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `AndroidGlassMenu` standard rows now accept a decorative React element as `icon`, such as
|
|
8
|
+
`<Ionicons />`, alongside the existing native glyph names. Custom icons render inside the
|
|
9
|
+
glass surface and follow its opening, scrolling and submenu animations without replacing
|
|
10
|
+
native row selection.
|
|
11
|
+
- `AndroidGlassMenu` now accepts `shadow={false}` to remove its Android drop shadow and
|
|
12
|
+
`shadowOpacity` (0–1) to set its strength. Both affect the root and nested menu surfaces,
|
|
13
|
+
including menus with custom React content. The existing light/dark defaults are unchanged.
|
|
14
|
+
|
|
15
|
+
### Compatibility
|
|
16
|
+
|
|
17
|
+
- Rebuild the Android app or development client for these native menu capabilities; a JS-only
|
|
18
|
+
update is not enough. iOS and web continue to use plain menu fallbacks.
|
|
19
|
+
|
|
20
|
+
## 0.1.10 — 2026-09-15
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Optional `blurGradient="top-to-bottom"` on View, Button and BottomTabs: a spatial Gaussian
|
|
25
|
+
blur that decreases linearly to zero at the bottom on Android 13+. Omission keeps uniform
|
|
26
|
+
blur; Android 12 falls back to uniform blur and older platforms retain plain surfaces.
|
|
27
|
+
|
|
28
|
+
- `AndroidGlassMenu` and `AndroidGlassMenuProvider`: anchored, same-window glass menus with
|
|
29
|
+
nested items, checkmarks, icons, separators, disabled/destructive actions and actions that
|
|
30
|
+
keep the menu open. Includes safe-area positioning, overlap/below placement, Android Back
|
|
31
|
+
handling, long-menu scrolling and plain iOS/web fallbacks.
|
|
32
|
+
- Custom interactive React menu content through `children` and optional `contentHeight`.
|
|
33
|
+
Children replace native rows, scroll within the panel and follow the opening/closing morph.
|
|
34
|
+
- Optional `theme="light" | "dark"` on View, Button, Menu and BottomTabs, with light/dark
|
|
35
|
+
material responses tuned against iOS references. Button, Menu and BottomTabs default to light.
|
|
36
|
+
- Optional BottomTabs glass props: `cornerRadius`, `blurRadius`, `refractionHeight`,
|
|
37
|
+
`refractionAmount`, `chromaticAberration`, `depthEffect`, `vibrancy`, `highlight`, `shadow`,
|
|
38
|
+
`tintColor`, `surfaceColor` and `fallbackColor`. They configure the bar surface; the selection
|
|
39
|
+
droplet keeps its own optics. Removing overrides restores the defaults.
|
|
40
|
+
- Optional BottomTabs `opacity` prop (0–1), affecting the entire bar including icons and labels.
|
|
41
|
+
When supplied it overrides `style.opacity`; existing styles continue to work when omitted.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
|
|
45
|
+
- Menu opening/closing morphs, finger-following deformation and release springs, animated
|
|
46
|
+
row-snapped highlights, and submenu headers that animate into position. The backdrop stays
|
|
47
|
+
anchored to screen coordinates throughout the morph.
|
|
48
|
+
- Button convenience labels follow the selected theme. Custom React text remains caller-styled.
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
|
|
52
|
+
- Opening or closing a menu no longer rebuilds the provider's native content wrapper, which
|
|
53
|
+
could leave the menu and tab bar sampling an empty backdrop until the next scroll.
|
|
54
|
+
- Dark menu appearance now applies to the native background as well as its text.
|
|
55
|
+
- Menu highlights stay on selectable rows instead of appearing in gaps or panel padding.
|
|
56
|
+
- Touches and scrolling inside custom React menu content no longer dismiss the panel.
|
|
57
|
+
|
|
58
|
+
### Compatibility
|
|
59
|
+
|
|
60
|
+
- GlassView without `theme` retains its original untinted material: blur 2 dp, refraction
|
|
61
|
+
height/amount 12/24 dp and vibrancy enabled. Explicit themes use 9 dp, 2/3 dp and vibrancy off.
|
|
62
|
+
- Toggle and Slider do not receive a theme prop and keep their existing appearance.
|
|
63
|
+
- Rebuild the native application to use the new menu and BottomTabs props; a JS-only update
|
|
64
|
+
does not add these native capabilities.
|
|
65
|
+
|
|
3
66
|
## 0.1.9 — 2026-09-14
|
|
4
67
|
|
|
5
68
|
- Republish the 0.1.3 implementation with the updated README and npm-compatible demo image URLs.
|
|
@@ -9,7 +72,7 @@
|
|
|
9
72
|
|
|
10
73
|
- Fix a crash when navigating to or from a screen that has a glass view (Expo Router and React
|
|
11
74
|
Navigation on react-native-screens): `IllegalStateException: Cannot locate windowRecomposer … is
|
|
12
|
-
|
|
75
|
+
not attached to a window`. React Native measures views that are not attached to the window —
|
|
13
76
|
a pushed screen or a tab opened for the first time, before react-native-screens attaches it, or
|
|
14
77
|
a screen it has detached — and measuring the glass layer there made Compose look for the
|
|
15
78
|
window. The glass layer is now skipped while detached and sized when it attaches.
|
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
<img src="https://raw.githubusercontent.com/kagantemizkan/expo-android-glass-view/5a563ac/.github/assets/hero.png" alt="Liquid Glass — expo-android-glass-view" width="1040" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# expo-android-glass-view
|
|
6
6
|
|
|
7
7
|
Liquid Glass for React Native on **Android**: real refraction, blur, vibrancy and rim
|
|
8
8
|
highlights behind any React content, rendered with Jetpack Compose — plus ready-made glass
|
|
9
|
-
buttons, toggles, sliders
|
|
9
|
+
buttons, toggles, sliders, a bottom tab bar and anchored menus.
|
|
10
10
|
|
|
11
11
|
The glass effects and the components come from
|
|
12
12
|
[Kyant0/AndroidLiquidGlass](https://github.com/Kyant0/AndroidLiquidGlass). The part that lets
|
|
@@ -27,14 +27,22 @@ import {
|
|
|
27
27
|
AndroidGlassSlider,
|
|
28
28
|
AndroidGlassBottomTabs,
|
|
29
29
|
AndroidGlassTab,
|
|
30
|
+
AndroidGlassMenu,
|
|
31
|
+
AndroidGlassMenuProvider,
|
|
30
32
|
MinimizeOnScrollProvider,
|
|
31
33
|
useMinimizeOnScrollHandler,
|
|
32
34
|
useMinimizeOnScroll,
|
|
33
35
|
} from 'expo-android-glass-view';
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
Glass components sample what is drawn behind them in the same window, keeping up with
|
|
39
|
+
scrolling lists, animations and layout changes. View, Button, Toggle, Slider and BottomTabs
|
|
40
|
+
need no provider. Menus require `AndroidGlassMenuProvider` above the navigator.
|
|
41
|
+
|
|
42
|
+
Version **0.1.11** adds React icons to standard menu rows and configurable Android menu shadows.
|
|
43
|
+
Version 0.1.10 introduced anchored menus, custom React menu content, light/dark materials and
|
|
44
|
+
configurable tab bar glass effects.
|
|
45
|
+
See [CHANGELOG.md](./CHANGELOG.md) for the release notes.
|
|
38
46
|
|
|
39
47
|
## Platforms
|
|
40
48
|
|
|
@@ -57,6 +65,9 @@ npx expo run:android
|
|
|
57
65
|
|
|
58
66
|
For bare React Native apps, [install Expo Modules](https://docs.expo.dev/bare/installing-expo-modules/) first.
|
|
59
67
|
|
|
68
|
+
When upgrading to 0.1.11, rebuild your native app or development client. Custom menu icons and
|
|
69
|
+
menu shadow controls require the matching native binary; updating JavaScript alone is insufficient.
|
|
70
|
+
|
|
60
71
|
## `AndroidGlassView`
|
|
61
72
|
|
|
62
73
|
A container: children render on top of the glass and stay fully interactive.
|
|
@@ -71,20 +82,22 @@ A container: children render on top of the glass and stay fully interactive.
|
|
|
71
82
|
|
|
72
83
|
Accepts every `View` prop plus:
|
|
73
84
|
|
|
74
|
-
| Prop | Type
|
|
75
|
-
| --------------------- |
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
85
|
+
| Prop | Type | Default | Description |
|
|
86
|
+
| --------------------- | ------------------- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
87
|
+
| `theme` | `"light" \| "dark"` | omitted | Optional appearance; omission preserves the original untinted glass. |
|
|
88
|
+
| `cornerRadius` | `number` | `style.borderRadius`, else `24` | Corner radius of the glass shape in dp. Use a large value (e.g. `999`) for a capsule. |
|
|
89
|
+
| `blurRadius` | `number` | `2` unthemed / `9` themed | Backdrop blur in dp. `0` disables it. |
|
|
90
|
+
| `blurGradient` | `"top-to-bottom"` | omitted | Android 13+: blur decreases linearly from `blurRadius` at the top to zero at the bottom. Omit for uniform blur; Android 12 uses uniform blur. |
|
|
91
|
+
| `refractionHeight` | `number` | `12` unthemed / `2` themed | Width of the refracting rim in dp. `0` disables refraction. |
|
|
92
|
+
| `refractionAmount` | `number` | `24` unthemed / `3` themed | How far content is bent at the rim, in dp. |
|
|
93
|
+
| `chromaticAberration` | `boolean` | `false` | Split the refraction per colour channel (prism fringe). |
|
|
94
|
+
| `depthEffect` | `boolean` | `false` | Stronger, depth-like bending towards the rim. |
|
|
95
|
+
| `vibrancy` | `boolean` | `true` unthemed / `false` themed | Boost the saturation of what is behind the glass. |
|
|
96
|
+
| `highlight` | `boolean` | `true` | Specular highlight along the rim. |
|
|
97
|
+
| `shadow` | `boolean` | `true` | Soft drop shadow around the shape. |
|
|
98
|
+
| `tintColor` | `ColorValue` | — | Colour tint mixed into the glass. |
|
|
99
|
+
| `surfaceColor` | `ColorValue` | — | Flat colour painted over the glass, on top of the refraction. |
|
|
100
|
+
| `fallbackColor` | `ColorValue` | `#242b33` dark / `rgba(255,255,255,0.7)` otherwise | Surface used where the effect cannot run (see _Platforms_). |
|
|
88
101
|
|
|
89
102
|
Don't set `backgroundColor` on a glass view — it would paint over the effect. Use `tintColor`
|
|
90
103
|
or `surfaceColor` instead.
|
|
@@ -105,14 +118,14 @@ highlight follows it.
|
|
|
105
118
|
</AndroidGlassButton>
|
|
106
119
|
```
|
|
107
120
|
|
|
108
|
-
Takes every `AndroidGlassView` prop
|
|
121
|
+
Takes every `AndroidGlassView` prop, with `theme="light"` and a capsule corner radius by default, plus:
|
|
109
122
|
|
|
110
|
-
| Prop | Type | Default | Description
|
|
111
|
-
| ------------- | ------------ | ------- |
|
|
112
|
-
| `onPress` | `() => void` | — | Called on tap.
|
|
113
|
-
| `title` | `string` | — | Convenience label (15 sp; white
|
|
114
|
-
| `titleStyle` | `TextStyle` | — | Style for `title`.
|
|
115
|
-
| `interactive` | `boolean` | `true` | Press and drag deformation.
|
|
123
|
+
| Prop | Type | Default | Description |
|
|
124
|
+
| ------------- | ------------ | ------- | ----------------------------------------------------------- |
|
|
125
|
+
| `onPress` | `() => void` | — | Called on tap. |
|
|
126
|
+
| `title` | `string` | — | Convenience label (15 sp; white with dark theme or a tint). |
|
|
127
|
+
| `titleStyle` | `TextStyle` | — | Style for `title`. |
|
|
128
|
+
| `interactive` | `boolean` | `true` | Press and drag deformation. |
|
|
116
129
|
|
|
117
130
|
The default size is 48 dp high with 16 dp horizontal padding; override it with `style`. The
|
|
118
131
|
children are drawn _inside_ the glass (clipped to it, deformed with it), so they are decorative:
|
|
@@ -169,6 +182,31 @@ Kyant's iOS 26 style tab bar: a glass capsule with a liquid selection droplet yo
|
|
|
169
182
|
between tabs. Under the droplet the tab content takes the accent colour and is magnified while
|
|
170
183
|
pressed.
|
|
171
184
|
|
|
185
|
+
All glass surface options are optional: `cornerRadius`, `blurRadius`, `blurGradient`, `refractionHeight`,
|
|
186
|
+
`refractionAmount`, `chromaticAberration`, `depthEffect`, `vibrancy`, `highlight`,
|
|
187
|
+
`shadow`, `tintColor`, `surfaceColor`, and `fallbackColor`. Omitted options preserve
|
|
188
|
+
existing theme defaults and the capsule shape. Removing an override restores its default.
|
|
189
|
+
These options affect the bar surface; the selection droplet retains its own optics.
|
|
190
|
+
`containerColor` is painted above tint/surface colours. On iOS/web, optical effects are
|
|
191
|
+
unavailable; the fallback uses the supplied colours and corner radius.
|
|
192
|
+
|
|
193
|
+
`opacity` (0–1) fades the entire bar including icons and labels. It overrides
|
|
194
|
+
`style.opacity` only when supplied; otherwise the style works as before.
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
<AndroidGlassBottomTabs
|
|
198
|
+
theme="dark"
|
|
199
|
+
opacity={0.85}
|
|
200
|
+
blurRadius={16}
|
|
201
|
+
refractionHeight={8}
|
|
202
|
+
refractionAmount={12}
|
|
203
|
+
chromaticAberration
|
|
204
|
+
shadow={false}>
|
|
205
|
+
<AndroidGlassTab label="Home" />
|
|
206
|
+
<AndroidGlassTab label="Search" />
|
|
207
|
+
</AndroidGlassBottomTabs>
|
|
208
|
+
```
|
|
209
|
+
|
|
172
210
|
<img src="https://raw.githubusercontent.com/kagantemizkan/expo-android-glass-view/5a563ac/.github/assets/tabbar.gif" alt="AndroidGlassBottomTabs" width="480" />
|
|
173
211
|
|
|
174
212
|
```tsx
|
|
@@ -182,14 +220,17 @@ pressed.
|
|
|
182
220
|
</AndroidGlassBottomTabs>
|
|
183
221
|
```
|
|
184
222
|
|
|
185
|
-
| Prop | Type | Default
|
|
186
|
-
| ------------------- | ------------------------------ |
|
|
187
|
-
| `
|
|
188
|
-
| `
|
|
189
|
-
| `
|
|
190
|
-
| `
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
223
|
+
| Prop | Type | Default | Description |
|
|
224
|
+
| ------------------- | ------------------------------ | ------------------------- | ------------------------------------------------------------------------------------------- |
|
|
225
|
+
| `theme` | `"light" \| "dark"` | `"light"` | Glass appearance, independent of the system. |
|
|
226
|
+
| `opacity` | `number` | `style.opacity`, else `1` | Whole bar opacity, including icons and labels; clamped to 0–1. |
|
|
227
|
+
| `cornerRadius` | `number` | capsule | Explicit bar radius in dp. |
|
|
228
|
+
| `selectedIndex` | `number` | `0` | |
|
|
229
|
+
| `onTabSelected` | `(index: number) => void` | — | Called on tap, or when the droplet is dropped on a tab. |
|
|
230
|
+
| `minimized` | `boolean` | `false` | Minimized look: shorter and narrower, labels faded out. Animated. See _Minimize on scroll_. |
|
|
231
|
+
| `onMinimizedChange` | `(minimized: boolean) => void` | — | Called with `false` when the user expands the minimized bar by touching it. |
|
|
232
|
+
| `accentColor` | `ColorValue` | system blue | Colour of the selected tab's content. |
|
|
233
|
+
| `containerColor` | `ColorValue` | theme material | Colour of the glass bar. |
|
|
193
234
|
|
|
194
235
|
Each child is one tab (equal widths). `AndroidGlassTab` is an icon over a 12 sp label, but any
|
|
195
236
|
view works — as with buttons, the tabs are drawn inside the glass, so keep them decorative. The
|
|
@@ -299,10 +340,147 @@ export default function TabLayout() {
|
|
|
299
340
|
The bar floats over the screens, so give their content some bottom padding. With React
|
|
300
341
|
Navigation, the same component works as `createBottomTabNavigator`'s `tabBar`.
|
|
301
342
|
|
|
343
|
+
## `AndroidGlassMenu`
|
|
344
|
+
|
|
345
|
+
<img src="https://raw.githubusercontent.com/kagantemizkan/expo-android-glass-view/main/.github/assets/menu.gif" alt="AndroidGlassMenu: opening, row highlight transitions and nested menus in dark mode" width="480" />
|
|
346
|
+
|
|
347
|
+
An anchored glass action menu with independent position, size and corner motion,
|
|
348
|
+
refracted labels, a selection pill that snaps to rows, checkmarks, separators and
|
|
349
|
+
disabled/destructive actions. The backdrop stays in screen coordinates while the
|
|
350
|
+
surface grows. Its surface stretches and moves toward the finger, then springs
|
|
351
|
+
back on release. The selection pill springs between row-aligned positions and
|
|
352
|
+
adapts to each row's height. It disappears when the finger is over separators,
|
|
353
|
+
headings, disabled rows or the panel's padding.
|
|
354
|
+
The menu renders in the same window as the screen, through a provider above the
|
|
355
|
+
navigator. It does not use React Native `Modal`.
|
|
356
|
+
|
|
357
|
+
```tsx
|
|
358
|
+
import { useRef, useState } from 'react';
|
|
359
|
+
import { View } from 'react-native';
|
|
360
|
+
import {
|
|
361
|
+
AndroidGlassButton,
|
|
362
|
+
AndroidGlassMenu,
|
|
363
|
+
AndroidGlassMenuProvider,
|
|
364
|
+
} from 'expo-android-glass-view';
|
|
365
|
+
|
|
366
|
+
// At your application root:
|
|
367
|
+
// <AndroidGlassMenuProvider><YourNavigator /></AndroidGlassMenuProvider>
|
|
368
|
+
|
|
369
|
+
function SortMenu() {
|
|
370
|
+
const anchorRef = useRef<View>(null);
|
|
371
|
+
const [visible, setVisible] = useState(false);
|
|
372
|
+
const [sort, setSort] = useState('recent');
|
|
373
|
+
return (
|
|
374
|
+
<>
|
|
375
|
+
<View ref={anchorRef} collapsable={false}>
|
|
376
|
+
<AndroidGlassButton title="Sort" onPress={() => setVisible(true)} />
|
|
377
|
+
</View>
|
|
378
|
+
<AndroidGlassMenu
|
|
379
|
+
visible={visible}
|
|
380
|
+
anchorRef={anchorRef}
|
|
381
|
+
items={[
|
|
382
|
+
{ id: 'recent', title: 'Most recent', checked: sort === 'recent' },
|
|
383
|
+
{ id: 'name', title: 'Name', checked: sort === 'name' },
|
|
384
|
+
]}
|
|
385
|
+
onSelect={setSort}
|
|
386
|
+
onDismiss={() => setVisible(false)}
|
|
387
|
+
/>
|
|
388
|
+
</>
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
`visible`, `anchorRef` and `onDismiss` are required. For native rows, supply `items` and `onSelect`. Set
|
|
394
|
+
`visible` to false in `onDismiss`, which runs on a dismissing selection or when
|
|
395
|
+
outside press / Android Back closes the root menu. `onSelect` receives the chosen item's unique `id`. Each item supports
|
|
396
|
+
`title`, `checked`, `disabled`, `destructive`, and `separator` (before the row).
|
|
397
|
+
|
|
398
|
+
Optional `width` defaults to 250 dp. `theme` is `light` or `dark` and defaults to
|
|
399
|
+
`light`. On Android, `shadow={false}` removes the drop shadow; `shadowOpacity`
|
|
400
|
+
sets its opacity from 0 to 1 (default 0.12 in light, 0.16 in dark). Both options
|
|
401
|
+
apply to nested surfaces and custom React content. Pass safe-area `insets`
|
|
402
|
+
(`top`, `right`, `bottom`, `left`) if the provider covers system bars; omitted edges
|
|
403
|
+
use 12 dp. Position is measured on opening and
|
|
404
|
+
window-size changes. The default `placement="overlap"` expands over the trigger,
|
|
405
|
+
aligned just beyond its right edge; `placement="below"` opens underneath. Both are
|
|
406
|
+
clamped to the provider bounds and flip above the trigger when needed. Keep the trigger stationary while open.
|
|
407
|
+
|
|
408
|
+
Items can include `children` (another item array). On Android, a front surface grows
|
|
409
|
+
from the selected row and leaves the parent visible behind it. Its header, a tap
|
|
410
|
+
on the parent, an outside press, or Android Back collapses it. There is no extra
|
|
411
|
+
back row on Android. Selecting a leaf calls `onSelect` with its id. Set
|
|
412
|
+
`keepsMenuPresented` on toggles and repeated actions to keep the menu open while
|
|
413
|
+
updating their checked state. `compact` uses a smaller row and `sectionTitle` adds
|
|
414
|
+
a muted heading. `icon` supports grid, heart, adjustments, photo, video, screenshot,
|
|
415
|
+
album, zoom-in, zoom-out, aspect and people glyphs.
|
|
416
|
+
For a custom icon, pass a React element instead of a glyph name. It stays inside the
|
|
417
|
+
native row and follows the menu's content animation, including in submenus:
|
|
418
|
+
|
|
419
|
+
```tsx
|
|
420
|
+
import Ionicons from '@expo/vector-icons/Ionicons';
|
|
421
|
+
|
|
422
|
+
const items = [
|
|
423
|
+
{ id: 'share', title: 'Share', icon: <Ionicons name="share-outline" size={20} color="#202124" /> },
|
|
424
|
+
];
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
Custom icons are decorative and use the size and colour you give them; use a light
|
|
428
|
+
colour for dark menus. The icon slot is 20 × 20 dp. Native row selection, scrolling,
|
|
429
|
+
and submenu behaviour are unchanged. This feature requires a new Android build.
|
|
430
|
+
|
|
431
|
+
Use `\n` for a two-line title; those rows receive extra height. If hiding the
|
|
432
|
+
trigger during the morph, keep its layout and ref mounted and restore it in
|
|
433
|
+
`onDismissed`, after the closing animation finishes. `sourceIcon="sort"` retains
|
|
434
|
+
the sort glyph during that transition. Decorative View groups inside a glass
|
|
435
|
+
button should use `pointerEvents="none"`. The provider keeps its last native panel
|
|
436
|
+
hidden and non-interactive after closing so its GPU programs stay ready.
|
|
437
|
+
|
|
438
|
+
Only one menu should be visible per provider. Tall menus reveal rows when dragged
|
|
439
|
+
along their upper/lower edge and support accessibility scrolling with TalkBack.
|
|
440
|
+
Dragging directly from the opening button into the menu is not part of this API. iOS and web use a plain scrollable
|
|
441
|
+
menu with the same selection API. On Android the animation follows system animator
|
|
442
|
+
duration settings.
|
|
443
|
+
|
|
444
|
+
### Custom React menu content
|
|
445
|
+
|
|
446
|
+
Pass `children` to replace the native action rows with live React content. `contentHeight`
|
|
447
|
+
sets the panel height in dp (default 240, including 16 dp content padding on each edge); it
|
|
448
|
+
is clamped to the available screen space, and overflowing content scrolls. When children
|
|
449
|
+
are present, `items` are ignored and `onSelect` is not used. Dismiss from a custom control by
|
|
450
|
+
setting `visible` to false; outside press and Android Back also dismiss.
|
|
451
|
+
|
|
452
|
+
```tsx
|
|
453
|
+
<AndroidGlassMenu
|
|
454
|
+
visible={open}
|
|
455
|
+
anchorRef={anchor}
|
|
456
|
+
theme="dark"
|
|
457
|
+
contentHeight={300}
|
|
458
|
+
onDismiss={() => setOpen(false)}>
|
|
459
|
+
<Text style={{ color: 'white' }}>Custom controls</Text>
|
|
460
|
+
<Switch value={enabled} onValueChange={setEnabled} />
|
|
461
|
+
<Pressable onPress={() => setOpen(false)}>
|
|
462
|
+
<Text style={{ color: 'white' }}>Done</Text>
|
|
463
|
+
</Pressable>
|
|
464
|
+
</AndroidGlassMenu>
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
The native glass retains its opening/closing morph; React children follow its scale, position
|
|
468
|
+
and fade, while retaining native touch responders and accessibility. Custom content does not
|
|
469
|
+
use native row snapping or the native label refraction shader. Style child text for the selected
|
|
470
|
+
theme yourself. Components render in the provider's React context, so place any context providers
|
|
471
|
+
needed by custom children above `AndroidGlassMenuProvider`.
|
|
472
|
+
|
|
302
473
|
## Colours and dark mode
|
|
303
474
|
|
|
304
|
-
|
|
305
|
-
|
|
475
|
+
View, Button, Menu and BottomTabs accept optional `theme="light" | "dark"`. Button, Menu and BottomTabs default to `light`. GlassView without a theme keeps its original untinted material; it does not select a theme automatically.
|
|
476
|
+
The material is tuned against the supplied iOS recordings: light has a milky translucent
|
|
477
|
+
colour response, dark retains a subdued charcoal response. View, Button, Menu and the tab
|
|
478
|
+
bar share the resting material; their shapes and interaction animations remain independent.
|
|
479
|
+
Toggle and Slider do not accept a theme prop and are unchanged by the glass appearance setting.
|
|
480
|
+
|
|
481
|
+
View/Button/BottomTabs effect overrides remain supported and survive theme changes. Removing an
|
|
482
|
+
override restores its default. The themed material uses blur 9 dp, refraction 2 / 3 dp and vibrancy off. Unthemed GlassView uses its original blur 2 dp, refraction 12 / 24 dp and vibrancy on. Removing its theme restores that material, including its original highlight and shadow. Button labels follow the appearance; custom child text colours are yours.
|
|
483
|
+
Fallback platforms use plain theme-aware surfaces.
|
|
306
484
|
|
|
307
485
|
## Gestures
|
|
308
486
|
|
|
@@ -321,15 +499,15 @@ are told a native gesture started. Vertical drags still scroll.
|
|
|
321
499
|
|
|
322
500
|
## How it works
|
|
323
501
|
|
|
324
|
-
|
|
502
|
+
Every glass view takes a live snapshot of what is drawn behind it, runs it through a
|
|
325
503
|
GPU lens (blur, refraction, vibrancy) and draws the result in its own shape.
|
|
326
504
|
|
|
327
505
|
### A Compose layer inside a React Native view
|
|
328
506
|
|
|
329
507
|
Each glass component is a React Native view (`GlassHostView`) whose first child is a Jetpack
|
|
330
508
|
Compose view drawing Kyant's `drawBackdrop` modifier. Your React children are regular React
|
|
331
|
-
Native views on top of that layer
|
|
332
|
-
|
|
509
|
+
Native views on top of that layer. Button and BottomTabs content is drawn _inside_ the glass
|
|
510
|
+
so it follows their deformation; custom menu children remain interactive React views.
|
|
333
511
|
|
|
334
512
|
### Seeing the React Native screen behind it
|
|
335
513
|
|
|
@@ -393,7 +571,8 @@ that glass view then runs its blur and refraction again on the GPU. Changes else
|
|
|
393
571
|
screen don't count, because each glass view only captures what can reach it (see _Seeing the
|
|
394
572
|
React Native screen behind it_).
|
|
395
573
|
|
|
396
|
-
|
|
574
|
+
Earlier baseline measurements with `adb shell dumpsys gfxinfo` and `atrace` on a release build
|
|
575
|
+
(no new 0.1.11 performance benchmark), on a mid-range phone:
|
|
397
576
|
Xiaomi 24117RN76E, MediaTek Helio G99, Android 16, 120 Hz.
|
|
398
577
|
|
|
399
578
|
| Screen | Glass views | Result |
|
|
@@ -425,6 +604,22 @@ In practice:
|
|
|
425
604
|
view tree's drawing and shows up empty behind the glass. `TextureView` content works.
|
|
426
605
|
- A React Native `Modal` is a separate window, so glass inside it only sees the modal's content.
|
|
427
606
|
|
|
607
|
+
### Android overscroll stretch
|
|
608
|
+
|
|
609
|
+
Repeatedly scrolling past the edge of a list can leave the sampled backdrop shifted inside a
|
|
610
|
+
fixed glass header. This has been reproduced with Android's overscroll stretch effect; the
|
|
611
|
+
header itself stays in place while the image inside the glass drifts.
|
|
612
|
+
|
|
613
|
+
Set `overScrollMode="never"` on the `ScrollView` or `FlatList` behind the glass to avoid this:
|
|
614
|
+
|
|
615
|
+
```tsx
|
|
616
|
+
<ScrollView overScrollMode="never">{content}</ScrollView>
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
This disables Android's edge stretch/glow feedback. Normal scrolling and glass effects,
|
|
620
|
+
including `blurGradient`, continue to work. This is a workaround for the backdrop capture
|
|
621
|
+
interaction, not native support for overscroll stretch.
|
|
622
|
+
|
|
428
623
|
## Credits and licenses
|
|
429
624
|
|
|
430
625
|
This package is licensed under Apache-2.0. It contains code from
|
|
@@ -28,6 +28,8 @@ import expo.modules.kotlin.viewevent.EventDispatcher
|
|
|
28
28
|
class AndroidGlassBottomTabs(context: Context, appContext: AppContext) : GlassHostView(context, appContext) {
|
|
29
29
|
|
|
30
30
|
override val drawsReactChildrenInCompose: Boolean = true
|
|
31
|
+
internal val glassState = GlassState().apply { cornerRadius = 999f }
|
|
32
|
+
|
|
31
33
|
override val claimsHorizontalDrags: Boolean = true
|
|
32
34
|
|
|
33
35
|
internal var selectedIndex by mutableIntStateOf(0)
|
|
@@ -84,6 +86,7 @@ class AndroidGlassBottomTabs(context: Context, appContext: AppContext) : GlassHo
|
|
|
84
86
|
}
|
|
85
87
|
},
|
|
86
88
|
backdrop = backdrop,
|
|
89
|
+
state = glassState,
|
|
87
90
|
tabsCount = tabsCount.coerceAtLeast(1),
|
|
88
91
|
drawTabs = { origin, frame, tint, scale ->
|
|
89
92
|
// Reading the generation subscribes this draw to changes of the React children.
|