diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index a32bf8c..dcbc834 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -162,7 +162,7 @@ export default function AlbumScreen() { }} /> - + ) } diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx index f11a0d1..98b7dac 100644 --- a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx @@ -121,7 +121,7 @@ export default function PlaylistScreen() { }} /> - + ) } diff --git a/apps/mobile/app/(app)/(tabs)/library/index.tsx b/apps/mobile/app/(app)/(tabs)/library/index.tsx index 7eef065..dfd8f57 100644 --- a/apps/mobile/app/(app)/(tabs)/library/index.tsx +++ b/apps/mobile/app/(app)/(tabs)/library/index.tsx @@ -118,12 +118,7 @@ export default function LibraryScreen() { ) if (status === "LoadingFirstPage" && !isCached) { - return ( - - {listHeader} - - - ) + return } return ( diff --git a/apps/mobile/components/skeletons.tsx b/apps/mobile/components/skeletons.tsx index 591a335..d0d0ec6 100644 --- a/apps/mobile/components/skeletons.tsx +++ b/apps/mobile/components/skeletons.tsx @@ -1,15 +1,20 @@ import { useMediaGridLayout } from "@/hooks/use-media-grid-layout" +import { useTabletLayout } from "@/hooks/use-tablet-layout" import { CollectionHero, useCollectionHeroLayout, } from "@/components/collection-hero" +import { + CollectionDivider, + collectionInset, +} from "@/components/collection-list" +import { tabletCardTextHeight } from "@/components/tablet-media-grid" import { Link } from "expo-router" import { useHeaderHeight } from "expo-router/react-navigation" import Reanimated from "react-native-reanimated" -import { type ReactNode, type ComponentProps } from "react" +import { type ComponentProps, type ReactNode } from "react" import { Platform, - ScrollView, StyleSheet, View, type DimensionValue, @@ -17,34 +22,42 @@ import { type ViewStyle, } from "react-native" -import { contentBottomInset } from "@/components/player" import { carouselCardWidth, radius, spacing, useThemeColors } from "@/lib/theme" -/** Reserve the transparent native header explicitly while skeletons cannot scroll. */ -function SkeletonContent({ +/** + * Loading screens never scroll, so they cannot rely on scroll-view inset + * adjustment. iOS headers are transparent and overlap the screen; Android + * headers are opaque and already sit above it. + */ +function SkeletonScreen({ children, - embedded = false, + style, + backgroundColor, + onLayout, }: { children: ReactNode - embedded?: boolean + style?: ComponentProps["style"] + backgroundColor?: string + onLayout?: () => void }) { const colors = useThemeColors() const headerHeight = useHeaderHeight() - if (embedded) return <>{children} - return ( - {children} - + ) } @@ -61,56 +74,103 @@ export function Skeleton({ style }: { style?: StyleProp }) { ) } +/** Occupies the line box of text at `fontSize`, so loaded text lands in place. */ function TextLine({ width, - height = 14, + fontSize, }: { width: DimensionValue - height?: number + fontSize: number }) { - return + return ( + + + + ) } -export function SongRowSkeleton() { +/** Mirrors `SongRow`, including its `inset` album/playlist layout. */ +export function SongRowSkeleton({ inset = false }: { inset?: boolean }) { const colors = useThemeColors() + const meta = ( + + + + + + + ) + if (inset) { + return ( + + + + {meta} + + + ) + } return ( - - - + {meta} + + ) +} + +function TrackRowSkeleton() { + const colors = useThemeColors() + return ( + + + + + + ) } -export function SongListSkeleton({ - rows = 10, - embedded = false, -}: { - rows?: number - embedded?: boolean -}) { +function SongRows({ rows, inset }: { rows: number; inset?: boolean }) { + return Array.from({ length: rows }, (_, index) => ( + + )) +} + +export function SongListSkeleton({ rows = 10 }: { rows?: number }) { return ( - - - {Array.from({ length: rows }, (_, index) => ( - - ))} - - + + + ) } +/** Mirrors the album, playlist, and artist cards in `media-cards`. */ function CardSkeleton({ width, + minHeight, round = false, }: { width: number + minHeight?: number round?: boolean }) { return ( - + - - {round ? null : } + + {round ? null : } ) } -export function MediaGridSkeleton({ - items = 6, - contentInset = true, - embedded = false, +/** Mirrors `MediaGridList`: a `FlatList` on phones, `TabletMediaGrid` on iPad. */ +function MediaGridContent({ + items, + contentInset, + header, }: { - items?: number - contentInset?: boolean - embedded?: boolean + items: number + contentInset: boolean + header?: ReactNode }) { + const tabletLayout = useTabletLayout() const { cardWidth, columns, onLayout, horizontalPadding, gap, ready } = useMediaGridLayout() return ( - + <> + {header} ( - + ) )} - + + ) +} + +export function MediaGridSkeleton({ + items = 6, + contentInset = true, + header, +}: { + items?: number + contentInset?: boolean + /** The loaded list's `ListHeaderComponent`, so it keeps its position. */ + header?: ReactNode +}) { + return ( + + + ) } export function CarouselSkeleton() { return ( - + - {Array.from({ length: 3 }, (_, index) => ( + {Array.from({ length: 8 }, (_, index) => ( ))} @@ -176,140 +265,148 @@ export function CarouselSkeleton() { } export function HomeSkeleton() { - const headerHeight = useHeaderHeight() - const colors = useThemeColors() return ( - - - - + + + + + + + ) +} + +function HeroActions({ + favorite = true, + reverse = false, +}: { + favorite?: boolean + reverse?: boolean +}) { + return ( + + {favorite ? : null} + + + ) } /** Album and playlist pages: cover, title, play buttons, then tracks. */ export function CollectionDetailSkeleton({ - zoomCoverSize, + variant, style, - round = false, backgroundColor, onLayout, }: { - zoomCoverSize?: number - style?: ComponentProps["style"] - round?: boolean + variant: "album" | "playlist" | "favorites" | "artist" + style?: ComponentProps["style"] backgroundColor?: string onLayout?: () => void }) { - const colors = useThemeColors() - const headerHeight = useHeaderHeight() const { landscape, coverSize: tabletCoverSize } = useCollectionHeroLayout() - const coverSize = - !round && landscape - ? tabletCoverSize! - : (zoomCoverSize ?? (round ? 180 : 210)) - const actions = ( - - - - - - ) - const artwork = ( - - ) + + if (variant === "artist" || variant === "favorites") { + const artist = variant === "artist" + const coverSize = artist ? 180 : 200 + const hero = ( + + + + + + ) + return ( + + {artist ? ( + + ) : ( + <> + {hero} + + + + )} + + ) + } + + const album = variant === "album" + const coverSize = tabletCoverSize ?? (album ? 220 : 200) return ( - - {round ? ( - - {zoomCoverSize ? ( - - {artwork} - - ) : ( - artwork - )} - - - {actions} - + + + + + + } + actions={} + > + + + {album ? ( + + ) : null} + + + {album ? ( + Array.from({ length: 10 }, (_, index) => ( + + )) ) : ( - - {artwork} - - ) : ( - artwork - ) - } - actions={actions} - > - - - - + )} - {round ? ( - - ) : ( - - )} - + ) } export function ArtistListSkeleton({ rows = 12 }: { rows?: number }) { const colors = useThemeColors() return ( - - - {Array.from({ length: rows }, (_, index) => ( - - - - - ))} - - + + {Array.from({ length: rows }, (_, index) => ( + + + + + ))} + ) } const styles = StyleSheet.create({ + screen: { flex: 1, overflow: "hidden" }, songRow: { flexDirection: "row", alignItems: "center", @@ -319,22 +416,55 @@ const styles = StyleSheet.create({ paddingHorizontal: spacing.lg, borderBottomWidth: StyleSheet.hairlineWidth, }, + insetRow: { + flexDirection: "row", + alignItems: "center", + gap: spacing.md, + paddingLeft: collectionInset, + }, + insetSongContent: { + flex: 1, + flexDirection: "row", + alignItems: "center", + alignSelf: "stretch", + minHeight: 64, + paddingVertical: 10, + marginRight: collectionInset, + borderBottomWidth: StyleSheet.hairlineWidth, + }, songArtwork: { width: 44, height: 44, borderRadius: 6 }, - songMeta: { flex: 1, gap: 6 }, - card: { gap: spacing.xs }, - grid: { flexDirection: "row", flexWrap: "wrap", gap: spacing.md }, - gridInset: { padding: spacing.lg }, - gridRowInset: { paddingHorizontal: spacing.lg }, - carousel: { gap: spacing.md, overflow: "hidden" }, - carouselRow: { flexDirection: "row", gap: spacing.md }, - home: { padding: spacing.lg, gap: spacing.xl }, - artistHero: { alignItems: "center", padding: spacing.lg, gap: spacing.sm }, - actions: { + songMeta: { flex: 1 }, + songSubtitle: { marginTop: 3 }, + trackRow: { flexDirection: "row", alignItems: "center", gap: spacing.sm, + paddingLeft: collectionInset, + }, + trackNumber: { width: 24, alignItems: "center" }, + trackContent: { + flex: 1, + justifyContent: "center", + alignSelf: "stretch", + minHeight: 52, + paddingVertical: 12, + marginRight: collectionInset, + borderBottomWidth: StyleSheet.hairlineWidth, + }, + card: { gap: spacing.xs }, + grid: { flexDirection: "row", flexWrap: "wrap" }, + carousel: { gap: spacing.md, overflow: "hidden" }, + carouselRow: { flexDirection: "row", gap: spacing.md }, + home: { padding: spacing.lg, gap: spacing.xl }, + centeredHero: { alignItems: "center", padding: spacing.lg, gap: spacing.sm }, + actions: { + flexDirection: "row", + alignItems: "center", + justifyContent: "center", + gap: spacing.sm, marginTop: spacing.sm, }, + actionsReverse: { flexDirection: "row-reverse" }, iconAction: { width: 44, height: 44, borderRadius: 22 }, playButton: { width: 160, height: 44, borderRadius: 999 }, artistRow: { diff --git a/apps/mobile/components/tablet-media-grid.tsx b/apps/mobile/components/tablet-media-grid.tsx index c9bf868..9a52543 100644 --- a/apps/mobile/components/tablet-media-grid.tsx +++ b/apps/mobile/components/tablet-media-grid.tsx @@ -19,6 +19,9 @@ import { useMediaGridLayout } from "@/hooks/use-media-grid-layout" import { tabletLayoutTransition } from "@/lib/tablet-motion" import { useThemeColors } from "@/lib/theme" +/** Height reserved under each tablet card's artwork for its title and subtitle. */ +export const tabletCardTextHeight = 48 + type GridProps = { content: MediaItem[] paddingBottom: number @@ -48,7 +51,7 @@ export function TabletMediaGrid({ const [headerHeight, setHeaderHeight] = useState(0) const [scrollY, setScrollY] = useState(0) const lastRequestedLength = useRef(-1) - const rowHeight = cardWidth + 48 + gap + const rowHeight = cardWidth + tabletCardTextHeight + gap const firstRow = Math.max( 0, Math.floor((scrollY - headerHeight) / rowHeight) - 2