diff --git a/apps/mobile/app/(app)/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/_layout.tsx index 051a11c..7763f94 100644 --- a/apps/mobile/app/(app)/(tabs)/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/_layout.tsx @@ -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 ( - + {Platform.OS === "android" ? ( ) : null} @@ -156,7 +164,7 @@ function TabsContent() { {!keyboardVisible ? : null} - + ) } diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index ba37d59..4039dea 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -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), diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx index 1904b00..7bc89f9 100644 --- a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx @@ -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), diff --git a/apps/mobile/contexts/android-tab-theme.tsx b/apps/mobile/contexts/android-tab-theme.tsx index 5e50641..0435951 100644 --- a/apps/mobile/contexts/android-tab-theme.tsx +++ b/apps/mobile/contexts/android-tab-theme.tsx @@ -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 +} + +export function renderAndroidArtworkBackground() { + return } /** 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 (