diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index a32bf8c..cbba238 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -523,6 +523,7 @@ const AlbumTrackRow = memo(function AlbumTrackRow({ group={swipeGroup} backgroundColor={palette.background} onPlayNext={() => void onAction(track, album, "play-next")} + onAddToQueue={() => void onAction(track, album, "play-last")} style={styles.trackRow} onPress={() => void onPlay(track.id as Id<"songs">, songIds)} > diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx index f11a0d1..8e6c50c 100644 --- a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx @@ -439,6 +439,7 @@ const PlaylistSongRow = memo(function PlaylistSongRow({ group: swipeGroup, backgroundColor: palette.background, onPlayNext: () => onAction(song, "play-next"), + onAddToQueue: () => onAction(song, "play-last"), } : undefined } diff --git a/apps/mobile/components/player.tsx b/apps/mobile/components/player.tsx index 0aaf866..4690ab9 100644 --- a/apps/mobile/components/player.tsx +++ b/apps/mobile/components/player.tsx @@ -45,6 +45,7 @@ export const SongRow = memo(function SongRow({ swipe?: { group: SwipeRowGroup onPlayNext: () => void + onAddToQueue: () => void backgroundColor: string } /** Album/playlist layout: the divider starts at the title, not the artwork. */ @@ -111,6 +112,7 @@ export const SongRow = memo(function SongRow({ void + onAddToQueue: () => void backgroundColor: string } onPlay: (song: BrowseSong) => void diff --git a/apps/mobile/components/song-swipe-row.tsx b/apps/mobile/components/song-swipe-row.tsx index 3e2f044..f61484a 100644 --- a/apps/mobile/components/song-swipe-row.tsx +++ b/apps/mobile/components/song-swipe-row.tsx @@ -41,6 +41,7 @@ export function SongSwipeRow({ group, onPress, onPlayNext, + onAddToQueue, }: { children: ReactNode style?: StyleProp @@ -48,6 +49,7 @@ export function SongSwipeRow({ group: SwipeRowGroup onPress?: () => void onPlayNext: () => void + onAddToQueue: () => void }) { const x = useSharedValue(0) const startX = useSharedValue(0) @@ -78,10 +80,10 @@ export function SongSwipeRow({ const activate = useCallback( (side: number) => { close() - if (side > 0) onPlayNext() + if (side > 0) onAddToQueue() // Download is intentionally a placeholder. }, - [close, onPlayNext] + [close, onAddToQueue] ) const tapRow = useCallback(() => { if (open) close() @@ -105,7 +107,11 @@ export function SongSwipeRow({ Math.min(width.value, startX.value + event.translationX) ) const commit = - Math.abs(x.value) > Math.max(ACTION_WIDTH, width.value * 0.55) + Math.abs(x.value) > + Math.max( + x.value > 0 ? ACTION_WIDTH * 2 : ACTION_WIDTH, + width.value * 0.55 + ) if (commit !== committed.value) { committed.value = commit commitProgress.value = withSpring(commit ? 1 : 0, SPRING) @@ -124,7 +130,7 @@ export function SongSwipeRow({ Math.abs(x.value) > 10 && projected * side > ACTION_WIDTH / 2 ? side : 0 - x.value = withSpring(target * ACTION_WIDTH, { + x.value = withSpring(target * ACTION_WIDTH * (target > 0 ? 2 : 1), { ...SPRING, velocity: event.velocityX, }) @@ -190,6 +196,18 @@ export function SongSwipeRow({ open={open === 1} onPress={() => activate(1)} /> + { + close() + onPlayNext() + }} + /> { - if (event.nativeEvent.actionName === "playNext") activate(1) + if (event.nativeEvent.actionName === "addToQueue") activate(1) + if (event.nativeEvent.actionName === "playNext") { + close() + onPlayNext() + } }} style={[styles.row, { backgroundColor }, rowStyle]} > @@ -225,6 +248,7 @@ export function SongSwipeRow({ function SwipeAction({ side, + secondary = false, x, height, progress, @@ -232,17 +256,32 @@ function SwipeAction({ onPress, }: { side: 1 | -1 + secondary?: boolean x: SharedValue height: SharedValue progress: SharedValue open: boolean onPress: () => void }) { - const actionStyle = useAnimatedStyle(() => ({ - width: Math.max(0, x.value * side), - })) - const pillStyle = useAnimatedStyle(() => { + const actionStyle = useAnimatedStyle(() => { const revealed = Math.max(0, x.value * side) + const primaryWidth = (revealed * (1 + progress.value)) / 2 + return { + width: + side < 0 + ? revealed + : secondary + ? revealed - primaryWidth + : primaryWidth, + ...(secondary ? { left: primaryWidth } : {}), + } + }) + const pillStyle = useAnimatedStyle(() => { + const total = Math.max(0, x.value * side) + const revealed = + side < 0 + ? total + : (total * (secondary ? 1 - progress.value : 1 + progress.value)) / 2 const resting = Math.max( 0, Math.min( @@ -292,14 +331,19 @@ function SwipeAction({ > 0 ? "Play Next" : "Download"} + accessibilityLabel={ + side > 0 ? (secondary ? "Play Next" : "Add to Queue") : "Download" + } onPress={onPress} style={styles.actionButton} > 0 ? "#6b5bff" : "#008dff" }, + { + backgroundColor: + side > 0 ? (secondary ? "#6b5bff" : "#f29943") : "#008dff", + }, pillStyle, ]} > @@ -307,7 +351,9 @@ function SwipeAction({ 0 - ? "text.line.first.and.arrowtriangle.forward" + ? secondary + ? "text.line.first.and.arrowtriangle.forward" + : "text.line.last.and.arrowtriangle.forward" : "arrow.down" } size={22}