fix(mobile): move the download button beside Play
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
be01255467
commit
f9f9b8acb6
4 files changed
+108
-92
No files matched your search
@@ -23,9 +23,9 @@ import {
|
||||
} from "@/components/collection-list"
|
||||
import { AudioFormatBadge } from "@/components/audio-format-badge"
|
||||
import {
|
||||
DownloadHeaderButton,
|
||||
CollectionDownloadButton,
|
||||
DownloadedQuality,
|
||||
} from "@/components/download-header-button"
|
||||
} from "@/components/collection-download-button"
|
||||
import { useOpenedFromDownloads } from "@/lib/downloads-navigation"
|
||||
import { downloadsQueueOrigin } from "@otunes/convex/download-quality"
|
||||
import {
|
||||
@@ -226,41 +226,35 @@ export default function AlbumScreen() {
|
||||
}
|
||||
: {}),
|
||||
headerRight: () => (
|
||||
<View style={styles.headerActions}>
|
||||
<DownloadHeaderButton
|
||||
target={downloadTarget}
|
||||
color={colors.foreground}
|
||||
/>
|
||||
<MediaActionMenu
|
||||
stationArtistId={album.artist.id}
|
||||
selectedCount={album.tracks.length}
|
||||
favorited={isAlbumFav(album.id)}
|
||||
downloaded={albumDownloaded}
|
||||
share={{ type: "album", albumId: album.id, title: album.title }}
|
||||
onAction={(action) => {
|
||||
if (action === "download") {
|
||||
void requestDownload(downloadTarget)
|
||||
} else if (action === "remove-download") {
|
||||
void removeDownload(downloadTarget)
|
||||
} else {
|
||||
void handleAlbumDetailAction(
|
||||
album.id as Id<"albums">,
|
||||
songIds,
|
||||
action,
|
||||
album.artist.id as Id<"artists">
|
||||
)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Pressable hitSlop={8}>
|
||||
<Ionicons
|
||||
name="ellipsis-horizontal"
|
||||
size={22}
|
||||
color={colors.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
</MediaActionMenu>
|
||||
</View>
|
||||
<MediaActionMenu
|
||||
stationArtistId={album.artist.id}
|
||||
selectedCount={album.tracks.length}
|
||||
favorited={isAlbumFav(album.id)}
|
||||
downloaded={albumDownloaded}
|
||||
share={{ type: "album", albumId: album.id, title: album.title }}
|
||||
onAction={(action) => {
|
||||
if (action === "download") {
|
||||
void requestDownload(downloadTarget)
|
||||
} else if (action === "remove-download") {
|
||||
void removeDownload(downloadTarget)
|
||||
} else {
|
||||
void handleAlbumDetailAction(
|
||||
album.id as Id<"albums">,
|
||||
songIds,
|
||||
action,
|
||||
album.artist.id as Id<"artists">
|
||||
)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Pressable hitSlop={8}>
|
||||
<Ionicons
|
||||
name="ellipsis-horizontal"
|
||||
size={22}
|
||||
color={colors.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
</MediaActionMenu>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
@@ -321,6 +315,14 @@ export default function AlbumScreen() {
|
||||
color={favorited ? palette.accent : palette.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
<CollectionDownloadButton
|
||||
target={downloadTarget}
|
||||
color={palette.foreground}
|
||||
style={[
|
||||
styles.iconAction,
|
||||
{ backgroundColor: palette.surface },
|
||||
]}
|
||||
/>
|
||||
<Button
|
||||
title="Play"
|
||||
icon="play"
|
||||
@@ -604,7 +606,6 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
empty: { flex: 1, alignItems: "center", justifyContent: "center" },
|
||||
headerActions: { flexDirection: "row", alignItems: "center", gap: 16 },
|
||||
cover: {
|
||||
width: 220,
|
||||
height: 220,
|
||||
|
||||
@@ -45,9 +45,10 @@ import { CollectionDetailSkeleton } from "@/components/skeletons"
|
||||
import { Button } from "@/components/ui/primitives"
|
||||
import { contentBottomInset, SongListRow } from "@/components/player"
|
||||
import {
|
||||
DownloadHeaderButton,
|
||||
CollectionDownloadButton,
|
||||
type CollectionDownloadTarget,
|
||||
DownloadedQuality,
|
||||
} from "@/components/download-header-button"
|
||||
} from "@/components/collection-download-button"
|
||||
import { useOpenedFromDownloads } from "@/lib/downloads-navigation"
|
||||
import { downloadsQueueOrigin } from "@otunes/convex/download-quality"
|
||||
import type { CollectionRef } from "@otunes/convex/client/download-queue"
|
||||
@@ -349,32 +350,26 @@ function PlaylistContent({
|
||||
}
|
||||
: {}),
|
||||
headerRight: () => (
|
||||
<View style={styles.headerActions}>
|
||||
<DownloadHeaderButton
|
||||
target={downloadTarget}
|
||||
color={colors.foreground}
|
||||
/>
|
||||
<MediaActionMenu
|
||||
selectedCount={songIds.length}
|
||||
playlistLabel={PLAYLIST_LABEL}
|
||||
downloaded={playlistDownloaded}
|
||||
share={{
|
||||
type: "playlist",
|
||||
playlistId: playlistId ?? "favorites",
|
||||
title: playlist?.title ?? "oTunes",
|
||||
}}
|
||||
includeActions={canEdit ? OWNER_MENU_ACTIONS : undefined}
|
||||
onAction={handlePlaylistMenuAction}
|
||||
>
|
||||
<Pressable hitSlop={8}>
|
||||
<Ionicons
|
||||
name="ellipsis-horizontal"
|
||||
size={22}
|
||||
color={colors.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
</MediaActionMenu>
|
||||
</View>
|
||||
<MediaActionMenu
|
||||
selectedCount={songIds.length}
|
||||
playlistLabel={PLAYLIST_LABEL}
|
||||
downloaded={playlistDownloaded}
|
||||
share={{
|
||||
type: "playlist",
|
||||
playlistId: playlistId ?? "favorites",
|
||||
title: playlist?.title ?? "oTunes",
|
||||
}}
|
||||
includeActions={canEdit ? OWNER_MENU_ACTIONS : undefined}
|
||||
onAction={handlePlaylistMenuAction}
|
||||
>
|
||||
<Pressable hitSlop={8}>
|
||||
<Ionicons
|
||||
name="ellipsis-horizontal"
|
||||
size={22}
|
||||
color={colors.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
</MediaActionMenu>
|
||||
),
|
||||
}
|
||||
}, [
|
||||
@@ -465,7 +460,7 @@ function PlaylistContent({
|
||||
isSubscribed={isSubscribed}
|
||||
showSubscribe={!playlist.isOwner && playlistId !== null}
|
||||
onSubscribeToggle={handleSubscribeToggle}
|
||||
downloadRef={downloadRef}
|
||||
downloadTarget={downloadTarget}
|
||||
onPlay={handlePlay}
|
||||
onShuffle={handleShuffle}
|
||||
/>
|
||||
@@ -576,11 +571,11 @@ const PlaylistHero = memo(function PlaylistHero({
|
||||
isSubscribed,
|
||||
showSubscribe = false,
|
||||
onSubscribeToggle,
|
||||
downloadRef,
|
||||
downloadTarget,
|
||||
onPlay,
|
||||
onShuffle,
|
||||
}: {
|
||||
downloadRef: CollectionRef
|
||||
downloadTarget: CollectionDownloadTarget
|
||||
entityId: string
|
||||
coverUri: string
|
||||
hasCover: boolean
|
||||
@@ -648,6 +643,11 @@ const PlaylistHero = memo(function PlaylistHero({
|
||||
/>
|
||||
</Pressable>
|
||||
) : null}
|
||||
<CollectionDownloadButton
|
||||
target={downloadTarget}
|
||||
color={palette.foreground}
|
||||
style={[styles.iconAction, { backgroundColor: palette.surface }]}
|
||||
/>
|
||||
<Button
|
||||
title="Play"
|
||||
icon="play"
|
||||
@@ -688,7 +688,7 @@ const PlaylistHero = memo(function PlaylistHero({
|
||||
{ownerName}
|
||||
</Text>
|
||||
<DownloadedQuality
|
||||
collection={downloadRef}
|
||||
collection={downloadTarget}
|
||||
color={palette.secondaryForeground}
|
||||
backgroundColor={palette.background}
|
||||
/>
|
||||
@@ -701,7 +701,6 @@ const PlaylistHero = memo(function PlaylistHero({
|
||||
const styles = StyleSheet.create({
|
||||
emptyResults: { padding: spacing.lg, textAlign: "center" },
|
||||
empty: { flex: 1, alignItems: "center", justifyContent: "center" },
|
||||
headerActions: { flexDirection: "row", alignItems: "center", gap: 16 },
|
||||
listContent: { paddingBottom: contentBottomInset },
|
||||
cover: {
|
||||
width: 200,
|
||||
|
||||
@@ -17,9 +17,10 @@ import { CollectionDetailSkeleton } from "@/components/skeletons"
|
||||
import { Button } from "@/components/ui/primitives"
|
||||
import { contentBottomInset, SongListRow } from "@/components/player"
|
||||
import {
|
||||
DownloadHeaderButton,
|
||||
CollectionDownloadButton,
|
||||
type CollectionDownloadTarget,
|
||||
DownloadedQuality,
|
||||
} from "@/components/download-header-button"
|
||||
} from "@/components/collection-download-button"
|
||||
import { useOpenedFromDownloads } from "@/lib/downloads-navigation"
|
||||
import { downloadsQueueOrigin } from "@otunes/convex/download-quality"
|
||||
import { FAVORITES_DOWNLOAD_ID } from "@/contexts/downloads"
|
||||
@@ -53,22 +54,13 @@ export default function FavoritesScreen() {
|
||||
const playOrigin = fromDownloads
|
||||
? downloadsQueueOrigin("playlist:favorites")
|
||||
: undefined
|
||||
const screenOptions = useMemo(
|
||||
const downloadTarget = useMemo(
|
||||
() => ({
|
||||
...SCREEN_OPTIONS,
|
||||
headerRight: () => (
|
||||
<DownloadHeaderButton
|
||||
target={{
|
||||
kind: "playlist",
|
||||
id: FAVORITES_DOWNLOAD_ID,
|
||||
title: favorites?.title ?? "Favorites",
|
||||
songIds,
|
||||
}}
|
||||
color={colors.foreground}
|
||||
/>
|
||||
),
|
||||
...DOWNLOAD_REF,
|
||||
title: favorites?.title ?? "Favorites",
|
||||
songIds,
|
||||
}),
|
||||
[colors.foreground, favorites?.title, songIds]
|
||||
[favorites?.title, songIds]
|
||||
)
|
||||
const { filteredSongs, onQueryChange, onSearchSubmit } =
|
||||
usePlaylistSearch(songs)
|
||||
@@ -134,7 +126,7 @@ export default function FavoritesScreen() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen options={screenOptions} />
|
||||
<Stack.Screen options={SCREEN_OPTIONS} />
|
||||
<PlaylistSearchBar
|
||||
onQueryChange={onQueryChange}
|
||||
onSearchSubmit={onSearchSubmit}
|
||||
@@ -157,6 +149,7 @@ export default function FavoritesScreen() {
|
||||
ListHeaderComponent={
|
||||
<FavoritesHero
|
||||
title={favorites.title}
|
||||
downloadTarget={downloadTarget}
|
||||
onPlay={handlePlay}
|
||||
onShuffle={handleShuffle}
|
||||
/>
|
||||
@@ -172,10 +165,12 @@ function songKey(song: BrowseSong) {
|
||||
|
||||
const FavoritesHero = memo(function FavoritesHero({
|
||||
title,
|
||||
downloadTarget,
|
||||
onPlay,
|
||||
onShuffle,
|
||||
}: {
|
||||
title: string
|
||||
downloadTarget: CollectionDownloadTarget
|
||||
onPlay: () => void
|
||||
onShuffle: () => void
|
||||
}) {
|
||||
@@ -202,6 +197,11 @@ const FavoritesHero = memo(function FavoritesHero({
|
||||
backgroundColor={colors.background}
|
||||
/>
|
||||
<View style={styles.actions}>
|
||||
<CollectionDownloadButton
|
||||
target={downloadTarget}
|
||||
color={colors.foreground}
|
||||
style={[styles.iconAction, { backgroundColor: colors.muted }]}
|
||||
/>
|
||||
<Button
|
||||
title="Play"
|
||||
icon="play"
|
||||
|
||||
+20
-4
@@ -1,5 +1,13 @@
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { Alert, Pressable, StyleSheet, Text, View } from "react-native"
|
||||
import {
|
||||
Alert,
|
||||
Pressable,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
type StyleProp,
|
||||
type ViewStyle,
|
||||
} from "react-native"
|
||||
import Svg, { Circle, Rect } from "react-native-svg"
|
||||
|
||||
import { AudioFormatBadge } from "@/components/audio-format-badge"
|
||||
@@ -51,13 +59,20 @@ function ProgressRing({
|
||||
)
|
||||
}
|
||||
|
||||
/** Download, progress, and downloaded states for an album or playlist header. */
|
||||
export function DownloadHeaderButton({
|
||||
export type CollectionDownloadTarget = Exclude<
|
||||
DownloadTarget,
|
||||
{ kind: "songs" }
|
||||
>
|
||||
|
||||
/** Download, progress, and downloaded states for an album or playlist hero, beside Play. */
|
||||
export function CollectionDownloadButton({
|
||||
target,
|
||||
color,
|
||||
style,
|
||||
}: {
|
||||
target: Exclude<DownloadTarget, { kind: "songs" }>
|
||||
target: CollectionDownloadTarget
|
||||
color: string
|
||||
style?: StyleProp<ViewStyle>
|
||||
}) {
|
||||
const { queue, requestDownload, removeDownload } = useDownloads()
|
||||
useDownloadsVersion()
|
||||
@@ -96,6 +111,7 @@ export function DownloadHeaderButton({
|
||||
}
|
||||
disabled={target.songIds.length === 0}
|
||||
onPress={handlePress}
|
||||
style={style}
|
||||
>
|
||||
{inProgress && status ? (
|
||||
<ProgressRing
|
||||
Reference in new issue
Block a user