fix: simplify player menu and match navigation icons

This commit is contained in:
joshuafhiggins committed 2026-11-15 13:42:11 -05:00 Verified
1 parent 8b49f2253d
commit 7806553a86
9 files changed
+26 -206

No files matched your search

+1 -1
View File
@@ -545,7 +545,7 @@ function SongMeta({
{ color: colors.foreground },
]}
/>
<PlayerArtistMenu song={song} compact={compact} onAction={handleAction}>
<PlayerArtistMenu song={song} onAction={handleAction}>
<MarqueeText
text={song.artist.name}
style={[
@@ -89,12 +89,12 @@ const MEDIA_ACTION_ITEMS: {
{
action: "go-artist",
label: () => "Go to Artist",
image: "person",
image: "music.mic",
},
{
action: "go-album",
label: () => "Go to Album",
image: "opticaldisc",
image: "square.stack",
},
{
action: "favorite",
@@ -1,56 +0,0 @@
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>
)
}
@@ -1,35 +0,0 @@
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>
)
}
+18 -27
View File
@@ -1,31 +1,18 @@
import { requireNativeView, requireOptionalNativeModule } from "expo"
import { useState, type ReactNode } from "react"
import { Platform, StyleSheet, View, type ViewProps } from "react-native"
import { StyleSheet, View } from "react-native"
import type { MediaAction } from "@/components/media-context-menu"
import { PlayerArtistFallbackMenu } from "@/components/player-artist-fallback-menu"
import {
MediaActionMenu,
type MediaAction,
} from "@/components/media-context-menu"
import type { BrowseSong } from "@otunes/convex/types"
const NativeMenu =
Platform.OS === "ios" && requireOptionalNativeModule("PlayerNavigationMenu")
? requireNativeView<
ViewProps & {
artist: string
album: string
fontSize: number
onAction: (event: { nativeEvent: { action: MediaAction } }) => void
}
>("PlayerNavigationMenu")
: null
export function PlayerArtistMenu({
song,
compact,
onAction,
children,
}: {
song: BrowseSong
compact: boolean
onAction: (action: MediaAction) => void
children: ReactNode
}) {
@@ -45,16 +32,20 @@ export function PlayerArtistMenu({
>
{children}
</View>
{NativeMenu ? (
<NativeMenu
{size.width > 0 ? (
<MediaActionMenu
style={StyleSheet.absoluteFill}
artist={song.artist.name}
album={song.album.title}
fontSize={compact ? 15 : 20}
onAction={({ nativeEvent }) => onAction(nativeEvent.action)}
/>
) : size.width > 0 ? (
<PlayerArtistFallbackMenu song={song} size={size} onAction={onAction} />
includeActions={["go-album", "go-artist"]}
onAction={onAction}
>
<View
style={size}
accessible
accessibilityRole="button"
accessibilityLabel={song.artist.name}
accessibilityHint="Opens album and artist options"
/>
</MediaActionMenu>
) : null}
</View>
)
@@ -1,4 +0,0 @@
{
"platforms": ["apple"],
"apple": { "modules": ["PlayerNavigationMenuModule"] }
}
@@ -1,17 +0,0 @@
Pod::Spec.new do |s|
s.name = 'PlayerNavigationMenu'
s.version = '1.0.0'
s.summary = 'Native player navigation menu for oTunes'
s.description = s.summary
s.license = { :type => 'MIT' }
s.author = 'oTunes'
s.homepage = 'https://otunes.abunchofknowitalls.com'
s.platforms = { :ios => '16.4' }
s.swift_version = '5.9'
s.source = { :git => '' }
s.static_framework = true
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.dependency 'ExpoModulesCore'
s.frameworks = 'UIKit'
s.source_files = '**/*.swift'
end
@@ -1,56 +0,0 @@
import ExpoModulesCore
import UIKit
public class PlayerNavigationMenuModule: Module {
public func definition() -> ModuleDefinition {
Name("PlayerNavigationMenu")
View(PlayerNavigationMenuView.self) {
Events("onAction")
Prop("artist") { (view: PlayerNavigationMenuView, value: String) in
view.artist = value
}
Prop("album") { (view: PlayerNavigationMenuView, value: String) in
view.album = value
}
Prop("fontSize") { (view: PlayerNavigationMenuView, value: Double) in
view.fontSize = CGFloat(value)
}
}
}
}
final class PlayerNavigationMenuView: ExpoView {
let onAction = EventDispatcher()
var artist = "" { didSet { updateMenu(); setNeedsLayout() } }
var album = "" { didSet { updateMenu() } }
var fontSize: CGFloat = 20 { didSet { setNeedsLayout() } }
private let button = UIButton(type: .custom)
required init(appContext: AppContext? = nil) {
super.init(appContext: appContext)
button.showsMenuAsPrimaryAction = true
button.preferredMenuElementOrder = .fixed
button.accessibilityHint = "Opens album and artist options"
addSubview(button)
}
private func updateMenu() {
button.accessibilityLabel = artist
button.menu = UIMenu(children: [
UIAction(title: "Go to Album", subtitle: album, image: UIImage(systemName: "square.stack")) { [weak self] _ in
self?.onAction(["action": "go-album"])
},
UIAction(title: "Go to Artist", subtitle: artist, image: UIImage(systemName: "music.mic")) { [weak self] _ in
self?.onAction(["action": "go-artist"])
},
])
}
override func layoutSubviews() {
super.layoutSubviews()
// Anchor to the visible artist text, not the marquee's offscreen track.
let textWidth = (artist as NSString).size(withAttributes: [.font: UIFont.systemFont(ofSize: fontSize)]).width
button.frame = CGRect(x: 0, y: 0, width: min(ceil(textWidth), bounds.width), height: bounds.height)
}
}
+5 -8
View File
@@ -3,15 +3,15 @@
import * as React from "react"
import Link from "next/link"
import {
Disc3,
GalleryVerticalEnd,
ListEnd,
ListPlus,
ListStart,
MicVocal,
MoreHorizontal,
Share2,
Shuffle,
Star,
User,
} from "lucide-react"
import { Button } from "@/components/ui/button"
@@ -22,10 +22,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import {
copyMediaShareLink,
type MediaShareContext,
} from "@/lib/media-links"
import { copyMediaShareLink, type MediaShareContext } from "@/lib/media-links"
import { cn } from "@/lib/utils"
export type MediaContextAction =
@@ -141,7 +138,7 @@ export function MediaContextMenuItems({
<DropdownMenuItem asChild className="justify-between">
<Link href={`/artist/${artist.id}`}>
Go to Artist
<User />
<MicVocal />
</Link>
</DropdownMenuItem>
) : null}
@@ -149,7 +146,7 @@ export function MediaContextMenuItems({
<DropdownMenuItem asChild className="justify-between">
<Link href={`/album/${album.id}`}>
Go to Album
<Disc3 />
<GalleryVerticalEnd />
</Link>
</DropdownMenuItem>
) : null}