fix(mobile): show artist menu subtitles without a native rebuild

This commit is contained in:
joshuafhiggins committed 2026-11-15 14:28:32 -05:00 Verified
1 parent 60aa5da47f
commit b85c57b5ca
3 files changed
+94 -17

No files matched your search

@@ -0,0 +1,56 @@
import {
Button,
Host,
Label,
Menu,
RNHostView,
Text,
VStack,
} from "@expo/ui/swift-ui"
import { menuOrder } from "@expo/ui/swift-ui/modifiers"
import { StyleSheet, View } from "react-native"
import type { PlayerArtistFallbackMenuProps } from "./player-artist-fallback-menu"
// Use custom SwiftUI labels because the community menu adapter drops subtitles.
export function PlayerArtistFallbackMenu({
song,
size,
onAction,
}: PlayerArtistFallbackMenuProps) {
return (
<Host style={StyleSheet.absoluteFill} ignoreSafeArea="all">
<Menu
modifiers={[menuOrder("fixed")]}
label={
<RNHostView matchContents>
<View
style={size}
accessible
accessibilityRole="button"
accessibilityLabel={song.artist.name}
accessibilityHint="Opens album and artist options"
/>
</RNHostView>
}
>
<Button onPress={() => onAction("go-album")}>
<Label systemImage="square.stack">
<VStack alignment="leading">
<Text>Go to Album</Text>
<Text>{song.album.title}</Text>
</VStack>
</Label>
</Button>
<Button onPress={() => onAction("go-artist")}>
<Label systemImage="music.mic">
<VStack alignment="leading">
<Text>Go to Artist</Text>
<Text>{song.artist.name}</Text>
</VStack>
</Label>
</Button>
</Menu>
</Host>
)
}
@@ -0,0 +1,35 @@
import { StyleSheet, View } from "react-native"
import {
MediaActionMenu,
type MediaAction,
} from "@/components/media-context-menu"
import type { BrowseSong } from "@otunes/convex/types"
export type PlayerArtistFallbackMenuProps = {
song: BrowseSong
size: { width: number; height: number }
onAction: (action: MediaAction) => void
}
export function PlayerArtistFallbackMenu({
song,
size,
onAction,
}: PlayerArtistFallbackMenuProps) {
return (
<MediaActionMenu
style={StyleSheet.absoluteFill}
includeActions={["go-album", "go-artist"]}
onAction={onAction}
>
<View
style={size}
accessible
accessibilityRole="button"
accessibilityLabel={song.artist.name}
accessibilityHint="Opens album and artist options"
/>
</MediaActionMenu>
)
}
+3 -17
View File
@@ -2,10 +2,8 @@ import { requireNativeView, requireOptionalNativeModule } from "expo"
import { useState, type ReactNode } from "react"
import { Platform, StyleSheet, View, type ViewProps } from "react-native"
import {
MediaActionMenu,
type MediaAction,
} from "@/components/media-context-menu"
import type { MediaAction } from "@/components/media-context-menu"
import { PlayerArtistFallbackMenu } from "@/components/player-artist-fallback-menu"
import type { BrowseSong } from "@otunes/convex/types"
const NativeMenu =
@@ -56,19 +54,7 @@ export function PlayerArtistMenu({
onAction={({ nativeEvent }) => onAction(nativeEvent.action)}
/>
) : size.width > 0 ? (
<MediaActionMenu
style={StyleSheet.absoluteFill}
includeActions={["go-album", "go-artist"]}
onAction={onAction}
>
<View
style={size}
accessible
accessibilityRole="button"
accessibilityLabel={song.artist.name}
accessibilityHint="Opens album and artist options"
/>
</MediaActionMenu>
<PlayerArtistFallbackMenu song={song} size={size} onAction={onAction} />
) : null}
</View>
)