expo-android-glass-view 0.1.10 → 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 CHANGED
@@ -1,5 +1,22 @@
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
+
3
20
  ## 0.1.10 — 2026-09-15
4
21
 
5
22
  ### Added
package/README.md CHANGED
@@ -39,8 +39,9 @@ Glass components sample what is drawn behind them in the same window, keeping up
39
39
  scrolling lists, animations and layout changes. View, Button, Toggle, Slider and BottomTabs
40
40
  need no provider. Menus require `AndroidGlassMenuProvider` above the navigator.
41
41
 
42
- Version **0.1.10** adds anchored menus with custom React content, optional light/dark materials,
43
- and configurable tab bar glass effects.
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.
44
45
  See [CHANGELOG.md](./CHANGELOG.md) for the release notes.
45
46
 
46
47
  ## Platforms
@@ -64,8 +65,8 @@ npx expo run:android
64
65
 
65
66
  For bare React Native apps, [install Expo Modules](https://docs.expo.dev/bare/installing-expo-modules/) first.
66
67
 
67
- When upgrading to 0.1.10, rebuild your native app or development client. The new menu and
68
- BottomTabs props require the matching native binary; updating JavaScript alone is insufficient.
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.
69
70
 
70
71
  ## `AndroidGlassView`
71
72
 
@@ -395,8 +396,11 @@ outside press / Android Back closes the root menu. `onSelect` receives the chose
395
396
  `title`, `checked`, `disabled`, `destructive`, and `separator` (before the row).
396
397
 
397
398
  Optional `width` defaults to 250 dp. `theme` is `light` or `dark` and defaults to
398
- `light`. Pass safe-area `insets` (`top`, `right`, `bottom`, `left`) if the provider
399
- covers system bars; omitted edges use 12 dp. Position is measured on opening and
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
400
404
  window-size changes. The default `placement="overlap"` expands over the trigger,
401
405
  aligned just beyond its right edge; `placement="below"` opens underneath. Both are
402
406
  clamped to the provider bounds and flip above the trigger when needed. Keep the trigger stationary while open.
@@ -409,6 +413,20 @@ back row on Android. Selecting a leaf calls `onSelect` with its id. Set
409
413
  updating their checked state. `compact` uses a smaller row and `sectionTitle` adds
410
414
  a muted heading. `icon` supports grid, heart, adjustments, photo, video, screenshot,
411
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.
412
430
 
413
431
  Use `\n` for a two-line title; those rows receive extra height. If hiding the
414
432
  trigger during the morph, keep its layout and ref mounted and restore it in
@@ -554,7 +572,7 @@ screen don't count, because each glass view only captures what can reach it (see
554
572
  React Native screen behind it_).
555
573
 
556
574
  Earlier baseline measurements with `adb shell dumpsys gfxinfo` and `atrace` on a release build
557
- (no new 0.1.10 performance benchmark), on a mid-range phone:
575
+ (no new 0.1.11 performance benchmark), on a mid-range phone:
558
576
  Xiaomi 24117RN76E, MediaTek Helio G99, Android 16, 120 Hz.
559
577
 
560
578
  | Screen | Glass views | Result |
@@ -47,6 +47,7 @@ import kotlin.math.roundToInt
47
47
  internal data class GlassMenuItem(
48
48
  val id: String, val title: String, val checked: Boolean = false, val disabled: Boolean = false,
49
49
  val destructive: Boolean = false, val separator: Boolean = false, val icon: String = "",
50
+ val iconViewIndex: Int = -1,
50
51
  val compact: Boolean = false, val sectionTitle: String = "", val keepsPresented: Boolean = false,
51
52
  val children: List<GlassMenuItem> = emptyList()
52
53
  )
@@ -54,9 +55,13 @@ internal data class GlassMenuItem(
54
55
  /** All menu motion and navigation stay on the UI thread, within the content's window. */
55
56
  @SuppressLint("ViewConstructor")
56
57
  class AndroidGlassMenuPanel(context: Context, appContext: AppContext) : GlassHostView(context, appContext) {
58
+ override val drawsReactChildrenInCompose: Boolean get() = customHeight <= 0f
59
+
57
60
  internal var items by mutableStateOf<List<GlassMenuItem>>(emptyList())
58
61
  internal var expanded by mutableStateOf(false)
59
62
  internal var dark by mutableStateOf(false)
63
+ internal var shadowEnabled by mutableStateOf(true)
64
+ internal var shadowOpacity by mutableStateOf<Float?>(null)
60
65
  internal var originX by mutableFloatStateOf(1f)
61
66
  internal var originY by mutableFloatStateOf(0f)
62
67
  internal var rowHeight by mutableFloatStateOf(48f)
@@ -73,7 +78,7 @@ class AndroidGlassMenuPanel(context: Context, appContext: AppContext) : GlassHos
73
78
  val item = array.getJSONObject(index)
74
79
  GlassMenuItem(item.optString("id"), item.optString("title"), item.optBoolean("checked"),
75
80
  item.optBoolean("disabled"), item.optBoolean("destructive"), item.optBoolean("separator"),
76
- item.optString("icon"), item.optBoolean("compact"), item.optString("sectionTitle"),
81
+ item.optString("icon"), item.optInt("iconViewIndex", -1), item.optBoolean("compact"), item.optString("sectionTitle"),
77
82
  item.optBoolean("keepsMenuPresented"), item.optJSONArray("children")?.let(::parse) ?: emptyList())
78
83
  }
79
84
  items = parse(JSONArray(json))
@@ -199,7 +204,7 @@ class AndroidGlassMenuPanel(context: Context, appContext: AppContext) : GlassHos
199
204
  val index = parentRows.indexOfFirst { it.id == id }
200
205
  if (index >= 0) {
201
206
  val parent = parentRows[index]
202
- val header = parent.copy(checked = false, separator = false, sectionTitle = "", icon = "", compact = false)
207
+ val header = parent.copy(checked = false, separator = false, sectionTitle = "", icon = "", iconViewIndex = -1, compact = false)
203
208
  val children = parent.children.mapIndexed { childIndex, item ->
204
209
  if (childIndex == 0) item.copy(separator = true) else item
205
210
  }
@@ -341,7 +346,11 @@ class AndroidGlassMenuPanel(context: Context, appContext: AppContext) : GlassHos
341
346
  }, effects = {
342
347
  glassEffects(menuGlass, effectScale, material, press)
343
348
  }, highlight = { menuGlass.rim.copy(alpha = menuGlass.rim.alpha + press * .25f) },
344
- shadow = { menuGlass.dropShadow },
349
+ shadow = {
350
+ if (!shadowEnabled) null else menuGlass.dropShadow.let { base ->
351
+ shadowOpacity?.let { base.copy(color = base.color.copy(alpha = it)) } ?: base
352
+ }
353
+ },
345
354
  onDrawSurface = { glassSurface(menuGlass, effectsSupported) }
346
355
  )
347
356
  .then(scrubbing)
@@ -392,6 +401,11 @@ class AndroidGlassMenuPanel(context: Context, appContext: AppContext) : GlassHos
392
401
  if(item.checked) drawMenuIcon("check",color)
393
402
  }
394
403
  if(item.icon.isNotEmpty()) Canvas(Modifier.padding(end=14.dp).size(20.dp).clearAndSetSemantics {}) { drawMenuIcon(item.icon,color) }
404
+ else if(item.iconViewIndex >= 0) Canvas(Modifier.padding(end=14.dp).size(20.dp).clearAndSetSemantics {}) {
405
+ if (reactChildrenGeneration >= 0) drawReactLayer(Offset.Zero, null) { canvas ->
406
+ drawReactChildInto(canvas, item.iconViewIndex)
407
+ }
408
+ }
395
409
  BasicText(item.title,Modifier.weight(1f),style=TextStyle(color=color,fontSize=16.5f.sp,lineHeight=20.sp,
396
410
  fontWeight=FontWeight((400f + 100f * headerProgress).roundToInt())),maxLines=2,overflow=TextOverflow.Ellipsis)
397
411
  if(item.children.isNotEmpty()) Canvas(Modifier.padding(start=12.dp)
@@ -128,6 +128,8 @@ class ExpoAndroidGlassViewModule : Module() {
128
128
  Prop("itemsJson") { view: AndroidGlassMenuPanel, value: String -> view.setItems(value) }
129
129
  Prop("expanded") { view: AndroidGlassMenuPanel, value: Boolean -> view.expanded = value }
130
130
  Prop("dark") { view: AndroidGlassMenuPanel, value: Boolean -> view.dark = value }
131
+ Prop("shadow") { view: AndroidGlassMenuPanel, value: Boolean? -> view.shadowEnabled = value ?: true }
132
+ Prop("shadowOpacity") { view: AndroidGlassMenuPanel, value: Float? -> view.shadowOpacity = value?.takeIf { it.isFinite() }?.coerceIn(0f, 1f) }
131
133
  Prop("originX") { view: AndroidGlassMenuPanel, value: Float -> view.originX = value.coerceIn(0f, 1f) }
132
134
  Prop("originY") { view: AndroidGlassMenuPanel, value: Float -> view.originY = value.coerceIn(0f, 1f) }
133
135
  Prop("rowHeight") { view: AndroidGlassMenuPanel, value: Float -> view.rowHeight = value.coerceAtLeast(44f) }
@@ -186,6 +186,19 @@ abstract class GlassHostView(context: Context, appContext: AppContext) : ExpoVie
186
186
  }
187
187
  }
188
188
 
189
+ /** Draw one React child at the current canvas origin, for inline native content slots. */
190
+ internal fun drawReactChildInto(canvas: Canvas, index: Int) {
191
+ val child = getReactChildAt(index) ?: return
192
+ if (child.visibility != View.VISIBLE) return
193
+ val save = canvas.save()
194
+ val matrix = child.matrix
195
+ if (!matrix.isIdentity) canvas.concat(matrix)
196
+ val alpha = child.alpha
197
+ if (alpha < 1f) canvas.saveLayerAlpha(0f, 0f, child.width.toFloat(), child.height.toFloat(), (alpha * 255f).toInt())
198
+ child.draw(canvas)
199
+ canvas.restoreToCount(save)
200
+ }
201
+
189
202
  override fun drawChild(canvas: Canvas, child: View, drawingTime: Long): Boolean {
190
203
  if (drawsReactChildrenInCompose && child !== composeView) return false
191
204
  return super.drawChild(canvas, child, drawingTime)
@@ -1 +1 @@
1
- {"version":3,"file":"AndroidGlassMenu.d.ts","sourceRoot":"","sources":["../src/AndroidGlassMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AAU5F,mFAAmF;AACnF,wBAAgB,wBAAwB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BA+K7E;AAED,oFAAoF;AACpF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,QAwDpE"}
1
+ {"version":3,"file":"AndroidGlassMenu.d.ts","sourceRoot":"","sources":["../src/AndroidGlassMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AAU5F,mFAAmF;AACnF,wBAAgB,wBAAwB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAiL7E;AAED,oFAAoF;AACpF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,QA8DpE"}
@@ -100,7 +100,7 @@ export function AndroidGlassMenuProvider({ children }) {
100
100
  height: Platform.OS === 'android' ? frame.availableHeight : frame.height,
101
101
  },
102
102
  ]}>
103
- <GlassMenuPanel key={entry.id} items={entry.children != null ? EMPTY_ITEMS : (entry.items ?? EMPTY_ITEMS)} customHeight={entry.children != null ? frame.height : 0} children={entry.children} expanded={entry.visible} dark={entry.theme === 'dark'} originX={frame.originX} originY={frame.originY} rowHeight={rowHeight} sourceIcon={entry.sourceIcon} backRequest={backRequest} onNavigate={(value) => {
103
+ <GlassMenuPanel key={entry.id} items={entry.children != null ? EMPTY_ITEMS : (entry.items ?? EMPTY_ITEMS)} customHeight={entry.children != null ? frame.height : 0} children={entry.children} expanded={entry.visible} dark={entry.theme === 'dark'} shadow={entry.shadow} shadowOpacity={entry.shadowOpacity} originX={frame.originX} originY={frame.originY} rowHeight={rowHeight} sourceIcon={entry.sourceIcon} backRequest={backRequest} onNavigate={(value) => {
104
104
  depth.current = value;
105
105
  }} onDismissRequest={dismissOrCollapse} onClosed={() => {
106
106
  if (!entry.visible) {
@@ -139,7 +139,7 @@ export default function AndroidGlassMenu(props) {
139
139
  const id = useId();
140
140
  if (!portal)
141
141
  throw new Error('AndroidGlassMenu requires AndroidGlassMenuProvider above the navigator.');
142
- const { children, contentHeight, visible, anchorRef, items, onSelect, onDismiss, onDismissed, sourceIcon, width, theme, insets, placement, } = props;
142
+ const { children, contentHeight, visible, anchorRef, items, onSelect, onDismiss, onDismissed, sourceIcon, width, theme, shadow, shadowOpacity, insets, placement, } = props;
143
143
  useEffect(() => {
144
144
  portal.set({
145
145
  id,
@@ -154,6 +154,8 @@ export default function AndroidGlassMenu(props) {
154
154
  sourceIcon,
155
155
  width,
156
156
  theme,
157
+ shadow,
158
+ shadowOpacity,
157
159
  insets,
158
160
  placement,
159
161
  });
@@ -171,6 +173,8 @@ export default function AndroidGlassMenu(props) {
171
173
  sourceIcon,
172
174
  width,
173
175
  theme,
176
+ shadow,
177
+ shadowOpacity,
174
178
  insets,
175
179
  placement,
176
180
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"AndroidGlassMenu.js","sourceRoot":"","sources":["../src/AndroidGlassMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,SAAS,EACT,KAAK,EACL,OA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,SAAS;YACT,KAAK;YACL,QAAQ;YACR,SAAS;YACT,WAAW;YACX,UAAU;YACV,KAAK;YACL,KAAK;YACL,MAAM;YACN,SAAS;SACV,CAAC,CAAC;IACL,CAAC,EAAE;QACD,MAAM;QACN,EAAE;QACF,QAAQ;QACR,aAAa;QACb,OAAO;QACP,SAAS;QACT,KAAK;QACL,QAAQ;QACR,SAAS;QACT,WAAW;QACX,UAAU;QACV,KAAK;QACL,KAAK;QACL,MAAM;QACN,SAAS;KACV,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACjB,OAAO,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE;IACtF,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE;IAC/B,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;CACvB,CAAC,CAAC","sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport {\n BackHandler,\n Pressable,\n Platform,\n StyleSheet,\n View,\n useWindowDimensions,\n} from 'react-native';\n\nimport type { AndroidGlassMenuProps, AndroidGlassMenuItem } from './AndroidGlassMenu.types';\nimport GlassMenuPanel from './GlassMenuPanel';\nimport { menuLayout } from './menuLayout';\n\nconst EMPTY_ITEMS: readonly AndroidGlassMenuItem[] = [];\n\ntype Entry = AndroidGlassMenuProps & { id: string };\ntype Portal = { set: (entry: Entry) => void; remove: (id: string) => void };\nconst Context = createContext<Portal | null>(null);\n\n/** Place above your navigator, in the same window as the content being sampled. */\nexport function AndroidGlassMenuProvider({ children }: { children: ReactNode }) {\n const [entry, setEntry] = useState<Entry | null>(null);\n const [frame, setFrame] = useState<{\n id: string;\n left: number;\n top: number;\n width: number;\n height: number;\n originX: number;\n originY: number;\n availableHeight: number;\n } | null>(null);\n const root = useRef<View>(null);\n const depth = useRef(0);\n const [backRequest, setBackRequest] = useState(0);\n const [closedId, setClosedId] = useState<string | null>(null);\n const hidden = !!entry && !entry.visible && closedId === entry.id;\n const panelId = useRef<string | null>(null);\n const { width: windowWidth, height: windowHeight, fontScale } = useWindowDimensions();\n const rowHeight = Math.max(48, 48 * fontScale);\n const portal = useMemo<Portal>(\n () => ({\n set: (next) => {\n if (next.visible) setClosedId(null);\n setEntry((current) => {\n if (next.visible) return next;\n if (current?.id !== next.id) return current;\n // Closing before measurement completed must not leave a back-button blocker.\n return panelId.current === next.id ? next : null;\n });\n },\n remove: (id) => {\n if (panelId.current === id) panelId.current = null;\n setEntry((current) => (current?.id === id ? null : current));\n setFrame((current) => (current?.id === id ? null : current));\n },\n }),\n []\n );\n\n useEffect(() => {\n depth.current = 0;\n }, [entry?.id]);\n\n const dismissOrCollapse = () => {\n if (depth.current > 0) setBackRequest((value) => value + 1);\n else entry?.onDismiss();\n };\n\n useEffect(() => {\n if (!entry?.visible) return;\n if (!entry.anchorRef.current) {\n entry.onDismiss();\n return;\n }\n let cancelled = false;\n root.current?.measureInWindow((rootX, rootY, rootWidth, rootHeight) => {\n entry.anchorRef.current?.measureInWindow((x, y, anchorWidth, anchorHeight) => {\n if (cancelled || rootWidth <= 0 || rootHeight <= 0) return;\n panelId.current = entry.id;\n const layout = menuLayout(\n { x: rootX, y: rootY, width: rootWidth, height: rootHeight },\n { x, y, width: anchorWidth, height: anchorHeight },\n entry.items ?? EMPTY_ITEMS,\n rowHeight,\n entry.width,\n entry.insets,\n entry.placement,\n fontScale,\n entry.children != null ? Math.max(48, entry.contentHeight ?? 240) : undefined\n );\n setFrame({\n id: entry.id,\n ...layout,\n availableHeight: Math.max(1, rootHeight - layout.top - (entry.insets?.bottom ?? 12)),\n });\n });\n });\n return () => {\n cancelled = true;\n };\n }, [entry, windowWidth, windowHeight, rowHeight, fontScale]);\n\n useEffect(() => {\n if (!entry || hidden) return;\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n if (depth.current > 0) setBackRequest((value) => value + 1);\n else entry.onDismiss();\n return true;\n });\n return () => subscription.remove();\n }, [entry, hidden]);\n\n return (\n <Context.Provider value={portal}>\n <View ref={root} collapsable={false} style={styles.root}>\n {/* Keep the native content tree stable when accessibility switches for the menu.\n Flattening this wrapper would invalidate the RenderNodes cached by glass backdrops. */}\n <View\n collapsable={false}\n style={styles.root}\n importantForAccessibility={entry?.visible ? 'no-hide-descendants' : 'auto'}\n accessibilityElementsHidden={!!entry?.visible}>\n {children}\n </View>\n {entry && frame?.id === entry.id && (\n <View\n style={[styles.overlay, hidden && styles.hidden]}\n pointerEvents={hidden ? 'none' : 'auto'}\n accessibilityViewIsModal={!hidden}\n importantForAccessibility={hidden ? 'no-hide-descendants' : 'auto'}\n accessibilityElementsHidden={hidden}>\n <Pressable\n style={StyleSheet.absoluteFill}\n onPress={dismissOrCollapse}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Close menu\"\n />\n <View\n style={[\n styles.panel,\n {\n left: frame.left,\n top: frame.top,\n width: frame.width,\n height: Platform.OS === 'android' ? frame.availableHeight : frame.height,\n },\n ]}>\n <GlassMenuPanel\n key={entry.id}\n items={entry.children != null ? EMPTY_ITEMS : (entry.items ?? EMPTY_ITEMS)}\n customHeight={entry.children != null ? frame.height : 0}\n children={entry.children}\n expanded={entry.visible}\n dark={entry.theme === 'dark'}\n originX={frame.originX}\n originY={frame.originY}\n rowHeight={rowHeight}\n sourceIcon={entry.sourceIcon}\n backRequest={backRequest}\n onNavigate={(value) => {\n depth.current = value;\n }}\n onDismissRequest={dismissOrCollapse}\n onClosed={() => {\n if (!entry.visible) {\n entry.onDismissed?.();\n // Keep the Compose layer and its GPU programs warm for the next opening.\n setClosedId(entry.id);\n }\n }}\n onSelect={(id) => {\n if (!entry.visible) return;\n const findItem = (\n items: readonly AndroidGlassMenuItem[]\n ): AndroidGlassMenuItem | undefined => {\n for (const item of items) {\n if (item.id === id) return item;\n const child = item.children && findItem(item.children);\n if (child) return child;\n }\n return undefined;\n };\n const item = findItem(entry.items ?? EMPTY_ITEMS);\n if (!item || item.disabled) return;\n if (!item.keepsMenuPresented) entry.onDismiss();\n entry.onSelect?.(id);\n }}\n />\n </View>\n </View>\n )}\n </View>\n </Context.Provider>\n );\n}\n\n/** Controlled anchored menu. Its panel is rendered above the provider's content. */\nexport default function AndroidGlassMenu(props: AndroidGlassMenuProps) {\n const portal = useContext(Context);\n const id = useId();\n if (!portal)\n throw new Error('AndroidGlassMenu requires AndroidGlassMenuProvider above the navigator.');\n const {\n children,\n contentHeight,\n visible,\n anchorRef,\n items,\n onSelect,\n onDismiss,\n onDismissed,\n sourceIcon,\n width,\n theme,\n insets,\n placement,\n } = props;\n useEffect(() => {\n portal.set({\n id,\n children,\n contentHeight,\n visible,\n anchorRef,\n items,\n onSelect,\n onDismiss,\n onDismissed,\n sourceIcon,\n width,\n theme,\n insets,\n placement,\n });\n }, [\n portal,\n id,\n children,\n contentHeight,\n visible,\n anchorRef,\n items,\n onSelect,\n onDismiss,\n onDismissed,\n sourceIcon,\n width,\n theme,\n insets,\n placement,\n ]);\n useEffect(() => () => portal.remove(id), [portal, id]);\n return null;\n}\n\nconst styles = StyleSheet.create({\n root: { flex: 1 },\n overlay: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10000 },\n panel: { position: 'absolute' },\n hidden: { opacity: 0 },\n});\n"]}
1
+ {"version":3,"file":"AndroidGlassMenu.js","sourceRoot":"","sources":["../src/AndroidGlassMenu.tsx"],"names":[],"mappings":"AAAA,OAAO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L,MAAM,EACN,aAAa,EACb,MAAM,EACN,SAAS,GACV,GAAG,KAAK,CAAC;IACV,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,GAAG,CAAC;YACT,EAAE;YACF,QAAQ;YACR,aAAa;YACb,OAAO;YACP,SAAS;YACT,KAAK;YACL,QAAQ;YACR,SAAS;YACT,WAAW;YACX,UAAU;YACV,KAAK;YACL,KAAK;YACL,MAAM;YACN,aAAa;YACb,MAAM;YACN,SAAS;SACV,CAAC,CAAC;IACL,CAAC,EAAE;QACD,MAAM;QACN,EAAE;QACF,QAAQ;QACR,aAAa;QACb,OAAO;QACP,SAAS;QACT,KAAK;QACL,QAAQ;QACR,SAAS;QACT,WAAW;QACX,UAAU;QACV,KAAK;QACL,KAAK;QACL,MAAM;QACN,aAAa;QACb,MAAM;QACN,SAAS;KACV,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACjB,OAAO,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE;IACtF,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE;IAC/B,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;CACvB,CAAC,CAAC","sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport {\n BackHandler,\n Pressable,\n Platform,\n StyleSheet,\n View,\n useWindowDimensions,\n} from 'react-native';\n\nimport type { AndroidGlassMenuProps, AndroidGlassMenuItem } from './AndroidGlassMenu.types';\nimport GlassMenuPanel from './GlassMenuPanel';\nimport { menuLayout } from './menuLayout';\n\nconst EMPTY_ITEMS: readonly AndroidGlassMenuItem[] = [];\n\ntype Entry = AndroidGlassMenuProps & { id: string };\ntype Portal = { set: (entry: Entry) => void; remove: (id: string) => void };\nconst Context = createContext<Portal | null>(null);\n\n/** Place above your navigator, in the same window as the content being sampled. */\nexport function AndroidGlassMenuProvider({ children }: { children: ReactNode }) {\n const [entry, setEntry] = useState<Entry | null>(null);\n const [frame, setFrame] = useState<{\n id: string;\n left: number;\n top: number;\n width: number;\n height: number;\n originX: number;\n originY: number;\n availableHeight: number;\n } | null>(null);\n const root = useRef<View>(null);\n const depth = useRef(0);\n const [backRequest, setBackRequest] = useState(0);\n const [closedId, setClosedId] = useState<string | null>(null);\n const hidden = !!entry && !entry.visible && closedId === entry.id;\n const panelId = useRef<string | null>(null);\n const { width: windowWidth, height: windowHeight, fontScale } = useWindowDimensions();\n const rowHeight = Math.max(48, 48 * fontScale);\n const portal = useMemo<Portal>(\n () => ({\n set: (next) => {\n if (next.visible) setClosedId(null);\n setEntry((current) => {\n if (next.visible) return next;\n if (current?.id !== next.id) return current;\n // Closing before measurement completed must not leave a back-button blocker.\n return panelId.current === next.id ? next : null;\n });\n },\n remove: (id) => {\n if (panelId.current === id) panelId.current = null;\n setEntry((current) => (current?.id === id ? null : current));\n setFrame((current) => (current?.id === id ? null : current));\n },\n }),\n []\n );\n\n useEffect(() => {\n depth.current = 0;\n }, [entry?.id]);\n\n const dismissOrCollapse = () => {\n if (depth.current > 0) setBackRequest((value) => value + 1);\n else entry?.onDismiss();\n };\n\n useEffect(() => {\n if (!entry?.visible) return;\n if (!entry.anchorRef.current) {\n entry.onDismiss();\n return;\n }\n let cancelled = false;\n root.current?.measureInWindow((rootX, rootY, rootWidth, rootHeight) => {\n entry.anchorRef.current?.measureInWindow((x, y, anchorWidth, anchorHeight) => {\n if (cancelled || rootWidth <= 0 || rootHeight <= 0) return;\n panelId.current = entry.id;\n const layout = menuLayout(\n { x: rootX, y: rootY, width: rootWidth, height: rootHeight },\n { x, y, width: anchorWidth, height: anchorHeight },\n entry.items ?? EMPTY_ITEMS,\n rowHeight,\n entry.width,\n entry.insets,\n entry.placement,\n fontScale,\n entry.children != null ? Math.max(48, entry.contentHeight ?? 240) : undefined\n );\n setFrame({\n id: entry.id,\n ...layout,\n availableHeight: Math.max(1, rootHeight - layout.top - (entry.insets?.bottom ?? 12)),\n });\n });\n });\n return () => {\n cancelled = true;\n };\n }, [entry, windowWidth, windowHeight, rowHeight, fontScale]);\n\n useEffect(() => {\n if (!entry || hidden) return;\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n if (depth.current > 0) setBackRequest((value) => value + 1);\n else entry.onDismiss();\n return true;\n });\n return () => subscription.remove();\n }, [entry, hidden]);\n\n return (\n <Context.Provider value={portal}>\n <View ref={root} collapsable={false} style={styles.root}>\n {/* Keep the native content tree stable when accessibility switches for the menu.\n Flattening this wrapper would invalidate the RenderNodes cached by glass backdrops. */}\n <View\n collapsable={false}\n style={styles.root}\n importantForAccessibility={entry?.visible ? 'no-hide-descendants' : 'auto'}\n accessibilityElementsHidden={!!entry?.visible}>\n {children}\n </View>\n {entry && frame?.id === entry.id && (\n <View\n style={[styles.overlay, hidden && styles.hidden]}\n pointerEvents={hidden ? 'none' : 'auto'}\n accessibilityViewIsModal={!hidden}\n importantForAccessibility={hidden ? 'no-hide-descendants' : 'auto'}\n accessibilityElementsHidden={hidden}>\n <Pressable\n style={StyleSheet.absoluteFill}\n onPress={dismissOrCollapse}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Close menu\"\n />\n <View\n style={[\n styles.panel,\n {\n left: frame.left,\n top: frame.top,\n width: frame.width,\n height: Platform.OS === 'android' ? frame.availableHeight : frame.height,\n },\n ]}>\n <GlassMenuPanel\n key={entry.id}\n items={entry.children != null ? EMPTY_ITEMS : (entry.items ?? EMPTY_ITEMS)}\n customHeight={entry.children != null ? frame.height : 0}\n children={entry.children}\n expanded={entry.visible}\n dark={entry.theme === 'dark'}\n shadow={entry.shadow}\n shadowOpacity={entry.shadowOpacity}\n originX={frame.originX}\n originY={frame.originY}\n rowHeight={rowHeight}\n sourceIcon={entry.sourceIcon}\n backRequest={backRequest}\n onNavigate={(value) => {\n depth.current = value;\n }}\n onDismissRequest={dismissOrCollapse}\n onClosed={() => {\n if (!entry.visible) {\n entry.onDismissed?.();\n // Keep the Compose layer and its GPU programs warm for the next opening.\n setClosedId(entry.id);\n }\n }}\n onSelect={(id) => {\n if (!entry.visible) return;\n const findItem = (\n items: readonly AndroidGlassMenuItem[]\n ): AndroidGlassMenuItem | undefined => {\n for (const item of items) {\n if (item.id === id) return item;\n const child = item.children && findItem(item.children);\n if (child) return child;\n }\n return undefined;\n };\n const item = findItem(entry.items ?? EMPTY_ITEMS);\n if (!item || item.disabled) return;\n if (!item.keepsMenuPresented) entry.onDismiss();\n entry.onSelect?.(id);\n }}\n />\n </View>\n </View>\n )}\n </View>\n </Context.Provider>\n );\n}\n\n/** Controlled anchored menu. Its panel is rendered above the provider's content. */\nexport default function AndroidGlassMenu(props: AndroidGlassMenuProps) {\n const portal = useContext(Context);\n const id = useId();\n if (!portal)\n throw new Error('AndroidGlassMenu requires AndroidGlassMenuProvider above the navigator.');\n const {\n children,\n contentHeight,\n visible,\n anchorRef,\n items,\n onSelect,\n onDismiss,\n onDismissed,\n sourceIcon,\n width,\n theme,\n shadow,\n shadowOpacity,\n insets,\n placement,\n } = props;\n useEffect(() => {\n portal.set({\n id,\n children,\n contentHeight,\n visible,\n anchorRef,\n items,\n onSelect,\n onDismiss,\n onDismissed,\n sourceIcon,\n width,\n theme,\n shadow,\n shadowOpacity,\n insets,\n placement,\n });\n }, [\n portal,\n id,\n children,\n contentHeight,\n visible,\n anchorRef,\n items,\n onSelect,\n onDismiss,\n onDismissed,\n sourceIcon,\n width,\n theme,\n shadow,\n shadowOpacity,\n insets,\n placement,\n ]);\n useEffect(() => () => portal.remove(id), [portal, id]);\n return null;\n}\n\nconst styles = StyleSheet.create({\n root: { flex: 1 },\n overlay: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10000 },\n panel: { position: 'absolute' },\n hidden: { opacity: 0 },\n});\n"]}
@@ -1,4 +1,4 @@
1
- import type { ReactNode, RefObject } from 'react';
1
+ import type { ReactElement, ReactNode, RefObject } from 'react';
2
2
  import type { View } from 'react-native';
3
3
  export type AndroidGlassMenuItem = {
4
4
  /** Stable, unique identifier returned by onSelect. */
@@ -6,8 +6,8 @@ export type AndroidGlassMenuItem = {
6
6
  title: string;
7
7
  /** A nested action list, shown with a trailing chevron. */
8
8
  children?: readonly AndroidGlassMenuItem[];
9
- /** Native line icon displayed before the title. */
10
- icon?: 'grid' | 'heart' | 'adjustments' | 'photo' | 'video' | 'screenshot' | 'album' | 'zoom-in' | 'zoom-out' | 'aspect' | 'people';
9
+ /** Native line icon or a decorative React icon displayed before the title. */
10
+ icon?: 'grid' | 'heart' | 'adjustments' | 'photo' | 'video' | 'screenshot' | 'album' | 'zoom-in' | 'zoom-out' | 'aspect' | 'people' | ReactElement;
11
11
  /** A compact row inside a submenu. */
12
12
  compact?: boolean;
13
13
  /** Optional muted section heading above this item. */
@@ -43,6 +43,10 @@ export type AndroidGlassMenuProps = {
43
43
  placement?: 'overlap' | 'below';
44
44
  /** Shared glass material. Default light, independent of the system. */
45
45
  theme?: 'light' | 'dark';
46
+ /** Android drop shadow. Default true. */
47
+ shadow?: boolean;
48
+ /** Android shadow opacity, 0–1. Defaults to 0.12 in light and 0.16 in dark. */
49
+ shadowOpacity?: number;
46
50
  /** Padding inside the provider bounds, e.g. safe-area insets. Default 12 on all sides. */
47
51
  insets?: {
48
52
  top?: number;
@@ -57,6 +61,8 @@ export type GlassMenuPanelProps = {
57
61
  items: readonly AndroidGlassMenuItem[];
58
62
  expanded: boolean;
59
63
  dark: boolean;
64
+ shadow?: boolean;
65
+ shadowOpacity?: number;
60
66
  originX: number;
61
67
  originY: number;
62
68
  rowHeight: number;
@@ -1 +1 @@
1
- {"version":3,"file":"AndroidGlassMenu.types.d.ts","sourceRoot":"","sources":["../src/AndroidGlassMenu.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,oBAAoB,GAAG;IACjC,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC3C,mDAAmD;IACnD,IAAI,CAAC,EACD,MAAM,GACN,OAAO,GACP,aAAa,GACb,OAAO,GACP,OAAO,GACP,YAAY,GACZ,OAAO,GACP,SAAS,GACT,UAAU,GACV,QAAQ,GACR,QAAQ,CAAC;IACb,sCAAsC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yCAAyC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,mFAAmF;IACnF,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3D,gEAAgE;IAChE,KAAK,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC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KAAK,IAAI,CAAC;IACpC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AndroidGlassMenu.types.js","sourceRoot":"","sources":["../src/AndroidGlassMenu.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode, RefObject } from 'react';\nimport type { View } from 'react-native';\n\nexport type AndroidGlassMenuItem = {\n /** Stable, unique identifier returned by onSelect. */\n id: string;\n title: string;\n /** A nested action list, shown with a trailing chevron. */\n children?: readonly AndroidGlassMenuItem[];\n /** Native line icon displayed before the title. */\n icon?:\n | 'grid'\n | 'heart'\n | 'adjustments'\n | 'photo'\n | 'video'\n | 'screenshot'\n | 'album'\n | 'zoom-in'\n | 'zoom-out'\n | 'aspect'\n | 'people';\n /** A compact row inside a submenu. */\n compact?: boolean;\n /** Optional muted section heading above this item. */\n sectionTitle?: string;\n /** Update an option without dismissing the menu. */\n keepsMenuPresented?: boolean;\n checked?: boolean;\n disabled?: boolean;\n destructive?: boolean;\n /** Draw a separator before this item. */\n separator?: boolean;\n};\n\nexport type AndroidGlassMenuProps = {\n visible: boolean;\n /** A non-collapsible View wrapping the trigger, measured in window coordinates. */\n anchorRef: RefObject<Pick<View, 'measureInWindow'> | null>;\n /** Standard native rows. Ignored when children are supplied. */\n items?: readonly AndroidGlassMenuItem[];\n onSelect?: (id: string) => void;\n /** Custom React content replacing the native rows. Interactive children stay live. */\n children?: ReactNode;\n /** Custom panel height in dp (including padding). Default 240; clamped to available space. */\n contentHeight?: number;\n /** Set visible to false here. Called on selection, outside press, and Android back. */\n onDismiss: () => void;\n /** Called after the closing animation has returned to the trigger. */\n onDismissed?: () => void;\n /** Trigger glyph retained by the native surface during its morph. */\n sourceIcon?: 'sort';\n /** Default 250 dp, clamped to the provider's available width. */\n width?: number;\n /** Default overlap: expands over its trigger, like the reference menu. */\n placement?: 'overlap' | 'below';\n /** Shared glass material. Default light, independent of the system. */\n theme?: 'light' | 'dark';\n /** Padding inside the provider bounds, e.g. safe-area insets. Default 12 on all sides. */\n insets?: { top?: number; right?: number; bottom?: number; left?: number };\n};\n\nexport type GlassMenuPanelProps = {\n children?: ReactNode;\n customHeight?: number;\n items: readonly AndroidGlassMenuItem[];\n expanded: boolean;\n dark: boolean;\n originX: number;\n originY: number;\n rowHeight: number;\n sourceIcon?: 'sort';\n backRequest: number;\n onNavigate: (depth: number) => void;\n onDismissRequest: () => void;\n onSelect: (id: string) => void;\n onClosed: () => void;\n};\n"]}
1
+ {"version":3,"file":"AndroidGlassMenu.types.js","sourceRoot":"","sources":["../src/AndroidGlassMenu.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactElement, ReactNode, RefObject } from 'react';\nimport type { View } from 'react-native';\n\nexport type AndroidGlassMenuItem = {\n /** Stable, unique identifier returned by onSelect. */\n id: string;\n title: string;\n /** A nested action list, shown with a trailing chevron. */\n children?: readonly AndroidGlassMenuItem[];\n /** Native line icon or a decorative React icon displayed before the title. */\n icon?:\n | 'grid'\n | 'heart'\n | 'adjustments'\n | 'photo'\n | 'video'\n | 'screenshot'\n | 'album'\n | 'zoom-in'\n | 'zoom-out'\n | 'aspect'\n | 'people'\n | ReactElement;\n /** A compact row inside a submenu. */\n compact?: boolean;\n /** Optional muted section heading above this item. */\n sectionTitle?: string;\n /** Update an option without dismissing the menu. */\n keepsMenuPresented?: boolean;\n checked?: boolean;\n disabled?: boolean;\n destructive?: boolean;\n /** Draw a separator before this item. */\n separator?: boolean;\n};\n\nexport type AndroidGlassMenuProps = {\n visible: boolean;\n /** A non-collapsible View wrapping the trigger, measured in window coordinates. */\n anchorRef: RefObject<Pick<View, 'measureInWindow'> | null>;\n /** Standard native rows. Ignored when children are supplied. */\n items?: readonly AndroidGlassMenuItem[];\n onSelect?: (id: string) => void;\n /** Custom React content replacing the native rows. Interactive children stay live. */\n children?: ReactNode;\n /** Custom panel height in dp (including padding). Default 240; clamped to available space. */\n contentHeight?: number;\n /** Set visible to false here. Called on selection, outside press, and Android back. */\n onDismiss: () => void;\n /** Called after the closing animation has returned to the trigger. */\n onDismissed?: () => void;\n /** Trigger glyph retained by the native surface during its morph. */\n sourceIcon?: 'sort';\n /** Default 250 dp, clamped to the provider's available width. */\n width?: number;\n /** Default overlap: expands over its trigger, like the reference menu. */\n placement?: 'overlap' | 'below';\n /** Shared glass material. Default light, independent of the system. */\n theme?: 'light' | 'dark';\n /** Android drop shadow. Default true. */\n shadow?: boolean;\n /** Android shadow opacity, 0–1. Defaults to 0.12 in light and 0.16 in dark. */\n shadowOpacity?: number;\n /** Padding inside the provider bounds, e.g. safe-area insets. Default 12 on all sides. */\n insets?: { top?: number; right?: number; bottom?: number; left?: number };\n};\n\nexport type GlassMenuPanelProps = {\n children?: ReactNode;\n customHeight?: number;\n items: readonly AndroidGlassMenuItem[];\n expanded: boolean;\n dark: boolean;\n shadow?: boolean;\n shadowOpacity?: number;\n originX: number;\n originY: number;\n rowHeight: number;\n sourceIcon?: 'sort';\n backRequest: number;\n onNavigate: (depth: number) => void;\n onDismissRequest: () => void;\n onSelect: (id: string) => void;\n onClosed: () => void;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"GlassMenuPanel.android.d.ts","sourceRoot":"","sources":["../src/GlassMenuPanel.android.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAmBpE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,YAAgB,EAChB,QAAQ,EACR,UAAU,EACV,GAAG,KAAK,EACT,EAAE,mBAAmB,+BA6BrB"}
1
+ {"version":3,"file":"GlassMenuPanel.android.d.ts","sourceRoot":"","sources":["../src/GlassMenuPanel.android.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAsBpE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,YAAgB,EAChB,QAAQ,EACR,UAAU,EACV,GAAG,KAAK,EACT,EAAE,mBAAmB,+BA4CrB"}
@@ -1,8 +1,15 @@
1
1
  import { requireNativeView } from 'expo';
2
- import { ScrollView, StyleSheet } from 'react-native';
2
+ import { useMemo } from 'react';
3
+ import { ScrollView, StyleSheet, View, } from 'react-native';
4
+ import { serializeMenuItems } from './menuItemSerialization';
3
5
  const NativePanel = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassMenuPanel');
4
6
  export default function GlassMenuPanel({ items, children, customHeight = 0, onSelect, onNavigate, ...props }) {
5
- return (<NativePanel {...props} style={styles.fill} customHeight={customHeight} itemsJson={JSON.stringify(items)} onItemSelected={(event) => onSelect(event.nativeEvent.id)} onNavigate={(event) => onNavigate(event.nativeEvent.depth)}>
7
+ const { itemsJson, icons } = useMemo(() => serializeMenuItems(items), [items]);
8
+ return (<NativePanel {...props} style={styles.fill} shadow={props.shadow ?? true} shadowOpacity={props.shadowOpacity ?? null} customHeight={customHeight} itemsJson={itemsJson} onItemSelected={(event) => onSelect(event.nativeEvent.id)} onNavigate={(event) => onNavigate(event.nativeEvent.depth)}>
9
+ {children == null &&
10
+ icons.map((icon, index) => (<View key={index} collapsable={false} pointerEvents="none" accessible={false} style={styles.icon}>
11
+ {icon}
12
+ </View>))}
6
13
  {children != null && (<ScrollView collapsable={false} pointerEvents={props.expanded ? 'auto' : 'none'} style={{
7
14
  position: 'absolute',
8
15
  top: 0,
@@ -16,5 +23,8 @@ export default function GlassMenuPanel({ items, children, customHeight = 0, onSe
16
23
  </ScrollView>)}
17
24
  </NativePanel>);
18
25
  }
19
- const styles = StyleSheet.create({ fill: { flex: 1 } });
26
+ const styles = StyleSheet.create({
27
+ fill: { flex: 1 },
28
+ icon: { position: 'absolute', left: 0, top: 0, width: 20, height: 20 },
29
+ });
20
30
  //# sourceMappingURL=GlassMenuPanel.android.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GlassMenuPanel.android.js","sourceRoot":"","sources":["../src/GlassMenuPanel.android.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAA6C,MAAM,cAAc,CAAC;AAIjG,MAAM,WAAW,GAeb,iBAAiB,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,CAAC;AAEvE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,YAAY,GAAG,CAAC,EAChB,QAAQ,EACR,UAAU,EACV,GAAG,KAAK,EACY;IACpB,OAAO,CACL,CAAC,WAAW,CACV,IAAI,KAAK,CAAC,CACV,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CACnB,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CACjC,cAAc,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAC1D,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAC3D;MAAA,CAAC,QAAQ,IAAI,IAAI,IAAI,CACnB,CAAC,UAAU,CACT,WAAW,CAAC,CAAC,KAAK,CAAC,CACnB,aAAa,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAChD,KAAK,CAAC,CAAC;gBACL,QAAQ,EAAE,UAAU;gBACpB,GAAG,EAAE,CAAC;gBACN,IAAI,EAAE,CAAC;gBACP,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,YAAY;gBACpB,YAAY,EAAE,EAAE;gBAChB,QAAQ,EAAE,QAAQ;aACnB,CAAC,CACF,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CACvC,yBAAyB,CAAC,SAAS,CACnC;UAAA,CAAC,QAAQ,CACX;QAAA,EAAE,UAAU,CAAC,CACd,CACH;IAAA,EAAE,WAAW,CAAC,CACf,CAAC;AACJ,CAAC;AACD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport type { ComponentType } from 'react';\nimport { ScrollView, StyleSheet, type NativeSyntheticEvent, type ViewProps } from 'react-native';\n\nimport type { GlassMenuPanelProps } from './AndroidGlassMenu.types';\n\nconst NativePanel: ComponentType<\n ViewProps & {\n itemsJson: string;\n expanded: boolean;\n dark: boolean;\n originX: number;\n originY: number;\n rowHeight: number;\n backRequest: number;\n customHeight?: number;\n onItemSelected: (event: NativeSyntheticEvent<{ id: string }>) => void;\n onNavigate: (event: NativeSyntheticEvent<{ depth: number }>) => void;\n onDismissRequest: () => void;\n onClosed: () => void;\n }\n> = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassMenuPanel');\n\nexport default function GlassMenuPanel({\n items,\n children,\n customHeight = 0,\n onSelect,\n onNavigate,\n ...props\n}: GlassMenuPanelProps) {\n return (\n <NativePanel\n {...props}\n style={styles.fill}\n customHeight={customHeight}\n itemsJson={JSON.stringify(items)}\n onItemSelected={(event) => onSelect(event.nativeEvent.id)}\n onNavigate={(event) => onNavigate(event.nativeEvent.depth)}>\n {children != null && (\n <ScrollView\n collapsable={false}\n pointerEvents={props.expanded ? 'auto' : 'none'}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n height: customHeight,\n borderRadius: 30,\n overflow: 'hidden',\n }}\n contentContainerStyle={{ padding: 16 }}\n keyboardShouldPersistTaps=\"handled\">\n {children}\n </ScrollView>\n )}\n </NativePanel>\n );\n}\nconst styles = StyleSheet.create({ fill: { flex: 1 } });\n"]}
1
+ {"version":3,"file":"GlassMenuPanel.android.js","sourceRoot":"","sources":["../src/GlassMenuPanel.android.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,OAAO,EAAsB,MAAM,OAAO,CAAC;AACpD,OAAO,EACL,UAAU,EACV,UAAU,EACV,IAAI,GAGL,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,WAAW,GAiBb,iBAAiB,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,CAAC;AAEvE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,YAAY,GAAG,CAAC,EAChB,QAAQ,EACR,UAAU,EACV,GAAG,KAAK,EACY;IACpB,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAE/E,OAAO,CACL,CAAC,WAAW,CACV,IAAI,KAAK,CAAC,CACV,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CACnB,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,CAC7B,aAAa,CAAC,CAAC,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,CAC3C,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,SAAS,CAAC,CAAC,SAAS,CAAC,CACrB,cAAc,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAC1D,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,C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EAAE;CACvE,CAAC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport { useMemo, type ComponentType } from 'react';\nimport {\n ScrollView,\n StyleSheet,\n View,\n type NativeSyntheticEvent,\n type ViewProps,\n} from 'react-native';\n\nimport type { GlassMenuPanelProps } from './AndroidGlassMenu.types';\nimport { serializeMenuItems } from './menuItemSerialization';\n\nconst NativePanel: ComponentType<\n ViewProps & {\n itemsJson: string;\n expanded: boolean;\n dark: boolean;\n shadow: boolean;\n shadowOpacity: number | null;\n originX: number;\n originY: number;\n rowHeight: number;\n backRequest: number;\n customHeight?: number;\n onItemSelected: (event: NativeSyntheticEvent<{ id: string }>) => void;\n onNavigate: (event: NativeSyntheticEvent<{ depth: number }>) => void;\n onDismissRequest: () => void;\n onClosed: () => void;\n }\n> = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassMenuPanel');\n\nexport default function GlassMenuPanel({\n items,\n children,\n customHeight = 0,\n onSelect,\n onNavigate,\n ...props\n}: GlassMenuPanelProps) {\n const { itemsJson, icons } = useMemo(() => serializeMenuItems(items), [items]);\n\n return (\n <NativePanel\n {...props}\n style={styles.fill}\n shadow={props.shadow ?? true}\n shadowOpacity={props.shadowOpacity ?? null}\n customHeight={customHeight}\n itemsJson={itemsJson}\n onItemSelected={(event) => onSelect(event.nativeEvent.id)}\n onNavigate={(event) => onNavigate(event.nativeEvent.depth)}>\n {children == null &&\n icons.map((icon, index) => (\n <View\n key={index}\n collapsable={false}\n pointerEvents=\"none\"\n accessible={false}\n style={styles.icon}>\n {icon}\n </View>\n ))}\n {children != null && (\n <ScrollView\n collapsable={false}\n pointerEvents={props.expanded ? 'auto' : 'none'}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n height: customHeight,\n borderRadius: 30,\n overflow: 'hidden',\n }}\n contentContainerStyle={{ padding: 16 }}\n keyboardShouldPersistTaps=\"handled\">\n {children}\n </ScrollView>\n )}\n </NativePanel>\n );\n}\nconst styles = StyleSheet.create({\n fill: { flex: 1 },\n icon: { position: 'absolute', left: 0, top: 0, width: 20, height: 20 },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"GlassMenuPanel.d.ts","sourceRoot":"","sources":["../src/GlassMenuPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,EAAE,SAAS,EAChB,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,QAAQ,GACT,EAAE,mBAAmB,+BAmFrB"}
1
+ {"version":3,"file":"GlassMenuPanel.d.ts","sourceRoot":"","sources":["../src/GlassMenuPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,EAAE,SAAS,EAChB,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,QAAQ,GACT,EAAE,mBAAmB,+BAsFrB"}
@@ -49,6 +49,7 @@ export default function GlassMenuPanel({ items: rootItems, children, expanded, d
49
49
  <Text style={{ color: dark ? 'white' : '#17191d', width: 24 }}>
50
50
  {item.checked ? '✓' : ''}
51
51
  </Text>
52
+ {item.icon != null && typeof item.icon !== 'string' && (<View style={styles.icon}>{item.icon}</View>)}
52
53
  <Text style={{
53
54
  flex: 1,
54
55
  fontSize: 17,
@@ -66,6 +67,7 @@ export default function GlassMenuPanel({ items: rootItems, children, expanded, d
66
67
  const styles = StyleSheet.create({
67
68
  panel: { borderRadius: 32, padding: 8 },
68
69
  row: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 12, borderRadius: 16 },
70
+ icon: { width: 20, height: 20, marginRight: 14 },
69
71
  separator: { height: 1, marginVertical: 5.5, marginHorizontal: 16, backgroundColor: '#88888844' },
70
72
  });
71
73
  //# sourceMappingURL=GlassMenuPanel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GlassMenuPanel.js","sourceRoot":"","sources":["../src/GlassMenuPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGlG,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,EAAE,SAAS,EAChB,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,QAAQ,GACY;IACpB,MAAM,EAAE,SAAS,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAC5C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAC;IAC/C,IAAI,KAAK,GAAG,SAAS,CAAC;IACtB,KAAK,MAAM,EAAE,IAAI,IAAI;QAAE,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,IAAI,KAAK,CAAC;IACvF,SAAS,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC1E,IAAI,kBAAkB,KAAK,WAAW,EAAE,CAAC;QACvC,qBAAqB,CAAC,WAAW,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,KAAK,CAA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H;UAAA,EAAE,SAAS,CACb;QAAA,EAAE,IAAI,CAAC,CACR,CAAC,CACJ;IAAA,EAAE,UAAU,CAAC,CACd,CAAC;AACJ,CAAC;AACD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IACvC,GAAG,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;IAC5F,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,gBAAgB,EAAE,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE;CAClG,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { Pressable, ScrollView, StyleSheet, Text, View, useWindowDimensions } from 'react-native';\n\nimport type { GlassMenuPanelProps } from './AndroidGlassMenu.types';\nimport { menuItemHeight } from './menuLayout';\n\nexport default function GlassMenuPanel({\n items: rootItems,\n children,\n expanded,\n dark,\n rowHeight,\n onSelect,\n backRequest,\n onNavigate,\n onClosed,\n}: GlassMenuPanelProps) {\n const { fontScale } = useWindowDimensions();\n const [path, setPath] = useState<string[]>([]);\n let items = rootItems;\n for (const id of path) items = items.find((item) => item.id === id)?.children ?? items;\n useEffect(() => onNavigate(path.length), [path, onNavigate]);\n const [handledBackRequest, setHandledBackRequest] = useState(backRequest);\n if (handledBackRequest !== backRequest) {\n setHandledBackRequest(backRequest);\n setPath(path.slice(0, -1));\n }\n if (!expanded && path.length) setPath([]);\n useEffect(() => {\n if (!expanded) onClosed();\n }, [expanded, onClosed]);\n if (children != null)\n return (\n <ScrollView\n pointerEvents={expanded ? 'auto' : 'none'}\n style={[styles.panel, { backgroundColor: dark ? '#292d32' : '#f2f2f2' }]}\n contentContainerStyle={{ padding: 16 }}\n keyboardShouldPersistTaps=\"handled\">\n {children}\n </ScrollView>\n );\n return (\n <ScrollView style={[styles.panel, { backgroundColor: dark ? '#292d32' : '#f2f2f2' }]}>\n {path.length > 0 && (\n <Pressable onPress={() => setPath((value) => value.slice(0, -1))} style={styles.row}>\n <Text style={{ color: dark ? 'white' : '#17191d', paddingVertical: 16 }}>‹ Back</Text>\n </Pressable>\n )}\n {items.map((item) => (\n <View key={item.id}>\n {item.separator && <View style={styles.separator} />}\n {item.sectionTitle && (\n <Text\n style={{\n color: dark ? '#ffffff88' : '#00000088',\n paddingLeft: 36,\n height: 30 * fontScale,\n fontSize: 13,\n textAlignVertical: 'center',\n }}>\n {item.sectionTitle}\n </Text>\n )}\n <Pressable\n disabled={item.disabled}\n accessibilityRole=\"menuitem\"\n accessibilityState={{ disabled: !!item.disabled, selected: !!item.checked }}\n onPress={() =>\n item.children?.length ? setPath([...path, item.id]) : onSelect(item.id)\n }\n style={({ pressed }) => [\n styles.row,\n {\n minHeight: menuItemHeight(item, rowHeight, fontScale),\n opacity: item.disabled ? 0.4 : 1,\n backgroundColor: pressed ? (dark ? '#ffffff22' : '#00000011') : 'transparent',\n },\n ]}>\n <Text style={{ color: dark ? 'white' : '#17191d', width: 24 }}>\n {item.checked ? '✓' : ''}\n </Text>\n <Text\n style={{\n flex: 1,\n fontSize: 17,\n color: item.destructive ? '#e5484d' : dark ? 'white' : '#17191d',\n }}>\n {item.title}\n </Text>\n {!!item.children?.length && (\n <Text style={{ color: dark ? 'white' : '#17191d', fontSize: 20, paddingLeft: 12 }}>\n ›\n </Text>\n )}\n </Pressable>\n </View>\n ))}\n </ScrollView>\n );\n}\nconst styles = StyleSheet.create({\n panel: { borderRadius: 32, padding: 8 },\n row: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 12, borderRadius: 16 },\n separator: { height: 1, marginVertical: 5.5, marginHorizontal: 16, backgroundColor: '#88888844' },\n});\n"]}
1
+ {"version":3,"file":"GlassMenuPanel.js","sourceRoot":"","sources":["../src/GlassMenuPanel.tsx"],"names":[],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WAAW,EAAE,EAAE,EAAE,CAAC,CAChF;;cACF,EAAE,IAAI,CAAC,CACR,CACH;UAAA,EAAE,SAAS,CACb;QAAA,EAAE,IAAI,CAAC,CACR,CAAC,CACJ;IAAA,EAAE,UAAU,CAAC,CACd,CAAC;AACJ,CAAC;AACD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IACvC,GAAG,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;IAC5F,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;IAChD,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,gBAAgB,EAAE,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE;CAClG,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { Pressable, ScrollView, StyleSheet, Text, View, useWindowDimensions } from 'react-native';\n\nimport type { GlassMenuPanelProps } from './AndroidGlassMenu.types';\nimport { menuItemHeight } from './menuLayout';\n\nexport default function GlassMenuPanel({\n items: rootItems,\n children,\n expanded,\n dark,\n rowHeight,\n onSelect,\n backRequest,\n onNavigate,\n onClosed,\n}: GlassMenuPanelProps) {\n const { fontScale } = useWindowDimensions();\n const [path, setPath] = useState<string[]>([]);\n let items = rootItems;\n for (const id of path) items = items.find((item) => item.id === id)?.children ?? items;\n useEffect(() => onNavigate(path.length), [path, onNavigate]);\n const [handledBackRequest, setHandledBackRequest] = useState(backRequest);\n if (handledBackRequest !== backRequest) {\n setHandledBackRequest(backRequest);\n setPath(path.slice(0, -1));\n }\n if (!expanded && path.length) setPath([]);\n useEffect(() => {\n if (!expanded) onClosed();\n }, [expanded, onClosed]);\n if (children != null)\n return (\n <ScrollView\n pointerEvents={expanded ? 'auto' : 'none'}\n style={[styles.panel, { backgroundColor: dark ? '#292d32' : '#f2f2f2' }]}\n contentContainerStyle={{ padding: 16 }}\n keyboardShouldPersistTaps=\"handled\">\n {children}\n </ScrollView>\n );\n return (\n <ScrollView style={[styles.panel, { backgroundColor: dark ? '#292d32' : '#f2f2f2' }]}>\n {path.length > 0 && (\n <Pressable onPress={() => setPath((value) => value.slice(0, -1))} style={styles.row}>\n <Text style={{ color: dark ? 'white' : '#17191d', paddingVertical: 16 }}>‹ Back</Text>\n </Pressable>\n )}\n {items.map((item) => (\n <View key={item.id}>\n {item.separator && <View style={styles.separator} />}\n {item.sectionTitle && (\n <Text\n style={{\n color: dark ? '#ffffff88' : '#00000088',\n paddingLeft: 36,\n height: 30 * fontScale,\n fontSize: 13,\n textAlignVertical: 'center',\n }}>\n {item.sectionTitle}\n </Text>\n )}\n <Pressable\n disabled={item.disabled}\n accessibilityRole=\"menuitem\"\n accessibilityState={{ disabled: !!item.disabled, selected: !!item.checked }}\n onPress={() =>\n item.children?.length ? setPath([...path, item.id]) : onSelect(item.id)\n }\n style={({ pressed }) => [\n styles.row,\n {\n minHeight: menuItemHeight(item, rowHeight, fontScale),\n opacity: item.disabled ? 0.4 : 1,\n backgroundColor: pressed ? (dark ? '#ffffff22' : '#00000011') : 'transparent',\n },\n ]}>\n <Text style={{ color: dark ? 'white' : '#17191d', width: 24 }}>\n {item.checked ? '✓' : ''}\n </Text>\n {item.icon != null && typeof item.icon !== 'string' && (\n <View style={styles.icon}>{item.icon}</View>\n )}\n <Text\n style={{\n flex: 1,\n fontSize: 17,\n color: item.destructive ? '#e5484d' : dark ? 'white' : '#17191d',\n }}>\n {item.title}\n </Text>\n {!!item.children?.length && (\n <Text style={{ color: dark ? 'white' : '#17191d', fontSize: 20, paddingLeft: 12 }}>\n ›\n </Text>\n )}\n </Pressable>\n </View>\n ))}\n </ScrollView>\n );\n}\nconst styles = StyleSheet.create({\n panel: { borderRadius: 32, padding: 8 },\n row: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 12, borderRadius: 16 },\n icon: { width: 20, height: 20, marginRight: 14 },\n separator: { height: 1, marginVertical: 5.5, marginHorizontal: 16, backgroundColor: '#88888844' },\n});\n"]}
@@ -0,0 +1,8 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { AndroidGlassMenuItem } from './AndroidGlassMenu.types';
3
+ /** Keep React elements in the native child tree, never in the JSON row payload. */
4
+ export declare function serializeMenuItems(items: readonly AndroidGlassMenuItem[]): {
5
+ itemsJson: string;
6
+ icons: ReactElement<unknown, string | import("react").JSXElementConstructor<any>>[];
7
+ };
8
+ //# sourceMappingURL=menuItemSerialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menuItemSerialization.d.ts","sourceRoot":"","sources":["../src/menuItemSerialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,oBAAoB,EAAE;;;EAaxE"}
@@ -0,0 +1,15 @@
1
+ /** Keep React elements in the native child tree, never in the JSON row payload. */
2
+ export function serializeMenuItems(items) {
3
+ const icons = [];
4
+ const serialize = (rows) => rows.map(({ icon, children, ...item }) => {
5
+ const iconViewIndex = typeof icon === 'string' || icon == null ? -1 : icons.push(icon) - 1;
6
+ return {
7
+ ...item,
8
+ icon: typeof icon === 'string' ? icon : '',
9
+ iconViewIndex,
10
+ children: children ? serialize(children) : [],
11
+ };
12
+ });
13
+ return { itemsJson: JSON.stringify(serialize(items)), icons };
14
+ }
15
+ //# sourceMappingURL=menuItemSerialization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menuItemSerialization.js","sourceRoot":"","sources":["../src/menuItemSerialization.ts"],"names":[],"mappings":"AAIA,mFAAmF;AACnF,MAAM,UAAU,kBAAkB,CAAC,KAAsC;IACvE,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,MAAM,SAAS,GAAG,CAAC,IAAqC,EAAY,EAAE,CACpE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE;QACvC,MAAM,aAAa,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3F,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YAC1C,aAAa;YACb,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;SAC9C,CAAC;IACJ,CAAC,CAAC,CAAC;IACL,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;AAChE,CAAC","sourcesContent":["import type { ReactElement } from 'react';\n\nimport type { AndroidGlassMenuItem } from './AndroidGlassMenu.types';\n\n/** Keep React elements in the native child tree, never in the JSON row payload. */\nexport function serializeMenuItems(items: readonly AndroidGlassMenuItem[]) {\n const icons: ReactElement[] = [];\n const serialize = (rows: readonly AndroidGlassMenuItem[]): object[] =>\n rows.map(({ icon, children, ...item }) => {\n const iconViewIndex = typeof icon === 'string' || icon == null ? -1 : icons.push(icon) - 1;\n return {\n ...item,\n icon: typeof icon === 'string' ? icon : '',\n iconViewIndex,\n children: children ? serialize(children) : [],\n };\n });\n return { itemsJson: JSON.stringify(serialize(items)), icons };\n}\n"]}
@@ -3,7 +3,7 @@ module.exports = {
3
3
  rootDir: '..',
4
4
  testEnvironment: 'node',
5
5
  watchman: false,
6
- testMatch: ['<rootDir>/src/__tests__/menuLayout.test.ts'],
6
+ testMatch: ['<rootDir>/src/__tests__/*.test.ts'],
7
7
  transform: {
8
8
  '^.+\\.tsx?$': ['babel-jest', { presets: ['babel-preset-expo'] }],
9
9
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-android-glass-view",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
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",
@@ -163,6 +163,8 @@ export function AndroidGlassMenuProvider({ children }: { children: ReactNode })
163
163
  children={entry.children}
164
164
  expanded={entry.visible}
165
165
  dark={entry.theme === 'dark'}
166
+ shadow={entry.shadow}
167
+ shadowOpacity={entry.shadowOpacity}
166
168
  originX={frame.originX}
167
169
  originY={frame.originY}
168
170
  rowHeight={rowHeight}
@@ -223,6 +225,8 @@ export default function AndroidGlassMenu(props: AndroidGlassMenuProps) {
223
225
  sourceIcon,
224
226
  width,
225
227
  theme,
228
+ shadow,
229
+ shadowOpacity,
226
230
  insets,
227
231
  placement,
228
232
  } = props;
@@ -240,6 +244,8 @@ export default function AndroidGlassMenu(props: AndroidGlassMenuProps) {
240
244
  sourceIcon,
241
245
  width,
242
246
  theme,
247
+ shadow,
248
+ shadowOpacity,
243
249
  insets,
244
250
  placement,
245
251
  });
@@ -257,6 +263,8 @@ export default function AndroidGlassMenu(props: AndroidGlassMenuProps) {
257
263
  sourceIcon,
258
264
  width,
259
265
  theme,
266
+ shadow,
267
+ shadowOpacity,
260
268
  insets,
261
269
  placement,
262
270
  ]);
@@ -1,4 +1,4 @@
1
- import type { ReactNode, RefObject } from 'react';
1
+ import type { ReactElement, ReactNode, RefObject } from 'react';
2
2
  import type { View } from 'react-native';
3
3
 
4
4
  export type AndroidGlassMenuItem = {
@@ -7,7 +7,7 @@ export type AndroidGlassMenuItem = {
7
7
  title: string;
8
8
  /** A nested action list, shown with a trailing chevron. */
9
9
  children?: readonly AndroidGlassMenuItem[];
10
- /** Native line icon displayed before the title. */
10
+ /** Native line icon or a decorative React icon displayed before the title. */
11
11
  icon?:
12
12
  | 'grid'
13
13
  | 'heart'
@@ -19,7 +19,8 @@ export type AndroidGlassMenuItem = {
19
19
  | 'zoom-in'
20
20
  | 'zoom-out'
21
21
  | 'aspect'
22
- | 'people';
22
+ | 'people'
23
+ | ReactElement;
23
24
  /** A compact row inside a submenu. */
24
25
  compact?: boolean;
25
26
  /** Optional muted section heading above this item. */
@@ -56,6 +57,10 @@ export type AndroidGlassMenuProps = {
56
57
  placement?: 'overlap' | 'below';
57
58
  /** Shared glass material. Default light, independent of the system. */
58
59
  theme?: 'light' | 'dark';
60
+ /** Android drop shadow. Default true. */
61
+ shadow?: boolean;
62
+ /** Android shadow opacity, 0–1. Defaults to 0.12 in light and 0.16 in dark. */
63
+ shadowOpacity?: number;
59
64
  /** Padding inside the provider bounds, e.g. safe-area insets. Default 12 on all sides. */
60
65
  insets?: { top?: number; right?: number; bottom?: number; left?: number };
61
66
  };
@@ -66,6 +71,8 @@ export type GlassMenuPanelProps = {
66
71
  items: readonly AndroidGlassMenuItem[];
67
72
  expanded: boolean;
68
73
  dark: boolean;
74
+ shadow?: boolean;
75
+ shadowOpacity?: number;
69
76
  originX: number;
70
77
  originY: number;
71
78
  rowHeight: number;
@@ -1,14 +1,23 @@
1
1
  import { requireNativeView } from 'expo';
2
- import type { ComponentType } from 'react';
3
- import { ScrollView, StyleSheet, type NativeSyntheticEvent, type ViewProps } from 'react-native';
2
+ import { useMemo, type ComponentType } from 'react';
3
+ import {
4
+ ScrollView,
5
+ StyleSheet,
6
+ View,
7
+ type NativeSyntheticEvent,
8
+ type ViewProps,
9
+ } from 'react-native';
4
10
 
5
11
  import type { GlassMenuPanelProps } from './AndroidGlassMenu.types';
12
+ import { serializeMenuItems } from './menuItemSerialization';
6
13
 
7
14
  const NativePanel: ComponentType<
8
15
  ViewProps & {
9
16
  itemsJson: string;
10
17
  expanded: boolean;
11
18
  dark: boolean;
19
+ shadow: boolean;
20
+ shadowOpacity: number | null;
12
21
  originX: number;
13
22
  originY: number;
14
23
  rowHeight: number;
@@ -29,14 +38,29 @@ export default function GlassMenuPanel({
29
38
  onNavigate,
30
39
  ...props
31
40
  }: GlassMenuPanelProps) {
41
+ const { itemsJson, icons } = useMemo(() => serializeMenuItems(items), [items]);
42
+
32
43
  return (
33
44
  <NativePanel
34
45
  {...props}
35
46
  style={styles.fill}
47
+ shadow={props.shadow ?? true}
48
+ shadowOpacity={props.shadowOpacity ?? null}
36
49
  customHeight={customHeight}
37
- itemsJson={JSON.stringify(items)}
50
+ itemsJson={itemsJson}
38
51
  onItemSelected={(event) => onSelect(event.nativeEvent.id)}
39
52
  onNavigate={(event) => onNavigate(event.nativeEvent.depth)}>
53
+ {children == null &&
54
+ icons.map((icon, index) => (
55
+ <View
56
+ key={index}
57
+ collapsable={false}
58
+ pointerEvents="none"
59
+ accessible={false}
60
+ style={styles.icon}>
61
+ {icon}
62
+ </View>
63
+ ))}
40
64
  {children != null && (
41
65
  <ScrollView
42
66
  collapsable={false}
@@ -58,4 +82,7 @@ export default function GlassMenuPanel({
58
82
  </NativePanel>
59
83
  );
60
84
  }
61
- const styles = StyleSheet.create({ fill: { flex: 1 } });
85
+ const styles = StyleSheet.create({
86
+ fill: { flex: 1 },
87
+ icon: { position: 'absolute', left: 0, top: 0, width: 20, height: 20 },
88
+ });
@@ -79,6 +79,9 @@ export default function GlassMenuPanel({
79
79
  <Text style={{ color: dark ? 'white' : '#17191d', width: 24 }}>
80
80
  {item.checked ? '✓' : ''}
81
81
  </Text>
82
+ {item.icon != null && typeof item.icon !== 'string' && (
83
+ <View style={styles.icon}>{item.icon}</View>
84
+ )}
82
85
  <Text
83
86
  style={{
84
87
  flex: 1,
@@ -101,5 +104,6 @@ export default function GlassMenuPanel({
101
104
  const styles = StyleSheet.create({
102
105
  panel: { borderRadius: 32, padding: 8 },
103
106
  row: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 12, borderRadius: 16 },
107
+ icon: { width: 20, height: 20, marginRight: 14 },
104
108
  separator: { height: 1, marginVertical: 5.5, marginHorizontal: 16, backgroundColor: '#88888844' },
105
109
  });
@@ -0,0 +1,19 @@
1
+ import type { ReactElement } from 'react';
2
+
3
+ import type { AndroidGlassMenuItem } from './AndroidGlassMenu.types';
4
+
5
+ /** Keep React elements in the native child tree, never in the JSON row payload. */
6
+ export function serializeMenuItems(items: readonly AndroidGlassMenuItem[]) {
7
+ const icons: ReactElement[] = [];
8
+ const serialize = (rows: readonly AndroidGlassMenuItem[]): object[] =>
9
+ rows.map(({ icon, children, ...item }) => {
10
+ const iconViewIndex = typeof icon === 'string' || icon == null ? -1 : icons.push(icon) - 1;
11
+ return {
12
+ ...item,
13
+ icon: typeof icon === 'string' ? icon : '',
14
+ iconViewIndex,
15
+ children: children ? serialize(children) : [],
16
+ };
17
+ });
18
+ return { itemsJson: JSON.stringify(serialize(items)), icons };
19
+ }