feat(mobile): open album and artist menu from player artist (#86)

This commit was merged in pull request #86.
This commit is contained in:
joshuafhiggins committed 2026-11-15 14:29:11 -05:00
1 parent b598173137
commit 0252aa8c46
4 files changed
+73 -17

No files matched your search

+10 -7
View File
@@ -44,6 +44,7 @@ import {
NowPlayingQueue,
QUEUE_HORIZONTAL_INSET,
} from "@/components/now-playing-queue"
import { PlayerArtistMenu } from "@/components/player-artist-menu"
import { PlayerSlider } from "@/components/player-slider"
import { PlayerSymbol } from "@/components/player-symbol"
import { useFavorites } from "@/contexts/favorites"
@@ -544,13 +545,15 @@ function SongMeta({
{ color: colors.foreground },
]}
/>
<MarqueeText
text={song.artist.name}
style={[
compact ? styles.compactArtist : styles.artist,
{ color: colors.secondaryForeground },
]}
/>
<PlayerArtistMenu song={song} onAction={handleAction}>
<MarqueeText
text={song.artist.name}
style={[
compact ? styles.compactArtist : styles.artist,
{ color: colors.secondaryForeground },
]}
/>
</PlayerArtistMenu>
</View>
<Pressable
onPress={() => void toggleSongFavorite(song.id)}
@@ -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",
@@ -0,0 +1,56 @@
import { useState, type ReactNode } from "react"
import { StyleSheet, View } from "react-native"
import {
MediaActionMenu,
type MediaAction,
} from "@/components/media-context-menu"
import type { BrowseSong } from "@otunes/convex/types"
export function PlayerArtistMenu({
song,
onAction,
children,
}: {
song: BrowseSong
onAction: (action: MediaAction) => void
children: ReactNode
}) {
const [size, setSize] = useState({ width: 0, height: 0 })
return (
<View
style={styles.container}
onLayout={({ nativeEvent: { layout } }) =>
setSize({ width: layout.width, height: layout.height })
}
>
<View
pointerEvents="none"
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
>
{children}
</View>
{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>
) : null}
</View>
)
}
const styles = StyleSheet.create({
container: { overflow: "hidden" },
})
+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}