Compare commits
2
Commits
No files matched your search
@@ -77,44 +77,39 @@ const QUEUE_ACTIONS: MediaAction[] = ["play-next", "play-last", "shuffle"]
|
||||
|
||||
const MEDIA_ACTION_ITEMS: {
|
||||
action: MediaAction
|
||||
label: (
|
||||
countSuffix: string,
|
||||
favorited: boolean | undefined,
|
||||
playlistLabel: string
|
||||
) => string
|
||||
label: (favorited: boolean | undefined, playlistLabel: string) => string
|
||||
image: NonNullable<MenuAction["image"]> & string
|
||||
destructive?: boolean
|
||||
}[] = [
|
||||
{
|
||||
action: "playlist",
|
||||
label: (countSuffix, _favorited, playlistLabel) =>
|
||||
`${playlistLabel}${countSuffix}`,
|
||||
label: (_favorited, playlistLabel) => playlistLabel,
|
||||
image: "text.badge.plus",
|
||||
},
|
||||
{
|
||||
action: "download",
|
||||
label: (countSuffix) => `Download${countSuffix}`,
|
||||
label: () => "Download",
|
||||
image: "arrow.down.circle",
|
||||
},
|
||||
{
|
||||
action: "remove-download",
|
||||
label: (countSuffix) => `Remove Download${countSuffix}`,
|
||||
label: () => "Remove Download",
|
||||
image: "xmark.circle",
|
||||
destructive: true,
|
||||
},
|
||||
{
|
||||
action: "play-next",
|
||||
label: (countSuffix) => `Play Next${countSuffix}`,
|
||||
label: () => "Play Next",
|
||||
image: "text.line.first.and.arrowtriangle.forward",
|
||||
},
|
||||
{
|
||||
action: "play-last",
|
||||
label: (countSuffix) => `Play Last${countSuffix}`,
|
||||
label: () => "Play Last",
|
||||
image: "text.line.last.and.arrowtriangle.forward",
|
||||
},
|
||||
{
|
||||
action: "shuffle",
|
||||
label: (countSuffix) => `Shuffle${countSuffix}`,
|
||||
label: () => "Shuffle",
|
||||
image: "shuffle",
|
||||
},
|
||||
{
|
||||
@@ -134,8 +129,7 @@ const MEDIA_ACTION_ITEMS: {
|
||||
},
|
||||
{
|
||||
action: "favorite",
|
||||
label: (countSuffix, favorited) =>
|
||||
`${favorited ? "Unfavorite" : "Favorite"}${countSuffix}`,
|
||||
label: (favorited) => (favorited ? "Unfavorite" : "Favorite"),
|
||||
image: "star",
|
||||
},
|
||||
{
|
||||
@@ -206,12 +200,7 @@ function isActionIncluded(
|
||||
export function buildMediaMenuActions(
|
||||
config: Omit<MediaMenuConfig, "onAction">
|
||||
): MenuAction[] {
|
||||
const {
|
||||
selectedCount = 1,
|
||||
favorited,
|
||||
playlistLabel = "Add to Playlist",
|
||||
} = config
|
||||
const countSuffix = selectedCount > 1 ? ` (${selectedCount})` : ""
|
||||
const { favorited, playlistLabel = "Add to Playlist" } = config
|
||||
|
||||
const actions: MenuAction[] = []
|
||||
|
||||
@@ -230,7 +219,7 @@ export function buildMediaMenuActions(
|
||||
|
||||
actions.push({
|
||||
id: item.action,
|
||||
title: item.label(countSuffix, favorited, playlistLabel),
|
||||
title: item.label(favorited, playlistLabel),
|
||||
image: item.action === "favorite" && favorited ? "star.fill" : item.image,
|
||||
...(item.destructive ? { attributes: { destructive: true } } : {}),
|
||||
})
|
||||
|
||||
@@ -198,7 +198,8 @@ function optionDetail(option: SizedDownloadOption, songCount: number) {
|
||||
return `${included} of ${songCount} songs, ${option.fallbackCount} in High`
|
||||
}
|
||||
|
||||
function DownloadQualitySheet({
|
||||
/** Centered popup asking which quality to download a target at. */
|
||||
function DownloadQualityPopup({
|
||||
pending,
|
||||
onClose,
|
||||
onPick,
|
||||
@@ -214,7 +215,7 @@ function DownloadQualitySheet({
|
||||
return (
|
||||
<Modal
|
||||
visible={pending !== null}
|
||||
animationType="slide"
|
||||
animationType="fade"
|
||||
transparent
|
||||
onRequestClose={onClose}
|
||||
>
|
||||
@@ -222,14 +223,11 @@ function DownloadQualitySheet({
|
||||
<Pressable style={styles.overlay} onPress={onClose}>
|
||||
<Pressable
|
||||
style={[
|
||||
styles.sheet,
|
||||
styles.popup,
|
||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
||||
]}
|
||||
onPress={(event) => event.stopPropagation()}
|
||||
>
|
||||
<View
|
||||
style={[styles.grabber, { backgroundColor: colors.border }]}
|
||||
/>
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>
|
||||
Download Quality
|
||||
</Text>
|
||||
@@ -433,7 +431,7 @@ export function DownloadsProvider({ children }: { children: ReactNode }) {
|
||||
<DownloadsContext.Provider value={value}>
|
||||
{children}
|
||||
{queue ? <DownloadSync queue={queue} /> : null}
|
||||
<DownloadQualitySheet
|
||||
<DownloadQualityPopup
|
||||
pending={pending}
|
||||
onClose={() => setPending(null)}
|
||||
onPick={handlePick}
|
||||
@@ -445,23 +443,17 @@ export function DownloadsProvider({ children }: { children: ReactNode }) {
|
||||
const styles = StyleSheet.create({
|
||||
overlay: {
|
||||
flex: 1,
|
||||
backgroundColor: "rgba(0,0,0,0.45)",
|
||||
justifyContent: "flex-end",
|
||||
backgroundColor: "rgba(0,0,0,0.6)",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
padding: 24,
|
||||
},
|
||||
sheet: {
|
||||
borderTopLeftRadius: 16,
|
||||
borderTopRightRadius: 16,
|
||||
popup: {
|
||||
width: "100%",
|
||||
maxWidth: 420,
|
||||
borderRadius: 16,
|
||||
borderWidth: 1,
|
||||
paddingHorizontal: 16,
|
||||
paddingTop: 8,
|
||||
paddingBottom: 24,
|
||||
},
|
||||
grabber: {
|
||||
width: 36,
|
||||
height: 4,
|
||||
borderRadius: 2,
|
||||
alignSelf: "center",
|
||||
marginBottom: 12,
|
||||
padding: 16,
|
||||
},
|
||||
title: { fontSize: 18, fontWeight: "700" },
|
||||
subtitle: { fontSize: 13, marginBottom: 4 },
|
||||
|
||||
@@ -74,10 +74,6 @@ export function MediaMenuSeparator() {
|
||||
)
|
||||
}
|
||||
|
||||
function actionLabel(base: string, selectedCount: number) {
|
||||
return selectedCount > 1 ? `${base} (${selectedCount})` : base
|
||||
}
|
||||
|
||||
export function MediaContextMenuItems({
|
||||
selectedCount,
|
||||
onAction,
|
||||
@@ -121,7 +117,7 @@ export function MediaContextMenuItems({
|
||||
className="justify-between"
|
||||
onClick={() => onAction("playlist")}
|
||||
>
|
||||
{actionLabel(playlistLabel, selectedCount)}
|
||||
{playlistLabel}
|
||||
<ListPlus />
|
||||
</MediaMenuItem>
|
||||
{downloaded !== undefined ? (
|
||||
@@ -129,10 +125,7 @@ export function MediaContextMenuItems({
|
||||
className="justify-between"
|
||||
onClick={() => onAction(downloaded ? "remove-download" : "download")}
|
||||
>
|
||||
{actionLabel(
|
||||
downloaded ? "Remove Download" : "Download",
|
||||
selectedCount
|
||||
)}
|
||||
{downloaded ? "Remove Download" : "Download"}
|
||||
{downloaded ? <CircleX /> : <ArrowDownToLine />}
|
||||
</MediaMenuItem>
|
||||
) : null}
|
||||
@@ -141,21 +134,21 @@ export function MediaContextMenuItems({
|
||||
className="justify-between"
|
||||
onClick={() => onAction("play-next")}
|
||||
>
|
||||
{actionLabel("Play Next", selectedCount)}
|
||||
Play Next
|
||||
<ListStart />
|
||||
</MediaMenuItem>
|
||||
<MediaMenuItem
|
||||
className="justify-between"
|
||||
onClick={() => onAction("play-last")}
|
||||
>
|
||||
{actionLabel("Play Last", selectedCount)}
|
||||
Play Last
|
||||
<ListEnd />
|
||||
</MediaMenuItem>
|
||||
<MediaMenuItem
|
||||
className="justify-between"
|
||||
onClick={() => onAction("shuffle")}
|
||||
>
|
||||
{actionLabel("Shuffle", selectedCount)}
|
||||
Shuffle
|
||||
<Shuffle />
|
||||
</MediaMenuItem>
|
||||
{stationArtistId ? (
|
||||
@@ -196,7 +189,7 @@ export function MediaContextMenuItems({
|
||||
className="justify-between"
|
||||
onClick={() => onAction("favorite")}
|
||||
>
|
||||
{actionLabel(favorited ? "Unfavorite" : "Favorite", selectedCount)}
|
||||
{favorited ? "Unfavorite" : "Favorite"}
|
||||
<Star />
|
||||
</MediaMenuItem>
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user