From 37df7ba9b4ddafff1220af467c204bd578fd24d5 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Sun, 15 Nov 2026 13:59:34 -0500 Subject: [PATCH 1/2] feat(mobile): add previews to iOS media context menus --- .../app/(app)/(tabs)/home/album/[id].tsx | 13 ++ .../app/(app)/(tabs)/home/browse/artists.tsx | 12 +- apps/mobile/components/media-cards.tsx | 13 ++ apps/mobile/components/media-context-menu.tsx | 114 +++++++++++++++++- apps/mobile/components/player.tsx | 11 ++ 5 files changed, 160 insertions(+), 3 deletions(-) diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index 343d139..a32bf8c 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -489,8 +489,21 @@ const AlbumTrackRow = memo(function AlbumTrackRow({ ) => Promise }) { const Row = Platform.OS === "ios" ? SongSwipeRow : Pressable + const { config } = useServerConfig() return ( void onAction(artist, action)} @@ -160,7 +166,11 @@ const ArtistRow = memo(function ArtistRow({ > {artist.name} - + ) diff --git a/apps/mobile/components/media-cards.tsx b/apps/mobile/components/media-cards.tsx index eb7cd5c..4b5e02f 100644 --- a/apps/mobile/components/media-cards.tsx +++ b/apps/mobile/components/media-cards.tsx @@ -94,6 +94,13 @@ export const AlbumCard = memo(function AlbumCard({ return ( void handleArtistAction(artist, action)} diff --git a/apps/mobile/components/media-context-menu.tsx b/apps/mobile/components/media-context-menu.tsx index 54c6dc2..6109c6c 100644 --- a/apps/mobile/components/media-context-menu.tsx +++ b/apps/mobile/components/media-context-menu.tsx @@ -4,12 +4,19 @@ import { requireNativeView } from "expo" import type { ComponentType, ReactNode } from "react" import { Platform, + Text, + useWindowDimensions, View, type StyleProp, type ViewProps, type ViewStyle, } from "react-native" +import { Ionicons } from "@expo/vector-icons" +import { CoverImage } from "@/components/cover-image" +import { useThemeColors } from "@/lib/theme" +import { useAppNavigation } from "@/lib/app-navigation" + import { useServerConfig } from "@/contexts/server-config" import type { MediaShareContext } from "@/lib/media-links" import { shouldShowShare } from "@/lib/media-links" @@ -32,7 +39,17 @@ export type MediaNavigation = { album?: { id: string } } +export type MediaMenuPreview = { + title: string + artist?: string + album?: string + artworkUrl: string + hasArtwork: boolean + kind: "album" | "artist" | "song" +} + export type MediaMenuConfig = { + preview?: MediaMenuPreview selectedCount?: number playlistLabel?: string favorited?: boolean @@ -214,10 +231,90 @@ function MediaMenuBase({ const NativeContextMenuView = Platform.OS === "ios" ? requireNativeView< - ViewProps & { disableForceFlatten?: boolean; children: ReactNode } + ViewProps & { + disableForceFlatten?: boolean + children: ReactNode + onPreviewTappedAnimationCompleted?: () => void + } >("ExpoRouterNativeLinkPreview", "NativeLinkPreviewView") : null +const NativeContextMenuPreview = + Platform.OS === "ios" + ? requireNativeView< + ViewProps & { + preferredContentSize: { width: number; height: number } + children: ReactNode + } + >("ExpoRouterNativeLinkPreview", "NativeLinkPreviewContentView") + : null + +function MediaPreview({ preview }: { preview: MediaMenuPreview }) { + const colors = useThemeColors() + const { width: windowWidth, fontScale } = useWindowDimensions() + if (!NativeContextMenuPreview) return null + + const width = Math.min(360, windowWidth - 32) + const height = Math.max(124, 32 + 76 * fontScale) + const isArtist = preview.kind === "artist" + return ( + + + + + + {preview.title} + + {preview.artist ? ( + + {preview.artist} + + ) : null} + {preview.album ? ( + + {preview.album} + + ) : null} + + {preview.kind !== "song" ? ( + + ) : null} + + + ) +} + const NativeContextMenuAction: ComponentType<{ identifier: string title: string @@ -233,11 +330,13 @@ const NativeContextMenuAction: ComponentType<{ function NativeMediaContextMenu({ children, + preview, onAction, share, ...actionConfig }: MediaMenuWrapperProps) { const { config } = useServerConfig() + const { push } = useAppNavigation() if (!NativeContextMenuView || !NativeContextMenuAction) { return children @@ -252,10 +351,21 @@ function NativeMediaContextMenu({ } return ( - + { + if (share?.type === "artist") push(`/artist/${share.artistId}`) + else if (share?.type === "album" || share?.type === "song") + push(`/album/${share.albumId}`) + }} + > {/* The native menu retains its first trigger. Keep that view mounted when focus changes replace the Siri entity wrapper inside it. */} {children} + {preview && (actionConfig.selectedCount ?? 1) === 1 ? ( + + ) : null} {buildMediaMenuActions({ ...actionConfig, share }).map((action) => ( void onAction: (song: BrowseSong, action: MediaAction) => void }) { + const { config } = useServerConfig() const handlePress = useCallback(() => onPlay(song), [onPlay, song]) return ( @@ -182,6 +183,16 @@ export const SongListRow = memo(function SongListRow({ swipe={swipe} onPress={handlePress} contextMenu={{ + preview: config + ? { + kind: "song", + title: song.title, + artist: song.artist.name, + album: song.album.title, + artworkUrl: albumCoverUrl(config.serverUrl, song.album.id), + hasArtwork: song.album.cover != null, + } + : undefined, stationArtistId: song.artist.id, favorited, playlistLabel, -- 2.54.1 From 5602413272fc75819968b84b2bc4ec359a55ba9f Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Sun, 15 Nov 2026 14:03:05 -0500 Subject: [PATCH 2/2] fix(mobile): keep context previews out of row layout --- apps/mobile/components/media-context-menu.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/mobile/components/media-context-menu.tsx b/apps/mobile/components/media-context-menu.tsx index 6109c6c..8a63f45 100644 --- a/apps/mobile/components/media-context-menu.tsx +++ b/apps/mobile/components/media-context-menu.tsx @@ -258,7 +258,12 @@ function MediaPreview({ preview }: { preview: MediaMenuPreview }) { const height = Math.max(124, 32 + 76 * fontScale) const isArtist = preview.kind === "artist" return ( - + // Match Expo Router's preview wrapper: UIKit mounts this separately, but + // Yoga must also keep it out of the trigger's normal layout. +