From a447c44384d99b9921392db515916321628dec39 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Fri, 23 Oct 2026 19:36:36 -0400 Subject: [PATCH 1/4] fix(mobile): align Android padding and screen colors --- apps/mobile/app.json | 19 ++- apps/mobile/app/(app)/(tabs)/_layout.tsx | 99 ++++++++---- .../app/(app)/(tabs)/home/album/[id].tsx | 19 ++- .../app/(app)/(tabs)/home/playlist/[id].tsx | 12 ++ .../mobile/app/(app)/(tabs)/home/settings.tsx | 17 +- apps/mobile/app/(app)/(tabs)/search/index.tsx | 12 ++ apps/mobile/app/(app)/_layout.tsx | 3 +- apps/mobile/app/(app)/player.tsx | 11 +- apps/mobile/app/(app)/settings.tsx | 17 +- apps/mobile/app/_layout.tsx | 6 +- apps/mobile/app/server.tsx | 17 +- apps/mobile/components/android-sheet.tsx | 15 ++ apps/mobile/components/auth-form.tsx | 52 +++--- apps/mobile/components/keyboard-form.tsx | 32 ++++ apps/mobile/components/media-context-menu.tsx | 6 +- apps/mobile/components/media-menu.android.tsx | 137 ++++++++++++++++ apps/mobile/components/media-menu.tsx | 1 + apps/mobile/components/mini-player.tsx | 57 +++++-- apps/mobile/components/player.tsx | 5 +- apps/mobile/components/ui/primitives.tsx | 15 +- apps/mobile/components/ui/toaster.tsx | 9 +- apps/mobile/contexts/add-to-playlist.tsx | 152 +++++++++--------- apps/mobile/contexts/android-tab-theme.tsx | 68 ++++++++ .../hooks/use-android-keyboard-visible.ts | 19 +++ apps/mobile/lib/navigation.ts | 17 +- apps/mobile/lib/theme.ts | 6 +- apps/mobile/package.json | 2 + apps/mobile/plugins/with-android-colors.js | 26 +++ pnpm-lock.yaml | 41 +++++ 29 files changed, 714 insertions(+), 178 deletions(-) create mode 100644 apps/mobile/components/android-sheet.tsx create mode 100644 apps/mobile/components/keyboard-form.tsx create mode 100644 apps/mobile/components/media-menu.android.tsx create mode 100644 apps/mobile/components/media-menu.tsx create mode 100644 apps/mobile/contexts/android-tab-theme.tsx create mode 100644 apps/mobile/hooks/use-android-keyboard-visible.ts create mode 100644 apps/mobile/plugins/with-android-colors.js diff --git a/apps/mobile/app.json b/apps/mobile/app.json index 9e61032..03cbba5 100644 --- a/apps/mobile/app.json +++ b/apps/mobile/app.json @@ -27,7 +27,9 @@ "monochromeImage": "./assets/android-icon-monochrome.png", "foregroundImage": "./assets/android-icon-foreground.png", "backgroundColor": "#C60322" - } + }, + "userInterfaceStyle": "dark", + "softwareKeyboardLayoutMode": "resize" }, "plugins": [ "expo-router", @@ -49,12 +51,23 @@ ], "expo-image", "expo-status-bar", - "expo-app-intents" + "expo-app-intents", + "./plugins/with-android-colors", + [ + "expo-navigation-bar", + { + "enforceContrast": false, + "style": "light" + } + ] ], "experiments": { "typedRoutes": true, "inlineModules": { - "watchedDirectories": ["app-intents", "native"] + "watchedDirectories": [ + "app-intents", + "native" + ] } }, "extra": { diff --git a/apps/mobile/app/(app)/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/_layout.tsx index 6f7f58a..051a11c 100644 --- a/apps/mobile/app/(app)/(tabs)/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/_layout.tsx @@ -1,37 +1,50 @@ +import { NavigationBar } from "expo-navigation-bar" +import { + AndroidTabThemeProvider, + useAndroidTabPalette, + useAndroidTabSelectedColor, +} from "@/contexts/android-tab-theme" import { DarkTheme, DefaultTheme, ThemeProvider } from "expo-router" import { NativeTabs } from "expo-router/native-tabs" -import { DynamicColorIOS, Platform, View, useColorScheme } from "react-native" +import { DynamicColorIOS, Platform, View } from "react-native" import { useMemo } from "react" import { AndroidMiniPlayer, TabBottomAccessory } from "@/components/mini-player" +import { useAndroidKeyboardVisible } from "@/hooks/use-android-keyboard-visible" import { usePlaybackQueue } from "@/contexts/playback" -import { appleMusic, colors } from "@/lib/theme" +import { appleMusic, colors, miniPlayerHeight, useIsDark } from "@/lib/theme" export const unstable_settings = { anchor: "library" } function useRouterTheme() { - const isDark = useColorScheme() === "dark" + const themeIsDark = useIsDark() + const androidPalette = useAndroidTabPalette() + const isDark = Platform.OS === "android" ? androidPalette.isDark : themeIsDark return useMemo(() => { const palette = isDark ? colors.dark : colors.light + const android = Platform.OS === "android" ? androidPalette : null const base = isDark ? DarkTheme : DefaultTheme return { ...base, colors: { ...base.colors, - background: palette.background, - card: palette.card, - text: palette.foreground, - border: palette.border, - primary: palette.primary, + background: android?.background ?? palette.background, + card: android?.surface ?? palette.card, + text: android?.foreground ?? palette.foreground, + border: android?.divider ?? palette.border, + primary: android?.accentText ?? palette.primary, }, } - }, [isDark]) + }, [isDark, androidPalette]) } function useNativeTabColors() { - const isDark = useColorScheme() === "dark" + const selectedColor = useAndroidTabSelectedColor() + const themeIsDark = useIsDark() + const androidPalette = useAndroidTabPalette() + const isDark = Platform.OS === "android" ? androidPalette.isDark : themeIsDark const inactive = appleMusic.tabInactive const iconColor = @@ -41,24 +54,23 @@ function useNativeTabColors() { selected: appleMusic.pink, } : { - default: isDark ? inactive : "#636366", - selected: appleMusic.pink, + default: androidPalette.secondaryForeground, + selected: selectedColor, } const labelColor = Platform.OS === "ios" ? DynamicColorIOS({ dark: inactive, light: "#636366" }) - : isDark - ? inactive - : "#636366" + : androidPalette.secondaryForeground return { isDark, + tintColor: Platform.OS === "android" ? selectedColor : appleMusic.pink, iconColor, labelStyle: { default: { color: labelColor, fontSize: 10 }, selected: { - color: appleMusic.pink, + color: Platform.OS === "android" ? selectedColor : appleMusic.pink, fontSize: 10, fontWeight: "600" as const, }, @@ -67,23 +79,32 @@ function useNativeTabColors() { ? "systemChromeMaterialDark" : "systemChromeMaterialLight", backgroundColor: - Platform.OS === "ios" - ? undefined - : isDark - ? appleMusic.background - : colors.light.background, + Platform.OS === "ios" ? undefined : androidPalette.background, } } -export default function TabsLayout() { +function TabsContent() { + const keyboardVisible = useAndroidKeyboardVisible() const routerTheme = useRouterTheme() const tabColors = useNativeTabColors() const { currentSong, queueSongIds } = usePlaybackQueue() const showBottomAccessory = Boolean(currentSong && queueSongIds.length > 0) + // NativeTabs already owns the tab bar and system navigation insets. + const androidContentStyle = + Platform.OS === "android" + ? { + paddingBottom: + showBottomAccessory && !keyboardVisible ? miniPlayerHeight : 0, + } + : undefined + return ( + {Platform.OS === "android" ? ( + + ) : null} {Platform.OS === "ios" && showBottomAccessory ? ( @@ -101,12 +125,20 @@ export default function TabsLayout() { ) : null} - + Home - + Library - + Search - + {!keyboardVisible ? : null} ) } + +export default function TabsLayout() { + if (Platform.OS !== "android") return + return ( + + + + ) +} diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index 8c7c878..7fb9ae0 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -1,8 +1,16 @@ +import { 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" import { memo, useCallback, useEffect, useMemo } from "react" -import { FlatList, Pressable, StyleSheet, Text, View } from "react-native" +import { + FlatList, + Platform, + Pressable, + StyleSheet, + Text, + View, +} from "react-native" import { Ionicons } from "@expo/vector-icons" import { @@ -61,6 +69,7 @@ export default function AlbumScreen() { coverUri, album ? album.cover != null : album === null ? false : undefined ) + useAndroidScreenPalette(palette) const songIds = useMemo( () => album?.tracks.map((track) => track.id as Id<"songs">) ?? [], [album] @@ -147,6 +156,14 @@ export default function AlbumScreen() { title: "", headerLargeTitle: false, headerTintColor: palette.foreground, + ...(Platform.OS === "android" + ? { + headerStyle: { backgroundColor: palette.background }, + statusBarStyle: palette.isDark + ? ("light" as const) + : ("dark" as const), + } + : {}), headerRight: () => ( { rememberSongs(songs) @@ -269,6 +271,14 @@ function PlaylistContent({ title: "", headerLargeTitle: false, headerTintColor: palette.foreground, + ...(Platform.OS === "android" + ? { + headerStyle: { backgroundColor: palette.background }, + statusBarStyle: palette.isDark + ? ("light" as const) + : ("dark" as const), + } + : {}), headerRight: () => ( {user.isAdmin ? ( {subtitle} ) : null} - + ) } diff --git a/apps/mobile/app/(app)/(tabs)/search/index.tsx b/apps/mobile/app/(app)/(tabs)/search/index.tsx index 7cb6756..1dc5e39 100644 --- a/apps/mobile/app/(app)/(tabs)/search/index.tsx +++ b/apps/mobile/app/(app)/(tabs)/search/index.tsx @@ -1,3 +1,5 @@ +import { Platform } from "react-native" +import { useThemeColors } from "@/lib/theme" import { Stack } from "expo-router" import { useCallback } from "react" @@ -5,6 +7,7 @@ import { SearchResults } from "@/components/search-results" import { useDebouncedSearch } from "@/hooks/use-debounced-search" export default function SearchScreen() { + const colors = useThemeColors() const { searchQuery, onQueryChange, onSearchSubmit } = useDebouncedSearch() const handleChangeText = useCallback( @@ -21,6 +24,15 @@ export default function SearchScreen() { onChangeText={handleChangeText} onSearchButtonPress={onSearchSubmit} autoCapitalize="none" + {...(Platform.OS === "android" + ? { + barTintColor: colors.background, + textColor: colors.foreground, + tintColor: colors.primary, + hintTextColor: colors.mutedForeground, + headerIconColor: colors.foreground, + } + : {})} /> diff --git a/apps/mobile/app/(app)/_layout.tsx b/apps/mobile/app/(app)/_layout.tsx index 186accd..5efd2ff 100644 --- a/apps/mobile/app/(app)/_layout.tsx +++ b/apps/mobile/app/(app)/_layout.tsx @@ -66,7 +66,8 @@ export default function AppLayout() { + {Platform.OS === "android" ? ( + <> + + + + ) : null} + return ( + + + + ) +} diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx index 51c5f71..40c8ce4 100644 --- a/apps/mobile/app/_layout.tsx +++ b/apps/mobile/app/_layout.tsx @@ -1,7 +1,7 @@ import { useConvexAuth } from "@convex-dev/auth/react" import { DarkTheme, Stack, ThemeProvider } from "expo-router" import { StatusBar } from "expo-status-bar" -import { useColorScheme } from "react-native" +import { useIsDark } from "@/lib/theme" import { GestureHandlerRootView } from "react-native-gesture-handler" import { SafeAreaProvider } from "react-native-safe-area-context" @@ -47,14 +47,14 @@ function RootNavigator() { } export default function RootLayout() { - const colorScheme = useColorScheme() + const isDark = useIsDark() return ( - + diff --git a/apps/mobile/app/server.tsx b/apps/mobile/app/server.tsx index 036c79b..6433fc3 100644 --- a/apps/mobile/app/server.tsx +++ b/apps/mobile/app/server.tsx @@ -1,13 +1,9 @@ import { useState } from "react" -import { - KeyboardAvoidingView, - Platform, - StyleSheet, - Text, - View, -} from "react-native" +import { StyleSheet, Text, View } from "react-native" import { SafeAreaView } from "react-native-safe-area-context" +import { KeyboardForm } from "@/components/keyboard-form" + import { Button, Card, Input } from "@/components/ui/primitives" import { useServerConfig } from "@/contexts/server-config" import { spacing, useThemeColors } from "@/lib/theme" @@ -41,10 +37,7 @@ export default function ServerScreen() { return ( - + oTunes @@ -82,7 +75,7 @@ export default function ServerScreen() { onPress={() => void handleContinue()} /> - + ) } diff --git a/apps/mobile/components/android-sheet.tsx b/apps/mobile/components/android-sheet.tsx new file mode 100644 index 0000000..840bc8e --- /dev/null +++ b/apps/mobile/components/android-sheet.tsx @@ -0,0 +1,15 @@ +import type { PropsWithChildren } from "react" +import { KeyboardAvoidingView, Platform } from "react-native" +import { SafeAreaView } from "react-native-safe-area-context" + +/** RN modals have their own window; protect their actions from navigation and IME. */ +export function AndroidSheet({ children }: PropsWithChildren) { + if (Platform.OS !== "android") return children + return ( + + + {children} + + + ) +} diff --git a/apps/mobile/components/auth-form.tsx b/apps/mobile/components/auth-form.tsx index 407acfd..42b0792 100644 --- a/apps/mobile/components/auth-form.tsx +++ b/apps/mobile/components/auth-form.tsx @@ -2,16 +2,11 @@ import { useAuthActions } from "@convex-dev/auth/react" import { Link } from "expo-router" import { useQuery } from "convex/react" import { useState } from "react" -import { - KeyboardAvoidingView, - Platform, - Pressable, - StyleSheet, - Text, - View, -} from "react-native" +import { Pressable, StyleSheet, Text, View } from "react-native" import { SafeAreaView } from "react-native-safe-area-context" +import { KeyboardForm } from "@/components/keyboard-form" + import { Button, Card, Input } from "@/components/ui/primitives" import { useServerConfig } from "@/contexts/server-config" import { api } from "@otunes/convex/_generated/api" @@ -92,14 +87,15 @@ export function AuthForm({ flow }: { flow: AuthFlow }) { return ( - + - {text.title} - + + {text.title} + + {text.description} {config ? ( @@ -111,8 +107,8 @@ export function AuthForm({ flow }: { flow: AuthFlow }) { {signupsDisabled ? ( - New account registration is currently disabled. Contact an administrator if you need - access. + New account registration is currently disabled. Contact an + administrator if you need access. ) : ( @@ -137,16 +133,28 @@ export function AuthForm({ flow }: { flow: AuthFlow }) { onChangeText={setPassword} placeholder="Password" secureTextEntry - autoComplete={flow === "signIn" ? "current-password" : "new-password"} + autoComplete={ + flow === "signIn" ? "current-password" : "new-password" + } + /> + {error ? ( + {error} + ) : null} +