feat(mobile): scroll-away inline screen titles on iOS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
joshuafhigginsandClaude Opus 5.5 committed 2026-11-20 00:09:30 -05:00 Verified
1 parent 96feb89b9d
commit 92ecb1f794
19 files changed
+330 -64

No files matched your search

@@ -1,7 +1,11 @@
import { Stack } from "expo-router"
import { renderTabScreenContent } from "@/components/tab-screen-content"
import { useStackScreenOptions, tabStackScreenTitles } from "@/lib/navigation"
import {
inlineTitleOptions,
tabStackScreenTitles,
useStackScreenOptions,
} from "@/lib/navigation"
import { tabletSections, TabletSectionContext } from "@/lib/tablet-navigation"
export default function TabletSectionLayout({ segment }: { segment: string }) {
@@ -14,6 +18,7 @@ export default function TabletSectionLayout({ segment }: { segment: string }) {
screenLayout={renderTabScreenContent}
screenOptions={({ route }) => ({
...options,
...inlineTitleOptions,
title:
route.name === "index"
? section?.title
@@ -2,7 +2,11 @@ import { renderTabScreenContent } from "@/components/tab-screen-content"
import { Stack } from "expo-router"
import { ProfileHeaderButton } from "@/components/profile-header-button"
import { tabStackScreenTitles, useStackScreenOptions } from "@/lib/navigation"
import {
inlineTitleOptions,
tabStackScreenTitles,
useStackScreenOptions,
} from "@/lib/navigation"
export const unstable_settings = {
anchor: "index",
@@ -16,6 +20,7 @@ export default function HomeLayout() {
screenLayout={renderTabScreenContent}
screenOptions={({ route }) => ({
...baseOptions,
...inlineTitleOptions,
title: tabStackScreenTitles[route.name] ?? "Home",
headerRight:
route.name === "index" ? () => <ProfileHeaderButton /> : undefined,
@@ -44,6 +44,8 @@ export default function AlbumsScreen() {
placeholder: "Search",
onChangeText: handleChangeText,
onSearchButtonPress: onSearchSubmit,
// A search button in the bar leaves room for the inline title.
placement: "integratedButton",
},
}}
/>
@@ -53,7 +55,7 @@ export default function AlbumsScreen() {
return (
<>
{searchBar}
<MediaGridSkeleton />
<MediaGridSkeleton title="Albums" />
</>
)
}
@@ -63,6 +65,7 @@ export default function AlbumsScreen() {
{searchBar}
<MediaGridList
title="Albums"
content={albums}
paddingBottom={contentBottomInset}
onEndReached={() => {
@@ -2,12 +2,13 @@ import { Ionicons } from "@expo/vector-icons"
import { Stack } from "expo-router"
import { memo, useCallback } from "react"
import {
FlatList,
type FlatList,
Pressable,
StyleSheet,
Text,
type ListRenderItemInfo,
} from "react-native"
import Animated from "react-native-reanimated"
import {
MediaContextMenu,
@@ -15,6 +16,7 @@ import {
} from "@/components/media-context-menu"
import { CoverImage } from "@/components/cover-image"
import { ArtistListSkeleton } from "@/components/skeletons"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import { contentBottomInset } from "@/components/player"
import { useServerConfig } from "@/contexts/server-config"
import {
@@ -33,6 +35,7 @@ import { spacing, useThemeColors } from "@/lib/theme"
const PAGE_SIZE = 50
export default function ArtistsScreen() {
const { ref, scrollY } = useScreenTitleScroll<FlatList<BrowseArtist>>()
const { push } = useAppNavigation()
const colors = useThemeColors()
const { config } = useServerConfig()
@@ -85,6 +88,8 @@ export default function ArtistsScreen() {
placeholder: "Search",
onChangeText: handleChangeText,
onSearchButtonPress: onSearchSubmit,
// A search button in the bar leaves room for the inline title.
placement: "integratedButton",
},
}}
/>
@@ -94,7 +99,7 @@ export default function ArtistsScreen() {
return (
<>
{searchBar}
<ArtistListSkeleton />
<ArtistListSkeleton title="Artists" />
</>
)
}
@@ -103,8 +108,11 @@ export default function ArtistsScreen() {
<>
{searchBar}
<FlatList
<Animated.FlatList
{...longListProps}
ref={ref}
scrollEventThrottle={16}
ListHeaderComponent={<ScreenTitle title="Artists" scrollY={scrollY} />}
data={artists}
keyExtractor={artistKey}
renderItem={renderItem}
@@ -1,3 +1,4 @@
import { useContext } from "react"
import { Pressable } from "react-native"
import { MediaGridList } from "@/components/media-cards"
@@ -10,19 +11,20 @@ import { Ionicons } from "@expo/vector-icons"
import { Stack } from "expo-router"
import { SymbolView } from "expo-symbols"
import { useAddToPlaylist } from "@/contexts/add-to-playlist"
import { TabletSectionContext } from "@/lib/tablet-navigation"
export default function PlaylistsTabScreen() {
const colors = useThemeColors()
const playlists = useCachedQuery(api.playlists.listAllPlaylists)
const { openCreatePlaylist } = useAddToPlaylist()
const title = useContext(TabletSectionContext)?.title ?? "Playlists"
if (playlists === undefined) {
return (
<>
<Stack.Screen
options={{
title: "Playlists",
headerLargeTitle: true,
title,
headerRight: () => (
<Pressable
onPress={openCreatePlaylist}
@@ -38,7 +40,7 @@ export default function PlaylistsTabScreen() {
),
}}
/>
<MediaGridSkeleton />
<MediaGridSkeleton title={title} />
</>
)
}
@@ -47,8 +49,7 @@ export default function PlaylistsTabScreen() {
<>
<Stack.Screen
options={{
title: "Playlists",
headerLargeTitle: true,
title,
headerRight: () => (
<Pressable
onPress={openCreatePlaylist}
@@ -61,6 +62,7 @@ export default function PlaylistsTabScreen() {
}}
/>
<MediaGridList
title={title}
content={playlists}
paddingBottom={tabContentBottomInset}
/>
@@ -1,10 +1,16 @@
import { Stack } from "expo-router"
import { useCallback, useState } from "react"
import { FlatList, StyleSheet, type ListRenderItemInfo } from "react-native"
import {
type FlatList,
StyleSheet,
type ListRenderItemInfo,
} from "react-native"
import Animated from "react-native-reanimated"
import type { MediaAction } from "@/components/media-context-menu"
import { contentBottomInset, SongListRow } from "@/components/player"
import { SongListSkeleton } from "@/components/skeletons"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import { useFavorites } from "@/contexts/favorites"
import { usePlaybackActions } from "@/contexts/playback"
import {
@@ -20,6 +26,7 @@ import { longListProps } from "@/lib/list"
const PAGE_SIZE = 50
export default function SongsScreen() {
const { ref, scrollY } = useScreenTitleScroll<FlatList<BrowseSong>>()
const { playFromLibrarySong } = usePlaybackActions()
const { isSongFavorite } = useFavorites()
const { handleSongAction } = useMediaMenuActions()
@@ -78,6 +85,8 @@ export default function SongsScreen() {
placeholder: "Search",
onChangeText: handleChangeText,
onSearchButtonPress: onSearchSubmit,
// A search button in the bar leaves room for the inline title.
placement: "integratedButton",
},
}}
/>
@@ -87,7 +96,7 @@ export default function SongsScreen() {
return (
<>
{searchBar}
<SongListSkeleton />
<SongListSkeleton title="Songs" />
</>
)
}
@@ -96,8 +105,11 @@ export default function SongsScreen() {
<>
{searchBar}
<FlatList
<Animated.FlatList
{...longListProps}
ref={ref}
scrollEventThrottle={16}
ListHeaderComponent={<ScreenTitle title="Songs" scrollY={scrollY} />}
data={songs}
keyExtractor={songKey}
renderItem={renderItem}
@@ -1,6 +1,6 @@
import { useMemo } from "react"
import {
FlatList,
type FlatList,
Pressable,
StyleSheet,
Text,
@@ -8,8 +8,10 @@ import {
type ListRenderItemInfo,
} from "react-native"
import { Stack } from "expo-router"
import Animated from "react-native-reanimated"
import { CoverImage } from "@/components/cover-image"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import { tabContentBottomInset } from "@/components/player"
import {
FAVORITES_DOWNLOAD_ID,
@@ -53,6 +55,7 @@ export default function DownloadsScreen() {
const { push } = useAppNavigation()
const { columns, cardWidth, onLayout, horizontalPadding, gap } =
useMediaGridLayout()
const { ref, scrollY } = useScreenTitleScroll<FlatList<Card>>()
const cards = useMemo<Card[]>(() => {
if (!queue) return []
@@ -135,8 +138,10 @@ export default function DownloadsScreen() {
return (
<>
<Stack.Screen options={{ title: "Downloads", headerLargeTitle: true }} />
<FlatList
<Stack.Screen options={{ title: "Downloads" }} />
<Animated.FlatList
ref={ref}
scrollEventThrottle={16}
key={columns}
onLayout={onLayout}
data={cards}
@@ -149,13 +154,20 @@ export default function DownloadsScreen() {
numColumns={columns}
style={{ flex: 1, backgroundColor: colors.background }}
contentContainerStyle={{
paddingTop: spacing.lg,
paddingHorizontal: horizontalPadding,
paddingBottom: tabContentBottomInset,
gap,
}}
columnWrapperStyle={columns > 1 ? { gap } : undefined}
contentInsetAdjustmentBehavior="automatic"
ListHeaderComponent={
<ScreenTitle
title="Downloads"
scrollY={scrollY}
// The list padding already insets the title.
style={{ paddingHorizontal: 0 }}
/>
}
ListEmptyComponent={
<View style={styles.empty}>
<Text style={{ color: colors.mutedForeground }}>
@@ -1,15 +1,17 @@
import { useCallback, useMemo } from "react"
import {
FlatList,
type FlatList,
Pressable,
StyleSheet,
Text,
View,
type ListRenderItemInfo,
} from "react-native"
import Animated from "react-native-reanimated"
import { Ionicons } from "@expo/vector-icons"
import { Stack } from "expo-router"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import { useSwipeRowGroup } from "@/components/ios-swipe-to-remove-row"
import type { MediaAction } from "@/components/media-context-menu"
import { contentBottomInset, SongListRow } from "@/components/player"
@@ -52,6 +54,7 @@ export default function OtherDownloadsScreen() {
const { isSongFavorite } = useFavorites()
const { handleSongAction } = useMediaMenuActions()
const swipeGroup = useSwipeRowGroup()
const { ref, scrollY } = useScreenTitleScroll<FlatList<BrowseSong>>()
const handlePlaySong = useCallback(
(song: BrowseSong) => void playFromSong(song.id, playableIds, PLAY_ORIGIN),
@@ -90,11 +93,11 @@ export default function OtherDownloadsScreen() {
return (
<>
<Stack.Screen
options={{ title: OTHER_DOWNLOADS_TITLE, headerLargeTitle: false }}
/>
<FlatList
<Stack.Screen options={{ title: OTHER_DOWNLOADS_TITLE }} />
<Animated.FlatList
{...longListProps}
ref={ref}
scrollEventThrottle={16}
data={songs}
keyExtractor={(song) => song.id}
renderItem={renderItem}
@@ -103,25 +106,32 @@ export default function OtherDownloadsScreen() {
contentInsetAdjustmentBehavior="automatic"
onScrollBeginDrag={swipeGroup.closeOpenRow}
ListHeaderComponent={
songs.length > 0 ? (
<View style={styles.actions}>
<Button
title="Play"
icon="play"
onPress={() => void playInOrder(playableIds, PLAY_ORIGIN)}
style={styles.play}
/>
<Pressable
accessibilityRole="button"
accessibilityLabel="Shuffle"
hitSlop={8}
onPress={() => void playShuffled(playableIds, PLAY_ORIGIN)}
style={[styles.shuffle, { backgroundColor: colors.card }]}
>
<Ionicons name="shuffle" size={24} color={colors.foreground} />
</Pressable>
</View>
) : undefined
<>
<ScreenTitle title={OTHER_DOWNLOADS_TITLE} scrollY={scrollY} />
{songs.length > 0 ? (
<View style={styles.actions}>
<Button
title="Play"
icon="play"
onPress={() => void playInOrder(playableIds, PLAY_ORIGIN)}
style={styles.play}
/>
<Pressable
accessibilityRole="button"
accessibilityLabel="Shuffle"
hitSlop={8}
onPress={() => void playShuffled(playableIds, PLAY_ORIGIN)}
style={[styles.shuffle, { backgroundColor: colors.card }]}
>
<Ionicons
name="shuffle"
size={24}
color={colors.foreground}
/>
</Pressable>
</View>
) : null}
</>
}
ListEmptyComponent={
<Text style={[styles.empty, { color: colors.mutedForeground }]}>
+16 -4
View File
@@ -1,8 +1,10 @@
import { memo } from "react"
import { ScrollView, StyleSheet } from "react-native"
import { type ScrollViewInstance, StyleSheet } from "react-native"
import Animated from "react-native-reanimated"
import { ContentCarousel } from "@/components/media-cards"
import { HomeSkeleton } from "@/components/skeletons"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import { tabContentBottomInset } from "@/components/player"
import { useCachedPaginatedQuery } from "@/hooks/use-cached-query"
import { api } from "@otunes/convex/_generated/api"
@@ -38,6 +40,7 @@ const HomeCarousels = memo(function HomeCarousels({
export default function HomeScreen() {
const colors = useThemeColors()
const { ref, scrollY } = useScreenTitleScroll<ScrollViewInstance>()
const recentlyAdded = useCachedPaginatedQuery(
api.library.browseRecentlyAddedPaginated,
{},
@@ -53,14 +56,16 @@ export default function HomeScreen() {
(result) => result.status === "LoadingFirstPage" && !result.isCached
)
if (isLoading) {
return <HomeSkeleton />
return <HomeSkeleton title="Home" />
}
const added = recentlyAdded.results.slice(0, CAROUSEL_ITEM_LIMIT)
const played = recentlyPlayed.results.slice(0, CAROUSEL_ITEM_LIMIT)
return (
<ScrollView
<Animated.ScrollView
ref={ref}
scrollEventThrottle={16}
style={{ flex: 1, backgroundColor: colors.background }}
contentContainerStyle={[
styles.content,
@@ -68,8 +73,9 @@ export default function HomeScreen() {
]}
contentInsetAdjustmentBehavior="automatic"
>
<ScreenTitle title="Home" scrollY={scrollY} style={styles.title} />
<HomeCarousels recentlyAdded={added} recentlyPlayed={played} />
</ScrollView>
</Animated.ScrollView>
)
}
@@ -78,4 +84,10 @@ const styles = StyleSheet.create({
padding: spacing.lg,
gap: spacing.xl,
},
// The content padding already insets the title.
title: {
paddingHorizontal: 0,
marginTop: -spacing.lg,
marginBottom: -spacing.md,
},
})
@@ -14,11 +14,12 @@ export default function RecentlyAddedScreen() {
)
if (status === "LoadingFirstPage" && !isCached) {
return <MediaGridSkeleton />
return <MediaGridSkeleton title="Recently Added" />
}
return (
<MediaGridList
title="Recently Added"
content={results}
paddingBottom={contentBottomInset}
onEndReached={() => {
@@ -14,11 +14,12 @@ export default function RecentlyPlayedScreen() {
)
if (status === "LoadingFirstPage" && !isCached) {
return <MediaGridSkeleton />
return <MediaGridSkeleton title="Recently Played" />
}
return (
<MediaGridList
title="Recently Played"
content={results}
paddingBottom={contentBottomInset}
onEndReached={() => {
@@ -3,7 +3,11 @@ import { renderTabScreenContent } from "@/components/tab-screen-content"
import { Stack } from "expo-router"
import { ProfileHeaderButton } from "@/components/profile-header-button"
import { tabStackScreenTitles, useStackScreenOptions } from "@/lib/navigation"
import {
inlineTitleOptions,
tabStackScreenTitles,
useStackScreenOptions,
} from "@/lib/navigation"
export const unstable_settings = {
anchor: "index",
@@ -18,6 +22,7 @@ export default function LibraryLayout() {
screenLayout={renderTabScreenContent}
screenOptions={({ route }) => ({
...baseOptions,
...inlineTitleOptions,
title:
tabStackScreenTitles[route.name] ??
(tabletLayout ? "Recently Added" : "Library"),
@@ -72,6 +72,7 @@ export default function LibraryScreen() {
const { push } = useAppNavigation()
const isTablet = tabletLayout
const colors = useThemeColors()
const title = isTablet ? "Recently Added" : "Library"
const { results, status, loadMore, isCached } = useCachedPaginatedQuery(
api.library.browseRecentlyAddedPaginated,
{},
@@ -124,11 +125,18 @@ export default function LibraryScreen() {
)
if (status === "LoadingFirstPage" && !isCached) {
return <MediaGridSkeleton contentInset={false} header={listHeader} />
return (
<MediaGridSkeleton
title={title}
contentInset={false}
header={listHeader}
/>
)
}
return (
<MediaGridList
title={title}
content={results}
paddingBottom={tabContentBottomInset}
contentInset={false}
@@ -2,7 +2,11 @@ import { renderTabScreenContent } from "@/components/tab-screen-content"
import { Stack } from "expo-router"
import { ProfileHeaderButton } from "@/components/profile-header-button"
import { tabStackScreenTitles, useStackScreenOptions } from "@/lib/navigation"
import {
inlineTitleOptions,
tabStackScreenTitles,
useStackScreenOptions,
} from "@/lib/navigation"
export const unstable_settings = {
anchor: "index",
@@ -16,6 +20,11 @@ export default function SearchLayout() {
screenLayout={renderTabScreenContent}
screenOptions={({ route }) => ({
...baseOptions,
// The search tab keeps the native large title: its header search
// field has to sit below the title, which an inline title can't do.
...(route.name === "index"
? { headerLargeTitle: true }
: inlineTitleOptions),
title: tabStackScreenTitles[route.name] ?? "Search",
headerRight:
route.name === "index" ? () => <ProfileHeaderButton /> : undefined,
+25 -2
View File
@@ -4,6 +4,7 @@ import { tabletLayoutTransition } from "@/lib/tablet-motion"
import { TabletMediaGrid } from "@/components/tablet-media-grid"
import { useMediaGridLayout } from "@/hooks/use-media-grid-layout"
import { MusicEntityView } from "@/components/music-entity-view"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import { Link } from "expo-router"
import { Ionicons } from "@expo/vector-icons"
import { memo, useCallback, type ReactElement } from "react"
@@ -300,17 +301,21 @@ export function MediaGridList({
onEndReached,
ListHeaderComponent,
contentInset = true,
title,
}: {
content: MediaItem[]
paddingBottom: number
onEndReached?: () => void
ListHeaderComponent?: ReactElement
contentInset?: boolean
/** iOS `ScreenTitle` shown above the grid; it replaces the top inset. */
title?: string
}) {
const tabletLayout = useTabletLayout()
const { columns, cardWidth, onLayout, horizontalPadding, gap } =
useMediaGridLayout()
const colors = useThemeColors()
const { ref, scrollY } = useScreenTitleScroll<FlatList<MediaItem>>()
const renderItem = useCallback(
({ item }: ListRenderItemInfo<MediaItem>) => (
<View style={{ width: cardWidth }}>
@@ -328,13 +333,30 @@ export function MediaGridList({
onEndReached={onEndReached}
ListHeaderComponent={ListHeaderComponent}
contentInset={contentInset}
title={title}
renderCard={renderTabletCard}
/>
)
}
const header = title ? (
<View>
<ScreenTitle
title={title}
scrollY={scrollY}
// Inset grids already pad the whole list horizontally.
style={{ paddingHorizontal: contentInset ? 0 : horizontalPadding }}
/>
{ListHeaderComponent}
</View>
) : (
ListHeaderComponent
)
return (
<FlatList
<Animated.FlatList
ref={ref}
scrollEventThrottle={16}
key={columns}
onLayout={onLayout}
data={content}
@@ -351,6 +373,7 @@ export function MediaGridList({
paddingBottom,
gap,
...(contentInset ? { paddingHorizontal: horizontalPadding } : {}),
...(title ? { paddingTop: 0 } : {}),
},
]}
columnWrapperStyle={[
@@ -359,7 +382,7 @@ export function MediaGridList({
{ gap },
]}
contentInsetAdjustmentBehavior="automatic"
ListHeaderComponent={ListHeaderComponent}
ListHeaderComponent={header}
onEndReached={onEndReached}
onEndReachedThreshold={0.5}
/>
+84
View File
@@ -0,0 +1,84 @@
import { useHeaderHeight } from "expo-router/react-navigation"
import type { Component } from "react"
import {
Platform,
StyleSheet,
type ScrollViewInstance,
type StyleProp,
type TextStyle,
} from "react-native"
import Animated, {
useAnimatedRef,
useAnimatedStyle,
useScrollOffset,
type SharedValue,
} from "react-native-reanimated"
import { spacing, useThemeColors } from "@/lib/theme"
/**
* Tracks the scroll view that renders a `ScreenTitle`. Attach `ref` to that
* Reanimated `Animated.ScrollView` / `Animated.FlatList` and pass `scrollY`
* to the title.
*/
export function useScreenTitleScroll<
TScrollView extends Component | ScrollViewInstance,
>() {
const ref = useAnimatedRef<TScrollView>()
const scrollY = useScrollOffset(ref)
return { ref, scrollY }
}
/**
* iOS screen title rendered as the first item of a screen's scroll content,
* in place of the native large title (Apple Music style): it scrolls away
* with the content, never collapses into the bar, and stays put on
* pull-down. Android keeps its native header title, so this renders nothing.
*/
export function ScreenTitle({
title,
scrollY,
style,
}: {
title: string
/** From `useScreenTitleScroll`; omit for screens that never scroll. */
scrollY?: SharedValue<number>
style?: StyleProp<TextStyle>
}) {
const colors = useThemeColors()
// At rest the scroll offset is minus the automatic header inset, so any
// offset below that is overscroll the title should cancel out.
const headerHeight = useHeaderHeight()
const pinStyle = useAnimatedStyle(() => ({
transform: [
{
translateY: scrollY ? Math.min(0, scrollY.value + headerHeight) : 0,
},
],
}))
if (Platform.OS !== "ios") return null
return (
<Animated.Text
accessibilityRole="header"
numberOfLines={2}
style={[styles.title, { color: colors.foreground }, style, pinStyle]}
>
{title}
</Animated.Text>
)
}
// Matches UIKit's large title metrics: 34pt bold in a 52pt tall area.
const styles = StyleSheet.create({
title: {
fontSize: 34,
lineHeight: 41,
fontWeight: "700",
letterSpacing: 0.37,
paddingHorizontal: spacing.lg,
paddingTop: 3,
paddingBottom: 8,
},
})
+49 -5
View File
@@ -9,6 +9,7 @@ import {
collectionInset,
} from "@/components/collection-list"
import { tabletCardTextHeight } from "@/components/tablet-media-grid"
import { ScreenTitle } from "@/components/screen-title"
import { Link } from "expo-router"
import { useHeaderHeight } from "expo-router/react-navigation"
import Reanimated from "react-native-reanimated"
@@ -151,9 +152,16 @@ function SongRows({ rows, inset }: { rows: number; inset?: boolean }) {
))
}
export function SongListSkeleton({ rows = 10 }: { rows?: number }) {
export function SongListSkeleton({
rows = 10,
title,
}: {
rows?: number
title?: string
}) {
return (
<SkeletonScreen>
{title ? <ScreenTitle title={title} /> : null}
<SongRows rows={rows} />
</SkeletonScreen>
)
@@ -234,23 +242,45 @@ export function MediaGridSkeleton({
items = 6,
contentInset = true,
header,
title,
}: {
items?: number
contentInset?: boolean
/** The loaded list's `ListHeaderComponent`, so it keeps its position. */
header?: ReactNode
/** The loaded list's `ScreenTitle`, which replaces its top inset. */
title?: string
}) {
return (
<SkeletonScreen>
<MediaGridContent
items={items}
contentInset={contentInset}
header={header}
contentInset={contentInset && !title}
header={
title ? (
<>
<MediaGridTitle title={title} />
{header}
</>
) : (
header
)
}
/>
</SkeletonScreen>
)
}
function MediaGridTitle({ title }: { title: string }) {
const { horizontalPadding } = useMediaGridLayout()
return (
<ScreenTitle
title={title}
style={{ paddingHorizontal: horizontalPadding }}
/>
)
}
export function CarouselSkeleton() {
return (
<View style={styles.carousel}>
@@ -264,10 +294,11 @@ export function CarouselSkeleton() {
)
}
export function HomeSkeleton() {
export function HomeSkeleton({ title }: { title: string }) {
return (
<SkeletonScreen>
<View style={styles.home}>
<ScreenTitle title={title} style={styles.homeTitle} />
<CarouselSkeleton />
<CarouselSkeleton />
</View>
@@ -388,10 +419,17 @@ export function CollectionDetailSkeleton({
)
}
export function ArtistListSkeleton({ rows = 12 }: { rows?: number }) {
export function ArtistListSkeleton({
rows = 12,
title,
}: {
rows?: number
title?: string
}) {
const colors = useThemeColors()
return (
<SkeletonScreen>
{title ? <ScreenTitle title={title} /> : null}
{Array.from({ length: rows }, (_, index) => (
<View
key={index}
@@ -456,6 +494,12 @@ const styles = StyleSheet.create({
carousel: { gap: spacing.md, overflow: "hidden" },
carouselRow: { flexDirection: "row", gap: spacing.md },
home: { padding: spacing.lg, gap: spacing.xl },
// Mirrors the home screen's title spacing.
homeTitle: {
paddingHorizontal: 0,
marginTop: -spacing.lg,
marginBottom: -spacing.md,
},
centeredHero: { alignItems: "center", padding: spacing.lg, gap: spacing.sm },
actions: {
flexDirection: "row",
+20 -5
View File
@@ -6,7 +6,7 @@ import {
type ReactElement,
} from "react"
import {
ScrollView,
type ScrollViewInstance,
View,
type NativeSyntheticEvent,
type NativeScrollEvent,
@@ -15,6 +15,7 @@ import Animated from "react-native-reanimated"
import { useSafeAreaInsets } from "react-native-safe-area-context"
import type { MediaItem } from "@/components/media-cards"
import { ScreenTitle, useScreenTitleScroll } from "@/components/screen-title"
import { useMediaGridLayout } from "@/hooks/use-media-grid-layout"
import { tabletLayoutTransition } from "@/lib/tablet-motion"
import { useThemeColors } from "@/lib/theme"
@@ -28,6 +29,8 @@ type GridProps = {
onEndReached?: () => void
ListHeaderComponent?: ReactElement
contentInset?: boolean
/** iOS `ScreenTitle` shown above the grid; it replaces the top inset. */
title?: string
renderCard: (item: MediaItem, width: number) => ReactElement
}
@@ -41,9 +44,12 @@ export function TabletMediaGrid({
onEndReached,
ListHeaderComponent,
contentInset = true,
title,
renderCard,
}: GridProps) {
const colors = useThemeColors()
const { ref, scrollY: titleScrollY } =
useScreenTitleScroll<ScrollViewInstance>()
const insets = useSafeAreaInsets()
const { columns, cardWidth, onLayout, horizontalPadding, gap, ready } =
useMediaGridLayout()
@@ -102,18 +108,27 @@ export function TabletMediaGrid({
setViewportHeight(event.nativeEvent.layout.height)
}}
>
<ScrollView
<Animated.ScrollView
ref={ref}
onScroll={onScroll}
scrollEventThrottle={32}
// Every frame, so the title pins smoothly on pull-down.
scrollEventThrottle={16}
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{
paddingTop: contentInset ? horizontalPadding : 0,
paddingTop: contentInset && !title ? horizontalPadding : 0,
paddingBottom: paddingBottom + insets.bottom,
}}
>
<View
onLayout={(event) => setHeaderHeight(event.nativeEvent.layout.height)}
>
{title ? (
<ScreenTitle
title={title}
scrollY={titleScrollY}
style={{ paddingHorizontal: horizontalPadding }}
/>
) : null}
{ListHeaderComponent}
</View>
<View style={{ height: gridHeight }}>
@@ -136,7 +151,7 @@ export function TabletMediaGrid({
)
})}
</View>
</ScrollView>
</Animated.ScrollView>
</Animated.View>
)
}
+8 -1
View File
@@ -17,13 +17,20 @@ export const tabStackScreenTitles: Record<string, string> = {
"downloads/other": "Other Downloaded Songs",
}
/**
* iOS tab stacks render their titles in the scroll content with
* `ScreenTitle`, so the bar keeps the title (for back menus) but hides it.
*/
export const inlineTitleOptions: StackScreenOptions =
Platform.OS === "ios" ? { headerTitleStyle: { color: "transparent" } } : {}
export function useStackScreenOptions(
overrides?: StackScreenOptions
): StackScreenOptions {
const theme = useThemeColors()
return {
headerLargeTitle: true,
headerLargeTitle: false,
headerTransparent: true,
headerTintColor: theme.foreground,
headerLargeTitleStyle: { color: theme.foreground },