Compare commits
1
Commits
No files matched your search
@@ -77,44 +77,39 @@ const QUEUE_ACTIONS: MediaAction[] = ["play-next", "play-last", "shuffle"]
|
|||||||
|
|
||||||
const MEDIA_ACTION_ITEMS: {
|
const MEDIA_ACTION_ITEMS: {
|
||||||
action: MediaAction
|
action: MediaAction
|
||||||
label: (
|
label: (favorited: boolean | undefined, playlistLabel: string) => string
|
||||||
countSuffix: string,
|
|
||||||
favorited: boolean | undefined,
|
|
||||||
playlistLabel: string
|
|
||||||
) => string
|
|
||||||
image: NonNullable<MenuAction["image"]> & string
|
image: NonNullable<MenuAction["image"]> & string
|
||||||
destructive?: boolean
|
destructive?: boolean
|
||||||
}[] = [
|
}[] = [
|
||||||
{
|
{
|
||||||
action: "playlist",
|
action: "playlist",
|
||||||
label: (countSuffix, _favorited, playlistLabel) =>
|
label: (_favorited, playlistLabel) => playlistLabel,
|
||||||
`${playlistLabel}${countSuffix}`,
|
|
||||||
image: "text.badge.plus",
|
image: "text.badge.plus",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: "download",
|
action: "download",
|
||||||
label: (countSuffix) => `Download${countSuffix}`,
|
label: () => "Download",
|
||||||
image: "arrow.down.circle",
|
image: "arrow.down.circle",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: "remove-download",
|
action: "remove-download",
|
||||||
label: (countSuffix) => `Remove Download${countSuffix}`,
|
label: () => "Remove Download",
|
||||||
image: "xmark.circle",
|
image: "xmark.circle",
|
||||||
destructive: true,
|
destructive: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: "play-next",
|
action: "play-next",
|
||||||
label: (countSuffix) => `Play Next${countSuffix}`,
|
label: () => "Play Next",
|
||||||
image: "text.line.first.and.arrowtriangle.forward",
|
image: "text.line.first.and.arrowtriangle.forward",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: "play-last",
|
action: "play-last",
|
||||||
label: (countSuffix) => `Play Last${countSuffix}`,
|
label: () => "Play Last",
|
||||||
image: "text.line.last.and.arrowtriangle.forward",
|
image: "text.line.last.and.arrowtriangle.forward",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: "shuffle",
|
action: "shuffle",
|
||||||
label: (countSuffix) => `Shuffle${countSuffix}`,
|
label: () => "Shuffle",
|
||||||
image: "shuffle",
|
image: "shuffle",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -134,8 +129,7 @@ const MEDIA_ACTION_ITEMS: {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: "favorite",
|
action: "favorite",
|
||||||
label: (countSuffix, favorited) =>
|
label: (favorited) => (favorited ? "Unfavorite" : "Favorite"),
|
||||||
`${favorited ? "Unfavorite" : "Favorite"}${countSuffix}`,
|
|
||||||
image: "star",
|
image: "star",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -206,12 +200,7 @@ function isActionIncluded(
|
|||||||
export function buildMediaMenuActions(
|
export function buildMediaMenuActions(
|
||||||
config: Omit<MediaMenuConfig, "onAction">
|
config: Omit<MediaMenuConfig, "onAction">
|
||||||
): MenuAction[] {
|
): MenuAction[] {
|
||||||
const {
|
const { favorited, playlistLabel = "Add to Playlist" } = config
|
||||||
selectedCount = 1,
|
|
||||||
favorited,
|
|
||||||
playlistLabel = "Add to Playlist",
|
|
||||||
} = config
|
|
||||||
const countSuffix = selectedCount > 1 ? ` (${selectedCount})` : ""
|
|
||||||
|
|
||||||
const actions: MenuAction[] = []
|
const actions: MenuAction[] = []
|
||||||
|
|
||||||
@@ -230,7 +219,7 @@ export function buildMediaMenuActions(
|
|||||||
|
|
||||||
actions.push({
|
actions.push({
|
||||||
id: item.action,
|
id: item.action,
|
||||||
title: item.label(countSuffix, favorited, playlistLabel),
|
title: item.label(favorited, playlistLabel),
|
||||||
image: item.action === "favorite" && favorited ? "star.fill" : item.image,
|
image: item.action === "favorite" && favorited ? "star.fill" : item.image,
|
||||||
...(item.destructive ? { attributes: { destructive: true } } : {}),
|
...(item.destructive ? { attributes: { destructive: true } } : {}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -74,10 +74,6 @@ export function MediaMenuSeparator() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function actionLabel(base: string, selectedCount: number) {
|
|
||||||
return selectedCount > 1 ? `${base} (${selectedCount})` : base
|
|
||||||
}
|
|
||||||
|
|
||||||
export function MediaContextMenuItems({
|
export function MediaContextMenuItems({
|
||||||
selectedCount,
|
selectedCount,
|
||||||
onAction,
|
onAction,
|
||||||
@@ -121,7 +117,7 @@ export function MediaContextMenuItems({
|
|||||||
className="justify-between"
|
className="justify-between"
|
||||||
onClick={() => onAction("playlist")}
|
onClick={() => onAction("playlist")}
|
||||||
>
|
>
|
||||||
{actionLabel(playlistLabel, selectedCount)}
|
{playlistLabel}
|
||||||
<ListPlus />
|
<ListPlus />
|
||||||
</MediaMenuItem>
|
</MediaMenuItem>
|
||||||
{downloaded !== undefined ? (
|
{downloaded !== undefined ? (
|
||||||
@@ -129,10 +125,7 @@ export function MediaContextMenuItems({
|
|||||||
className="justify-between"
|
className="justify-between"
|
||||||
onClick={() => onAction(downloaded ? "remove-download" : "download")}
|
onClick={() => onAction(downloaded ? "remove-download" : "download")}
|
||||||
>
|
>
|
||||||
{actionLabel(
|
{downloaded ? "Remove Download" : "Download"}
|
||||||
downloaded ? "Remove Download" : "Download",
|
|
||||||
selectedCount
|
|
||||||
)}
|
|
||||||
{downloaded ? <CircleX /> : <ArrowDownToLine />}
|
{downloaded ? <CircleX /> : <ArrowDownToLine />}
|
||||||
</MediaMenuItem>
|
</MediaMenuItem>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -141,21 +134,21 @@ export function MediaContextMenuItems({
|
|||||||
className="justify-between"
|
className="justify-between"
|
||||||
onClick={() => onAction("play-next")}
|
onClick={() => onAction("play-next")}
|
||||||
>
|
>
|
||||||
{actionLabel("Play Next", selectedCount)}
|
Play Next
|
||||||
<ListStart />
|
<ListStart />
|
||||||
</MediaMenuItem>
|
</MediaMenuItem>
|
||||||
<MediaMenuItem
|
<MediaMenuItem
|
||||||
className="justify-between"
|
className="justify-between"
|
||||||
onClick={() => onAction("play-last")}
|
onClick={() => onAction("play-last")}
|
||||||
>
|
>
|
||||||
{actionLabel("Play Last", selectedCount)}
|
Play Last
|
||||||
<ListEnd />
|
<ListEnd />
|
||||||
</MediaMenuItem>
|
</MediaMenuItem>
|
||||||
<MediaMenuItem
|
<MediaMenuItem
|
||||||
className="justify-between"
|
className="justify-between"
|
||||||
onClick={() => onAction("shuffle")}
|
onClick={() => onAction("shuffle")}
|
||||||
>
|
>
|
||||||
{actionLabel("Shuffle", selectedCount)}
|
Shuffle
|
||||||
<Shuffle />
|
<Shuffle />
|
||||||
</MediaMenuItem>
|
</MediaMenuItem>
|
||||||
{stationArtistId ? (
|
{stationArtistId ? (
|
||||||
@@ -196,7 +189,7 @@ export function MediaContextMenuItems({
|
|||||||
className="justify-between"
|
className="justify-between"
|
||||||
onClick={() => onAction("favorite")}
|
onClick={() => onAction("favorite")}
|
||||||
>
|
>
|
||||||
{actionLabel(favorited ? "Unfavorite" : "Favorite", selectedCount)}
|
{favorited ? "Unfavorite" : "Favorite"}
|
||||||
<Star />
|
<Star />
|
||||||
</MediaMenuItem>
|
</MediaMenuItem>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in new issue
Block a user