fix(mobile): let playlist owners remove songs on iOS

PR #85 swapped the iOS swipe-to-remove for SongSwipeRow, leaving no way to
remove a single song on iOS. Add a destructive trailing Remove swipe action
for owned playlists and a "Remove from Playlist" context menu item on both
platforms. Also stop passing SongSwipeRow props to a plain Pressable on
Android album rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
joshuafhigginsandClaude Opus 5.5 committed 2026-11-16 19:21:29 -05:00 Verified
1 parent dce66b7697
commit e0a06cec8a
6 files changed
+171 -68

No files matched your search

@@ -488,8 +488,46 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
action: MediaAction
) => Promise<void>
}) {
const Row = Platform.OS === "ios" ? SongSwipeRow : Pressable
const { config } = useServerConfig()
const handlePress = () => void onPlay(track.id as Id<"songs">, songIds)
const content = (
<>
<PaletteText
tone="secondaryForeground"
style={[styles.trackNumber, { color: palette.secondaryForeground }]}
>
{number}
</PaletteText>
<View
style={[styles.trackContent, { borderBottomColor: palette.divider }]}
>
<View style={styles.trackMeta}>
<PaletteText
tone="foreground"
style={[styles.trackTitle, { color: palette.foreground }]}
numberOfLines={1}
>
{track.title}
</PaletteText>
{track.artists ? (
<PaletteText
tone="secondaryForeground"
style={{ color: palette.secondaryForeground }}
numberOfLines={1}
>
{track.artists.join(", ")}
</PaletteText>
) : null}
</View>
<PaletteText
tone="secondaryForeground"
style={{ color: palette.secondaryForeground }}
>
{formatDuration(track.durationSeconds)}
</PaletteText>
</View>
</>
)
return (
<MediaContextMenu
preview={
@@ -519,51 +557,21 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
onAction={(action) => void onAction(track, album, action)}
>
<MusicEntityView kind="song" id={track.id}>
<Row
group={swipeGroup}
backgroundColor={palette.background}
onPlayNext={() => void onAction(track, album, "play-next")}
style={styles.trackRow}
onPress={() => void onPlay(track.id as Id<"songs">, songIds)}
>
<PaletteText
tone="secondaryForeground"
style={[styles.trackNumber, { color: palette.secondaryForeground }]}
{Platform.OS === "ios" ? (
<SongSwipeRow
group={swipeGroup}
backgroundColor={palette.background}
onPlayNext={() => void onAction(track, album, "play-next")}
style={styles.trackRow}
onPress={handlePress}
>
{number}
</PaletteText>
<View
style={[
styles.trackContent,
{ borderBottomColor: palette.divider },
]}
>
<View style={styles.trackMeta}>
<PaletteText
tone="foreground"
style={[styles.trackTitle, { color: palette.foreground }]}
numberOfLines={1}
>
{track.title}
</PaletteText>
{track.artists ? (
<PaletteText
tone="secondaryForeground"
style={{ color: palette.secondaryForeground }}
numberOfLines={1}
>
{track.artists.join(", ")}
</PaletteText>
) : null}
</View>
<PaletteText
tone="secondaryForeground"
style={{ color: palette.secondaryForeground }}
>
{formatDuration(track.durationSeconds)}
</PaletteText>
</View>
</Row>
{content}
</SongSwipeRow>
) : (
<Pressable style={styles.trackRow} onPress={handlePress}>
{content}
</Pressable>
)}
</MusicEntityView>
</MediaContextMenu>
)
@@ -202,12 +202,6 @@ function PlaylistContent({
[playFromSong, songIds, playlistId]
)
const handleSongMenuAction = useCallback(
(song: BrowseSong, action: MediaAction) =>
void handleSongAction(song, action),
[handleSongAction]
)
const handleRemoveSong = useCallback(
async (songId: Id<"songs">) => {
if (!playlistId) return false
@@ -226,6 +220,14 @@ function PlaylistContent({
[playlistId, removeSongs]
)
const handleSongMenuAction = useCallback(
(song: BrowseSong, action: MediaAction) => {
if (action === "remove-from-playlist") void handleRemoveSong(song.id)
else void handleSongAction(song, action)
},
[handleRemoveSong, handleSongAction]
)
const handlePlay = useCallback(() => {
if (playlistId) void playPlaylist(playlistId, songIds)
}, [playPlaylist, playlistId, songIds])
@@ -433,12 +435,14 @@ const PlaylistSongRow = memo(function PlaylistSongRow({
playlistLabel={PLAYLIST_LABEL}
palette={palette}
inset
removable={removable}
swipe={
Platform.OS === "ios"
? {
group: swipeGroup,
backgroundColor: palette.background,
onPlayNext: () => onAction(song, "play-next"),
onRemove: removable ? () => void handleRemove() : undefined,
}
: undefined
}
@@ -32,6 +32,7 @@ export type MediaAction =
| "favorite"
| "go-artist"
| "go-album"
| "remove-from-playlist"
| "delete-playlist"
export type MediaNavigation = {
@@ -54,6 +55,7 @@ export type MediaMenuConfig = {
playlistLabel?: string
favorited?: boolean
showFavorite?: boolean
showRemoveFromPlaylist?: boolean
stationArtistId?: string
navigation?: MediaNavigation
share?: MediaShareContext
@@ -76,6 +78,7 @@ const MEDIA_ACTION_ITEMS: {
playlistLabel: string
) => string
image: NonNullable<MenuAction["image"]> & string
destructive?: boolean
}[] = [
{
action: "playlist",
@@ -119,6 +122,12 @@ const MEDIA_ACTION_ITEMS: {
`${favorited ? "Unfavorite" : "Favorite"}${countSuffix}`,
image: "star",
},
{
action: "remove-from-playlist",
label: () => "Remove from Playlist",
image: "minus.circle",
destructive: true,
},
{
action: "delete-playlist",
label: () => "Delete Playlist",
@@ -134,6 +143,10 @@ function isActionIncluded(
return false
}
if (action === "remove-from-playlist") {
return config.showRemoveFromPlaylist === true
}
if (config.includeActions) {
return config.includeActions.includes(action)
}
@@ -190,6 +203,7 @@ export function buildMediaMenuActions(
id: item.action,
title: item.label(countSuffix, favorited, playlistLabel),
image: item.action === "favorite" && favorited ? "star.fill" : item.image,
...(item.destructive ? { attributes: { destructive: true } } : {}),
})
}
@@ -324,6 +338,7 @@ const NativeContextMenuAction: ComponentType<{
identifier: string
title: string
icon?: string
destructive?: boolean
onSelected: () => void
}> | null =
Platform.OS === "ios"
@@ -377,6 +392,7 @@ function NativeMediaContextMenu({
identifier={action.id ?? action.title}
title={action.title}
icon={typeof action.image === "string" ? action.image : undefined}
destructive={action.attributes?.destructive}
onSelected={() => handleAction(action.id as MediaAction)}
/>
))}
@@ -25,6 +25,7 @@ const actionIcons = {
favorite: "star-outline",
"go-artist": "person-outline",
"go-album": "disc-outline",
"remove-from-playlist": "remove-circle-outline",
"delete-playlist": "trash-outline",
} satisfies Record<MediaAction, ComponentProps<typeof Ionicons>["name"]>
+7
View File
@@ -45,6 +45,7 @@ export const SongRow = memo(function SongRow({
swipe?: {
group: SwipeRowGroup
onPlayNext: () => void
onRemove?: () => 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({
<SongSwipeRow
group={swipe.group}
onPlayNext={swipe.onPlayNext}
onRemove={swipe.onRemove}
backgroundColor={swipe.backgroundColor}
onPress={onPress}
style={rowStyle}
@@ -156,6 +158,7 @@ export const SongListRow = memo(function SongListRow({
palette,
inset,
swipe,
removable,
onPlay,
onAction,
}: {
@@ -167,8 +170,11 @@ export const SongListRow = memo(function SongListRow({
swipe?: {
group: SwipeRowGroup
onPlayNext: () => void
onRemove?: () => void
backgroundColor: string
}
/** Shows "Remove from Playlist" in the context menu. */
removable?: boolean
onPlay: (song: BrowseSong) => void
onAction: (song: BrowseSong, action: MediaAction) => void
}) {
@@ -196,6 +202,7 @@ export const SongListRow = memo(function SongListRow({
stationArtistId: song.artist.id,
favorited,
playlistLabel,
showRemoveFromPlaylist: removable,
navigation: {
artist: { id: song.artist.id },
album: { id: song.album.id },
+84 -17
View File
@@ -41,6 +41,7 @@ export function SongSwipeRow({
group,
onPress,
onPlayNext,
onRemove,
}: {
children: ReactNode
style?: StyleProp<ViewStyle>
@@ -48,7 +49,10 @@ export function SongSwipeRow({
group: SwipeRowGroup
onPress?: () => void
onPlayNext: () => void
/** Adds a destructive trailing Remove action that a full swipe commits. */
onRemove?: () => void
}) {
const trailingWidth = onRemove ? ACTION_WIDTH * 2 : ACTION_WIDTH
const x = useSharedValue(0)
const startX = useSharedValue(0)
const width = useSharedValue(0)
@@ -79,9 +83,10 @@ export function SongSwipeRow({
(side: number) => {
close()
if (side > 0) onPlayNext()
else onRemove?.()
// Download is intentionally a placeholder.
},
[close, onPlayNext]
[close, onPlayNext, onRemove]
)
const tapRow = useCallback(() => {
if (open) close()
@@ -105,7 +110,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 : trailingWidth,
width.value * 0.55
)
if (commit !== committed.value) {
committed.value = commit
commitProgress.value = withSpring(commit ? 1 : 0, SPRING)
@@ -124,10 +133,13 @@ export function SongSwipeRow({
Math.abs(x.value) > 10 && projected * side > ACTION_WIDTH / 2
? side
: 0
x.value = withSpring(target * ACTION_WIDTH, {
...SPRING,
velocity: event.velocityX,
})
x.value = withSpring(
target * (target < 0 ? trailingWidth : ACTION_WIDTH),
{
...SPRING,
velocity: event.velocityX,
}
)
scheduleOnRN(settle, target)
})
.onFinalize((_event, success) => {
@@ -152,6 +164,7 @@ export function SongSwipeRow({
settle,
startX,
tapRow,
trailingWidth,
width,
x,
])
@@ -190,13 +203,27 @@ export function SongSwipeRow({
open={open === 1}
onPress={() => activate(1)}
/>
{onRemove ? (
<SwipeAction
side={-1}
remove
paired
x={x}
height={height}
progress={commitProgress}
open={open === -1}
onPress={() => activate(-1)}
/>
) : null}
<SwipeAction
side={-1}
paired={!!onRemove}
secondary={!!onRemove}
x={x}
height={height}
progress={commitProgress}
open={open === -1}
onPress={() => activate(-1)}
onPress={onRemove ? close : () => activate(-1)}
/>
<GestureDetector gesture={gesture}>
<Animated.View
@@ -206,9 +233,13 @@ export function SongSwipeRow({
accessibilityActions={[
{ name: "playNext", label: "Play Next" },
{ name: "download", label: "Download" },
...(onRemove
? [{ name: "remove", label: "Remove from Playlist" }]
: []),
]}
onAccessibilityAction={(event) => {
if (event.nativeEvent.actionName === "playNext") activate(1)
if (event.nativeEvent.actionName === "remove") activate(-1)
}}
style={[styles.row, { backgroundColor }, rowStyle]}
>
@@ -223,8 +254,15 @@ export function SongSwipeRow({
)
}
/**
* Paired actions split the revealed width: the edge action grows to fill it as
* a full swipe commits, while the inner `secondary` action shrinks away.
*/
function SwipeAction({
side,
paired = false,
secondary = false,
remove = false,
x,
height,
progress,
@@ -232,17 +270,36 @@ function SwipeAction({
onPress,
}: {
side: 1 | -1
paired?: boolean
secondary?: boolean
remove?: boolean
x: SharedValue<number>
height: SharedValue<number>
progress: SharedValue<number>
open: boolean
onPress: () => void
}) {
const actionStyle = useAnimatedStyle(() => ({
width: Math.max(0, x.value * side),
}))
const revealedWidth = () => {
"worklet"
const total = Math.max(0, x.value * side)
if (!paired) return total
const edge = (total * (1 + progress.value)) / 2
return secondary ? total - edge : edge
}
const actionStyle = useAnimatedStyle(() => {
const total = Math.max(0, x.value * side)
const own = revealedWidth()
return {
width: own,
...(secondary
? side > 0
? { left: total - own }
: { right: total - own }
: {}),
}
})
const pillStyle = useAnimatedStyle(() => {
const revealed = Math.max(0, x.value * side)
const revealed = revealedWidth()
const resting = Math.max(
0,
Math.min(
@@ -271,7 +328,7 @@ function SwipeAction({
transform: [
{
scale: interpolate(
x.value * side,
revealedWidth(),
[24, 64],
[0, 1],
Extrapolation.CLAMP
@@ -292,23 +349,33 @@ function SwipeAction({
>
<Pressable
accessibilityRole="button"
accessibilityLabel={side > 0 ? "Play Next" : "Download"}
accessibilityLabel={
remove ? "Remove from Playlist" : side > 0 ? "Play Next" : "Download"
}
onPress={onPress}
style={styles.actionButton}
>
<Animated.View
style={[
styles.pill,
{ backgroundColor: side > 0 ? "#6b5bff" : "#008dff" },
{
backgroundColor: remove
? "#ff3b30"
: side > 0
? "#6b5bff"
: "#008dff",
},
pillStyle,
]}
>
<Animated.View style={iconStyle}>
<SymbolView
name={
side > 0
? "text.line.first.and.arrowtriangle.forward"
: "arrow.down"
remove
? "trash"
: side > 0
? "text.line.first.and.arrowtriangle.forward"
: "arrow.down"
}
size={22}
tintColor="white"