fix(mobile): synchronize artwork page and bar backgrounds

This commit is contained in:
joshuafhiggins committed 2026-11-05 17:49:30 -05:00 Verified
1 parent 4f3733eecf
commit 7d4dc9a4de
4 files changed
+48 -24

No files matched your search

+13 -5
View File
@@ -1,12 +1,14 @@
import Animated from "react-native-reanimated"
import { NavigationBar } from "expo-navigation-bar"
import {
AndroidTabThemeProvider,
useAndroidTabPalette,
useAndroidTabBackgroundStyle,
useAndroidTabSelectedColor,
} from "@/contexts/android-tab-theme"
import { DarkTheme, DefaultTheme, ThemeProvider } from "expo-router"
import { NativeTabs } from "expo-router/native-tabs"
import { DynamicColorIOS, Platform, View } from "react-native"
import { DynamicColorIOS, Platform } from "react-native"
import { useMemo } from "react"
import { AndroidMiniPlayer, TabBottomAccessory } from "@/components/mini-player"
@@ -78,8 +80,8 @@ function useNativeTabColors() {
blurEffect: isDark
? "systemChromeMaterialDark"
: "systemChromeMaterialLight",
backgroundColor:
Platform.OS === "ios" ? undefined : androidPalette.background,
// Reveal the shared UI-thread background beneath the native tab bar.
backgroundColor: Platform.OS === "ios" ? undefined : "transparent",
}
}
@@ -87,6 +89,7 @@ function TabsContent() {
const keyboardVisible = useAndroidKeyboardVisible()
const routerTheme = useRouterTheme()
const tabColors = useNativeTabColors()
const backgroundStyle = useAndroidTabBackgroundStyle()
const { currentSong, queueSongIds } = usePlaybackQueue()
const showBottomAccessory = Boolean(currentSong && queueSongIds.length > 0)
@@ -101,7 +104,12 @@ function TabsContent() {
return (
<ThemeProvider value={routerTheme}>
<View style={{ flex: 1 }}>
<Animated.View
style={[
{ flex: 1 },
Platform.OS === "android" ? backgroundStyle : undefined,
]}
>
{Platform.OS === "android" ? (
<NavigationBar style={tabColors.isDark ? "light" : "dark"} />
) : null}
@@ -156,7 +164,7 @@ function TabsContent() {
</NativeTabs.Trigger>
</NativeTabs>
{!keyboardVisible ? <AndroidMiniPlayer /> : null}
</View>
</Animated.View>
</ThemeProvider>
)
}
@@ -1,5 +1,8 @@
import Animated from "react-native-reanimated"
import { useAndroidScreenPalette } from "@/contexts/android-tab-theme"
import {
renderAndroidArtworkBackground,
useAndroidScreenPalette,
} from "@/contexts/android-tab-theme"
import { MusicEntityView } from "@/components/music-entity-view"
import { Stack, useIsFocused, useLocalSearchParams } from "expo-router"
import { StatusBar } from "expo-status-bar"
@@ -132,7 +135,8 @@ export default function AlbumScreen() {
headerLargeTitle: false,
...(Platform.OS === "android"
? {
headerStyle: { backgroundColor: palette.background },
headerStyle: { backgroundColor: "transparent" },
headerBackground: renderAndroidArtworkBackground,
headerTintColor: palette.foreground,
}
: {}),
@@ -182,7 +186,8 @@ export default function AlbumScreen() {
headerTintColor: palette.foreground,
...(Platform.OS === "android"
? {
headerStyle: { backgroundColor: palette.background },
headerStyle: { backgroundColor: "transparent" },
headerBackground: renderAndroidArtworkBackground,
statusBarStyle: palette.isDark
? ("light" as const)
: ("dark" as const),
@@ -3,7 +3,10 @@ import {
PlaylistSearchBar,
usePlaylistSearch,
} from "@/components/playlist-search-bar"
import { useAndroidScreenPalette } from "@/contexts/android-tab-theme"
import {
renderAndroidArtworkBackground,
useAndroidScreenPalette,
} from "@/contexts/android-tab-theme"
import { MusicEntityView } from "@/components/music-entity-view"
import { useMutation } from "convex/react"
import { memo, useCallback, useEffect, useMemo } from "react"
@@ -101,7 +104,8 @@ export default function PlaylistScreen() {
headerLargeTitle: false,
...(Platform.OS === "android"
? {
headerStyle: { backgroundColor: palette.background },
headerStyle: { backgroundColor: "transparent" },
headerBackground: renderAndroidArtworkBackground,
headerTintColor: palette.foreground,
}
: {}),
@@ -263,7 +267,8 @@ function PlaylistContent({
headerTintColor: palette.foreground,
...(Platform.OS === "android"
? {
headerStyle: { backgroundColor: palette.background },
headerStyle: { backgroundColor: "transparent" },
headerBackground: renderAndroidArtworkBackground,
statusBarStyle: palette.isDark
? ("light" as const)
: ("dark" as const),
+19 -13
View File
@@ -14,8 +14,8 @@ import {
useRef,
type PropsWithChildren,
} from "react"
import { Animated, Easing, Platform } from "react-native"
import {
import { Animated, Easing, Platform, StyleSheet } from "react-native"
import Reanimated, {
interpolateColor,
useReducedMotion,
useSharedValue,
@@ -108,9 +108,21 @@ export function useAndroidTabSelectedColor() {
export function useAndroidTabBackgroundStyle() {
const theme = useContext(AndroidTabTheme)
const fallback = useDefaultPalette().background
return useAnimatedStyle(() => ({
backgroundColor: theme?.background.value ?? fallback,
}))
return useAnimatedStyle(() =>
Platform.OS === "android"
? { backgroundColor: theme?.background.value ?? fallback }
: {}
)
}
/** Native headers draw this same UI-thread background as the page and bars. */
function AndroidArtworkBackground() {
const style = useAndroidTabBackgroundStyle()
return <Reanimated.View style={[StyleSheet.absoluteFill, style]} />
}
export function renderAndroidArtworkBackground() {
return <AndroidArtworkBackground />
}
/** Run backgrounds on the UI thread even while React is rendering track rows. */
@@ -175,7 +187,7 @@ function useFadingPalette(target: CoverPalette, initial: CoverPalette) {
return Platform.OS === "android" ? displayed : target
}
/** Fade each page independently; shared bars follow the focused page. */
/** The focused artwork screen selects the shared background for page and bars. */
export function useAndroidScreenPalette(palette: CoverPalette) {
const isFocused = useIsFocused()
const owner = useRoute().key
@@ -196,13 +208,7 @@ export function useAndroidScreenPalette(palette: CoverPalette) {
const setPalette = theme?.setPalette
const target = isFocused && laidOut && !closing ? palette : defaultPalette
const displayed = useFadingPalette(target, defaultPalette)
const background = useFadingBackground(
target.background,
defaultPalette.background
)
const backgroundStyle = useAnimatedStyle(() =>
Platform.OS === "android" ? { backgroundColor: background.value } : {}
)
const backgroundStyle = useAndroidTabBackgroundStyle()
useLayoutEffect(() => {
if (