From 6766711d58e369fbacb62a340b24b57e461a2b7d Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Sun, 8 Nov 2026 15:47:33 -0500 Subject: [PATCH 01/11] feat(mobile): adapt navigation and playback to iPad windows --- apps/mobile/README.md | 14 + .../_layout.tsx | 25 + .../album/[id].tsx | 1 + .../artist/[id].tsx | 1 + .../browse/albums.tsx | 1 + .../browse/artists.tsx | 1 + .../browse/playlists.tsx | 1 + .../browse/songs.tsx | 1 + .../index.tsx | 23 + .../playlist/[id].tsx | 1 + .../playlist/favorites.tsx | 1 + .../queue.tsx | 1 + .../recently-added.tsx | 1 + .../recently-played.tsx | 1 + .../settings.tsx | 1 + apps/mobile/app/(app)/(tabs)/_layout.tsx | 78 ++- apps/mobile/app/(app)/(tabs)/home/_layout.tsx | 2 + .../app/(app)/(tabs)/home/album/[id].tsx | 276 ++++++----- .../app/(app)/(tabs)/home/playlist/[id].tsx | 166 ++++--- .../app/(app)/(tabs)/library/_layout.tsx | 8 +- .../mobile/app/(app)/(tabs)/library/index.tsx | 84 +++- .../app/(app)/(tabs)/search/_layout.tsx | 2 + apps/mobile/app/(app)/player.tsx | 28 +- apps/mobile/components/collection-hero.tsx | 66 +++ apps/mobile/components/media-cards.tsx | 126 +++-- apps/mobile/components/now-playing-queue.tsx | 116 +++-- apps/mobile/components/player.tsx | 17 +- .../components/profile-header-button.tsx | 16 +- apps/mobile/components/skeletons.tsx | 144 +++--- apps/mobile/components/tab-screen-content.tsx | 27 ++ apps/mobile/components/tablet-media-grid.tsx | 139 ++++++ apps/mobile/components/tablet-mini-player.tsx | 289 ++++++++++++ apps/mobile/components/tablet-now-playing.tsx | 444 ++++++++++++++++++ apps/mobile/components/tablet-sidebar.tsx | 39 ++ apps/mobile/contexts/android-tab-theme.tsx | 70 ++- apps/mobile/contexts/playback.tsx | 18 +- apps/mobile/contexts/tablet-player-layout.tsx | 54 +++ apps/mobile/hooks/use-cover-palette.ts | 37 +- apps/mobile/hooks/use-media-grid-layout.ts | 47 ++ apps/mobile/hooks/use-open-settings.ts | 14 + apps/mobile/hooks/use-tablet-layout.ts | 7 + apps/mobile/lib/app-navigation.ts | 39 +- apps/mobile/lib/cover-palette.ts | 328 ++++--------- apps/mobile/lib/now-playing-colors.ts | 27 +- apps/mobile/lib/tablet-motion.ts | 13 + apps/mobile/lib/tablet-navigation.ts | 14 + apps/mobile/lib/theme.ts | 1 + apps/mobile/native/TabletSidebar.swift | 246 ++++++++++ apps/mobile/package.json | 1 + patches/react-native-screens@4.30.0.patch | 25 + pnpm-lock.yaml | 37 +- 51 files changed, 2426 insertions(+), 693 deletions(-) create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/_layout.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/album/[id].tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/artist/[id].tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/albums.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/artists.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/playlists.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/songs.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/index.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/playlist/[id].tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/playlist/favorites.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/queue.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/recently-added.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/recently-played.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/settings.tsx create mode 100644 apps/mobile/components/collection-hero.tsx create mode 100644 apps/mobile/components/tab-screen-content.tsx create mode 100644 apps/mobile/components/tablet-media-grid.tsx create mode 100644 apps/mobile/components/tablet-mini-player.tsx create mode 100644 apps/mobile/components/tablet-now-playing.tsx create mode 100644 apps/mobile/components/tablet-sidebar.tsx create mode 100644 apps/mobile/contexts/tablet-player-layout.tsx create mode 100644 apps/mobile/hooks/use-media-grid-layout.ts create mode 100644 apps/mobile/hooks/use-open-settings.ts create mode 100644 apps/mobile/hooks/use-tablet-layout.ts create mode 100644 apps/mobile/lib/tablet-motion.ts create mode 100644 apps/mobile/lib/tablet-navigation.ts create mode 100644 apps/mobile/native/TabletSidebar.swift diff --git a/apps/mobile/README.md b/apps/mobile/README.md index 7fb65bd..5ca7e20 100644 --- a/apps/mobile/README.md +++ b/apps/mobile/README.md @@ -42,3 +42,17 @@ Native sharing supplies media titles and artwork through iOS link metadata and A thumbnail, while sharing the original HTTPS URL. Receiving apps control whether they display previews. If artwork cannot load, the URL is still shared. Existing builds without the native sharing module fall back to URL-only sharing. + +### iPad sidebar + +Expo Router owns navigation through `NativeTabs sidebarAdaptable`. +`native/TabletSidebar.swift` adds UIKit Library and Playlists groups and the pinned +account footer, which the current Expo Router API does not expose. The bridge +reuses the router's tab instances so each destination retains its navigation stack. + +The `react-native-screens` patch checks the selected leaf controller rather than +the group's root controller. It also notifies the sidebar bridge after each native +tab reconciliation, so startup updates cannot replace the Library and Playlists +sections with a flat tab list. Keep both behaviors when updating the dependency. +After changing native modules or dependency patches, run `pod install` in `ios` +and rebuild the development app. diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/_layout.tsx new file mode 100644 index 0000000..9453ea3 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/_layout.tsx @@ -0,0 +1,25 @@ +import { Stack } from "expo-router" + +import { renderTabScreenContent } from "@/components/tab-screen-content" +import { useStackScreenOptions, tabStackScreenTitles } from "@/lib/navigation" +import { tabletSections, TabletSectionContext } from "@/lib/tablet-navigation" + +export default function TabletSectionLayout({ segment }: { segment: string }) { + const section = tabletSections.find((item) => item.group === segment) + const options = useStackScreenOptions() + + return ( + + ({ + ...options, + title: + route.name === "index" + ? section?.title + : tabStackScreenTitles[route.name], + })} + /> + + ) +} diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/album/[id].tsx new file mode 100644 index 0000000..f22686e --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/album/[id].tsx @@ -0,0 +1 @@ +export { default } from "../../library/album/[id]" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/artist/[id].tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/artist/[id].tsx new file mode 100644 index 0000000..0953a71 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/artist/[id].tsx @@ -0,0 +1 @@ +export { default } from "../../library/artist/[id]" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/albums.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/albums.tsx new file mode 100644 index 0000000..bb0b5fd --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/albums.tsx @@ -0,0 +1 @@ +export { default } from "../../library/browse/albums" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/artists.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/artists.tsx new file mode 100644 index 0000000..561a24b --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/artists.tsx @@ -0,0 +1 @@ +export { default } from "../../library/browse/artists" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/playlists.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/playlists.tsx new file mode 100644 index 0000000..a5d9b72 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/playlists.tsx @@ -0,0 +1 @@ +export { default } from "../../library/browse/playlists" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/songs.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/songs.tsx new file mode 100644 index 0000000..6111e73 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/browse/songs.tsx @@ -0,0 +1 @@ +export { default } from "../../library/browse/songs" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/index.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/index.tsx new file mode 100644 index 0000000..688cd25 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/index.tsx @@ -0,0 +1,23 @@ +import { useContext } from "react" +import Albums from "../home/browse/albums" +import Artists from "../home/browse/artists" +import Songs from "../home/browse/songs" +import Playlists from "../home/browse/playlists" +import Favorites from "../home/playlist/favorites" +import RecentlyPlayed from "../home/recently-played" +import { TabletSectionContext } from "@/lib/tablet-navigation" + +const screens = { + albums: Albums, + artists: Artists, + songs: Songs, + playlists: Playlists, + favorites: Favorites, + recent: RecentlyPlayed, +} + +export default function TabletSectionScreen() { + const section = useContext(TabletSectionContext) + const Screen = screens[section?.name ?? "albums"] + return +} diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/playlist/[id].tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/playlist/[id].tsx new file mode 100644 index 0000000..eb057b7 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/playlist/[id].tsx @@ -0,0 +1 @@ +export { default } from "../../library/playlist/[id]" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/playlist/favorites.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/playlist/favorites.tsx new file mode 100644 index 0000000..3a58009 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/playlist/favorites.tsx @@ -0,0 +1 @@ +export { default } from "../../library/playlist/favorites" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/queue.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/queue.tsx new file mode 100644 index 0000000..4d4acb6 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/queue.tsx @@ -0,0 +1 @@ +export { default } from "../library/queue" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/recently-added.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/recently-added.tsx new file mode 100644 index 0000000..01eca97 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/recently-added.tsx @@ -0,0 +1 @@ +export { default } from "../library/recently-added" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/recently-played.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/recently-played.tsx new file mode 100644 index 0000000..18d4064 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/recently-played.tsx @@ -0,0 +1 @@ +export { default } from "../library/recently-played" diff --git a/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/settings.tsx b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/settings.tsx new file mode 100644 index 0000000..9ec79d9 --- /dev/null +++ b/apps/mobile/app/(app)/(tabs)/(albums,artists,songs,playlists,favorites,recent)/settings.tsx @@ -0,0 +1 @@ +export { default } from "../library/settings" diff --git a/apps/mobile/app/(app)/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/_layout.tsx index 261251f..512741d 100644 --- a/apps/mobile/app/(app)/(tabs)/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/_layout.tsx @@ -1,7 +1,10 @@ +import { useTabletLayout } from "@/hooks/use-tablet-layout" +import { TabletMiniPlayer } from "@/components/tablet-mini-player" +import { TabletPlayerLayoutProvider } from "@/contexts/tablet-player-layout" import Animated from "react-native-reanimated" import { NavigationBar } from "expo-navigation-bar" import { - AndroidTabThemeProvider, + ScreenPaletteProvider, useAndroidTabPalette, useAndroidTabBackgroundStyle, useAndroidNativeTabColors, @@ -88,6 +91,7 @@ function useNativeTabColors() { } function TabsContent() { + const tabletLayout = useTabletLayout() const homeColors = useAndroidNativeTabColors() const libraryColors = useAndroidNativeTabColors() const searchColors = useAndroidNativeTabColors() @@ -109,16 +113,12 @@ function TabsContent() { return ( - + {Platform.OS === "android" ? ( ) : null} - {Platform.OS === "ios" && showBottomAccessory ? ( + {Platform.OS === "ios" && !tabletLayout && showBottomAccessory ? ( @@ -162,7 +162,9 @@ function TabsContent() { sf="music.note.square.stack.fill" md="library_music" /> - Library + + {tabletLayout ? "Recently Added" : "Library"} + Search + + + + + + {!keyboardVisible ? : null} + {tabletLayout ? : null} ) } export default function TabsLayout() { - if (Platform.OS !== "android") return return ( - - - + + + + + ) } diff --git a/apps/mobile/app/(app)/(tabs)/home/_layout.tsx b/apps/mobile/app/(app)/(tabs)/home/_layout.tsx index 87b926d..75da6ca 100644 --- a/apps/mobile/app/(app)/(tabs)/home/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/home/_layout.tsx @@ -1,3 +1,4 @@ +import { renderTabScreenContent } from "@/components/tab-screen-content" import { Stack } from "expo-router" import { ProfileHeaderButton } from "@/components/profile-header-button" @@ -12,6 +13,7 @@ export default function HomeLayout() { return ( ({ ...baseOptions, title: tabStackScreenTitles[route.name] ?? "Home", diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index 834ee31..d4ba20d 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -1,3 +1,7 @@ +import { + CollectionHero, + useCollectionHeroLayout, +} from "@/components/collection-hero" import { PaletteText, PaletteIcon, @@ -6,7 +10,7 @@ import { import Animated from "react-native-reanimated" import { renderAndroidArtworkBackground, - useAndroidScreenPalette, + useScreenPalette, } from "@/contexts/android-tab-theme" import { MusicEntityView } from "@/components/music-entity-view" import { Link, Stack, useIsFocused, useLocalSearchParams } from "expo-router" @@ -67,12 +71,13 @@ export default function AlbumScreen() { const isFocused = useIsFocused() const coverUri = config && typeof id === "string" ? albumCoverUrl(config.serverUrl, id) : "" + const heroLayout = useCollectionHeroLayout() const { palette: artworkPalette, settled } = useCoverPalette( coverUri, album ? album.cover != null : album === null ? false : undefined ) const { palette, onLayout, backgroundStyle } = - useAndroidScreenPalette(artworkPalette) + useScreenPalette(artworkPalette) const songIds = useMemo( () => album?.tracks.map((track) => track.id as Id<"songs">) ?? [], [album] @@ -243,131 +248,161 @@ export default function AlbumScreen() { indicatorStyle={palette.isDark ? "white" : "black"} ListHeaderComponent={ - - - - - - - - {album.title} - - push(`/artist/${album.artist.id}`)} - style={styles.artistPressable} + + + + + + + } + actions={ + + void toggleAlbumFavorite(album.id)} + hitSlop={8} + style={[ + styles.iconAction, + { backgroundColor: palette.surface }, + ]} + > + + +