57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import type { NativeStackNavigationOptions } from "expo-router"
|
|
import { Platform } from "react-native"
|
|
|
|
import { useThemeColors } from "@/lib/theme"
|
|
|
|
type StackScreenOptions = NativeStackNavigationOptions
|
|
|
|
export const tabStackScreenTitles: Record<string, string> = {
|
|
"browse/albums": "Albums",
|
|
"browse/artists": "Artists",
|
|
"browse/songs": "Songs",
|
|
"browse/playlists": "Playlists",
|
|
"recently-played": "Recently Played",
|
|
"recently-added": "Recently Added",
|
|
settings: "Settings",
|
|
"downloads/index": "Downloads",
|
|
"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" } } : {}
|
|
|
|
/** Tab roots show the profile button in the header, except on iOS where `ScreenTitle` holds it. */
|
|
export function showHeaderProfile(routeName: string) {
|
|
return routeName === "index" && Platform.OS !== "ios"
|
|
}
|
|
|
|
export function useStackScreenOptions(
|
|
overrides?: StackScreenOptions
|
|
): StackScreenOptions {
|
|
const theme = useThemeColors()
|
|
|
|
return {
|
|
headerLargeTitle: false,
|
|
headerTransparent: true,
|
|
headerTintColor: theme.foreground,
|
|
headerLargeTitleStyle: { color: theme.foreground },
|
|
headerBackButtonDisplayMode: "minimal",
|
|
...(Platform.OS === "android"
|
|
? {
|
|
animation: "fade",
|
|
headerLargeTitle: false,
|
|
headerTransparent: false,
|
|
headerStyle: { backgroundColor: theme.background },
|
|
headerShadowVisible: false,
|
|
statusBarStyle: "light" as const,
|
|
contentStyle: { backgroundColor: theme.background },
|
|
}
|
|
: {}),
|
|
...overrides,
|
|
}
|
|
}
|