Compare commits
3
Commits
No files matched your search
@@ -54,6 +54,7 @@
|
|||||||
"expo-status-bar",
|
"expo-status-bar",
|
||||||
"expo-app-intents",
|
"expo-app-intents",
|
||||||
"./plugins/with-android-colors",
|
"./plugins/with-android-colors",
|
||||||
|
"./plugins/with-android-fast-fade",
|
||||||
[
|
[
|
||||||
"expo-navigation-bar",
|
"expo-navigation-bar",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import { NavigationBar } from "expo-navigation-bar"
|
|||||||
import {
|
import {
|
||||||
ScreenPaletteProvider,
|
ScreenPaletteProvider,
|
||||||
useAndroidTabPalette,
|
useAndroidTabPalette,
|
||||||
useAndroidTabBackgroundStyle,
|
useAndroidTabHasArtworkPalette,
|
||||||
useAndroidNativeTabColors,
|
useTabletBackgroundStyle,
|
||||||
} from "@/contexts/android-tab-theme"
|
} from "@/contexts/android-tab-theme"
|
||||||
import { DarkTheme, DefaultTheme, ThemeProvider } from "expo-router"
|
import { DarkTheme, DefaultTheme, ThemeProvider } from "expo-router"
|
||||||
import { NativeTabs } from "expo-router/native-tabs"
|
import { NativeTabs } from "expo-router/native-tabs"
|
||||||
@@ -46,12 +46,13 @@ function useRouterTheme() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function useNativeTabColors() {
|
function useNativeTabColors() {
|
||||||
// These props initialize native tabs; the worklet owns subsequent colors.
|
|
||||||
const selectedColor = colors.dark.primary
|
|
||||||
const themeIsDark = useIsDark()
|
const themeIsDark = useIsDark()
|
||||||
const androidPalette = colors.dark
|
const androidPalette = useAndroidTabPalette()
|
||||||
const artworkPalette = useAndroidTabPalette()
|
const hasArtworkPalette = useAndroidTabHasArtworkPalette()
|
||||||
const isDark = Platform.OS === "android" ? artworkPalette.isDark : themeIsDark
|
const selectedColor = hasArtworkPalette
|
||||||
|
? androidPalette.foreground
|
||||||
|
: androidPalette.accentText
|
||||||
|
const isDark = Platform.OS === "android" ? androidPalette.isDark : themeIsDark
|
||||||
const inactive = appleMusic.tabInactive
|
const inactive = appleMusic.tabInactive
|
||||||
|
|
||||||
const iconColor =
|
const iconColor =
|
||||||
@@ -61,14 +62,14 @@ function useNativeTabColors() {
|
|||||||
selected: appleMusic.pink,
|
selected: appleMusic.pink,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
default: androidPalette.mutedForeground,
|
default: androidPalette.secondaryForeground,
|
||||||
selected: selectedColor,
|
selected: selectedColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
const labelColor =
|
const labelColor =
|
||||||
Platform.OS === "ios"
|
Platform.OS === "ios"
|
||||||
? DynamicColorIOS({ dark: inactive, light: "#636366" })
|
? DynamicColorIOS({ dark: inactive, light: "#636366" })
|
||||||
: androidPalette.mutedForeground
|
: androidPalette.secondaryForeground
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isDark,
|
isDark,
|
||||||
@@ -85,20 +86,17 @@ function useNativeTabColors() {
|
|||||||
blurEffect: isDark
|
blurEffect: isDark
|
||||||
? "systemChromeMaterialDark"
|
? "systemChromeMaterialDark"
|
||||||
: "systemChromeMaterialLight",
|
: "systemChromeMaterialLight",
|
||||||
// Reveal the shared UI-thread background beneath the native tab bar.
|
backgroundColor:
|
||||||
backgroundColor: Platform.OS === "ios" ? undefined : "transparent",
|
Platform.OS === "ios" ? undefined : androidPalette.background,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function TabsContent() {
|
function TabsContent() {
|
||||||
const tabletLayout = useTabletLayout()
|
const tabletLayout = useTabletLayout()
|
||||||
const homeColors = useAndroidNativeTabColors()
|
|
||||||
const libraryColors = useAndroidNativeTabColors()
|
|
||||||
const searchColors = useAndroidNativeTabColors()
|
|
||||||
const keyboardVisible = useAndroidKeyboardVisible()
|
const keyboardVisible = useAndroidKeyboardVisible()
|
||||||
const routerTheme = useRouterTheme()
|
const routerTheme = useRouterTheme()
|
||||||
const tabColors = useNativeTabColors()
|
const tabColors = useNativeTabColors()
|
||||||
const backgroundStyle = useAndroidTabBackgroundStyle()
|
const backgroundStyle = useTabletBackgroundStyle()
|
||||||
const { currentSong, queueSongIds } = usePlaybackQueue()
|
const { currentSong, queueSongIds } = usePlaybackQueue()
|
||||||
const showBottomAccessory = Boolean(currentSong && queueSongIds.length > 0)
|
const showBottomAccessory = Boolean(currentSong && queueSongIds.length > 0)
|
||||||
|
|
||||||
@@ -140,9 +138,6 @@ function TabsContent() {
|
|||||||
|
|
||||||
<NativeTabs.Trigger
|
<NativeTabs.Trigger
|
||||||
name="home"
|
name="home"
|
||||||
unstable_nativeProps={
|
|
||||||
Platform.OS === "android" ? homeColors : undefined
|
|
||||||
}
|
|
||||||
disableTransparentOnScrollEdge
|
disableTransparentOnScrollEdge
|
||||||
contentStyle={androidContentStyle}
|
contentStyle={androidContentStyle}
|
||||||
>
|
>
|
||||||
@@ -152,9 +147,6 @@ function TabsContent() {
|
|||||||
|
|
||||||
<NativeTabs.Trigger
|
<NativeTabs.Trigger
|
||||||
name="library"
|
name="library"
|
||||||
unstable_nativeProps={
|
|
||||||
Platform.OS === "android" ? libraryColors : undefined
|
|
||||||
}
|
|
||||||
disableTransparentOnScrollEdge
|
disableTransparentOnScrollEdge
|
||||||
contentStyle={androidContentStyle}
|
contentStyle={androidContentStyle}
|
||||||
>
|
>
|
||||||
@@ -169,9 +161,6 @@ function TabsContent() {
|
|||||||
|
|
||||||
<NativeTabs.Trigger
|
<NativeTabs.Trigger
|
||||||
name="search"
|
name="search"
|
||||||
unstable_nativeProps={
|
|
||||||
Platform.OS === "android" ? searchColors : undefined
|
|
||||||
}
|
|
||||||
disableTransparentOnScrollEdge
|
disableTransparentOnScrollEdge
|
||||||
contentStyle={androidContentStyle}
|
contentStyle={androidContentStyle}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -7,21 +7,14 @@ import {
|
|||||||
CollectionHero,
|
CollectionHero,
|
||||||
useCollectionHeroLayout,
|
useCollectionHeroLayout,
|
||||||
} from "@/components/collection-hero"
|
} from "@/components/collection-hero"
|
||||||
import {
|
|
||||||
PaletteText,
|
|
||||||
PaletteIcon,
|
|
||||||
renderArtworkBackButton,
|
|
||||||
} from "@/components/palette-text"
|
|
||||||
import Animated from "react-native-reanimated"
|
import Animated from "react-native-reanimated"
|
||||||
import {
|
import { useScreenPalette } from "@/contexts/android-tab-theme"
|
||||||
renderAndroidArtworkBackground,
|
|
||||||
useScreenPalette,
|
|
||||||
} from "@/contexts/android-tab-theme"
|
|
||||||
import { MusicEntityView } from "@/components/music-entity-view"
|
import { MusicEntityView } from "@/components/music-entity-view"
|
||||||
import { Link, Stack, useIsFocused, useLocalSearchParams } from "expo-router"
|
import { Link, Stack, useIsFocused, useLocalSearchParams } from "expo-router"
|
||||||
import { StatusBar } from "expo-status-bar"
|
import { StatusBar } from "expo-status-bar"
|
||||||
import { memo, useCallback, useEffect, useMemo } from "react"
|
import { memo, useCallback, useEffect, useMemo } from "react"
|
||||||
import { Platform, Pressable, StyleSheet, View } from "react-native"
|
import { Platform, Pressable, StyleSheet, Text, View } from "react-native"
|
||||||
|
import { Ionicons } from "@expo/vector-icons"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CollectionDivider,
|
CollectionDivider,
|
||||||
@@ -142,10 +135,7 @@ export default function AlbumScreen() {
|
|||||||
headerLargeTitle: false,
|
headerLargeTitle: false,
|
||||||
...(Platform.OS === "android"
|
...(Platform.OS === "android"
|
||||||
? {
|
? {
|
||||||
headerStyle: { backgroundColor: "transparent" },
|
headerStyle: { backgroundColor: palette.background },
|
||||||
headerBackground: renderAndroidArtworkBackground,
|
|
||||||
headerBackVisible: false,
|
|
||||||
headerLeft: renderArtworkBackButton,
|
|
||||||
headerTintColor: palette.foreground,
|
headerTintColor: palette.foreground,
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
@@ -173,9 +163,9 @@ export default function AlbumScreen() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View style={[styles.empty, { backgroundColor: colors.background }]}>
|
<View style={[styles.empty, { backgroundColor: colors.background }]}>
|
||||||
<PaletteText style={{ color: colors.mutedForeground }}>
|
<Text style={{ color: colors.mutedForeground }}>
|
||||||
Album not found.
|
Album not found.
|
||||||
</PaletteText>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
@@ -196,10 +186,7 @@ export default function AlbumScreen() {
|
|||||||
headerTintColor: palette.foreground,
|
headerTintColor: palette.foreground,
|
||||||
...(Platform.OS === "android"
|
...(Platform.OS === "android"
|
||||||
? {
|
? {
|
||||||
headerStyle: { backgroundColor: "transparent" },
|
headerStyle: { backgroundColor: palette.background },
|
||||||
headerBackground: renderAndroidArtworkBackground,
|
|
||||||
headerBackVisible: false,
|
|
||||||
headerLeft: renderArtworkBackButton,
|
|
||||||
statusBarStyle: palette.isDark
|
statusBarStyle: palette.isDark
|
||||||
? ("light" as const)
|
? ("light" as const)
|
||||||
: ("dark" as const),
|
: ("dark" as const),
|
||||||
@@ -221,8 +208,7 @@ export default function AlbumScreen() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Pressable hitSlop={8}>
|
<Pressable hitSlop={8}>
|
||||||
<PaletteIcon
|
<Ionicons
|
||||||
tone="foreground"
|
|
||||||
name="ellipsis-horizontal"
|
name="ellipsis-horizontal"
|
||||||
size={22}
|
size={22}
|
||||||
color={palette.isDark ? "#fff" : "#000"}
|
color={palette.isDark ? "#fff" : "#000"}
|
||||||
@@ -283,8 +269,7 @@ export default function AlbumScreen() {
|
|||||||
{ backgroundColor: palette.surface },
|
{ backgroundColor: palette.surface },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<PaletteIcon
|
<Ionicons
|
||||||
tone={favorited ? "accent" : "foreground"}
|
|
||||||
name={favorited ? "star" : "star-outline"}
|
name={favorited ? "star" : "star-outline"}
|
||||||
size={24}
|
size={24}
|
||||||
color={favorited ? palette.accent : palette.foreground}
|
color={favorited ? palette.accent : palette.foreground}
|
||||||
@@ -310,8 +295,7 @@ export default function AlbumScreen() {
|
|||||||
{ backgroundColor: palette.surface },
|
{ backgroundColor: palette.surface },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<PaletteIcon
|
<Ionicons
|
||||||
tone="foreground"
|
|
||||||
name="shuffle"
|
name="shuffle"
|
||||||
size={24}
|
size={24}
|
||||||
color={palette.foreground}
|
color={palette.foreground}
|
||||||
@@ -320,8 +304,7 @@ export default function AlbumScreen() {
|
|||||||
</View>
|
</View>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<PaletteText
|
<Text
|
||||||
tone="foreground"
|
|
||||||
style={[
|
style={[
|
||||||
styles.title,
|
styles.title,
|
||||||
heroLayout.landscape && styles.titleLandscape,
|
heroLayout.landscape && styles.titleLandscape,
|
||||||
@@ -329,13 +312,12 @@ export default function AlbumScreen() {
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{album.title}
|
{album.title}
|
||||||
</PaletteText>
|
</Text>
|
||||||
<Pressable
|
<Pressable
|
||||||
onPress={() => push(`/artist/${album.artist.id}`)}
|
onPress={() => push(`/artist/${album.artist.id}`)}
|
||||||
style={styles.artistPressable}
|
style={styles.artistPressable}
|
||||||
>
|
>
|
||||||
<PaletteText
|
<Text
|
||||||
tone="accentText"
|
|
||||||
style={[
|
style={[
|
||||||
styles.artist,
|
styles.artist,
|
||||||
heroLayout.landscape && styles.artistLandscape,
|
heroLayout.landscape && styles.artistLandscape,
|
||||||
@@ -343,7 +325,7 @@ export default function AlbumScreen() {
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{album.artist.name}
|
{album.artist.name}
|
||||||
</PaletteText>
|
</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@@ -357,25 +339,18 @@ export default function AlbumScreen() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{metadata ? (
|
{metadata ? (
|
||||||
<PaletteText
|
<Text style={{ color: palette.secondaryForeground }}>
|
||||||
tone="secondaryForeground"
|
|
||||||
style={{ color: palette.secondaryForeground }}
|
|
||||||
>
|
|
||||||
{metadata}
|
{metadata}
|
||||||
</PaletteText>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
{album.hasLossless ? (
|
{album.hasLossless ? (
|
||||||
<>
|
<>
|
||||||
{metadata ? (
|
{metadata ? (
|
||||||
<PaletteText
|
<Text style={{ color: palette.secondaryForeground }}>
|
||||||
tone="secondaryForeground"
|
|
||||||
style={{ color: palette.secondaryForeground }}
|
|
||||||
>
|
|
||||||
·
|
·
|
||||||
</PaletteText>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
<AudioFormatBadge
|
<AudioFormatBadge
|
||||||
artwork
|
|
||||||
format="lossless"
|
format="lossless"
|
||||||
color={palette.secondaryForeground}
|
color={palette.secondaryForeground}
|
||||||
backgroundColor={palette.background}
|
backgroundColor={palette.background}
|
||||||
@@ -385,15 +360,11 @@ export default function AlbumScreen() {
|
|||||||
{album.hasAtmos ? (
|
{album.hasAtmos ? (
|
||||||
<>
|
<>
|
||||||
{metadata || album.hasLossless ? (
|
{metadata || album.hasLossless ? (
|
||||||
<PaletteText
|
<Text style={{ color: palette.secondaryForeground }}>
|
||||||
tone="secondaryForeground"
|
|
||||||
style={{ color: palette.secondaryForeground }}
|
|
||||||
>
|
|
||||||
·
|
·
|
||||||
</PaletteText>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
<AudioFormatBadge
|
<AudioFormatBadge
|
||||||
artwork
|
|
||||||
format="atmos"
|
format="atmos"
|
||||||
color={palette.secondaryForeground}
|
color={palette.secondaryForeground}
|
||||||
backgroundColor={palette.background}
|
backgroundColor={palette.background}
|
||||||
@@ -517,12 +488,11 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
|||||||
style={styles.trackRow}
|
style={styles.trackRow}
|
||||||
onPress={() => void onPlay(track.id as Id<"songs">, songIds)}
|
onPress={() => void onPlay(track.id as Id<"songs">, songIds)}
|
||||||
>
|
>
|
||||||
<PaletteText
|
<Text
|
||||||
tone="secondaryForeground"
|
|
||||||
style={[styles.trackNumber, { color: palette.secondaryForeground }]}
|
style={[styles.trackNumber, { color: palette.secondaryForeground }]}
|
||||||
>
|
>
|
||||||
{number}
|
{number}
|
||||||
</PaletteText>
|
</Text>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
styles.trackContent,
|
styles.trackContent,
|
||||||
@@ -530,29 +500,24 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<View style={styles.trackMeta}>
|
<View style={styles.trackMeta}>
|
||||||
<PaletteText
|
<Text
|
||||||
tone="foreground"
|
|
||||||
style={[styles.trackTitle, { color: palette.foreground }]}
|
style={[styles.trackTitle, { color: palette.foreground }]}
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
>
|
>
|
||||||
{track.title}
|
{track.title}
|
||||||
</PaletteText>
|
</Text>
|
||||||
{track.artists ? (
|
{track.artists ? (
|
||||||
<PaletteText
|
<Text
|
||||||
tone="secondaryForeground"
|
|
||||||
style={{ color: palette.secondaryForeground }}
|
style={{ color: palette.secondaryForeground }}
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
>
|
>
|
||||||
{track.artists.join(", ")}
|
{track.artists.join(", ")}
|
||||||
</PaletteText>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
<PaletteText
|
<Text style={{ color: palette.secondaryForeground }}>
|
||||||
tone="secondaryForeground"
|
|
||||||
style={{ color: palette.secondaryForeground }}
|
|
||||||
>
|
|
||||||
{formatDuration(track.durationSeconds)}
|
{formatDuration(track.durationSeconds)}
|
||||||
</PaletteText>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</Row>
|
</Row>
|
||||||
</MusicEntityView>
|
</MusicEntityView>
|
||||||
|
|||||||
@@ -2,20 +2,12 @@ import {
|
|||||||
CollectionHero,
|
CollectionHero,
|
||||||
useCollectionHeroLayout,
|
useCollectionHeroLayout,
|
||||||
} from "@/components/collection-hero"
|
} from "@/components/collection-hero"
|
||||||
import {
|
|
||||||
PaletteText,
|
|
||||||
PaletteIcon,
|
|
||||||
renderArtworkBackButton,
|
|
||||||
} from "@/components/palette-text"
|
|
||||||
import Animated from "react-native-reanimated"
|
import Animated from "react-native-reanimated"
|
||||||
import {
|
import {
|
||||||
PlaylistSearchBar,
|
PlaylistSearchBar,
|
||||||
usePlaylistSearch,
|
usePlaylistSearch,
|
||||||
} from "@/components/playlist-search-bar"
|
} from "@/components/playlist-search-bar"
|
||||||
import {
|
import { useScreenPalette } from "@/contexts/android-tab-theme"
|
||||||
renderAndroidArtworkBackground,
|
|
||||||
useScreenPalette,
|
|
||||||
} from "@/contexts/android-tab-theme"
|
|
||||||
import { MusicEntityView } from "@/components/music-entity-view"
|
import { MusicEntityView } from "@/components/music-entity-view"
|
||||||
import { useMutation } from "convex/react"
|
import { useMutation } from "convex/react"
|
||||||
import { memo, useCallback, useEffect, useMemo } from "react"
|
import { memo, useCallback, useEffect, useMemo } from "react"
|
||||||
@@ -31,10 +23,12 @@ import {
|
|||||||
Platform,
|
Platform,
|
||||||
Pressable,
|
Pressable,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
|
Text,
|
||||||
View,
|
View,
|
||||||
type ListRenderItemInfo,
|
type ListRenderItemInfo,
|
||||||
} from "react-native"
|
} from "react-native"
|
||||||
import ReanimatedSwipeable from "react-native-gesture-handler/ReanimatedSwipeable"
|
import ReanimatedSwipeable from "react-native-gesture-handler/ReanimatedSwipeable"
|
||||||
|
import { Ionicons } from "@expo/vector-icons"
|
||||||
|
|
||||||
import { CollectionDivider } from "@/components/collection-list"
|
import { CollectionDivider } from "@/components/collection-list"
|
||||||
import { CoverImage } from "@/components/cover-image"
|
import { CoverImage } from "@/components/cover-image"
|
||||||
@@ -111,10 +105,7 @@ export default function PlaylistScreen() {
|
|||||||
headerLargeTitle: false,
|
headerLargeTitle: false,
|
||||||
...(Platform.OS === "android"
|
...(Platform.OS === "android"
|
||||||
? {
|
? {
|
||||||
headerStyle: { backgroundColor: "transparent" },
|
headerStyle: { backgroundColor: palette.background },
|
||||||
headerBackground: renderAndroidArtworkBackground,
|
|
||||||
headerBackVisible: false,
|
|
||||||
headerLeft: renderArtworkBackButton,
|
|
||||||
headerTintColor: palette.foreground,
|
headerTintColor: palette.foreground,
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
@@ -142,9 +133,9 @@ export default function PlaylistScreen() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View style={[styles.empty, { backgroundColor: colors.background }]}>
|
<View style={[styles.empty, { backgroundColor: colors.background }]}>
|
||||||
<PaletteText style={{ color: colors.mutedForeground }}>
|
<Text style={{ color: colors.mutedForeground }}>
|
||||||
Playlist not found.
|
Playlist not found.
|
||||||
</PaletteText>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
@@ -279,10 +270,7 @@ function PlaylistContent({
|
|||||||
headerTintColor: palette.foreground,
|
headerTintColor: palette.foreground,
|
||||||
...(Platform.OS === "android"
|
...(Platform.OS === "android"
|
||||||
? {
|
? {
|
||||||
headerStyle: { backgroundColor: "transparent" },
|
headerStyle: { backgroundColor: palette.background },
|
||||||
headerBackground: renderAndroidArtworkBackground,
|
|
||||||
headerBackVisible: false,
|
|
||||||
headerLeft: renderArtworkBackButton,
|
|
||||||
statusBarStyle: palette.isDark
|
statusBarStyle: palette.isDark
|
||||||
? ("light" as const)
|
? ("light" as const)
|
||||||
: ("dark" as const),
|
: ("dark" as const),
|
||||||
@@ -301,8 +289,7 @@ function PlaylistContent({
|
|||||||
onAction={handlePlaylistMenuAction}
|
onAction={handlePlaylistMenuAction}
|
||||||
>
|
>
|
||||||
<Pressable hitSlop={8}>
|
<Pressable hitSlop={8}>
|
||||||
<PaletteIcon
|
<Ionicons
|
||||||
tone="foreground"
|
|
||||||
name="ellipsis-horizontal"
|
name="ellipsis-horizontal"
|
||||||
size={22}
|
size={22}
|
||||||
color={palette.isDark ? "#fff" : "#000"}
|
color={palette.isDark ? "#fff" : "#000"}
|
||||||
@@ -372,15 +359,14 @@ function PlaylistContent({
|
|||||||
contentInsetAdjustmentBehavior="automatic"
|
contentInsetAdjustmentBehavior="automatic"
|
||||||
onScrollBeginDrag={swipeGroup.closeOpenRow}
|
onScrollBeginDrag={swipeGroup.closeOpenRow}
|
||||||
ListEmptyComponent={
|
ListEmptyComponent={
|
||||||
<PaletteText
|
<Text
|
||||||
tone="secondaryForeground"
|
|
||||||
style={[
|
style={[
|
||||||
styles.emptyResults,
|
styles.emptyResults,
|
||||||
{ color: palette.secondaryForeground },
|
{ color: palette.secondaryForeground },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{songs.length ? "No songs found." : "No songs in this playlist."}
|
{songs.length ? "No songs found." : "No songs in this playlist."}
|
||||||
</PaletteText>
|
</Text>
|
||||||
}
|
}
|
||||||
ListHeaderComponent={
|
ListHeaderComponent={
|
||||||
<PlaylistHero
|
<PlaylistHero
|
||||||
@@ -473,19 +459,15 @@ const PlaylistSongRow = memo(function PlaylistSongRow({
|
|||||||
}}
|
}}
|
||||||
style={[styles.removeAction, { backgroundColor: colors.destructive }]}
|
style={[styles.removeAction, { backgroundColor: colors.destructive }]}
|
||||||
>
|
>
|
||||||
<PaletteIcon
|
<Ionicons name="trash" size={22} color={colors.primaryForeground} />
|
||||||
name="trash"
|
<Text
|
||||||
size={22}
|
|
||||||
color={colors.primaryForeground}
|
|
||||||
/>
|
|
||||||
<PaletteText
|
|
||||||
style={[
|
style={[
|
||||||
styles.removeActionText,
|
styles.removeActionText,
|
||||||
{ color: colors.primaryForeground },
|
{ color: colors.primaryForeground },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
Remove
|
Remove
|
||||||
</PaletteText>
|
</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -565,8 +547,7 @@ const PlaylistHero = memo(function PlaylistHero({
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<PaletteIcon
|
<Ionicons
|
||||||
tone={isSubscribed ? "foreground" : "accentForeground"}
|
|
||||||
name={isSubscribed ? "checkmark" : "add"}
|
name={isSubscribed ? "checkmark" : "add"}
|
||||||
size={24}
|
size={24}
|
||||||
color={
|
color={
|
||||||
@@ -592,18 +573,12 @@ const PlaylistHero = memo(function PlaylistHero({
|
|||||||
onPress={onShuffle}
|
onPress={onShuffle}
|
||||||
style={[styles.iconAction, { backgroundColor: palette.surface }]}
|
style={[styles.iconAction, { backgroundColor: palette.surface }]}
|
||||||
>
|
>
|
||||||
<PaletteIcon
|
<Ionicons name="shuffle" size={24} color={palette.foreground} />
|
||||||
tone="foreground"
|
|
||||||
name="shuffle"
|
|
||||||
size={24}
|
|
||||||
color={palette.foreground}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<PaletteText
|
<Text
|
||||||
tone="foreground"
|
|
||||||
style={[
|
style={[
|
||||||
styles.title,
|
styles.title,
|
||||||
heroLayout.landscape && styles.titleLandscape,
|
heroLayout.landscape && styles.titleLandscape,
|
||||||
@@ -611,16 +586,15 @@ const PlaylistHero = memo(function PlaylistHero({
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{title}
|
{title}
|
||||||
</PaletteText>
|
</Text>
|
||||||
<PaletteText
|
<Text
|
||||||
tone="foreground"
|
|
||||||
style={{
|
style={{
|
||||||
color: palette.foreground,
|
color: palette.foreground,
|
||||||
fontSize: heroLayout.landscape ? 22 : 16,
|
fontSize: heroLayout.landscape ? 22 : 16,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{ownerName}
|
{ownerName}
|
||||||
</PaletteText>
|
</Text>
|
||||||
</CollectionHero>
|
</CollectionHero>
|
||||||
<CollectionDivider color={palette.divider} />
|
<CollectionDivider color={palette.divider} />
|
||||||
</MusicEntityView>
|
</MusicEntityView>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import {
|
|||||||
} from "@/lib/artwork-color-preference"
|
} from "@/lib/artwork-color-preference"
|
||||||
import { initialsFromName } from "@/lib/format"
|
import { initialsFromName } from "@/lib/format"
|
||||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||||
|
import { clearCoverPaletteCache } from "@/hooks/use-cover-palette"
|
||||||
import { useProfileImageUrl } from "@/hooks/use-profile-image-url"
|
import { useProfileImageUrl } from "@/hooks/use-profile-image-url"
|
||||||
import { changeServer, signOut } from "@/lib/session"
|
import { changeServer, signOut } from "@/lib/session"
|
||||||
import { radius, spacing, useThemeColors } from "@/lib/theme"
|
import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||||
@@ -185,6 +186,7 @@ function AppearanceSection() {
|
|||||||
setSaving(true)
|
setSaving(true)
|
||||||
try {
|
try {
|
||||||
await setArtworkColorsEnabled(checked)
|
await setArtworkColorsEnabled(checked)
|
||||||
|
clearCoverPaletteCache()
|
||||||
} catch {
|
} catch {
|
||||||
showError("Could not save artwork colors preference.")
|
showError("Could not save artwork colors preference.")
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { PaletteText } from "@/components/palette-text"
|
import { StyleSheet, Text, View } from "react-native"
|
||||||
import { StyleSheet, View } from "react-native"
|
|
||||||
import Svg, { G, Path } from "react-native-svg"
|
import Svg, { G, Path } from "react-native-svg"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -69,12 +68,10 @@ function LosslessMark({
|
|||||||
|
|
||||||
/** The Dolby Atmos or Lossless label shown under the progress bar. */
|
/** The Dolby Atmos or Lossless label shown under the progress bar. */
|
||||||
export function AudioFormatBadge({
|
export function AudioFormatBadge({
|
||||||
artwork = false,
|
|
||||||
format,
|
format,
|
||||||
color,
|
color,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
}: {
|
}: {
|
||||||
artwork?: boolean
|
|
||||||
format: PlaybackFormat
|
format: PlaybackFormat
|
||||||
color: string
|
color: string
|
||||||
backgroundColor: string
|
backgroundColor: string
|
||||||
@@ -87,12 +84,7 @@ export function AudioFormatBadge({
|
|||||||
) : (
|
) : (
|
||||||
<LosslessMark color={color} backgroundColor={backgroundColor} />
|
<LosslessMark color={color} backgroundColor={backgroundColor} />
|
||||||
)}
|
)}
|
||||||
<PaletteText
|
<Text style={[styles.label, { color }]}>{label}</Text>
|
||||||
tone={artwork ? "secondaryForeground" : undefined}
|
|
||||||
style={[styles.label, { color }]}
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</PaletteText>
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { PaletteText } from "@/components/palette-text"
|
|
||||||
import { memo } from "react"
|
import { memo } from "react"
|
||||||
import { StyleSheet, View } from "react-native"
|
import { StyleSheet, Text, View } from "react-native"
|
||||||
|
|
||||||
import { useThemeColors } from "@/lib/theme"
|
import { useThemeColors } from "@/lib/theme"
|
||||||
|
|
||||||
@@ -26,12 +25,9 @@ export const DiscHeader = memo(function DiscHeader({
|
|||||||
}) {
|
}) {
|
||||||
const colors = useThemeColors()
|
const colors = useThemeColors()
|
||||||
return (
|
return (
|
||||||
<PaletteText
|
<Text style={[styles.discHeader, { color: color ?? colors.foreground }]}>
|
||||||
tone={color ? "foreground" : undefined}
|
|
||||||
style={[styles.discHeader, { color: color ?? colors.foreground }]}
|
|
||||||
>
|
|
||||||
{label}
|
{label}
|
||||||
</PaletteText>
|
</Text>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import { PaletteText, PaletteIcon } from "@/components/palette-text"
|
|
||||||
import Animated from "react-native-reanimated"
|
|
||||||
import {
|
import {
|
||||||
useAndroidTabPalette,
|
useAndroidTabPalette,
|
||||||
useAndroidTabBackgroundStyle,
|
|
||||||
useAndroidTabHasArtworkPalette,
|
useAndroidTabHasArtworkPalette,
|
||||||
} from "@/contexts/android-tab-theme"
|
} from "@/contexts/android-tab-theme"
|
||||||
|
import { Ionicons } from "@expo/vector-icons"
|
||||||
import { NativeTabs } from "expo-router/native-tabs"
|
import { NativeTabs } from "expo-router/native-tabs"
|
||||||
import { useRouter } from "expo-router"
|
import { useRouter } from "expo-router"
|
||||||
import { Platform, Pressable, StyleSheet, View } from "react-native"
|
import { Platform, Pressable, StyleSheet, Text, View } from "react-native"
|
||||||
|
|
||||||
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
||||||
|
|
||||||
@@ -67,8 +65,7 @@ function MiniPlayerContent({
|
|||||||
<View
|
<View
|
||||||
style={isAccessory ? styles.accessoryInlineMeta : styles.inlineMeta}
|
style={isAccessory ? styles.accessoryInlineMeta : styles.inlineMeta}
|
||||||
>
|
>
|
||||||
<PaletteText
|
<Text
|
||||||
tone="foreground"
|
|
||||||
style={[
|
style={[
|
||||||
isAccessory ? styles.accessoryTitle : styles.title,
|
isAccessory ? styles.accessoryTitle : styles.title,
|
||||||
{ color: colors.foreground },
|
{ color: colors.foreground },
|
||||||
@@ -76,7 +73,7 @@ function MiniPlayerContent({
|
|||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
>
|
>
|
||||||
{currentSong.title}
|
{currentSong.title}
|
||||||
</PaletteText>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<Pressable
|
<Pressable
|
||||||
style={styles.controlButton}
|
style={styles.controlButton}
|
||||||
@@ -86,8 +83,7 @@ function MiniPlayerContent({
|
|||||||
}}
|
}}
|
||||||
hitSlop={6}
|
hitSlop={6}
|
||||||
>
|
>
|
||||||
<PaletteIcon
|
<Ionicons
|
||||||
tone="foreground"
|
|
||||||
name={isPlaying ? "pause" : "play"}
|
name={isPlaying ? "pause" : "play"}
|
||||||
size={20}
|
size={20}
|
||||||
color={colors.foreground}
|
color={colors.foreground}
|
||||||
@@ -105,8 +101,7 @@ function MiniPlayerContent({
|
|||||||
style={artworkStyle}
|
style={artworkStyle}
|
||||||
/>
|
/>
|
||||||
<View style={isAccessory ? styles.accessoryMeta : styles.meta}>
|
<View style={isAccessory ? styles.accessoryMeta : styles.meta}>
|
||||||
<PaletteText
|
<Text
|
||||||
tone="foreground"
|
|
||||||
style={[
|
style={[
|
||||||
isAccessory ? styles.accessoryTitle : styles.title,
|
isAccessory ? styles.accessoryTitle : styles.title,
|
||||||
{ color: colors.foreground },
|
{ color: colors.foreground },
|
||||||
@@ -114,9 +109,8 @@ function MiniPlayerContent({
|
|||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
>
|
>
|
||||||
{currentSong.title}
|
{currentSong.title}
|
||||||
</PaletteText>
|
</Text>
|
||||||
<PaletteText
|
<Text
|
||||||
tone="secondaryForeground"
|
|
||||||
style={[
|
style={[
|
||||||
isAccessory ? styles.accessoryArtist : styles.artist,
|
isAccessory ? styles.accessoryArtist : styles.artist,
|
||||||
{ color: colors.mutedForeground },
|
{ color: colors.mutedForeground },
|
||||||
@@ -124,7 +118,7 @@ function MiniPlayerContent({
|
|||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
>
|
>
|
||||||
{currentSong.artist.name}
|
{currentSong.artist.name}
|
||||||
</PaletteText>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.controls}>
|
<View style={styles.controls}>
|
||||||
{Platform.OS === "android" && !isAccessory ? (
|
{Platform.OS === "android" && !isAccessory ? (
|
||||||
@@ -138,12 +132,7 @@ function MiniPlayerContent({
|
|||||||
}}
|
}}
|
||||||
hitSlop={6}
|
hitSlop={6}
|
||||||
>
|
>
|
||||||
<PaletteIcon
|
<Ionicons name="play-back" size={24} color={colors.foreground} />
|
||||||
tone="foreground"
|
|
||||||
name="play-back"
|
|
||||||
size={24}
|
|
||||||
color={colors.foreground}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
</Pressable>
|
||||||
) : null}
|
) : null}
|
||||||
<Pressable
|
<Pressable
|
||||||
@@ -154,8 +143,7 @@ function MiniPlayerContent({
|
|||||||
}}
|
}}
|
||||||
hitSlop={6}
|
hitSlop={6}
|
||||||
>
|
>
|
||||||
<PaletteIcon
|
<Ionicons
|
||||||
tone="foreground"
|
|
||||||
name={isPlaying ? "pause" : "play"}
|
name={isPlaying ? "pause" : "play"}
|
||||||
size={24}
|
size={24}
|
||||||
color={colors.foreground}
|
color={colors.foreground}
|
||||||
@@ -169,12 +157,7 @@ function MiniPlayerContent({
|
|||||||
}}
|
}}
|
||||||
hitSlop={6}
|
hitSlop={6}
|
||||||
>
|
>
|
||||||
<PaletteIcon
|
<Ionicons name="play-forward" size={24} color={colors.foreground} />
|
||||||
tone="foreground"
|
|
||||||
name="play-forward"
|
|
||||||
size={24}
|
|
||||||
color={colors.foreground}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
@@ -184,10 +167,9 @@ function MiniPlayerContent({
|
|||||||
function MiniPlayerChrome({ children }: { children: React.ReactNode }) {
|
function MiniPlayerChrome({ children }: { children: React.ReactNode }) {
|
||||||
const palette = useAndroidTabPalette()
|
const palette = useAndroidTabPalette()
|
||||||
const hasArtworkPalette = useAndroidTabHasArtworkPalette()
|
const hasArtworkPalette = useAndroidTabHasArtworkPalette()
|
||||||
const backgroundStyle = useAndroidTabBackgroundStyle()
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.View style={[styles.androidBar, backgroundStyle]}>
|
<View style={[styles.androidBar, { backgroundColor: palette.background }]}>
|
||||||
{children}
|
{children}
|
||||||
{hasArtworkPalette ? (
|
{hasArtworkPalette ? (
|
||||||
<View
|
<View
|
||||||
@@ -205,7 +187,7 @@ function MiniPlayerChrome({ children }: { children: React.ReactNode }) {
|
|||||||
{ backgroundColor: palette.secondaryForeground },
|
{ backgroundColor: palette.secondaryForeground },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Animated.View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
import { Ionicons } from "@expo/vector-icons"
|
|
||||||
import type { ComponentProps } from "react"
|
|
||||||
import { Pressable, type TextProps } from "react-native"
|
|
||||||
import { useRouter } from "expo-router"
|
|
||||||
import Animated from "react-native-reanimated"
|
|
||||||
|
|
||||||
import {
|
|
||||||
useAnimatedPaletteColor,
|
|
||||||
type PaletteColor,
|
|
||||||
} from "@/contexts/android-tab-theme"
|
|
||||||
|
|
||||||
const AnimatedIcon = Animated.createAnimatedComponent(Ionicons)
|
|
||||||
|
|
||||||
/** Keep artwork text colors on the same UI-thread animation as the background. */
|
|
||||||
export function PaletteText({
|
|
||||||
tone,
|
|
||||||
style,
|
|
||||||
...props
|
|
||||||
}: TextProps & { tone?: PaletteColor }) {
|
|
||||||
const colorStyle = useAnimatedPaletteColor(tone)
|
|
||||||
return <Animated.Text {...props} style={[style, colorStyle]} />
|
|
||||||
}
|
|
||||||
|
|
||||||
export function PaletteIcon({
|
|
||||||
tone,
|
|
||||||
style,
|
|
||||||
...props
|
|
||||||
}: ComponentProps<typeof Ionicons> & { tone?: PaletteColor }) {
|
|
||||||
const colorStyle = useAnimatedPaletteColor(tone)
|
|
||||||
return <AnimatedIcon {...props} style={[style, colorStyle]} />
|
|
||||||
}
|
|
||||||
|
|
||||||
function ArtworkBackButton() {
|
|
||||||
const router = useRouter()
|
|
||||||
return (
|
|
||||||
<Pressable
|
|
||||||
accessibilityRole="button"
|
|
||||||
accessibilityLabel="Navigate up"
|
|
||||||
hitSlop={8}
|
|
||||||
onPress={() => router.back()}
|
|
||||||
>
|
|
||||||
<PaletteIcon tone="foreground" name="arrow-back" size={24} />
|
|
||||||
</Pressable>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function renderArtworkBackButton() {
|
|
||||||
return <ArtworkBackButton />
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { SongSwipeRow } from "@/components/song-swipe-row"
|
import { SongSwipeRow } from "@/components/song-swipe-row"
|
||||||
import type { SwipeRowGroup } from "@/components/ios-swipe-to-remove-row"
|
import type { SwipeRowGroup } from "@/components/ios-swipe-to-remove-row"
|
||||||
import { PaletteText } from "@/components/palette-text"
|
|
||||||
import { MusicEntityView } from "@/components/music-entity-view"
|
import { MusicEntityView } from "@/components/music-entity-view"
|
||||||
import { collectionInset } from "@/components/collection-list"
|
import { collectionInset } from "@/components/collection-list"
|
||||||
import { CoverImage } from "@/components/cover-image"
|
import { CoverImage } from "@/components/cover-image"
|
||||||
@@ -16,7 +15,7 @@ import {
|
|||||||
useThemeColors,
|
useThemeColors,
|
||||||
} from "@/lib/theme"
|
} from "@/lib/theme"
|
||||||
import { memo, useCallback } from "react"
|
import { memo, useCallback } from "react"
|
||||||
import { Platform, Pressable, StyleSheet, View } from "react-native"
|
import { Platform, Pressable, StyleSheet, Text, View } from "react-native"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MediaContextMenu,
|
MediaContextMenu,
|
||||||
@@ -64,27 +63,22 @@ export const SongRow = memo(function SongRow({
|
|||||||
const content = (
|
const content = (
|
||||||
<>
|
<>
|
||||||
<View style={styles.rowMeta}>
|
<View style={styles.rowMeta}>
|
||||||
<PaletteText
|
<Text
|
||||||
tone={palette ? "foreground" : undefined}
|
|
||||||
style={[styles.rowTitle, { color: foreground }]}
|
style={[styles.rowTitle, { color: foreground }]}
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
>
|
>
|
||||||
{song.title}
|
{song.title}
|
||||||
</PaletteText>
|
</Text>
|
||||||
<PaletteText
|
<Text
|
||||||
tone={palette ? "secondaryForeground" : undefined}
|
|
||||||
style={[styles.rowSubtitle, { color: secondaryForeground }]}
|
style={[styles.rowSubtitle, { color: secondaryForeground }]}
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
>
|
>
|
||||||
{song.artist.name} · {song.album.title}
|
{song.artist.name} · {song.album.title}
|
||||||
</PaletteText>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<PaletteText
|
<Text style={[styles.duration, { color: secondaryForeground }]}>
|
||||||
tone={palette ? "secondaryForeground" : undefined}
|
|
||||||
style={[styles.duration, { color: secondaryForeground }]}
|
|
||||||
>
|
|
||||||
{formatDuration(song.durationSeconds)}
|
{formatDuration(song.durationSeconds)}
|
||||||
</PaletteText>
|
</Text>
|
||||||
{trailing}
|
{trailing}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import { SafeAreaView } from "react-native-safe-area-context"
|
|||||||
import { Platform } from "react-native"
|
import { Platform } from "react-native"
|
||||||
import type { ReactNode } from "react"
|
import type { ReactNode } from "react"
|
||||||
|
|
||||||
import { useAndroidTabBackgroundStyle } from "@/contexts/android-tab-theme"
|
import { useTabletBackgroundStyle } from "@/contexts/android-tab-theme"
|
||||||
import { TabletPlayerLayoutSync } from "@/contexts/tablet-player-layout"
|
import { TabletPlayerLayoutSync } from "@/contexts/tablet-player-layout"
|
||||||
import { TabletSidebar } from "@/components/tablet-sidebar"
|
import { TabletSidebar } from "@/components/tablet-sidebar"
|
||||||
|
|
||||||
/** Apply sidebar insets natively, before Yoga measures the content pane. */
|
/** Apply sidebar insets natively, before Yoga measures the content pane. */
|
||||||
export function TabScreenContent({ children }: { children: ReactNode }) {
|
export function TabScreenContent({ children }: { children: ReactNode }) {
|
||||||
const backgroundStyle = useAndroidTabBackgroundStyle()
|
const backgroundStyle = useTabletBackgroundStyle()
|
||||||
if (Platform.OS !== "ios" || !Platform.isPad) return <>{children}</>
|
if (Platform.OS !== "ios" || !Platform.isPad) return <>{children}</>
|
||||||
return (
|
return (
|
||||||
<Animated.View style={[{ flex: 1 }, backgroundStyle]}>
|
<Animated.View style={[{ flex: 1 }, backgroundStyle]}>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PaletteText, PaletteIcon } from "@/components/palette-text"
|
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
Platform,
|
Platform,
|
||||||
@@ -74,20 +73,8 @@ export function Button({
|
|||||||
<ActivityIndicator color={textColor} />
|
<ActivityIndicator color={textColor} />
|
||||||
) : (
|
) : (
|
||||||
<View style={styles.buttonContent}>
|
<View style={styles.buttonContent}>
|
||||||
{icon ? (
|
{icon ? <Ionicons name={icon} size={18} color={textColor} /> : null}
|
||||||
<PaletteIcon
|
<Text style={[styles.buttonText, { color: textColor }]}>{title}</Text>
|
||||||
tone={tint ? "accentForeground" : undefined}
|
|
||||||
name={icon}
|
|
||||||
size={18}
|
|
||||||
color={textColor}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
<PaletteText
|
|
||||||
tone={tint ? "accentForeground" : undefined}
|
|
||||||
style={[styles.buttonText, { color: textColor }]}
|
|
||||||
>
|
|
||||||
{title}
|
|
||||||
</PaletteText>
|
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
|||||||
@@ -14,14 +14,10 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
type PropsWithChildren,
|
type PropsWithChildren,
|
||||||
} from "react"
|
} from "react"
|
||||||
import { Platform, StyleSheet, type HostInstance } from "react-native"
|
import { Platform } from "react-native"
|
||||||
import Reanimated, {
|
import {
|
||||||
useSharedValue,
|
useSharedValue,
|
||||||
useAnimatedStyle,
|
useAnimatedStyle,
|
||||||
useAnimatedReaction,
|
|
||||||
useAnimatedRef,
|
|
||||||
setNativeProps,
|
|
||||||
processColor,
|
|
||||||
withTiming,
|
withTiming,
|
||||||
type SharedValue,
|
type SharedValue,
|
||||||
} from "react-native-reanimated"
|
} from "react-native-reanimated"
|
||||||
@@ -29,19 +25,17 @@ import Reanimated, {
|
|||||||
import { themeCoverPalette, type CoverPalette } from "@/lib/cover-palette"
|
import { themeCoverPalette, type CoverPalette } from "@/lib/cover-palette"
|
||||||
import { useIsDark, useThemeColors } from "@/lib/theme"
|
import { useIsDark, useThemeColors } from "@/lib/theme"
|
||||||
|
|
||||||
export type PaletteColor = Exclude<keyof CoverPalette, "isDark">
|
|
||||||
type PaletteColors = Pick<CoverPalette, PaletteColor> & {
|
|
||||||
selectedColor: string
|
|
||||||
}
|
|
||||||
|
|
||||||
type TabTheme = {
|
type TabTheme = {
|
||||||
palette: CoverPalette
|
palette: CoverPalette
|
||||||
colors: SharedValue<PaletteColors>
|
|
||||||
hasArtworkPalette: boolean
|
hasArtworkPalette: boolean
|
||||||
|
tabletBackground: SharedValue<string>
|
||||||
setPalette: (palette: CoverPalette | null, owner: string) => void
|
setPalette: (palette: CoverPalette | null, owner: string) => void
|
||||||
}
|
}
|
||||||
const AndroidTabTheme = createContext<TabTheme | null>(null)
|
const AndroidTabTheme = createContext<TabTheme | null>(null)
|
||||||
|
|
||||||
|
const isTablet = Platform.OS === "ios" && Platform.isPad
|
||||||
|
const sharesPalette = Platform.OS === "android" || isTablet
|
||||||
|
|
||||||
function useDefaultPalette() {
|
function useDefaultPalette() {
|
||||||
const theme = useThemeColors()
|
const theme = useThemeColors()
|
||||||
const isDark = useIsDark()
|
const isDark = useIsDark()
|
||||||
@@ -60,52 +54,37 @@ export function ScreenPaletteProvider({ children }: PropsWithChildren) {
|
|||||||
palette.foreground !== defaultPalette.foreground ||
|
palette.foreground !== defaultPalette.foreground ||
|
||||||
palette.secondaryForeground !== defaultPalette.secondaryForeground ||
|
palette.secondaryForeground !== defaultPalette.secondaryForeground ||
|
||||||
palette.accent !== defaultPalette.accent
|
palette.accent !== defaultPalette.accent
|
||||||
const { isDark: _defaultIsDark, ...defaultColors } = defaultPalette
|
const tabletBackground = useSharedValue(defaultPalette.background)
|
||||||
const animatedColors = useSharedValue<PaletteColors>({
|
|
||||||
...defaultColors,
|
|
||||||
selectedColor: defaultPalette.accentText,
|
|
||||||
})
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const { isDark: _isDark, ...colors } = palette
|
if (!isTablet) return
|
||||||
animatedColors.value = withTiming(
|
tabletBackground.value = withTiming(palette.background, {
|
||||||
{
|
duration: TABLET_FADE_MS,
|
||||||
...colors,
|
})
|
||||||
selectedColor: hasArtwork
|
}, [tabletBackground, palette.background])
|
||||||
? palette.foreground
|
|
||||||
: defaultPalette.accentText,
|
|
||||||
},
|
|
||||||
{ duration: PALETTE_FADE_MS }
|
|
||||||
)
|
|
||||||
}, [animatedColors, palette, defaultPalette, hasArtwork])
|
|
||||||
const paletteOwner = useRef<string | null>(null)
|
const paletteOwner = useRef<string | null>(null)
|
||||||
const setPalette = useCallback(
|
const setPalette = useCallback(
|
||||||
(palette: CoverPalette | null, owner: string) => {
|
(palette: CoverPalette | null, owner: string) => {
|
||||||
if (!palette && paletteOwner.current !== owner) return
|
if (!palette && paletteOwner.current !== owner) return
|
||||||
paletteOwner.current = palette ? owner : null
|
paletteOwner.current = palette ? owner : null
|
||||||
// Start on the UI thread immediately. React may defer commits while
|
if (isTablet) {
|
||||||
// the native stack is animating, including transitionStart state updates.
|
// React may defer commits while the iPad stack is animating.
|
||||||
const target = palette ?? defaultPalette
|
tabletBackground.value = withTiming(
|
||||||
const { isDark: _isDark, ...colors } = target
|
(palette ?? defaultPalette).background,
|
||||||
animatedColors.value = withTiming(
|
{ duration: TABLET_FADE_MS }
|
||||||
{
|
)
|
||||||
...colors,
|
}
|
||||||
selectedColor: palette ? target.foreground : target.accentText,
|
|
||||||
},
|
|
||||||
{ duration: PALETTE_FADE_MS }
|
|
||||||
)
|
|
||||||
setScreen(palette ? { palette, owner } : null)
|
setScreen(palette ? { palette, owner } : null)
|
||||||
},
|
},
|
||||||
[animatedColors, defaultPalette]
|
[tabletBackground, defaultPalette]
|
||||||
)
|
)
|
||||||
const artworkPalette = hasArtwork ? palette : null
|
|
||||||
const value = useMemo(
|
const value = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
palette: artworkPalette ?? defaultPalette,
|
palette: hasArtwork ? palette : defaultPalette,
|
||||||
colors: animatedColors,
|
hasArtworkPalette: hasArtwork,
|
||||||
hasArtworkPalette: artworkPalette !== null,
|
tabletBackground,
|
||||||
setPalette,
|
setPalette,
|
||||||
}),
|
}),
|
||||||
[defaultPalette, artworkPalette, setPalette, animatedColors]
|
[defaultPalette, hasArtwork, palette, setPalette, tabletBackground]
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
<AndroidTabTheme.Provider value={value}>
|
<AndroidTabTheme.Provider value={value}>
|
||||||
@@ -114,50 +93,6 @@ export function ScreenPaletteProvider({ children }: PropsWithChildren) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* NativeTabs forwards raw screen props to its Fabric screen. Bind that host
|
|
||||||
* directly so appearance updates stay on the UI thread with the page colors.
|
|
||||||
*/
|
|
||||||
export function useAndroidNativeTabColors() {
|
|
||||||
const colors = useContext(AndroidTabTheme)?.colors
|
|
||||||
const ref = useAnimatedRef<HostInstance>()
|
|
||||||
const mounted = useSharedValue(false)
|
|
||||||
const attach = useCallback(
|
|
||||||
(host: HostInstance | null) => {
|
|
||||||
if (host) ref(host)
|
|
||||||
mounted.value = host !== null
|
|
||||||
},
|
|
||||||
[ref, mounted]
|
|
||||||
)
|
|
||||||
|
|
||||||
useAnimatedReaction(
|
|
||||||
() => ({ colors: colors?.value, mounted: mounted.value }),
|
|
||||||
({ colors: palette, mounted: ready }) => {
|
|
||||||
if (Platform.OS !== "android" || !ready || !palette) return
|
|
||||||
const normal = processColor(palette.secondaryForeground)
|
|
||||||
const selected = processColor(palette.selectedColor)
|
|
||||||
setNativeProps(ref, {
|
|
||||||
standardAppearance: {
|
|
||||||
tabBarBackgroundColor: processColor("transparent"),
|
|
||||||
tabBarItemRippleColor: selected,
|
|
||||||
tabBarItemActiveIndicatorEnabled: false,
|
|
||||||
tabBarItemTitleSmallLabelFontSize: 10,
|
|
||||||
tabBarItemTitleLargeLabelFontSize: 10,
|
|
||||||
normal: {
|
|
||||||
tabBarItemTitleFontColor: normal,
|
|
||||||
tabBarItemIconColor: normal,
|
|
||||||
},
|
|
||||||
selected: {
|
|
||||||
tabBarItemTitleFontColor: selected,
|
|
||||||
tabBarItemIconColor: selected,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return { ref: attach, style: { backgroundColor: "transparent" } }
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useAndroidTabPalette() {
|
export function useAndroidTabPalette() {
|
||||||
const theme = useContext(AndroidTabTheme)
|
const theme = useContext(AndroidTabTheme)
|
||||||
const defaultPalette = useDefaultPalette()
|
const defaultPalette = useDefaultPalette()
|
||||||
@@ -168,53 +103,29 @@ export function useAndroidTabHasArtworkPalette() {
|
|||||||
return useContext(AndroidTabTheme)?.hasArtworkPalette ?? false
|
return useContext(AndroidTabTheme)?.hasArtworkPalette ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useAndroidTabBackgroundStyle() {
|
/** iPad fades the sidebar and content pane together; other layouts skip it. */
|
||||||
const theme = useContext(AndroidTabTheme)
|
export function useTabletBackgroundStyle() {
|
||||||
const fallback = useDefaultPalette().background
|
const background = useContext(AndroidTabTheme)?.tabletBackground
|
||||||
const colors = theme?.colors
|
|
||||||
return useAnimatedStyle(() =>
|
return useAnimatedStyle(() =>
|
||||||
Platform.OS === "android" || (Platform.OS === "ios" && Platform.isPad)
|
isTablet && background ? { backgroundColor: background.value } : {}
|
||||||
? { backgroundColor: colors?.value.background ?? fallback }
|
|
||||||
: {}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Color tokens share the background's UI-thread timing. */
|
const TABLET_FADE_MS = 400
|
||||||
export function useAnimatedPaletteColor(tone: PaletteColor | undefined) {
|
|
||||||
const colors = useContext(AndroidTabTheme)?.colors
|
|
||||||
return useAnimatedStyle(() =>
|
|
||||||
Platform.OS === "android" && tone && colors
|
|
||||||
? { color: colors.value[tone] }
|
|
||||||
: {}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Native headers draw this same UI-thread background as the page and bars. */
|
/**
|
||||||
function AndroidArtworkBackground() {
|
* Artwork screens always paint their own palette so it slides with the page.
|
||||||
const style = useAndroidTabBackgroundStyle()
|
* Shared chrome (tab bar, mini player) switches when the transition starts.
|
||||||
return <Reanimated.View style={[StyleSheet.absoluteFill, style]} />
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
export function renderAndroidArtworkBackground() {
|
|
||||||
return <AndroidArtworkBackground />
|
|
||||||
}
|
|
||||||
|
|
||||||
const PALETTE_FADE_MS = 400
|
|
||||||
|
|
||||||
/** The focused artwork screen selects the shared background for page and bars. */
|
|
||||||
export function useScreenPalette(palette: CoverPalette) {
|
export function useScreenPalette(palette: CoverPalette) {
|
||||||
const isFocused = useIsFocused()
|
const isFocused = useIsFocused()
|
||||||
const isTablet = Platform.OS === "ios" && Platform.isPad
|
|
||||||
const sharesPalette =
|
|
||||||
Platform.OS === "android" || (Platform.OS === "ios" && Platform.isPad)
|
|
||||||
const owner = useRoute().key
|
const owner = useRoute().key
|
||||||
const navigation =
|
const navigation =
|
||||||
useNavigation<NativeStackNavigationProp<Record<string, undefined>>>()
|
useNavigation<NativeStackNavigationProp<Record<string, undefined>>>()
|
||||||
const [laidOut, setLaidOut] = useState(false)
|
const [laidOut, setLaidOut] = useState(false)
|
||||||
const [closing, setClosing] = useState(false)
|
const [closing, setClosing] = useState(false)
|
||||||
const onLayout = useCallback(() => setLaidOut(true), [])
|
const onLayout = useCallback(() => setLaidOut(true), [])
|
||||||
const theme = useContext(AndroidTabTheme)
|
const setPalette = useContext(AndroidTabTheme)?.setPalette
|
||||||
const setPalette = theme?.setPalette
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!sharesPalette) return
|
if (!sharesPalette) return
|
||||||
const start = navigation.addListener("transitionStart", ({ data }) => {
|
const start = navigation.addListener("transitionStart", ({ data }) => {
|
||||||
@@ -230,20 +141,18 @@ export function useScreenPalette(palette: CoverPalette) {
|
|||||||
start()
|
start()
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
}, [navigation, sharesPalette, setPalette, owner, palette])
|
}, [navigation, setPalette, owner, palette])
|
||||||
const defaultPalette = useDefaultPalette()
|
|
||||||
const ready = laidOut || isTablet
|
const ready = laidOut || isTablet
|
||||||
const target = isFocused && ready && !closing ? palette : defaultPalette
|
const backgroundStyle = useTabletBackgroundStyle()
|
||||||
const backgroundStyle = useAndroidTabBackgroundStyle()
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!sharesPalette || !setPalette || !isFocused || !ready || closing) return
|
if (!sharesPalette || !setPalette || !isFocused || !ready || closing) return
|
||||||
setPalette(palette, owner)
|
setPalette(palette, owner)
|
||||||
return () => setPalette(null, owner)
|
return () => setPalette(null, owner)
|
||||||
}, [closing, ready, isFocused, owner, palette, setPalette, sharesPalette])
|
}, [closing, ready, isFocused, owner, palette, setPalette])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
palette: Platform.OS === "android" ? target : palette,
|
palette,
|
||||||
backgroundStyle,
|
backgroundStyle,
|
||||||
onLayout: sharesPalette ? onLayout : undefined,
|
onLayout: sharesPalette ? onLayout : undefined,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,13 @@ export function createCoverPaletteSource<Swatches>({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { prefetch, usePalette }
|
/** Forget in-memory swatches so covers are re-extracted. */
|
||||||
|
function clear() {
|
||||||
|
swatchesByKey.clear()
|
||||||
|
pending.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
return { prefetch, usePalette, clear }
|
||||||
}
|
}
|
||||||
|
|
||||||
function sameSwatches(a: unknown, b: unknown) {
|
function sameSwatches(a: unknown, b: unknown) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
type CoverPaletteResult,
|
type CoverPaletteResult,
|
||||||
} from "@/hooks/cover-palette-source"
|
} from "@/hooks/cover-palette-source"
|
||||||
import {
|
import {
|
||||||
|
clearLegacyCoverPaletteCache,
|
||||||
prefetchLegacyCoverPalette,
|
prefetchLegacyCoverPalette,
|
||||||
useLegacyCoverPalette,
|
useLegacyCoverPalette,
|
||||||
} from "@/hooks/use-legacy-cover-palette"
|
} from "@/hooks/use-legacy-cover-palette"
|
||||||
@@ -12,6 +13,7 @@ import {
|
|||||||
} from "@/lib/artwork-color-preference"
|
} from "@/lib/artwork-color-preference"
|
||||||
import { extractCoverSwatches } from "@/lib/artwork-colors"
|
import { extractCoverSwatches } from "@/lib/artwork-colors"
|
||||||
import { deriveCoverPalette, type CoverSwatches } from "@/lib/cover-palette"
|
import { deriveCoverPalette, type CoverSwatches } from "@/lib/cover-palette"
|
||||||
|
import { clearCachePrefix } from "@/lib/persistent-cache"
|
||||||
|
|
||||||
export { COVER_PALETTE_WAIT_MS } from "@/hooks/cover-palette-source"
|
export { COVER_PALETTE_WAIT_MS } from "@/hooks/cover-palette-source"
|
||||||
|
|
||||||
@@ -21,6 +23,16 @@ const region = createCoverPaletteSource<CoverSwatches>({
|
|||||||
derive: (swatches) => deriveCoverPalette(swatches),
|
derive: (swatches) => deriveCoverPalette(swatches),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forget every extracted palette, in memory and on device, so covers are
|
||||||
|
* re-extracted. Both pipelines share the `palette:` cache prefix.
|
||||||
|
*/
|
||||||
|
export function clearCoverPaletteCache() {
|
||||||
|
region.clear()
|
||||||
|
clearLegacyCoverPaletteCache()
|
||||||
|
clearCachePrefix("palette")
|
||||||
|
}
|
||||||
|
|
||||||
/** Warm visible artwork colors before a detail page is pushed. */
|
/** Warm visible artwork colors before a detail page is pushed. */
|
||||||
export function prefetchCoverPalette(uri: string) {
|
export function prefetchCoverPalette(uri: string) {
|
||||||
void loadArtworkColorsEnabled().then((enabled) =>
|
void loadArtworkColorsEnabled().then((enabled) =>
|
||||||
|
|||||||
@@ -65,3 +65,5 @@ export const prefetchLegacyCoverPalette = legacy.prefetch
|
|||||||
|
|
||||||
/** `react-native-image-colors` pipeline used when new artwork colors are off. */
|
/** `react-native-image-colors` pipeline used when new artwork colors are off. */
|
||||||
export const useLegacyCoverPalette = legacy.usePalette
|
export const useLegacyCoverPalette = legacy.usePalette
|
||||||
|
|
||||||
|
export const clearLegacyCoverPaletteCache = legacy.clear
|
||||||
@@ -28,7 +28,7 @@ export function useStackScreenOptions(
|
|||||||
headerBackButtonDisplayMode: "minimal",
|
headerBackButtonDisplayMode: "minimal",
|
||||||
...(Platform.OS === "android"
|
...(Platform.OS === "android"
|
||||||
? {
|
? {
|
||||||
animation: "slide_from_right",
|
animation: "fade",
|
||||||
headerLargeTitle: false,
|
headerLargeTitle: false,
|
||||||
headerTransparent: false,
|
headerTransparent: false,
|
||||||
headerStyle: { backgroundColor: theme.background },
|
headerStyle: { backgroundColor: theme.background },
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
const fs = require("fs")
|
||||||
|
const path = require("path")
|
||||||
|
const { withDangerousMod } = require("expo/config-plugins")
|
||||||
|
|
||||||
|
// Overrides react-native-screens' 150ms crossfade for `animation: "fade"`.
|
||||||
|
// App resources win over library resources with the same name, so the stack
|
||||||
|
// fades through black in 100ms: the old page out, then the new page in.
|
||||||
|
const anims = {
|
||||||
|
"rns_fade_out.xml": `<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromAlpha="1.0"
|
||||||
|
android:toAlpha="0.0"
|
||||||
|
android:duration="50" />
|
||||||
|
`,
|
||||||
|
"rns_fade_in.xml": `<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromAlpha="0.0"
|
||||||
|
android:toAlpha="1.0"
|
||||||
|
android:startOffset="50"
|
||||||
|
android:duration="50" />
|
||||||
|
`,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = (config) =>
|
||||||
|
withDangerousMod(config, [
|
||||||
|
"android",
|
||||||
|
(config) => {
|
||||||
|
const dir = path.join(
|
||||||
|
config.modRequest.platformProjectRoot,
|
||||||
|
"app/src/main/res/anim"
|
||||||
|
)
|
||||||
|
fs.mkdirSync(dir, { recursive: true })
|
||||||
|
for (const [name, xml] of Object.entries(anims)) {
|
||||||
|
fs.writeFileSync(path.join(dir, name), `<?xml version="1.0" encoding="utf-8"?>\n${xml}`)
|
||||||
|
}
|
||||||
|
return config
|
||||||
|
},
|
||||||
|
])
|
||||||
@@ -198,6 +198,15 @@ export async function clearPersistentCache() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Deletes every entry whose key starts with `<prefix>:`. */
|
||||||
|
export function clearCachePrefix(prefix: string) {
|
||||||
|
for (const key of [...memory.keys()]) {
|
||||||
|
if (entryPrefix(key) !== prefix) continue
|
||||||
|
removeFromMemory(key)
|
||||||
|
scheduleWrite(key, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function subscribeCache(key: string, listener: () => void) {
|
export function subscribeCache(key: string, listener: () => void) {
|
||||||
let keyListeners = listeners.get(key)
|
let keyListeners = listeners.get(key)
|
||||||
if (!keyListeners) {
|
if (!keyListeners) {
|
||||||
|
|||||||
Reference in new issue
Block a user