Compare commits
No files matched your search
@@ -1,7 +1,7 @@
|
||||
/ios/
|
||||
/android/
|
||||
ios/
|
||||
android/
|
||||
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
|
||||
# The following patterns were generated by expo-cli
|
||||
|
||||
expo-env.d.ts
|
||||
# @end expo-cli
|
||||
# @end expo-cli
|
||||
@@ -1,44 +0,0 @@
|
||||
# Mobile build variants
|
||||
|
||||
EAS profiles set `APP_VARIANT` to select the app identity in `app.config.ts`.
|
||||
Both iOS bundle identifiers and Android package names use these values:
|
||||
|
||||
| Profile | App name | Identifier |
|
||||
| --- | --- | --- |
|
||||
| development | oTunes (Development) | com.abunchofknowitalls.otunes.development |
|
||||
| preview | oTunes (Preview) | com.abunchofknowitalls.otunes.preview |
|
||||
| production | oTunes | com.abunchofknowitalls.otunes |
|
||||
|
||||
Build with `eas build --profile development`, `--profile preview`, or
|
||||
`--profile production` from this directory.
|
||||
|
||||
For local builds and Metro, select the same variant explicitly:
|
||||
|
||||
```sh
|
||||
APP_VARIANT=development pnpm ios
|
||||
APP_VARIANT=development pnpm android
|
||||
APP_VARIANT=development pnpm start
|
||||
```
|
||||
|
||||
An unset `APP_VARIANT` keeps the production identity. Unknown variants fail
|
||||
configuration. URL schemes are `otunes-development`, `otunes-preview`, and
|
||||
`otunes` respectively, allowing the apps to be installed together.
|
||||
|
||||
### Shared links and artwork
|
||||
|
||||
Shared URLs stay as ordinary HTTPS links. The web page's "Open App" action
|
||||
opens `otunes://open?url=<encoded HTTPS URL>`, including the server address and
|
||||
album, artist, or playlist destination. No domain association files, signing
|
||||
settings, or per-server mobile builds are needed.
|
||||
|
||||
The app checks the link's server against its configured server before opening
|
||||
media. Links for another server do not switch the current server. On a fresh
|
||||
installation, the server address is prefilled in setup. The destination is kept
|
||||
in memory through setup and sign-in, and is opened after authentication.
|
||||
The browser may ask before opening the app. If the app is absent, the web page
|
||||
remains available. Native changes still require a new mobile build.
|
||||
|
||||
Native sharing supplies media titles and artwork through iOS link metadata and Android's chooser
|
||||
thumbnail, while sharing the original HTTPS URL. Receiving apps control whether
|
||||
they display previews. If artwork cannot load, the URL is still shared. Existing
|
||||
builds without the native sharing module fall back to URL-only sharing.
|
||||
@@ -1,51 +0,0 @@
|
||||
import type { ConfigContext, ExpoConfig } from "expo/config"
|
||||
|
||||
export default ({ config }: ConfigContext): ExpoConfig => {
|
||||
const variant: string =
|
||||
process.env.APP_VARIANT ?? process.env.EAS_BUILD_PROFILE ?? "production"
|
||||
if (
|
||||
variant !== "development" &&
|
||||
variant !== "preview" &&
|
||||
variant !== "production"
|
||||
) {
|
||||
throw new Error(`Unsupported APP_VARIANT: ${variant}`)
|
||||
}
|
||||
|
||||
const suffix = variant === "production" ? "" : `.${variant}`
|
||||
const iconSuffix = variant === "production" ? "" : `-${variant}`
|
||||
const nameSuffix =
|
||||
variant === "development"
|
||||
? " (Development)"
|
||||
: variant === "preview"
|
||||
? " (Preview)"
|
||||
: ""
|
||||
// Expo writes this filename into Xcode build settings without quoting it.
|
||||
const composer = {
|
||||
development: "oTunesDev",
|
||||
preview: "oTunesPreview",
|
||||
production: "oTunes",
|
||||
}[variant]
|
||||
|
||||
return {
|
||||
...config,
|
||||
name: `${config.name}${nameSuffix}`,
|
||||
slug: config.slug!,
|
||||
scheme: variant === "production" ? "otunes" : `otunes-${variant}`,
|
||||
icon: `./assets/icon${iconSuffix}.png`,
|
||||
ios: {
|
||||
...config.ios,
|
||||
bundleIdentifier: `${config.ios!.bundleIdentifier}${suffix}`,
|
||||
icon: `./assets/${composer}.icon`,
|
||||
},
|
||||
android: {
|
||||
...config.android,
|
||||
package: `${config.android!.package}${suffix}`,
|
||||
icon: `./assets/android-icon${iconSuffix}.png`,
|
||||
adaptiveIcon: {
|
||||
monochromeImage: "./assets/android-icon-monochrome.png",
|
||||
foregroundImage: `./assets/android-icon-foreground${iconSuffix}.png`,
|
||||
backgroundImage: `./assets/android-icon-background${iconSuffix}.png`,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,8 @@
|
||||
"adaptiveIcon": {
|
||||
"monochromeImage": "./assets/android-icon-monochrome.png",
|
||||
"foregroundImage": "./assets/android-icon-foreground.png",
|
||||
"backgroundImage": "./assets/android-icon-background.png"
|
||||
},
|
||||
"userInterfaceStyle": "dark",
|
||||
"softwareKeyboardLayoutMode": "resize",
|
||||
"icon": "./assets/android-icon.png"
|
||||
"backgroundColor": "#C60322"
|
||||
}
|
||||
},
|
||||
"plugins": [
|
||||
"expo-router",
|
||||
@@ -52,23 +49,12 @@
|
||||
],
|
||||
"expo-image",
|
||||
"expo-status-bar",
|
||||
"expo-app-intents",
|
||||
"./plugins/with-android-colors",
|
||||
[
|
||||
"expo-navigation-bar",
|
||||
{
|
||||
"enforceContrast": false,
|
||||
"style": "light"
|
||||
}
|
||||
]
|
||||
"expo-app-intents"
|
||||
],
|
||||
"experiments": {
|
||||
"typedRoutes": true,
|
||||
"inlineModules": {
|
||||
"watchedDirectories": [
|
||||
"app-intents",
|
||||
"native"
|
||||
]
|
||||
"watchedDirectories": ["app-intents"]
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
|
||||
@@ -1,54 +1,37 @@
|
||||
import Animated from "react-native-reanimated"
|
||||
import { NavigationBar } from "expo-navigation-bar"
|
||||
import {
|
||||
AndroidTabThemeProvider,
|
||||
useAndroidTabPalette,
|
||||
useAndroidTabBackgroundStyle,
|
||||
useAndroidNativeTabColors,
|
||||
} from "@/contexts/android-tab-theme"
|
||||
import { DarkTheme, DefaultTheme, ThemeProvider } from "expo-router"
|
||||
import { NativeTabs } from "expo-router/native-tabs"
|
||||
import { DynamicColorIOS, Platform } from "react-native"
|
||||
import { DynamicColorIOS, Platform, useColorScheme } from "react-native"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { AndroidMiniPlayer, TabBottomAccessory } from "@/components/mini-player"
|
||||
import { useAndroidKeyboardVisible } from "@/hooks/use-android-keyboard-visible"
|
||||
import { TabBottomAccessory } from "@/components/mini-player"
|
||||
import { usePlaybackQueue } from "@/contexts/playback"
|
||||
import { appleMusic, colors, miniPlayerHeight, useIsDark } from "@/lib/theme"
|
||||
import { appleMusic, colors } from "@/lib/theme"
|
||||
|
||||
export const unstable_settings = { anchor: "library" }
|
||||
|
||||
function useRouterTheme() {
|
||||
const themeIsDark = useIsDark()
|
||||
const androidPalette = useAndroidTabPalette()
|
||||
const isDark = Platform.OS === "android" ? androidPalette.isDark : themeIsDark
|
||||
const isDark = useColorScheme() === "dark"
|
||||
|
||||
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: android?.background ?? palette.background,
|
||||
card: android?.surface ?? palette.card,
|
||||
text: android?.foreground ?? palette.foreground,
|
||||
border: android?.divider ?? palette.border,
|
||||
primary: android?.accentText ?? palette.primary,
|
||||
background: palette.background,
|
||||
card: palette.card,
|
||||
text: palette.foreground,
|
||||
border: palette.border,
|
||||
primary: palette.primary,
|
||||
},
|
||||
}
|
||||
}, [isDark, androidPalette])
|
||||
}, [isDark])
|
||||
}
|
||||
|
||||
function useNativeTabColors() {
|
||||
// These props initialize native tabs; the worklet owns subsequent colors.
|
||||
const selectedColor = colors.dark.primary
|
||||
const themeIsDark = useIsDark()
|
||||
const androidPalette = colors.dark
|
||||
const artworkPalette = useAndroidTabPalette()
|
||||
const isDark = Platform.OS === "android" ? artworkPalette.isDark : themeIsDark
|
||||
const isDark = useColorScheme() === "dark"
|
||||
const inactive = appleMusic.tabInactive
|
||||
|
||||
const iconColor =
|
||||
@@ -58,23 +41,24 @@ function useNativeTabColors() {
|
||||
selected: appleMusic.pink,
|
||||
}
|
||||
: {
|
||||
default: androidPalette.mutedForeground,
|
||||
selected: selectedColor,
|
||||
default: isDark ? inactive : "#636366",
|
||||
selected: appleMusic.pink,
|
||||
}
|
||||
|
||||
const labelColor =
|
||||
Platform.OS === "ios"
|
||||
? DynamicColorIOS({ dark: inactive, light: "#636366" })
|
||||
: androidPalette.mutedForeground
|
||||
: isDark
|
||||
? inactive
|
||||
: "#636366"
|
||||
|
||||
return {
|
||||
isDark,
|
||||
tintColor: Platform.OS === "android" ? selectedColor : appleMusic.pink,
|
||||
iconColor,
|
||||
labelStyle: {
|
||||
default: { color: labelColor, fontSize: 10 },
|
||||
selected: {
|
||||
color: Platform.OS === "android" ? selectedColor : appleMusic.pink,
|
||||
color: appleMusic.pink,
|
||||
fontSize: 10,
|
||||
fontWeight: "600" as const,
|
||||
},
|
||||
@@ -82,112 +66,58 @@ function useNativeTabColors() {
|
||||
blurEffect: isDark
|
||||
? "systemChromeMaterialDark"
|
||||
: "systemChromeMaterialLight",
|
||||
// Reveal the shared UI-thread background beneath the native tab bar.
|
||||
backgroundColor: Platform.OS === "ios" ? undefined : "transparent",
|
||||
backgroundColor:
|
||||
Platform.OS === "ios"
|
||||
? undefined
|
||||
: isDark
|
||||
? appleMusic.background
|
||||
: colors.light.background,
|
||||
}
|
||||
}
|
||||
|
||||
function TabsContent() {
|
||||
const homeColors = useAndroidNativeTabColors()
|
||||
const libraryColors = useAndroidNativeTabColors()
|
||||
const searchColors = useAndroidNativeTabColors()
|
||||
const keyboardVisible = useAndroidKeyboardVisible()
|
||||
export default function TabsLayout() {
|
||||
const routerTheme = useRouterTheme()
|
||||
const tabColors = useNativeTabColors()
|
||||
const backgroundStyle = useAndroidTabBackgroundStyle()
|
||||
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 (
|
||||
<ThemeProvider value={routerTheme}>
|
||||
<Animated.View
|
||||
style={[
|
||||
{ flex: 1 },
|
||||
Platform.OS === "android" ? backgroundStyle : undefined,
|
||||
]}
|
||||
<NativeTabs
|
||||
blurEffect={
|
||||
tabColors.blurEffect as
|
||||
"systemChromeMaterialDark" | "systemChromeMaterialLight"
|
||||
}
|
||||
backgroundColor={tabColors.backgroundColor}
|
||||
iconColor={tabColors.iconColor}
|
||||
labelStyle={tabColors.labelStyle}
|
||||
tintColor={appleMusic.pink}
|
||||
minimizeBehavior="onScrollDown"
|
||||
>
|
||||
{Platform.OS === "android" ? (
|
||||
<NavigationBar style={tabColors.isDark ? "light" : "dark"} />
|
||||
{showBottomAccessory ? (
|
||||
<NativeTabs.BottomAccessory>
|
||||
<TabBottomAccessory />
|
||||
</NativeTabs.BottomAccessory>
|
||||
) : null}
|
||||
<NativeTabs
|
||||
blurEffect={
|
||||
tabColors.blurEffect as
|
||||
"systemChromeMaterialDark" | "systemChromeMaterialLight"
|
||||
}
|
||||
backgroundColor={tabColors.backgroundColor}
|
||||
iconColor={tabColors.iconColor}
|
||||
labelStyle={tabColors.labelStyle}
|
||||
tintColor={tabColors.tintColor}
|
||||
minimizeBehavior="onScrollDown"
|
||||
{...(Platform.OS === "android"
|
||||
? { disableIndicator: true, rippleColor: tabColors.tintColor }
|
||||
: {})}
|
||||
>
|
||||
{Platform.OS === "ios" && showBottomAccessory ? (
|
||||
<NativeTabs.BottomAccessory>
|
||||
<TabBottomAccessory />
|
||||
</NativeTabs.BottomAccessory>
|
||||
) : null}
|
||||
|
||||
<NativeTabs.Trigger
|
||||
name="home"
|
||||
unstable_nativeProps={
|
||||
Platform.OS === "android" ? homeColors : undefined
|
||||
}
|
||||
disableTransparentOnScrollEdge
|
||||
contentStyle={androidContentStyle}
|
||||
>
|
||||
<NativeTabs.Trigger.Icon sf="house.fill" md="home" />
|
||||
<NativeTabs.Trigger.Label>Home</NativeTabs.Trigger.Label>
|
||||
</NativeTabs.Trigger>
|
||||
<NativeTabs.Trigger name="home" disableTransparentOnScrollEdge>
|
||||
<NativeTabs.Trigger.Icon sf="house.fill" md="home" />
|
||||
<NativeTabs.Trigger.Label>Home</NativeTabs.Trigger.Label>
|
||||
</NativeTabs.Trigger>
|
||||
|
||||
<NativeTabs.Trigger
|
||||
name="library"
|
||||
unstable_nativeProps={
|
||||
Platform.OS === "android" ? libraryColors : undefined
|
||||
}
|
||||
disableTransparentOnScrollEdge
|
||||
contentStyle={androidContentStyle}
|
||||
>
|
||||
<NativeTabs.Trigger.Icon
|
||||
sf="music.note.square.stack.fill"
|
||||
md="library_music"
|
||||
/>
|
||||
<NativeTabs.Trigger.Label>Library</NativeTabs.Trigger.Label>
|
||||
</NativeTabs.Trigger>
|
||||
<NativeTabs.Trigger name="library" disableTransparentOnScrollEdge>
|
||||
<NativeTabs.Trigger.Icon
|
||||
sf="music.note.square.stack.fill"
|
||||
md="library_music"
|
||||
/>
|
||||
<NativeTabs.Trigger.Label>Library</NativeTabs.Trigger.Label>
|
||||
</NativeTabs.Trigger>
|
||||
|
||||
<NativeTabs.Trigger
|
||||
name="search"
|
||||
unstable_nativeProps={
|
||||
Platform.OS === "android" ? searchColors : undefined
|
||||
}
|
||||
disableTransparentOnScrollEdge
|
||||
contentStyle={androidContentStyle}
|
||||
>
|
||||
<NativeTabs.Trigger.Icon sf="magnifyingglass" md="search" />
|
||||
<NativeTabs.Trigger.Label>Search</NativeTabs.Trigger.Label>
|
||||
</NativeTabs.Trigger>
|
||||
</NativeTabs>
|
||||
{!keyboardVisible ? <AndroidMiniPlayer /> : null}
|
||||
</Animated.View>
|
||||
<NativeTabs.Trigger name="search" disableTransparentOnScrollEdge>
|
||||
<NativeTabs.Trigger.Icon sf="magnifyingglass" md="search" />
|
||||
<NativeTabs.Trigger.Label>Search</NativeTabs.Trigger.Label>
|
||||
</NativeTabs.Trigger>
|
||||
</NativeTabs>
|
||||
</ThemeProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export default function TabsLayout() {
|
||||
if (Platform.OS !== "android") return <TabsContent />
|
||||
return (
|
||||
<AndroidTabThemeProvider>
|
||||
<TabsContent />
|
||||
</AndroidTabThemeProvider>
|
||||
)
|
||||
}
|
||||
@@ -1,25 +1,15 @@
|
||||
import {
|
||||
PaletteText,
|
||||
PaletteIcon,
|
||||
renderArtworkBackButton,
|
||||
} from "@/components/palette-text"
|
||||
import Animated from "react-native-reanimated"
|
||||
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"
|
||||
import { memo, useCallback, useEffect, useMemo } from "react"
|
||||
import { Platform, Pressable, StyleSheet, View } from "react-native"
|
||||
import { FlatList, Pressable, StyleSheet, Text, View } from "react-native"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
|
||||
import {
|
||||
CollectionDivider,
|
||||
collectionInset,
|
||||
DiscHeader,
|
||||
} from "@/components/collection-list"
|
||||
import { AudioFormatBadge } from "@/components/audio-format-badge"
|
||||
import { CoverImage } from "@/components/cover-image"
|
||||
|
||||
import {
|
||||
@@ -67,31 +57,15 @@ export default function AlbumScreen() {
|
||||
const isFocused = useIsFocused()
|
||||
const coverUri =
|
||||
config && typeof id === "string" ? albumCoverUrl(config.serverUrl, id) : ""
|
||||
const { palette: artworkPalette, settled } = useCoverPalette(
|
||||
const { palette, settled } = useCoverPalette(
|
||||
coverUri,
|
||||
album ? album.cover != null : album === null ? false : undefined
|
||||
)
|
||||
const { palette, onLayout, backgroundStyle } =
|
||||
useAndroidScreenPalette(artworkPalette)
|
||||
const songIds = useMemo(
|
||||
() => album?.tracks.map((track) => track.id as Id<"songs">) ?? [],
|
||||
[album]
|
||||
)
|
||||
|
||||
// Older servers do not include album format availability yet.
|
||||
const formatTracks = useCachedQuery(
|
||||
api.library.getSongsForPlayback,
|
||||
album && (album.hasLossless === undefined || album.hasAtmos === undefined)
|
||||
? { ids: songIds }
|
||||
: "skip"
|
||||
)
|
||||
const hasLossless =
|
||||
album?.hasLossless ??
|
||||
formatTracks?.some((track) => track && "lossless" in track.files)
|
||||
const hasAtmos =
|
||||
album?.hasAtmos ??
|
||||
formatTracks?.some((track) => track && "atmos" in track.files)
|
||||
|
||||
useEffect(() => {
|
||||
if (album) {
|
||||
rememberSongs(albumDetailSongs(album))
|
||||
@@ -113,9 +87,7 @@ export default function AlbumScreen() {
|
||||
songIds={songIds}
|
||||
palette={palette}
|
||||
favorited={isSongFavorite(item.track.id)}
|
||||
onPlay={(songId, ids) =>
|
||||
playFromSong(songId, ids, `album:${album.id}`)
|
||||
}
|
||||
onPlay={playFromSong}
|
||||
onAction={handleAlbumTrackAction}
|
||||
/>
|
||||
) : null
|
||||
@@ -137,24 +109,9 @@ export default function AlbumScreen() {
|
||||
options={{
|
||||
title: "",
|
||||
headerLargeTitle: false,
|
||||
...(Platform.OS === "android"
|
||||
? {
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerBackground: renderAndroidArtworkBackground,
|
||||
headerBackVisible: false,
|
||||
headerLeft: renderArtworkBackButton,
|
||||
headerTintColor: palette.foreground,
|
||||
}
|
||||
: {}),
|
||||
}}
|
||||
/>
|
||||
<CollectionDetailSkeleton
|
||||
onLayout={onLayout}
|
||||
style={backgroundStyle}
|
||||
backgroundColor={
|
||||
Platform.OS === "android" ? palette.background : undefined
|
||||
}
|
||||
/>
|
||||
<CollectionDetailSkeleton />
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -169,9 +126,9 @@ export default function AlbumScreen() {
|
||||
}}
|
||||
/>
|
||||
<View style={[styles.empty, { backgroundColor: colors.background }]}>
|
||||
<PaletteText style={{ color: colors.mutedForeground }}>
|
||||
<Text style={{ color: colors.mutedForeground }}>
|
||||
Album not found.
|
||||
</PaletteText>
|
||||
</Text>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
@@ -190,23 +147,12 @@ export default function AlbumScreen() {
|
||||
title: "",
|
||||
headerLargeTitle: false,
|
||||
headerTintColor: palette.foreground,
|
||||
...(Platform.OS === "android"
|
||||
? {
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerBackground: renderAndroidArtworkBackground,
|
||||
headerBackVisible: false,
|
||||
headerLeft: renderArtworkBackButton,
|
||||
statusBarStyle: palette.isDark
|
||||
? ("light" as const)
|
||||
: ("dark" as const),
|
||||
}
|
||||
: {}),
|
||||
headerRight: () => (
|
||||
<MediaActionMenu
|
||||
stationArtistId={album.artist.id}
|
||||
selectedCount={album.tracks.length}
|
||||
favorited={isAlbumFav(album.id)}
|
||||
share={{ type: "album", albumId: album.id, title: album.title }}
|
||||
share={{ type: "album", albumId: album.id }}
|
||||
onAction={(action) =>
|
||||
void handleAlbumDetailAction(
|
||||
album.id as Id<"albums">,
|
||||
@@ -217,26 +163,21 @@ export default function AlbumScreen() {
|
||||
}
|
||||
>
|
||||
<Pressable hitSlop={8}>
|
||||
<PaletteIcon
|
||||
tone="foreground"
|
||||
<Ionicons
|
||||
name="ellipsis-horizontal"
|
||||
size={22}
|
||||
color={palette.isDark ? "#fff" : "#000"}
|
||||
color={palette.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
</MediaActionMenu>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<Animated.FlatList
|
||||
onLayout={onLayout}
|
||||
<FlatList
|
||||
{...longListProps}
|
||||
data={listItems}
|
||||
keyExtractor={albumListItemKey}
|
||||
style={[
|
||||
{ flex: 1, backgroundColor: palette.background },
|
||||
backgroundStyle,
|
||||
]}
|
||||
style={{ flex: 1, backgroundColor: palette.background }}
|
||||
contentContainerStyle={{ paddingBottom: contentBottomInset }}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
indicatorStyle={palette.isDark ? "white" : "black"}
|
||||
@@ -248,77 +189,22 @@ export default function AlbumScreen() {
|
||||
hasCover={album.cover != null}
|
||||
style={styles.cover}
|
||||
/>
|
||||
<PaletteText
|
||||
tone="foreground"
|
||||
style={[styles.title, { color: palette.foreground }]}
|
||||
>
|
||||
<Text style={[styles.title, { color: palette.foreground }]}>
|
||||
{album.title}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
<Pressable
|
||||
onPress={() => push(`/artist/${album.artist.id}`)}
|
||||
style={styles.artistPressable}
|
||||
>
|
||||
<PaletteText
|
||||
tone="accentText"
|
||||
style={[styles.artist, { color: palette.accentText }]}
|
||||
>
|
||||
<Text style={[styles.artist, { color: palette.accentText }]}>
|
||||
{album.artist.name}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
</Pressable>
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
flexWrap: "wrap",
|
||||
gap: 8,
|
||||
}}
|
||||
>
|
||||
{metadata ? (
|
||||
<PaletteText
|
||||
tone="secondaryForeground"
|
||||
style={{ color: palette.secondaryForeground }}
|
||||
>
|
||||
{metadata}
|
||||
</PaletteText>
|
||||
) : null}
|
||||
{hasLossless ? (
|
||||
<>
|
||||
{metadata ? (
|
||||
<PaletteText
|
||||
tone="secondaryForeground"
|
||||
style={{ color: palette.secondaryForeground }}
|
||||
>
|
||||
·
|
||||
</PaletteText>
|
||||
) : null}
|
||||
<AudioFormatBadge
|
||||
artwork
|
||||
format="lossless"
|
||||
color={palette.secondaryForeground}
|
||||
backgroundColor={palette.background}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
{hasAtmos ? (
|
||||
<>
|
||||
{metadata || hasLossless ? (
|
||||
<PaletteText
|
||||
tone="secondaryForeground"
|
||||
style={{ color: palette.secondaryForeground }}
|
||||
>
|
||||
·
|
||||
</PaletteText>
|
||||
) : null}
|
||||
<AudioFormatBadge
|
||||
artwork
|
||||
format="atmos"
|
||||
color={palette.secondaryForeground}
|
||||
backgroundColor={palette.background}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
</View>
|
||||
{metadata ? (
|
||||
<Text style={{ color: palette.secondaryForeground }}>
|
||||
{metadata}
|
||||
</Text>
|
||||
) : null}
|
||||
<View style={styles.actions}>
|
||||
<Pressable
|
||||
onPress={() => void toggleAlbumFavorite(album.id)}
|
||||
@@ -328,8 +214,7 @@ export default function AlbumScreen() {
|
||||
{ backgroundColor: palette.surface },
|
||||
]}
|
||||
>
|
||||
<PaletteIcon
|
||||
tone={favorited ? "accent" : "foreground"}
|
||||
<Ionicons
|
||||
name={favorited ? "star" : "star-outline"}
|
||||
size={24}
|
||||
color={favorited ? palette.accent : palette.foreground}
|
||||
@@ -355,8 +240,7 @@ export default function AlbumScreen() {
|
||||
{ backgroundColor: palette.surface },
|
||||
]}
|
||||
>
|
||||
<PaletteIcon
|
||||
tone="foreground"
|
||||
<Ionicons
|
||||
name="shuffle"
|
||||
size={24}
|
||||
color={palette.foreground}
|
||||
@@ -449,7 +333,6 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
type: "song",
|
||||
albumId: album.id,
|
||||
songId: track.id,
|
||||
title: `${track.title} - ${album.title}`,
|
||||
}}
|
||||
onAction={(action) => void onAction(track, album, action)}
|
||||
>
|
||||
@@ -458,12 +341,11 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
style={styles.trackRow}
|
||||
onPress={() => void onPlay(track.id as Id<"songs">, songIds)}
|
||||
>
|
||||
<PaletteText
|
||||
tone="secondaryForeground"
|
||||
<Text
|
||||
style={[styles.trackNumber, { color: palette.secondaryForeground }]}
|
||||
>
|
||||
{number}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
<View
|
||||
style={[
|
||||
styles.trackContent,
|
||||
@@ -471,29 +353,24 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
]}
|
||||
>
|
||||
<View style={styles.trackMeta}>
|
||||
<PaletteText
|
||||
tone="foreground"
|
||||
<Text
|
||||
style={[styles.trackTitle, { color: palette.foreground }]}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{track.title}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
{track.artists ? (
|
||||
<PaletteText
|
||||
tone="secondaryForeground"
|
||||
<Text
|
||||
style={{ color: palette.secondaryForeground }}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{track.artists.join(", ")}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
<PaletteText
|
||||
tone="secondaryForeground"
|
||||
style={{ color: palette.secondaryForeground }}
|
||||
>
|
||||
<Text style={{ color: palette.secondaryForeground }}>
|
||||
{formatDuration(track.durationSeconds)}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
</MusicEntityView>
|
||||
|
||||
@@ -75,11 +75,7 @@ export default function ArtistScreen() {
|
||||
<MediaActionMenu
|
||||
selectedCount={data.albums.length}
|
||||
favorited={isArtistFav(data.artist.id)}
|
||||
share={{
|
||||
type: "artist",
|
||||
artistId: data.artist.id,
|
||||
title: data.artist.name,
|
||||
}}
|
||||
share={{ type: "artist", artistId: data.artist.id }}
|
||||
onAction={(action) =>
|
||||
void handleArtistAction(data.artist, action)
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ const ArtistRow = memo(function ArtistRow({
|
||||
return (
|
||||
<MediaContextMenu
|
||||
favorited={favorited}
|
||||
share={{ type: "artist", artistId: artist.id, title: artist.name }}
|
||||
share={{ type: "artist", artistId: artist.id }}
|
||||
onAction={(action) => void onAction(artist, action)}
|
||||
>
|
||||
<Pressable
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
import {
|
||||
PaletteText,
|
||||
PaletteIcon,
|
||||
renderArtworkBackButton,
|
||||
} from "@/components/palette-text"
|
||||
import Animated from "react-native-reanimated"
|
||||
import {
|
||||
PlaylistSearchBar,
|
||||
usePlaylistSearch,
|
||||
} from "@/components/playlist-search-bar"
|
||||
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"
|
||||
@@ -23,13 +9,16 @@ import {
|
||||
} from "expo-router"
|
||||
import { StatusBar } from "expo-status-bar"
|
||||
import {
|
||||
FlatList,
|
||||
Platform,
|
||||
Pressable,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
type ListRenderItemInfo,
|
||||
} from "react-native"
|
||||
import ReanimatedSwipeable from "react-native-gesture-handler/ReanimatedSwipeable"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
|
||||
import { CollectionDivider } from "@/components/collection-list"
|
||||
import { CoverImage } from "@/components/cover-image"
|
||||
@@ -49,7 +38,10 @@ import { contentBottomInset, SongListRow } from "@/components/player"
|
||||
import { useFavorites } from "@/contexts/favorites"
|
||||
import { usePlaybackActions } from "@/contexts/playback"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||
import {
|
||||
useCachedPaginatedQuery,
|
||||
useCachedQuery,
|
||||
} from "@/hooks/use-cached-query"
|
||||
import { useCoverPalette } from "@/hooks/use-cover-palette"
|
||||
import { useMediaMenuActions } from "@/hooks/use-media-menu-actions"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
@@ -62,6 +54,7 @@ import { showError } from "@/lib/toast"
|
||||
import { playlistCoverUrl } from "@/lib/urls"
|
||||
import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
const PAGE_SIZE = 50
|
||||
const PLAYLIST_LABEL = "Add to Another Playlist"
|
||||
const OWNER_MENU_ACTIONS: MediaAction[] = [
|
||||
"share",
|
||||
@@ -80,49 +73,55 @@ export default function PlaylistScreen() {
|
||||
const playlistId = typeof id === "string" ? (id as Id<"playlists">) : null
|
||||
const playlist = useCachedQuery(
|
||||
api.playlists.browsePlaylistDetail,
|
||||
playlistId ? { id: playlistId } : "skip"
|
||||
playlistId
|
||||
? {
|
||||
id: playlistId,
|
||||
includeSongs: false,
|
||||
}
|
||||
: "skip"
|
||||
)
|
||||
const {
|
||||
results: songs,
|
||||
status,
|
||||
loadMore,
|
||||
isCached,
|
||||
} = useCachedPaginatedQuery(
|
||||
api.playlists.browsePlaylistSongsPaginated,
|
||||
playlistId ? { id: playlistId } : "skip",
|
||||
{ initialNumItems: PAGE_SIZE }
|
||||
)
|
||||
const allSongIds = useCachedQuery(
|
||||
api.playlists.getPlaylistSongIds,
|
||||
playlistId ? { playlistId } : "skip"
|
||||
)
|
||||
const songs = playlist?.songs
|
||||
const coverUri =
|
||||
config && playlistId
|
||||
? playlistCoverUrl(config.serverUrl, playlist?.id ?? playlistId)
|
||||
: ""
|
||||
const { palette: artworkPalette, settled } = useCoverPalette(
|
||||
const { palette, settled } = useCoverPalette(
|
||||
coverUri,
|
||||
playlist ? playlist.cover != null : playlist === null ? false : undefined
|
||||
)
|
||||
const { palette, onLayout, backgroundStyle } =
|
||||
useAndroidScreenPalette(artworkPalette)
|
||||
|
||||
useEffect(() => {
|
||||
if (songs) rememberSongs(songs)
|
||||
rememberSongs(songs)
|
||||
}, [songs])
|
||||
|
||||
if (playlist === undefined || !config || !settled) {
|
||||
if (
|
||||
playlist === undefined ||
|
||||
(status === "LoadingFirstPage" && !isCached) ||
|
||||
!config ||
|
||||
!settled
|
||||
) {
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: "",
|
||||
headerLargeTitle: false,
|
||||
...(Platform.OS === "android"
|
||||
? {
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerBackground: renderAndroidArtworkBackground,
|
||||
headerBackVisible: false,
|
||||
headerLeft: renderArtworkBackButton,
|
||||
headerTintColor: palette.foreground,
|
||||
}
|
||||
: {}),
|
||||
}}
|
||||
/>
|
||||
<CollectionDetailSkeleton
|
||||
onLayout={onLayout}
|
||||
style={backgroundStyle}
|
||||
backgroundColor={
|
||||
Platform.OS === "android" ? palette.background : undefined
|
||||
}
|
||||
/>
|
||||
<CollectionDetailSkeleton />
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -137,9 +136,9 @@ export default function PlaylistScreen() {
|
||||
}}
|
||||
/>
|
||||
<View style={[styles.empty, { backgroundColor: colors.background }]}>
|
||||
<PaletteText style={{ color: colors.mutedForeground }}>
|
||||
<Text style={{ color: colors.mutedForeground }}>
|
||||
Playlist not found.
|
||||
</PaletteText>
|
||||
</Text>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
@@ -147,30 +146,32 @@ export default function PlaylistScreen() {
|
||||
|
||||
return (
|
||||
<PlaylistContent
|
||||
backgroundStyle={backgroundStyle}
|
||||
onLayout={onLayout}
|
||||
playlist={playlist}
|
||||
songs={playlist.songs}
|
||||
songs={songs}
|
||||
allSongIds={allSongIds}
|
||||
coverUri={coverUri}
|
||||
palette={palette}
|
||||
onEndReached={() => {
|
||||
if (status === "CanLoadMore") loadMore(PAGE_SIZE)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function PlaylistContent({
|
||||
backgroundStyle,
|
||||
onLayout,
|
||||
playlist,
|
||||
songs,
|
||||
allSongIds,
|
||||
coverUri,
|
||||
palette,
|
||||
onEndReached,
|
||||
}: {
|
||||
onLayout?: () => void
|
||||
backgroundStyle: ReturnType<typeof useAndroidScreenPalette>["backgroundStyle"]
|
||||
playlist: BrowsePlaylistDetail
|
||||
songs: BrowseSong[]
|
||||
allSongIds: Id<"songs">[] | undefined
|
||||
coverUri: string
|
||||
palette: CoverPalette
|
||||
onEndReached: () => void
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const isFocused = useIsFocused()
|
||||
@@ -186,15 +187,13 @@ function PlaylistContent({
|
||||
const playlistId = playlist.id
|
||||
const isSubscribed = playlist.isSubscribed
|
||||
const canEdit = playlist.isOwner && playlistId !== null
|
||||
const songIds = useMemo(() => songs.map((song) => song.id), [songs])
|
||||
const { filteredSongs, onQueryChange, onSearchSubmit } =
|
||||
usePlaylistSearch(songs)
|
||||
const loadedSongIds = useMemo(() => songs.map((song) => song.id), [songs])
|
||||
const songIds = allSongIds ?? loadedSongIds
|
||||
const swipeGroup = useSwipeRowGroup()
|
||||
|
||||
const handlePlaySong = useCallback(
|
||||
(song: BrowseSong) =>
|
||||
void playFromSong(song.id, songIds, `playlist:${playlistId}`),
|
||||
[playFromSong, songIds, playlistId]
|
||||
(song: BrowseSong) => void playFromSong(song.id, songIds),
|
||||
[playFromSong, songIds]
|
||||
)
|
||||
|
||||
const handleSongMenuAction = useCallback(
|
||||
@@ -222,12 +221,12 @@ function PlaylistContent({
|
||||
)
|
||||
|
||||
const handlePlay = useCallback(() => {
|
||||
if (playlistId) void playPlaylist(playlistId, songIds)
|
||||
}, [playPlaylist, playlistId, songIds])
|
||||
if (playlistId) void playPlaylist(playlistId, allSongIds)
|
||||
}, [allSongIds, playPlaylist, playlistId])
|
||||
|
||||
const handleShuffle = useCallback(() => {
|
||||
if (playlistId) void playPlaylistShuffled(playlistId, songIds)
|
||||
}, [playPlaylistShuffled, playlistId, songIds])
|
||||
if (playlistId) void playPlaylistShuffled(playlistId, allSongIds)
|
||||
}, [allSongIds, playPlaylistShuffled, playlistId])
|
||||
|
||||
const handleSubscribeToggle = useCallback(async () => {
|
||||
if (!playlistId) return
|
||||
@@ -270,17 +269,6 @@ function PlaylistContent({
|
||||
title: "",
|
||||
headerLargeTitle: false,
|
||||
headerTintColor: palette.foreground,
|
||||
...(Platform.OS === "android"
|
||||
? {
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerBackground: renderAndroidArtworkBackground,
|
||||
headerBackVisible: false,
|
||||
headerLeft: renderArtworkBackButton,
|
||||
statusBarStyle: palette.isDark
|
||||
? ("light" as const)
|
||||
: ("dark" as const),
|
||||
}
|
||||
: {}),
|
||||
headerRight: () => (
|
||||
<MediaActionMenu
|
||||
selectedCount={songIds.length}
|
||||
@@ -288,17 +276,15 @@ function PlaylistContent({
|
||||
share={{
|
||||
type: "playlist",
|
||||
playlistId: playlistId ?? "favorites",
|
||||
title: playlist?.title ?? "oTunes",
|
||||
}}
|
||||
includeActions={canEdit ? OWNER_MENU_ACTIONS : undefined}
|
||||
onAction={handlePlaylistMenuAction}
|
||||
>
|
||||
<Pressable hitSlop={8}>
|
||||
<PaletteIcon
|
||||
tone="foreground"
|
||||
<Ionicons
|
||||
name="ellipsis-horizontal"
|
||||
size={22}
|
||||
color={palette.isDark ? "#fff" : "#000"}
|
||||
color={palette.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
</MediaActionMenu>
|
||||
@@ -309,10 +295,7 @@ function PlaylistContent({
|
||||
deletePlaylist,
|
||||
handlePlaylistDetailAction,
|
||||
palette.foreground,
|
||||
palette.background,
|
||||
palette.isDark,
|
||||
playlistId,
|
||||
playlist?.title,
|
||||
router,
|
||||
songIds,
|
||||
])
|
||||
@@ -347,35 +330,18 @@ function PlaylistContent({
|
||||
<StatusBar style={palette.isDark ? "light" : "dark"} />
|
||||
) : null}
|
||||
<Stack.Screen options={screenOptions} />
|
||||
<PlaylistSearchBar
|
||||
onQueryChange={onQueryChange}
|
||||
onSearchSubmit={onSearchSubmit}
|
||||
/>
|
||||
<Animated.FlatList
|
||||
onLayout={onLayout}
|
||||
<FlatList
|
||||
{...longListProps}
|
||||
data={filteredSongs}
|
||||
data={songs}
|
||||
keyExtractor={songKey}
|
||||
renderItem={renderItem}
|
||||
style={[
|
||||
{ flex: 1, backgroundColor: palette.background },
|
||||
backgroundStyle,
|
||||
]}
|
||||
style={{ flex: 1, backgroundColor: palette.background }}
|
||||
indicatorStyle={palette.isDark ? "white" : "black"}
|
||||
contentContainerStyle={styles.listContent}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
onEndReached={onEndReached}
|
||||
onEndReachedThreshold={0.5}
|
||||
onScrollBeginDrag={swipeGroup.closeOpenRow}
|
||||
ListEmptyComponent={
|
||||
<PaletteText
|
||||
tone="secondaryForeground"
|
||||
style={[
|
||||
styles.emptyResults,
|
||||
{ color: palette.secondaryForeground },
|
||||
]}
|
||||
>
|
||||
{songs.length ? "No songs found." : "No songs in this playlist."}
|
||||
</PaletteText>
|
||||
}
|
||||
ListHeaderComponent={
|
||||
<PlaylistHero
|
||||
entityId={playlistId ?? "otunes:favorites"}
|
||||
@@ -468,19 +434,15 @@ const PlaylistSongRow = memo(function PlaylistSongRow({
|
||||
}}
|
||||
style={[styles.removeAction, { backgroundColor: colors.destructive }]}
|
||||
>
|
||||
<PaletteIcon
|
||||
name="trash"
|
||||
size={22}
|
||||
color={colors.primaryForeground}
|
||||
/>
|
||||
<PaletteText
|
||||
<Ionicons name="trash" size={22} color={colors.primaryForeground} />
|
||||
<Text
|
||||
style={[
|
||||
styles.removeActionText,
|
||||
{ color: colors.primaryForeground },
|
||||
]}
|
||||
>
|
||||
Remove
|
||||
</PaletteText>
|
||||
</Text>
|
||||
</Pressable>
|
||||
)}
|
||||
>
|
||||
@@ -518,18 +480,10 @@ const PlaylistHero = memo(function PlaylistHero({
|
||||
<MusicEntityView kind="playlist" id={entityId}>
|
||||
<View style={styles.hero}>
|
||||
<CoverImage uri={coverUri} hasCover={hasCover} style={styles.cover} />
|
||||
<PaletteText
|
||||
tone="foreground"
|
||||
style={[styles.title, { color: palette.foreground }]}
|
||||
>
|
||||
<Text style={[styles.title, { color: palette.foreground }]}>
|
||||
{title}
|
||||
</PaletteText>
|
||||
<PaletteText
|
||||
tone="secondaryForeground"
|
||||
style={{ color: palette.secondaryForeground }}
|
||||
>
|
||||
{ownerName}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
<Text style={{ color: palette.secondaryForeground }}>{ownerName}</Text>
|
||||
<View style={styles.actions}>
|
||||
{showSubscribe ? (
|
||||
<Pressable
|
||||
@@ -547,8 +501,7 @@ const PlaylistHero = memo(function PlaylistHero({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<PaletteIcon
|
||||
tone={isSubscribed ? "foreground" : "accentForeground"}
|
||||
<Ionicons
|
||||
name={isSubscribed ? "checkmark" : "add"}
|
||||
size={24}
|
||||
color={
|
||||
@@ -574,12 +527,7 @@ const PlaylistHero = memo(function PlaylistHero({
|
||||
onPress={onShuffle}
|
||||
style={[styles.iconAction, { backgroundColor: palette.surface }]}
|
||||
>
|
||||
<PaletteIcon
|
||||
tone="foreground"
|
||||
name="shuffle"
|
||||
size={24}
|
||||
color={palette.foreground}
|
||||
/>
|
||||
<Ionicons name="shuffle" size={24} color={palette.foreground} />
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
@@ -589,7 +537,6 @@ const PlaylistHero = memo(function PlaylistHero({
|
||||
})
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
emptyResults: { padding: spacing.lg, textAlign: "center" },
|
||||
empty: { flex: 1, alignItems: "center", justifyContent: "center" },
|
||||
listContent: { paddingBottom: contentBottomInset },
|
||||
hero: { alignItems: "center", padding: spacing.lg, gap: spacing.sm },
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
import {
|
||||
PlaylistSearchBar,
|
||||
usePlaylistSearch,
|
||||
} from "@/components/playlist-search-bar"
|
||||
import { memo, useCallback, useEffect, useMemo } from "react"
|
||||
import {
|
||||
FlatList,
|
||||
@@ -19,7 +15,10 @@ import { contentBottomInset, SongListRow } from "@/components/player"
|
||||
import { useFavorites } from "@/contexts/favorites"
|
||||
import { usePlaybackActions } from "@/contexts/playback"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||
import {
|
||||
useCachedPaginatedQuery,
|
||||
useCachedQuery,
|
||||
} from "@/hooks/use-cached-query"
|
||||
import { useMediaMenuActions } from "@/hooks/use-media-menu-actions"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import type { MediaAction } from "@/components/media-context-menu"
|
||||
@@ -30,23 +29,32 @@ import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { Stack } from "expo-router"
|
||||
|
||||
const PAGE_SIZE = 50
|
||||
const SCREEN_OPTIONS = { title: "", headerLargeTitle: false }
|
||||
|
||||
export default function FavoritesScreen() {
|
||||
const colors = useThemeColors()
|
||||
const { config } = useServerConfig()
|
||||
const favorites = useCachedQuery(api.favorites.browseFavoritesPlaylistDetail)
|
||||
const songs = favorites?.songs ?? []
|
||||
const favorites = useCachedQuery(api.favorites.browseFavoritesSummary)
|
||||
const {
|
||||
results: songs,
|
||||
status,
|
||||
loadMore,
|
||||
isCached,
|
||||
} = useCachedPaginatedQuery(
|
||||
api.favorites.browseFavoritesSongsPaginated,
|
||||
{},
|
||||
{ initialNumItems: PAGE_SIZE }
|
||||
)
|
||||
const { playInOrder, playShuffled, playFromSong } = usePlaybackActions()
|
||||
const { isSongFavorite } = useFavorites()
|
||||
const { handleSongAction } = useMediaMenuActions()
|
||||
const songIds = useMemo(() => songs.map((song) => song.id), [songs])
|
||||
const { filteredSongs, onQueryChange, onSearchSubmit } =
|
||||
usePlaylistSearch(songs)
|
||||
const loadedSongIds = useMemo(() => songs.map((song) => song.id), [songs])
|
||||
const songIds = favorites?.songIds ?? loadedSongIds
|
||||
|
||||
useEffect(() => {
|
||||
if (favorites) rememberSongs(favorites.songs)
|
||||
}, [favorites])
|
||||
rememberSongs(songs)
|
||||
}, [songs])
|
||||
|
||||
const handlePlaySong = useCallback(
|
||||
(song: BrowseSong) => void playFromSong(song.id, songIds),
|
||||
@@ -80,7 +88,11 @@ export default function FavoritesScreen() {
|
||||
[handlePlaySong, handleSongMenuAction, isSongFavorite]
|
||||
)
|
||||
|
||||
if (favorites === undefined || !config) {
|
||||
if (
|
||||
favorites === undefined ||
|
||||
(status === "LoadingFirstPage" && !isCached) ||
|
||||
!config
|
||||
) {
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen options={SCREEN_OPTIONS} />
|
||||
@@ -105,25 +117,18 @@ export default function FavoritesScreen() {
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen options={SCREEN_OPTIONS} />
|
||||
<PlaylistSearchBar
|
||||
onQueryChange={onQueryChange}
|
||||
onSearchSubmit={onSearchSubmit}
|
||||
/>
|
||||
<FlatList
|
||||
{...longListProps}
|
||||
data={filteredSongs}
|
||||
data={songs}
|
||||
keyExtractor={songKey}
|
||||
renderItem={renderItem}
|
||||
style={{ flex: 1, backgroundColor: colors.background }}
|
||||
contentContainerStyle={styles.listContent}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
ListEmptyComponent={
|
||||
<Text
|
||||
style={[styles.emptyResults, { color: colors.mutedForeground }]}
|
||||
>
|
||||
{songs.length ? "No songs found." : "No songs in this playlist."}
|
||||
</Text>
|
||||
}
|
||||
onEndReached={() => {
|
||||
if (status === "CanLoadMore") loadMore(PAGE_SIZE)
|
||||
}}
|
||||
onEndReachedThreshold={0.5}
|
||||
ListHeaderComponent={
|
||||
<FavoritesHero
|
||||
title={favorites.title}
|
||||
@@ -190,7 +195,6 @@ const FavoritesHero = memo(function FavoritesHero({
|
||||
})
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
emptyResults: { padding: spacing.lg, textAlign: "center" },
|
||||
empty: { flex: 1, alignItems: "center", justifyContent: "center" },
|
||||
listContent: { paddingBottom: contentBottomInset },
|
||||
hero: { alignItems: "center", padding: spacing.lg, gap: spacing.sm },
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { useAction, useMutation, useQuery } from "convex/react"
|
||||
import { Image } from "expo-image"
|
||||
import * as ImagePicker from "expo-image-picker"
|
||||
import { useState } from "react"
|
||||
import { router } from "expo-router"
|
||||
import {
|
||||
Platform,
|
||||
Pressable,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
@@ -376,13 +373,8 @@ function QualitySection({ user }: { user: CurrentUser }) {
|
||||
<SettingsCard title="Spatial Audio">
|
||||
<SwitchRow
|
||||
title="Prefer Dolby Atmos"
|
||||
subtitle={
|
||||
dolbyAtmosSupported
|
||||
? "Use Atmos versions when they are available."
|
||||
: "This device does not support Dolby Atmos playback."
|
||||
}
|
||||
disabled={!dolbyAtmosSupported}
|
||||
value={dolbyAtmosSupported && (user.preferAtmos ?? false)}
|
||||
subtitle="Use Atmos versions when they are available."
|
||||
value={user.preferAtmos ?? false}
|
||||
onValueChange={(checked) =>
|
||||
void updateAtmos({ preferAtmos: checked }).catch((error: Error) =>
|
||||
showError(error.message)
|
||||
@@ -466,7 +458,7 @@ function UsersSection({
|
||||
<SettingsCard title="Sign Up">
|
||||
<SwitchRow
|
||||
title="Disable account creation"
|
||||
subtitle="Stop people from registering themselves. Admins can still create accounts."
|
||||
subtitle="Stop people from registering themselves. Admins can still create accounts from the web app."
|
||||
value={appSettings?.disableAccountCreation ?? false}
|
||||
onValueChange={(checked) =>
|
||||
void setDisableCreation({ disabled: checked }).catch(
|
||||
@@ -480,10 +472,6 @@ function UsersSection({
|
||||
title="People"
|
||||
subtitle="Manage who can access this server."
|
||||
>
|
||||
<Button
|
||||
title="Create account"
|
||||
onPress={() => router.push("/(app)/create-account")}
|
||||
/>
|
||||
<View style={styles.userList}>
|
||||
{users.map((user, index) => (
|
||||
<View
|
||||
@@ -507,10 +495,7 @@ function UsersSection({
|
||||
</Text>
|
||||
{user.isAdmin ? (
|
||||
<View
|
||||
style={[
|
||||
styles.badge,
|
||||
{ backgroundColor: colors.muted },
|
||||
]}
|
||||
style={[styles.badge, { backgroundColor: colors.muted }]}
|
||||
>
|
||||
<Text
|
||||
style={[
|
||||
@@ -647,12 +632,10 @@ function SwitchRow({
|
||||
subtitle,
|
||||
value,
|
||||
onValueChange,
|
||||
disabled,
|
||||
}: {
|
||||
title: string
|
||||
subtitle?: string
|
||||
value: boolean
|
||||
disabled?: boolean
|
||||
onValueChange: (checked: boolean) => void
|
||||
}) {
|
||||
const colors = useThemeColors()
|
||||
@@ -667,17 +650,7 @@ function SwitchRow({
|
||||
<Text style={{ color: colors.mutedForeground }}>{subtitle}</Text>
|
||||
) : null}
|
||||
</View>
|
||||
<Switch
|
||||
value={value}
|
||||
disabled={disabled}
|
||||
onValueChange={onValueChange}
|
||||
{...(Platform.OS === "android"
|
||||
? {
|
||||
trackColor: { false: colors.muted, true: colors.primary },
|
||||
thumbColor: colors.foreground,
|
||||
}
|
||||
: {})}
|
||||
/>
|
||||
<Switch value={value} onValueChange={onValueChange} />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { Platform } from "react-native"
|
||||
import { useThemeColors } from "@/lib/theme"
|
||||
import { Stack } from "expo-router"
|
||||
import { useCallback } from "react"
|
||||
|
||||
@@ -7,7 +5,6 @@ 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(
|
||||
@@ -24,15 +21,6 @@ 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,
|
||||
}
|
||||
: {})}
|
||||
/>
|
||||
|
||||
<SearchResults searchQuery={searchQuery} />
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
import { router, type Href } from "expo-router"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import {
|
||||
incomingMediaLink,
|
||||
subscribeIncomingMediaLink,
|
||||
takeIncomingMediaLink,
|
||||
} from "@/lib/incoming-media-link"
|
||||
import { useConvexAuth as useLocalConvexAuth } from "@convex-dev/auth/react"
|
||||
import {
|
||||
useConvexAuth as useServerConvexAuth,
|
||||
@@ -12,7 +5,7 @@ import {
|
||||
} from "convex/react"
|
||||
import { Stack } from "expo-router"
|
||||
import { Platform } from "react-native"
|
||||
import { useEffect, useSyncExternalStore } from "react"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { AppIntentBridge } from "@/components/app-intent-bridge"
|
||||
import { ConvexAuthRecovery } from "@/components/convex-auth-recovery"
|
||||
@@ -31,18 +24,6 @@ export default function AppLayout() {
|
||||
const { isWebSocketConnected } = useConvexConnectionState()
|
||||
const { invalidateSession } = useInvalidateAuthSession()
|
||||
const stackOptions = useStackScreenOptions()
|
||||
const { config } = useServerConfig()
|
||||
const pendingDestination = useSyncExternalStore(
|
||||
subscribeIncomingMediaLink,
|
||||
() => (config ? incomingMediaLink(config.serverUrl) : null),
|
||||
() => null
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!config || !pendingDestination) return
|
||||
const destination = takeIncomingMediaLink(config.serverUrl)
|
||||
if (destination) router.replace(destination as Href)
|
||||
}, [config, pendingDestination])
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
@@ -85,8 +66,7 @@ export default function AppLayout() {
|
||||
<Stack.Screen
|
||||
name="settings"
|
||||
options={{
|
||||
headerShown: Platform.OS === "android",
|
||||
title: "Settings",
|
||||
headerShown: false,
|
||||
presentation:
|
||||
Platform.OS === "ios" ? "modal" : "fullScreenModal",
|
||||
animation: "slide_from_bottom",
|
||||
@@ -94,25 +74,14 @@ export default function AppLayout() {
|
||||
gestureDirection: "vertical",
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="create-account"
|
||||
options={{
|
||||
title: "Create account",
|
||||
presentation: "modal",
|
||||
headerLargeTitle: false,
|
||||
headerTransparent: false,
|
||||
headerStyle: { backgroundColor: "#000" },
|
||||
headerTintColor: "#fff",
|
||||
contentStyle: { backgroundColor: "#000" },
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="player"
|
||||
options={{
|
||||
headerShown: false,
|
||||
// Keep the library visible behind the custom swipe animation.
|
||||
presentation: "transparentModal",
|
||||
contentStyle: { backgroundColor: "transparent" },
|
||||
presentation:
|
||||
Platform.OS === "ios"
|
||||
? "transparentModal"
|
||||
: "fullScreenModal",
|
||||
animation: "slide_from_bottom",
|
||||
gestureEnabled: true,
|
||||
gestureDirection: "vertical",
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
import { useAction, useQuery } from "convex/react"
|
||||
import { ConvexError } from "convex/values"
|
||||
import { router, Stack } from "expo-router"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Switch,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native"
|
||||
import { SafeAreaView } from "react-native-safe-area-context"
|
||||
import { toast } from "sonner-native"
|
||||
|
||||
import { Button, Input, LoadingView } from "@/components/ui/primitives"
|
||||
import { colors, spacing } from "@/lib/theme"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
|
||||
export default function CreateAccountScreen() {
|
||||
const user = useQuery(api.auth.currentUser)
|
||||
const createUser = useAction(api.users.adminCreateUser)
|
||||
const [name, setName] = useState("")
|
||||
const [email, setEmail] = useState("")
|
||||
const [password, setPassword] = useState("")
|
||||
const [isAdmin, setIsAdmin] = useState(false)
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const pending = useRef(false)
|
||||
const mounted = useRef(true)
|
||||
|
||||
useEffect(() => {
|
||||
mounted.current = true
|
||||
return () => {
|
||||
mounted.current = false
|
||||
}
|
||||
}, [])
|
||||
|
||||
async function handleCreate() {
|
||||
if (pending.current || !user?.isAdmin) return
|
||||
setError(null)
|
||||
if (!name.trim() || !email.trim().includes("@") || password.length < 8) {
|
||||
setError(
|
||||
"Enter a name, valid email, and password of at least 8 characters."
|
||||
)
|
||||
return
|
||||
}
|
||||
pending.current = true
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await createUser({
|
||||
name: name.trim(),
|
||||
email: email.trim().toLowerCase(),
|
||||
password,
|
||||
isAdmin,
|
||||
})
|
||||
toast.success("Account created")
|
||||
if (mounted.current) router.back()
|
||||
} catch (error) {
|
||||
if (!mounted.current) return
|
||||
setError(
|
||||
error instanceof ConvexError && typeof error.data === "string"
|
||||
? error.data
|
||||
: "Could not create account. Try again."
|
||||
)
|
||||
} finally {
|
||||
pending.current = false
|
||||
if (mounted.current) setSubmitting(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView edges={["bottom", "left", "right"]} style={styles.screen}>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
gestureEnabled: !submitting,
|
||||
}}
|
||||
/>
|
||||
{user === undefined ? (
|
||||
<LoadingView />
|
||||
) : !user?.isAdmin ? (
|
||||
<Text style={[styles.text, styles.message]}>
|
||||
Admin access required.
|
||||
</Text>
|
||||
) : (
|
||||
<KeyboardAvoidingView
|
||||
style={styles.screen}
|
||||
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
||||
keyboardVerticalOffset={Platform.OS === "ios" ? 100 : 0}
|
||||
>
|
||||
<ScrollView
|
||||
contentContainerStyle={styles.form}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
keyboardDismissMode="on-drag"
|
||||
>
|
||||
<View style={styles.field}>
|
||||
<Text style={styles.label}>Name</Text>
|
||||
<Input
|
||||
accessibilityLabel="Name"
|
||||
value={name}
|
||||
onChangeText={setName}
|
||||
autoCapitalize="words"
|
||||
autoComplete="off"
|
||||
editable={!submitting}
|
||||
style={styles.input}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.field}>
|
||||
<Text style={styles.label}>Email</Text>
|
||||
<Input
|
||||
accessibilityLabel="Email"
|
||||
value={email}
|
||||
onChangeText={setEmail}
|
||||
keyboardType="email-address"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
autoComplete="off"
|
||||
editable={!submitting}
|
||||
style={styles.input}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.field}>
|
||||
<Text style={styles.label}>Password</Text>
|
||||
<Input
|
||||
accessibilityLabel="Password"
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
secureTextEntry
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
autoComplete="new-password"
|
||||
placeholder="At least 8 characters"
|
||||
editable={!submitting}
|
||||
style={styles.input}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.row}>
|
||||
<Text style={styles.text}>Grant admin access</Text>
|
||||
<Switch
|
||||
accessibilityLabel="Grant admin access"
|
||||
trackColor={{
|
||||
false: colors.dark.muted,
|
||||
true: colors.dark.primary,
|
||||
}}
|
||||
thumbColor={colors.dark.foreground}
|
||||
value={isAdmin}
|
||||
onValueChange={setIsAdmin}
|
||||
disabled={submitting}
|
||||
/>
|
||||
</View>
|
||||
{error ? (
|
||||
<Text accessibilityRole="alert" style={styles.error}>
|
||||
{error}
|
||||
</Text>
|
||||
) : null}
|
||||
<Button
|
||||
title={submitting ? "Creating account…" : "Create account"}
|
||||
disabled={submitting}
|
||||
onPress={() => void handleCreate()}
|
||||
tint={{
|
||||
background: colors.dark.primary,
|
||||
foreground: colors.dark.primaryForeground,
|
||||
}}
|
||||
/>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
)}
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
screen: { flex: 1, backgroundColor: "#000" },
|
||||
form: { padding: spacing.lg, gap: spacing.lg },
|
||||
field: { gap: spacing.sm },
|
||||
label: {
|
||||
color: colors.dark.mutedForeground,
|
||||
fontSize: 12,
|
||||
fontWeight: "600",
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: 0.6,
|
||||
},
|
||||
text: { color: colors.dark.foreground, fontSize: 16, flexShrink: 1 },
|
||||
input: {
|
||||
backgroundColor: colors.dark.muted,
|
||||
color: colors.dark.foreground,
|
||||
borderColor: colors.dark.border,
|
||||
},
|
||||
row: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: spacing.md,
|
||||
minHeight: 48,
|
||||
},
|
||||
message: { padding: spacing.lg },
|
||||
error: { color: colors.dark.destructive, fontSize: 14, lineHeight: 20 },
|
||||
})
|
||||
@@ -1,7 +1,5 @@
|
||||
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||
import { NavigationBar } from "expo-navigation-bar"
|
||||
import { MusicEntityView } from "@/components/music-entity-view"
|
||||
import { Stack, useRouter } from "expo-router"
|
||||
import { useRouter } from "expo-router"
|
||||
import * as Haptics from "expo-haptics"
|
||||
import { StatusBar } from "expo-status-bar"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
@@ -31,7 +29,6 @@ import { api } from "@otunes/convex/_generated/api"
|
||||
import { playbackFormat } from "@otunes/convex/playback-stream"
|
||||
|
||||
import { AudioFormatBadge } from "@/components/audio-format-badge"
|
||||
import { AudioOutputButton } from "@/components/audio-output-button"
|
||||
import { CoverImage } from "@/components/cover-image"
|
||||
import { MarqueeText } from "@/components/marquee-text"
|
||||
import {
|
||||
@@ -50,7 +47,6 @@ import { useServerConfig } from "@/contexts/server-config"
|
||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||
import { useCoverPalette } from "@/hooks/use-cover-palette"
|
||||
import { useMediaMenuActions } from "@/hooks/use-media-menu-actions"
|
||||
import { useSystemVolume } from "@/hooks/use-system-volume"
|
||||
import { formatDuration, formatRemainingDuration } from "@/lib/format"
|
||||
import {
|
||||
nowPlayingColors,
|
||||
@@ -84,15 +80,15 @@ export default function PlayerScreen() {
|
||||
repeatEnabled,
|
||||
currentTime,
|
||||
duration,
|
||||
volume,
|
||||
queueSongIds,
|
||||
setIsPlaying,
|
||||
setVolume,
|
||||
seekTo,
|
||||
skipNext,
|
||||
skipPrevious,
|
||||
} = usePlayback()
|
||||
const { volume, setVolume, available: volumeAvailable } = useSystemVolume()
|
||||
const [showQueue, setShowQueue] = useState(false)
|
||||
const [isDismissing, setIsDismissing] = useState(false)
|
||||
const [stageHeight, setStageHeight] = useState(0)
|
||||
const [scrubTime, setScrubTime] = useState<number | null>(null)
|
||||
const user = useCachedQuery(api.auth.currentUser)
|
||||
@@ -105,7 +101,7 @@ export default function PlayerScreen() {
|
||||
? playbackFormat(
|
||||
playbackInfo.files,
|
||||
user.playbackQuality,
|
||||
dolbyAtmosSupported && (user.preferAtmos ?? false)
|
||||
user.preferAtmos ?? false
|
||||
)
|
||||
: null
|
||||
|
||||
@@ -164,7 +160,6 @@ export default function PlayerScreen() {
|
||||
event.translationY > DISMISS_DISTANCE ||
|
||||
event.velocityY > DISMISS_VELOCITY
|
||||
) {
|
||||
scheduleOnRN(setIsDismissing, true)
|
||||
dismissY.value = withTiming(
|
||||
windowHeight,
|
||||
{ duration: 220 },
|
||||
@@ -221,18 +216,6 @@ export default function PlayerScreen() {
|
||||
return (
|
||||
<Animated.View style={[styles.root, backgroundStyle, dismissStyle]}>
|
||||
<StatusBar style={colors.isDark ? "light" : "dark"} />
|
||||
{Platform.OS === "android" ? (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
statusBarStyle: colors.isDark ? "light" : "dark",
|
||||
// The swipe already animates the player offscreen.
|
||||
animation: isDismissing ? "none" : "slide_from_bottom",
|
||||
}}
|
||||
/>
|
||||
<NavigationBar style={colors.isDark ? "light" : "dark"} />
|
||||
</>
|
||||
) : null}
|
||||
|
||||
<MusicEntityView
|
||||
kind="song"
|
||||
@@ -394,35 +377,31 @@ export default function PlayerScreen() {
|
||||
</TransportButton>
|
||||
</View>
|
||||
|
||||
{volumeAvailable ? (
|
||||
<PlayerSlider
|
||||
accessibilityLabel="Volume"
|
||||
commitHoldMs={0}
|
||||
animateValueChanges
|
||||
value={volume}
|
||||
maximumValue={1}
|
||||
fillColor={colors.sliderFill}
|
||||
activeFillColor={colors.foreground}
|
||||
trackColor={colors.sliderTrack}
|
||||
onValueChange={setVolume}
|
||||
leading={
|
||||
<PlayerSymbol
|
||||
name="speaker.fill"
|
||||
fallback="volume-low"
|
||||
size={14}
|
||||
color={colors.secondaryForeground}
|
||||
/>
|
||||
}
|
||||
trailing={
|
||||
<PlayerSymbol
|
||||
name="speaker.wave.3.fill"
|
||||
fallback="volume-high"
|
||||
size={14}
|
||||
color={colors.secondaryForeground}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
<PlayerSlider
|
||||
accessibilityLabel="Volume"
|
||||
value={volume}
|
||||
maximumValue={1}
|
||||
fillColor={colors.sliderFill}
|
||||
activeFillColor={colors.foreground}
|
||||
trackColor={colors.sliderTrack}
|
||||
onValueChange={setVolume}
|
||||
leading={
|
||||
<PlayerSymbol
|
||||
name="speaker.fill"
|
||||
fallback="volume-low"
|
||||
size={14}
|
||||
color={colors.secondaryForeground}
|
||||
/>
|
||||
}
|
||||
trailing={
|
||||
<PlayerSymbol
|
||||
name="speaker.wave.3.fill"
|
||||
fallback="volume-high"
|
||||
size={14}
|
||||
color={colors.secondaryForeground}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
<View style={styles.footer}>
|
||||
<Pressable
|
||||
@@ -440,10 +419,21 @@ export default function PlayerScreen() {
|
||||
color={colors.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
<AudioOutputButton
|
||||
color={colors.foreground}
|
||||
style={styles.queueButton}
|
||||
/>
|
||||
<Pressable
|
||||
disabled
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={Platform.OS === "ios" ? "AirPlay" : "Cast"}
|
||||
accessibilityState={{ disabled: true }}
|
||||
style={[styles.queueButton, styles.unavailable]}
|
||||
>
|
||||
<PlayerSymbol
|
||||
name="airplay.audio"
|
||||
fallback={{ material: "cast" }}
|
||||
size={27}
|
||||
weight="semibold"
|
||||
color={colors.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
onPress={toggleQueue}
|
||||
hitSlop={8}
|
||||
|
||||
@@ -1,16 +1 @@
|
||||
import { Platform } from "react-native"
|
||||
import { SafeAreaView } from "react-native-safe-area-context"
|
||||
|
||||
import SettingsScreen from "./(tabs)/home/settings"
|
||||
|
||||
export default function Settings() {
|
||||
if (Platform.OS !== "android") return <SettingsScreen />
|
||||
return (
|
||||
<SafeAreaView
|
||||
edges={["bottom", "left", "right"]}
|
||||
style={{ flex: 1, backgroundColor: "#000" }}
|
||||
>
|
||||
<SettingsScreen />
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
export { default } from "./(tabs)/home/settings"
|
||||
@@ -1,54 +0,0 @@
|
||||
import { loadServerConfig, parseServerHostname } from "@/lib/server-config"
|
||||
import { secureGetItem } from "@/lib/auth-storage"
|
||||
import { rememberIncomingMediaLink } from "@/lib/incoming-media-link"
|
||||
import { showError } from "@/lib/toast"
|
||||
|
||||
export async function redirectSystemPath({
|
||||
path,
|
||||
}: {
|
||||
path: string
|
||||
initial: boolean
|
||||
}) {
|
||||
try {
|
||||
const link = new URL(path, "otunes:///")
|
||||
if (
|
||||
!["otunes:", "otunes-development:", "otunes-preview:"].includes(
|
||||
link.protocol
|
||||
) ||
|
||||
link.hostname !== "open"
|
||||
) {
|
||||
return path
|
||||
}
|
||||
|
||||
const target = new URL(link.searchParams.get("url") ?? "")
|
||||
const server = parseServerHostname(target.host)
|
||||
if (
|
||||
!server ||
|
||||
!["https:", "http:"].includes(target.protocol) ||
|
||||
target.username ||
|
||||
target.password ||
|
||||
new URL(server.serverUrl).origin !== target.origin ||
|
||||
!/^\/(album|artist|playlist)\/[a-zA-Z0-9_-]+$/.test(target.pathname)
|
||||
) {
|
||||
return "/"
|
||||
}
|
||||
|
||||
const config = await loadServerConfig(secureGetItem)
|
||||
if (config && new URL(config.serverUrl).origin !== target.origin) {
|
||||
showError("This link belongs to a different oTunes server")
|
||||
return "/"
|
||||
}
|
||||
|
||||
const query = new URLSearchParams()
|
||||
const songId = target.searchParams.get("s")
|
||||
if (target.pathname.startsWith("/album/") && songId) query.set("s", songId)
|
||||
const suffix = query.size ? `?${query}` : ""
|
||||
const destination = `/(app)/(tabs)/home${target.pathname}${suffix}`
|
||||
rememberIncomingMediaLink(destination, target.origin)
|
||||
return config
|
||||
? destination
|
||||
: `/server?hostname=${encodeURIComponent(server.hostname)}`
|
||||
} catch {
|
||||
return "/"
|
||||
}
|
||||
}
|
||||
@@ -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 { useIsDark } from "@/lib/theme"
|
||||
import { useColorScheme } from "react-native"
|
||||
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 isDark = useIsDark()
|
||||
const colorScheme = useColorScheme()
|
||||
|
||||
return (
|
||||
<GestureHandlerRootView style={{ flex: 1, backgroundColor: "#000" }}>
|
||||
<SafeAreaProvider>
|
||||
<ServerConfigProvider>
|
||||
<ConvexAppProvider>
|
||||
<StatusBar style={isDark ? "light" : "dark"} />
|
||||
<StatusBar style={colorScheme === "dark" ? "light" : "dark"} />
|
||||
<ThemeProvider value={navigationTheme}>
|
||||
<RootNavigator />
|
||||
</ThemeProvider>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useConvexAuth } from "@convex-dev/auth/react"
|
||||
import { incomingMediaLink } from "@/lib/incoming-media-link"
|
||||
import { Redirect, type Href } from "expo-router"
|
||||
import { Redirect } from "expo-router"
|
||||
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
|
||||
@@ -12,16 +11,9 @@ export default function Index() {
|
||||
return <Redirect href="/server" />
|
||||
}
|
||||
|
||||
const destination = auth?.isAuthenticated
|
||||
? incomingMediaLink(config.serverUrl)
|
||||
: null
|
||||
|
||||
return (
|
||||
<Redirect
|
||||
href={
|
||||
(destination as Href) ??
|
||||
(auth?.isAuthenticated ? "/(app)/(tabs)/library" : "/signin")
|
||||
}
|
||||
href={auth?.isAuthenticated ? "/(app)/(tabs)/library" : "/signin"}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
import { useLocalSearchParams } from "expo-router"
|
||||
import { useEffect, useState } from "react"
|
||||
import { StyleSheet, Text, View } from "react-native"
|
||||
import { useState } from "react"
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
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"
|
||||
@@ -12,14 +15,7 @@ import { spacing, useThemeColors } from "@/lib/theme"
|
||||
export default function ServerScreen() {
|
||||
const colors = useThemeColors()
|
||||
const { setServerHostname } = useServerConfig()
|
||||
const { hostname: linkedHostname } = useLocalSearchParams<{
|
||||
hostname?: string
|
||||
}>()
|
||||
const [hostname, setHostname] = useState(linkedHostname ?? "")
|
||||
useEffect(() => {
|
||||
if (linkedHostname) setHostname(linkedHostname)
|
||||
}, [linkedHostname])
|
||||
|
||||
const [hostname, setHostname] = useState("")
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
|
||||
@@ -45,7 +41,10 @@ export default function ServerScreen() {
|
||||
|
||||
return (
|
||||
<SafeAreaView style={[styles.safe, { backgroundColor: colors.background }]}>
|
||||
<KeyboardForm style={styles.container}>
|
||||
<KeyboardAvoidingView
|
||||
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
||||
style={styles.container}
|
||||
>
|
||||
<View style={styles.hero}>
|
||||
<Text style={[styles.brand, { color: colors.foreground }]}>
|
||||
oTunes
|
||||
@@ -83,7 +82,7 @@ export default function ServerScreen() {
|
||||
onPress={() => void handleContinue()}
|
||||
/>
|
||||
</Card>
|
||||
</KeyboardForm>
|
||||
</KeyboardAvoidingView>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 310 KiB |
|
Before Width: | Height: | Size: 286 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 963 KiB |
@@ -26,7 +26,7 @@
|
||||
"image-name" : "music.note.png",
|
||||
"name" : "music.note",
|
||||
"position" : {
|
||||
"scale" : 1.5,
|
||||
"scale" : 1,
|
||||
"translation-in-points" : [
|
||||
0,
|
||||
0
|
||||
|
||||
|
Before Width: | Height: | Size: 8.8 KiB |
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"fill" : {
|
||||
"linear-gradient" : [
|
||||
"display-p3:0.00000,0.55106,0.91748,1.00000",
|
||||
"display-p3:0.00320,0.24546,0.91602,1.00000"
|
||||
]
|
||||
},
|
||||
"groups" : [
|
||||
{
|
||||
"layers" : [
|
||||
{
|
||||
"fill-specializations" : [
|
||||
{
|
||||
"value" : "automatic"
|
||||
},
|
||||
{
|
||||
"appearance" : "dark",
|
||||
"value" : {
|
||||
"linear-gradient" : [
|
||||
"display-p3:0.00000,0.55106,0.91748,1.00000",
|
||||
"display-p3:0.00320,0.24546,0.91602,1.00000"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"image-name" : "music.note.png",
|
||||
"name" : "music.note",
|
||||
"position" : {
|
||||
"scale" : 1.5,
|
||||
"translation-in-points" : [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"shadow" : {
|
||||
"kind" : "neutral",
|
||||
"opacity" : 0.6
|
||||
},
|
||||
"translucency" : {
|
||||
"enabled" : false,
|
||||
"value" : 0.2
|
||||
}
|
||||
}
|
||||
],
|
||||
"supported-platforms" : {
|
||||
"circles" : [
|
||||
"watchOS"
|
||||
],
|
||||
"squares" : "shared"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 8.8 KiB |
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"fill" : {
|
||||
"linear-gradient" : [
|
||||
"display-p3:0.03297,0.65562,0.91748,1.00000",
|
||||
"display-p3:0.01787,0.85470,0.91602,1.00000"
|
||||
]
|
||||
},
|
||||
"groups" : [
|
||||
{
|
||||
"layers" : [
|
||||
{
|
||||
"fill-specializations" : [
|
||||
{
|
||||
"value" : "automatic"
|
||||
},
|
||||
{
|
||||
"appearance" : "dark",
|
||||
"value" : {
|
||||
"linear-gradient" : [
|
||||
"display-p3:0.03297,0.65562,0.91748,1.00000",
|
||||
"display-p3:0.01787,0.85470,0.91602,1.00000"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"image-name" : "music.note.png",
|
||||
"name" : "music.note",
|
||||
"position" : {
|
||||
"scale" : 1.5,
|
||||
"translation-in-points" : [
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"shadow" : {
|
||||
"kind" : "neutral",
|
||||
"opacity" : 0.6
|
||||
},
|
||||
"translucency" : {
|
||||
"enabled" : false,
|
||||
"value" : 0.2
|
||||
}
|
||||
}
|
||||
],
|
||||
"supported-platforms" : {
|
||||
"circles" : [
|
||||
"watchOS"
|
||||
],
|
||||
"squares" : "shared"
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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 (
|
||||
<KeyboardAvoidingView behavior="height" style={{ flex: 1 }}>
|
||||
<SafeAreaView edges={["bottom", "left", "right"]} style={{ flex: 1 }}>
|
||||
{children}
|
||||
</SafeAreaView>
|
||||
</KeyboardAvoidingView>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { PaletteText } from "@/components/palette-text"
|
||||
import { StyleSheet, View } from "react-native"
|
||||
import { StyleSheet, Text, View } from "react-native"
|
||||
import Svg, { G, Path } from "react-native-svg"
|
||||
|
||||
import type { PlaybackFormat } from "@otunes/convex/playback-stream"
|
||||
@@ -75,12 +74,10 @@ function LosslessMark({
|
||||
|
||||
/** The Dolby Atmos or Lossless label shown under the progress bar. */
|
||||
export function AudioFormatBadge({
|
||||
artwork = false,
|
||||
format,
|
||||
color,
|
||||
backgroundColor,
|
||||
}: {
|
||||
artwork?: boolean
|
||||
format: PlaybackFormat
|
||||
color: string
|
||||
backgroundColor: string
|
||||
@@ -93,12 +90,7 @@ export function AudioFormatBadge({
|
||||
) : (
|
||||
<LosslessMark color={color} backgroundColor={backgroundColor} />
|
||||
)}
|
||||
<PaletteText
|
||||
tone={artwork ? "secondaryForeground" : undefined}
|
||||
style={[styles.label, { color }]}
|
||||
>
|
||||
{label}
|
||||
</PaletteText>
|
||||
<Text style={[styles.label, { color }]}>{label}</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
import {
|
||||
requireNativeView,
|
||||
requireOptionalNativeModule,
|
||||
type NativeModule,
|
||||
} from "expo"
|
||||
import {
|
||||
Platform,
|
||||
Pressable,
|
||||
type StyleProp,
|
||||
type ViewProps,
|
||||
type ViewStyle,
|
||||
} from "react-native"
|
||||
|
||||
import { PlayerSymbol } from "@/components/player-symbol"
|
||||
import { showError } from "@/lib/toast"
|
||||
|
||||
type AudioOutputModule = NativeModule & {
|
||||
showPicker: () => Promise<boolean>
|
||||
}
|
||||
|
||||
const audioOutput =
|
||||
requireOptionalNativeModule<AudioOutputModule>("AudioOutput")
|
||||
const AirPlayPicker =
|
||||
Platform.OS === "ios" && audioOutput
|
||||
? requireNativeView<ViewProps & { tint: string }>("AudioOutput")
|
||||
: null
|
||||
|
||||
export function AudioOutputButton({
|
||||
color,
|
||||
style,
|
||||
}: {
|
||||
color: string
|
||||
style: StyleProp<ViewStyle>
|
||||
}) {
|
||||
if (AirPlayPicker) {
|
||||
return <AirPlayPicker tint={color} style={style} />
|
||||
}
|
||||
|
||||
const available =
|
||||
Platform.OS === "android" && Platform.Version >= 33 && audioOutput !== null
|
||||
|
||||
async function showPicker() {
|
||||
try {
|
||||
if (!(await audioOutput?.showPicker())) {
|
||||
showError("Audio output selection is unavailable on this device.")
|
||||
}
|
||||
} catch {
|
||||
showError("Audio output selection could not be opened.")
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
onPress={showPicker}
|
||||
disabled={!available}
|
||||
hitSlop={8}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={Platform.OS === "ios" ? "AirPlay" : "Audio output"}
|
||||
accessibilityState={{ disabled: !available }}
|
||||
style={[style, !available && { opacity: 0.35 }]}
|
||||
>
|
||||
<PlayerSymbol
|
||||
name="airplay.audio"
|
||||
fallback={{ material: "cast" }}
|
||||
size={27}
|
||||
weight="semibold"
|
||||
color={color}
|
||||
/>
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
@@ -2,11 +2,16 @@ import { useAuthActions } from "@convex-dev/auth/react"
|
||||
import { Link } from "expo-router"
|
||||
import { useQuery } from "convex/react"
|
||||
import { useState } from "react"
|
||||
import { Pressable, StyleSheet, Text, View } from "react-native"
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
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"
|
||||
@@ -87,15 +92,14 @@ export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
|
||||
return (
|
||||
<SafeAreaView style={[styles.safe, { backgroundColor: colors.background }]}>
|
||||
<KeyboardForm style={styles.container}>
|
||||
<KeyboardAvoidingView
|
||||
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
||||
style={styles.container}
|
||||
>
|
||||
<Card>
|
||||
<View style={styles.header}>
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>
|
||||
{text.title}
|
||||
</Text>
|
||||
<Text
|
||||
style={[styles.description, { color: colors.mutedForeground }]}
|
||||
>
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>{text.title}</Text>
|
||||
<Text style={[styles.description, { color: colors.mutedForeground }]}>
|
||||
{text.description}
|
||||
</Text>
|
||||
{config ? (
|
||||
@@ -107,8 +111,8 @@ export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
|
||||
{signupsDisabled ? (
|
||||
<Text style={{ color: colors.mutedForeground }}>
|
||||
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.
|
||||
</Text>
|
||||
) : (
|
||||
<View style={styles.form}>
|
||||
@@ -133,28 +137,16 @@ export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
onChangeText={setPassword}
|
||||
placeholder="Password"
|
||||
secureTextEntry
|
||||
autoComplete={
|
||||
flow === "signIn" ? "current-password" : "new-password"
|
||||
}
|
||||
/>
|
||||
{error ? (
|
||||
<Text style={{ color: colors.destructive }}>{error}</Text>
|
||||
) : null}
|
||||
<Button
|
||||
title={text.submit}
|
||||
loading={submitting}
|
||||
onPress={() => void handleSubmit()}
|
||||
autoComplete={flow === "signIn" ? "current-password" : "new-password"}
|
||||
/>
|
||||
{error ? <Text style={{ color: colors.destructive }}>{error}</Text> : null}
|
||||
<Button title={text.submit} loading={submitting} onPress={() => void handleSubmit()} />
|
||||
{!hideSignUpLink ? (
|
||||
<View style={styles.switchRow}>
|
||||
<Text style={{ color: colors.mutedForeground }}>
|
||||
{text.switchPrompt}{" "}
|
||||
</Text>
|
||||
<Text style={{ color: colors.mutedForeground }}>{text.switchPrompt} </Text>
|
||||
<Link href={text.switchHref} asChild>
|
||||
<Pressable>
|
||||
<Text
|
||||
style={{ color: colors.foreground, fontWeight: "600" }}
|
||||
>
|
||||
<Text style={{ color: colors.foreground, fontWeight: "600" }}>
|
||||
{text.switchLabel}
|
||||
</Text>
|
||||
</Pressable>
|
||||
@@ -175,7 +167,7 @@ export function AuthForm({ flow }: { flow: AuthFlow }) {
|
||||
>
|
||||
<Text style={{ color: colors.mutedForeground }}>Change server</Text>
|
||||
</Pressable>
|
||||
</KeyboardForm>
|
||||
</KeyboardAvoidingView>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { PaletteText } from "@/components/palette-text"
|
||||
import { memo } from "react"
|
||||
import { StyleSheet, View } from "react-native"
|
||||
import { StyleSheet, Text, View } from "react-native"
|
||||
|
||||
import { useThemeColors } from "@/lib/theme"
|
||||
|
||||
@@ -26,12 +25,9 @@ export const DiscHeader = memo(function DiscHeader({
|
||||
}) {
|
||||
const colors = useThemeColors()
|
||||
return (
|
||||
<PaletteText
|
||||
tone={color ? "foreground" : undefined}
|
||||
style={[styles.discHeader, { color: color ?? colors.foreground }]}
|
||||
>
|
||||
<Text style={[styles.discHeader, { color: color ?? colors.foreground }]}>
|
||||
{label}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Ionicons } from "@expo/vector-icons"
|
||||
import { Image, type ImageContentFit, type ImageStyle } from "expo-image"
|
||||
import { memo, useMemo } from "react"
|
||||
import {
|
||||
Platform,
|
||||
PixelRatio,
|
||||
StyleProp,
|
||||
StyleSheet,
|
||||
@@ -10,8 +9,6 @@ import {
|
||||
type ViewStyle,
|
||||
} from "react-native"
|
||||
|
||||
import { prefetchCoverPalette } from "@/hooks/use-cover-palette"
|
||||
|
||||
import { useThemeColors } from "@/lib/theme"
|
||||
import {
|
||||
coverImageSizes,
|
||||
@@ -109,9 +106,6 @@ export const CoverImage = memo(function CoverImage({
|
||||
contentFit={contentFit}
|
||||
transition={150}
|
||||
blurRadius={blurRadius}
|
||||
onLoad={
|
||||
Platform.OS === "android" ? () => prefetchCoverPalette(uri) : undefined
|
||||
}
|
||||
cachePolicy="memory-disk"
|
||||
recyclingKey={sourceUri}
|
||||
enforceEarlyResizing
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import type { PropsWithChildren } from "react"
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
ScrollView,
|
||||
type StyleProp,
|
||||
type ViewStyle,
|
||||
} from "react-native"
|
||||
|
||||
/** Android resizes for the IME; scrolling keeps tall forms and actions reachable. */
|
||||
export function KeyboardForm({
|
||||
children,
|
||||
style,
|
||||
}: PropsWithChildren<{ style?: StyleProp<ViewStyle> }>) {
|
||||
if (Platform.OS === "android") {
|
||||
return (
|
||||
<ScrollView
|
||||
style={{ flex: 1 }}
|
||||
contentContainerStyle={[style, { flex: undefined, flexGrow: 1 }]}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
keyboardDismissMode="on-drag"
|
||||
>
|
||||
{children}
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<KeyboardAvoidingView behavior="padding" style={style}>
|
||||
{children}
|
||||
</KeyboardAvoidingView>
|
||||
)
|
||||
}
|
||||
@@ -3,9 +3,7 @@ import { Ionicons } from "@expo/vector-icons"
|
||||
import { memo, useCallback, type ReactElement } from "react"
|
||||
import {
|
||||
FlatList,
|
||||
Platform,
|
||||
Pressable,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
@@ -35,7 +33,6 @@ import {
|
||||
export type MediaItem = BrowseAlbum | BrowseArtist | PlaylistSummary
|
||||
|
||||
const GRID_INITIAL_ROWS = 5
|
||||
const MAX_NON_VIRTUAL_CAROUSEL_ITEMS = 10
|
||||
|
||||
export const AlbumCard = memo(function AlbumCard({
|
||||
album,
|
||||
@@ -80,7 +77,7 @@ export const AlbumCard = memo(function AlbumCard({
|
||||
favorited={isAlbumFavorite(album.id)}
|
||||
stationArtistId={album.artist.id}
|
||||
navigation={{ artist: { id: album.artist.id } }}
|
||||
share={{ type: "album", albumId: album.id, title: album.title }}
|
||||
share={{ type: "album", albumId: album.id }}
|
||||
onAction={(action) => void handleAlbumAction(album, action)}
|
||||
>
|
||||
<MusicEntityView kind="album" id={album.id}>
|
||||
@@ -125,7 +122,7 @@ export const ArtistCard = memo(function ArtistCard({
|
||||
return (
|
||||
<MediaContextMenu
|
||||
favorited={isArtistFavorite(artist.id)}
|
||||
share={{ type: "artist", artistId: artist.id, title: artist.name }}
|
||||
share={{ type: "artist", artistId: artist.id }}
|
||||
onAction={(action) => void handleArtistAction(artist, action)}
|
||||
>
|
||||
<MusicEntityView kind="artist" id={artist.id}>
|
||||
@@ -176,11 +173,7 @@ export const PlaylistCard = memo(function PlaylistCard({
|
||||
return (
|
||||
<MediaContextMenu
|
||||
showFavorite={false}
|
||||
share={{
|
||||
type: "playlist",
|
||||
playlistId: playlist.id,
|
||||
title: playlist.title,
|
||||
}}
|
||||
share={{ type: "playlist", playlistId: playlist.id }}
|
||||
onAction={(action) => void handlePlaylistAction(playlist, action)}
|
||||
>
|
||||
<MusicEntityView kind="playlist" id={playlist.id}>
|
||||
@@ -313,30 +306,14 @@ function ContentCarouselBody({
|
||||
/>
|
||||
) : null}
|
||||
</Pressable>
|
||||
{Platform.OS === "android" &&
|
||||
content.length <= MAX_NON_VIRTUAL_CAROUSEL_ITEMS ? (
|
||||
<ScrollView
|
||||
horizontal
|
||||
style={styles.androidCarousel}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
contentContainerStyle={styles.carouselContent}
|
||||
>
|
||||
{content.map((item) => (
|
||||
<View key={mediaItemKey(item)}>
|
||||
<CarouselCard item={item} width={carouselCardWidth} />
|
||||
</View>
|
||||
))}
|
||||
</ScrollView>
|
||||
) : (
|
||||
<FlatList
|
||||
data={content}
|
||||
keyExtractor={mediaItemKey}
|
||||
renderItem={renderCarouselItem}
|
||||
horizontal
|
||||
showsHorizontalScrollIndicator={false}
|
||||
contentContainerStyle={styles.carouselContent}
|
||||
/>
|
||||
)}
|
||||
<FlatList
|
||||
data={content}
|
||||
keyExtractor={mediaItemKey}
|
||||
renderItem={renderCarouselItem}
|
||||
horizontal
|
||||
showsHorizontalScrollIndicator={false}
|
||||
contentContainerStyle={styles.carouselContent}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -366,10 +343,6 @@ const styles = StyleSheet.create({
|
||||
fontSize: 22,
|
||||
fontWeight: "700",
|
||||
},
|
||||
androidCarousel: {
|
||||
// Horizontal lists should measure their cards, not stretch the Home sections.
|
||||
flexGrow: 0,
|
||||
},
|
||||
carouselContent: {
|
||||
gap: spacing.md,
|
||||
},
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { MenuAction } from "@expo/ui/community/menu"
|
||||
import { MenuView } from "@/components/media-menu"
|
||||
import { MenuView, type MenuAction } from "@expo/ui/community/menu"
|
||||
import { requireNativeView } from "expo"
|
||||
import type { ComponentType, ReactNode } from "react"
|
||||
import {
|
||||
@@ -172,7 +171,8 @@ export function buildMediaMenuActions(
|
||||
actions.push({
|
||||
id: item.action,
|
||||
title: item.label(countSuffix, favorited, playlistLabel),
|
||||
image: item.action === "favorite" && favorited ? "star.fill" : item.image,
|
||||
image:
|
||||
item.action === "favorite" && favorited ? "star.fill" : item.image,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import type { ComponentProps } from "react"
|
||||
import type { MediaAction } from "@/components/media-context-menu"
|
||||
import type { MenuComponentProps } from "@expo/ui/community/menu"
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuItem,
|
||||
Host,
|
||||
RNHostView,
|
||||
Text,
|
||||
} from "@expo/ui/jetpack-compose"
|
||||
import { useState } from "react"
|
||||
import { Pressable, View } from "react-native"
|
||||
import { Gesture, GestureDetector } from "react-native-gesture-handler"
|
||||
|
||||
import { appleMusic } from "@/lib/theme"
|
||||
|
||||
const actionIcons = {
|
||||
share: "share-outline",
|
||||
playlist: "list-outline",
|
||||
"play-next": "play-forward-outline",
|
||||
"play-last": "list",
|
||||
shuffle: "shuffle",
|
||||
"create-station": "radio-outline",
|
||||
favorite: "star-outline",
|
||||
"go-artist": "person-outline",
|
||||
"go-album": "disc-outline",
|
||||
"delete-playlist": "trash-outline",
|
||||
} satisfies Record<MediaAction, ComponentProps<typeof Ionicons>["name"]>
|
||||
|
||||
// The community MenuView creates a dynamic-color Host internally. Own this
|
||||
// Android host so menus use the same fixed palette as the rest of the app.
|
||||
export function MenuView({
|
||||
actions,
|
||||
children,
|
||||
style,
|
||||
shouldOpenOnLongPress,
|
||||
onPressAction,
|
||||
}: MenuComponentProps) {
|
||||
const [expanded, setExpanded] = useState(false)
|
||||
const longPress = Gesture.LongPress()
|
||||
.runOnJS(true)
|
||||
.onStart(() => setExpanded(true))
|
||||
return (
|
||||
<View style={style}>
|
||||
<Host
|
||||
colorScheme="dark"
|
||||
seedColor={appleMusic.pink}
|
||||
colorOverrides={{
|
||||
primary: appleMusic.pink,
|
||||
onPrimary: "#FFFFFF",
|
||||
surface: "#000000",
|
||||
onSurface: "#FFFFFF",
|
||||
onSurfaceVariant: "#FFFFFF",
|
||||
surfaceContainer: "#1C1C1E",
|
||||
surfaceContainerHigh: "#1C1C1E",
|
||||
surfaceTint: "#000000",
|
||||
outline: "#545458",
|
||||
outlineVariant: "#545458",
|
||||
error: "#FF453A",
|
||||
}}
|
||||
// Rows fill their parent width; compact action buttons keep intrinsic sizing.
|
||||
matchContents={shouldOpenOnLongPress ? { vertical: true } : true}
|
||||
>
|
||||
<DropdownMenu
|
||||
expanded={expanded}
|
||||
onDismissRequest={() => setExpanded(false)}
|
||||
color={appleMusic.elevated}
|
||||
cornerRadius={4}
|
||||
shadowElevation={0}
|
||||
properties={{ clippingEnabled: false }}
|
||||
>
|
||||
<DropdownMenu.Trigger>
|
||||
<RNHostView
|
||||
matchContents={shouldOpenOnLongPress ? { vertical: true } : true}
|
||||
>
|
||||
{shouldOpenOnLongPress ? (
|
||||
<GestureDetector gesture={longPress}>
|
||||
<View collapsable={false}>{children}</View>
|
||||
</GestureDetector>
|
||||
) : (
|
||||
<Pressable
|
||||
onPress={() => setExpanded(true)}
|
||||
accessible={false}
|
||||
focusable={false}
|
||||
android_disableSound
|
||||
>
|
||||
<View pointerEvents="none">{children}</View>
|
||||
</Pressable>
|
||||
)}
|
||||
</RNHostView>
|
||||
</DropdownMenu.Trigger>
|
||||
<DropdownMenu.Items>
|
||||
{actions
|
||||
.filter((action) => !action.attributes?.hidden)
|
||||
.map((action) => (
|
||||
<DropdownMenuItem
|
||||
key={action.id ?? action.title}
|
||||
enabled={!action.attributes?.disabled}
|
||||
elementColors={{
|
||||
textColor: action.attributes?.destructive
|
||||
? "#FF453A"
|
||||
: "#FFFFFF",
|
||||
}}
|
||||
onClick={() => {
|
||||
setExpanded(false)
|
||||
onPressAction?.({
|
||||
nativeEvent: { event: action.id ?? action.title },
|
||||
})
|
||||
}}
|
||||
>
|
||||
<DropdownMenuItem.LeadingIcon>
|
||||
<RNHostView matchContents>
|
||||
<Ionicons
|
||||
name={
|
||||
action.id === "favorite" &&
|
||||
action.image === "star.fill"
|
||||
? "star"
|
||||
: (actionIcons[action.id as MediaAction] ??
|
||||
"ellipsis-horizontal")
|
||||
}
|
||||
size={20}
|
||||
color={
|
||||
action.attributes?.destructive ? "#FF453A" : "#FFFFFF"
|
||||
}
|
||||
accessible={false}
|
||||
/>
|
||||
</RNHostView>
|
||||
</DropdownMenuItem.LeadingIcon>
|
||||
<DropdownMenuItem.Text>
|
||||
<Text>{action.title}</Text>
|
||||
</DropdownMenuItem.Text>
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenu.Items>
|
||||
</DropdownMenu>
|
||||
</Host>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export { MenuView } from "@expo/ui/community/menu"
|
||||
@@ -1,22 +1,20 @@
|
||||
import { PaletteText, PaletteIcon } from "@/components/palette-text"
|
||||
import Animated from "react-native-reanimated"
|
||||
import {
|
||||
useAndroidTabPalette,
|
||||
useAndroidTabBackgroundStyle,
|
||||
useAndroidTabHasArtworkPalette,
|
||||
} from "@/contexts/android-tab-theme"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { NativeTabs } from "expo-router/native-tabs"
|
||||
import { useRouter } from "expo-router"
|
||||
import { Platform, Pressable, StyleSheet, View } from "react-native"
|
||||
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
||||
import { Platform, Pressable, StyleSheet, Text, View } from "react-native"
|
||||
|
||||
import { CoverImage } from "@/components/cover-image"
|
||||
|
||||
import { usePlaybackActions, usePlaybackQueue } from "@/contexts/playback"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import { albumCoverUrl } from "@/lib/urls"
|
||||
import { miniPlayerHeight, tabBarHeight, useThemeColors } from "@/lib/theme"
|
||||
import {
|
||||
miniPlayerHeight,
|
||||
tabBarHeight,
|
||||
useBlurTint,
|
||||
useMiniPlayerBackground,
|
||||
useThemeColors,
|
||||
} from "@/lib/theme"
|
||||
|
||||
function MiniPlayerContent({
|
||||
placement,
|
||||
@@ -27,19 +25,10 @@ function MiniPlayerContent({
|
||||
variant: "bar" | "accessory"
|
||||
onOpenPlayer: () => void
|
||||
}) {
|
||||
const theme = useThemeColors()
|
||||
const palette = useAndroidTabPalette()
|
||||
const colors =
|
||||
Platform.OS === "android"
|
||||
? {
|
||||
...theme,
|
||||
foreground: palette.foreground,
|
||||
mutedForeground: palette.secondaryForeground,
|
||||
}
|
||||
: theme
|
||||
const colors = useThemeColors()
|
||||
const { config } = useServerConfig()
|
||||
const { currentSong, isPlaying } = usePlaybackQueue()
|
||||
const { setIsPlaying, skipNext, skipPrevious } = usePlaybackActions()
|
||||
const { setIsPlaying, skipNext } = usePlaybackActions()
|
||||
|
||||
if (!currentSong || !config) {
|
||||
return null
|
||||
@@ -67,8 +56,7 @@ function MiniPlayerContent({
|
||||
<View
|
||||
style={isAccessory ? styles.accessoryInlineMeta : styles.inlineMeta}
|
||||
>
|
||||
<PaletteText
|
||||
tone="foreground"
|
||||
<Text
|
||||
style={[
|
||||
isAccessory ? styles.accessoryTitle : styles.title,
|
||||
{ color: colors.foreground },
|
||||
@@ -76,7 +64,7 @@ function MiniPlayerContent({
|
||||
numberOfLines={1}
|
||||
>
|
||||
{currentSong.title}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
</View>
|
||||
<Pressable
|
||||
style={styles.controlButton}
|
||||
@@ -86,8 +74,7 @@ function MiniPlayerContent({
|
||||
}}
|
||||
hitSlop={6}
|
||||
>
|
||||
<PaletteIcon
|
||||
tone="foreground"
|
||||
<Ionicons
|
||||
name={isPlaying ? "pause" : "play"}
|
||||
size={20}
|
||||
color={colors.foreground}
|
||||
@@ -105,8 +92,7 @@ function MiniPlayerContent({
|
||||
style={artworkStyle}
|
||||
/>
|
||||
<View style={isAccessory ? styles.accessoryMeta : styles.meta}>
|
||||
<PaletteText
|
||||
tone="foreground"
|
||||
<Text
|
||||
style={[
|
||||
isAccessory ? styles.accessoryTitle : styles.title,
|
||||
{ color: colors.foreground },
|
||||
@@ -114,9 +100,8 @@ function MiniPlayerContent({
|
||||
numberOfLines={1}
|
||||
>
|
||||
{currentSong.title}
|
||||
</PaletteText>
|
||||
<PaletteText
|
||||
tone="secondaryForeground"
|
||||
</Text>
|
||||
<Text
|
||||
style={[
|
||||
isAccessory ? styles.accessoryArtist : styles.artist,
|
||||
{ color: colors.mutedForeground },
|
||||
@@ -124,28 +109,9 @@ function MiniPlayerContent({
|
||||
numberOfLines={1}
|
||||
>
|
||||
{currentSong.artist.name}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
</View>
|
||||
<View style={styles.controls}>
|
||||
{Platform.OS === "android" && !isAccessory ? (
|
||||
<Pressable
|
||||
style={styles.controlButton}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Previous track"
|
||||
onPress={(event) => {
|
||||
event.stopPropagation()
|
||||
void skipPrevious()
|
||||
}}
|
||||
hitSlop={6}
|
||||
>
|
||||
<PaletteIcon
|
||||
tone="foreground"
|
||||
name="play-back"
|
||||
size={24}
|
||||
color={colors.foreground}
|
||||
/>
|
||||
</Pressable>
|
||||
) : null}
|
||||
<Pressable
|
||||
style={styles.controlButton}
|
||||
onPress={(event) => {
|
||||
@@ -154,8 +120,7 @@ function MiniPlayerContent({
|
||||
}}
|
||||
hitSlop={6}
|
||||
>
|
||||
<PaletteIcon
|
||||
tone="foreground"
|
||||
<Ionicons
|
||||
name={isPlaying ? "pause" : "play"}
|
||||
size={24}
|
||||
color={colors.foreground}
|
||||
@@ -169,12 +134,7 @@ function MiniPlayerContent({
|
||||
}}
|
||||
hitSlop={6}
|
||||
>
|
||||
<PaletteIcon
|
||||
tone="foreground"
|
||||
name="play-forward"
|
||||
size={24}
|
||||
color={colors.foreground}
|
||||
/>
|
||||
<Ionicons name="play-forward" size={24} color={colors.foreground} />
|
||||
</Pressable>
|
||||
</View>
|
||||
</Pressable>
|
||||
@@ -182,30 +142,14 @@ function MiniPlayerContent({
|
||||
}
|
||||
|
||||
function MiniPlayerChrome({ children }: { children: React.ReactNode }) {
|
||||
const palette = useAndroidTabPalette()
|
||||
const hasArtworkPalette = useAndroidTabHasArtworkPalette()
|
||||
const backgroundStyle = useAndroidTabBackgroundStyle()
|
||||
const colors = useThemeColors()
|
||||
const backgroundColor = useMiniPlayerBackground()
|
||||
|
||||
return (
|
||||
<Animated.View style={[styles.androidBar, backgroundStyle]}>
|
||||
<View style={[styles.androidBar, { backgroundColor }]}>
|
||||
<View style={[styles.topBorder, { backgroundColor: colors.border }]} />
|
||||
{children}
|
||||
{hasArtworkPalette ? (
|
||||
<View
|
||||
style={[
|
||||
styles.separator,
|
||||
styles.topBorder,
|
||||
{ backgroundColor: palette.secondaryForeground },
|
||||
]}
|
||||
/>
|
||||
) : null}
|
||||
<View
|
||||
style={[
|
||||
styles.separator,
|
||||
styles.bottomBorder,
|
||||
{ backgroundColor: palette.secondaryForeground },
|
||||
]}
|
||||
/>
|
||||
</Animated.View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -234,31 +178,43 @@ export function TabBottomAccessory() {
|
||||
|
||||
return content
|
||||
}
|
||||
/** NativeTabs.BottomAccessory only renders on iOS. */
|
||||
export function AndroidMiniPlayer() {
|
||||
const router = useRouter()
|
||||
const insets = useSafeAreaInsets()
|
||||
const { currentSong, queueSongIds } = usePlaybackQueue()
|
||||
if (Platform.OS !== "android" || !currentSong || queueSongIds.length === 0) {
|
||||
return null
|
||||
}
|
||||
return (
|
||||
<View
|
||||
style={[
|
||||
styles.floatingContainer,
|
||||
{ bottom: tabBarHeight + insets.bottom },
|
||||
]}
|
||||
>
|
||||
<MiniPlayerChrome>
|
||||
<MiniPlayerContent
|
||||
placement="regular"
|
||||
variant="bar"
|
||||
onOpenPlayer={() => router.push("/player")}
|
||||
/>
|
||||
</MiniPlayerChrome>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
//
|
||||
// function useFloatingMiniPlayerLayout() {
|
||||
// const segments = useSegments() as string[]
|
||||
// const insets = useSafeAreaInsets()
|
||||
//
|
||||
// const onPlayerModal = segments.includes("player")
|
||||
// const onAuthFlow =
|
||||
// segments.includes("signin") ||
|
||||
// segments.includes("signup") ||
|
||||
// segments.includes("server")
|
||||
// const onTabs = segments.includes("(tabs)")
|
||||
//
|
||||
// const bottom = insets.bottom + (onTabs ? 0 : 0)
|
||||
//
|
||||
// return {
|
||||
// bottom,
|
||||
// hidden: onPlayerModal || onAuthFlow || onTabs,
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// export function FloatingMiniPlayer() {
|
||||
// const router = useRouter()
|
||||
// const { bottom, hidden } = useFloatingMiniPlayerLayout()
|
||||
// const { currentSong, queueSongIds } = usePlayback()
|
||||
//
|
||||
// if (hidden || !currentSong || queueSongIds.length === 0) {
|
||||
// return null
|
||||
// }
|
||||
//
|
||||
// return (
|
||||
// <View pointerEvents="box-none" style={[styles.floatingContainer, { bottom }]}>
|
||||
// <MiniPlayerChrome>
|
||||
// <MiniPlayerContent onOpenPlayer={() => router.push("/player")} />
|
||||
// </MiniPlayerChrome>
|
||||
// </View>
|
||||
// )
|
||||
// }
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
floatingContainer: {
|
||||
@@ -278,15 +234,9 @@ const styles = StyleSheet.create({
|
||||
androidBar: {
|
||||
overflow: "hidden",
|
||||
},
|
||||
separator: {
|
||||
position: "absolute",
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: 1,
|
||||
zIndex: 1,
|
||||
topBorder: {
|
||||
height: StyleSheet.hairlineWidth,
|
||||
},
|
||||
topBorder: { top: 0 },
|
||||
bottomBorder: { bottom: 0 },
|
||||
content: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
|
||||
@@ -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 />
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import { useEffect, useMemo, useRef, type ReactNode } from "react"
|
||||
import { StyleSheet, View } from "react-native"
|
||||
import { Gesture, GestureDetector } from "react-native-gesture-handler"
|
||||
import Animated, {
|
||||
cancelAnimation,
|
||||
interpolate,
|
||||
interpolateColor,
|
||||
useAnimatedStyle,
|
||||
@@ -35,8 +34,6 @@ export function PlayerSlider({
|
||||
leading,
|
||||
trailing,
|
||||
accessibilityLabel,
|
||||
commitHoldMs = COMMIT_HOLD_MS,
|
||||
animateValueChanges = false,
|
||||
}: {
|
||||
value: number
|
||||
maximumValue: number
|
||||
@@ -49,9 +46,6 @@ export function PlayerSlider({
|
||||
leading?: ReactNode
|
||||
trailing?: ReactNode
|
||||
accessibilityLabel: string
|
||||
animateValueChanges?: boolean
|
||||
/** Seeking needs a hold while playback catches up; system volume does not. */
|
||||
commitHoldMs?: number
|
||||
}) {
|
||||
const max = maximumValue > 0 ? maximumValue : 1
|
||||
const fraction = useSharedValue(clamp(value / max))
|
||||
@@ -63,38 +57,23 @@ export function PlayerSlider({
|
||||
|
||||
useEffect(() => {
|
||||
if (dragging.value || Date.now() < holdUntil.current) return
|
||||
const next = clamp(value / max)
|
||||
fraction.value = animateValueChanges
|
||||
? withTiming(next, { duration: 160 })
|
||||
: next
|
||||
}, [animateValueChanges, dragging, fraction, max, value])
|
||||
fraction.value = clamp(value / max)
|
||||
}, [dragging, fraction, max, value])
|
||||
|
||||
const callbacks = useRef({
|
||||
onValueChange,
|
||||
onSlidingStart,
|
||||
onSlidingComplete,
|
||||
value,
|
||||
commitHoldMs,
|
||||
max,
|
||||
})
|
||||
callbacks.current = {
|
||||
onValueChange,
|
||||
onSlidingStart,
|
||||
onSlidingComplete,
|
||||
value,
|
||||
commitHoldMs,
|
||||
max,
|
||||
}
|
||||
callbacks.current = { onValueChange, onSlidingStart, onSlidingComplete, max }
|
||||
|
||||
const gesture = useMemo(() => {
|
||||
const start = () => callbacks.current.onSlidingStart?.()
|
||||
const change = (next: number) =>
|
||||
callbacks.current.onValueChange?.(next * callbacks.current.max)
|
||||
const complete = (next: number) => {
|
||||
holdUntil.current = Date.now() + callbacks.current.commitHoldMs
|
||||
if (callbacks.current.commitHoldMs === 0) {
|
||||
fraction.value = clamp(callbacks.current.value / callbacks.current.max)
|
||||
}
|
||||
holdUntil.current = Date.now() + COMMIT_HOLD_MS
|
||||
callbacks.current.onSlidingComplete?.(next * callbacks.current.max)
|
||||
}
|
||||
|
||||
@@ -106,7 +85,6 @@ export function PlayerSlider({
|
||||
active.value = withSpring(1, { duration: 250, dampingRatio: 0.8 })
|
||||
})
|
||||
.onStart(() => {
|
||||
cancelAnimation(fraction)
|
||||
dragging.value = true
|
||||
startFraction.value = fraction.value
|
||||
scheduleOnRN(start)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { PaletteText } from "@/components/palette-text"
|
||||
import { MusicEntityView } from "@/components/music-entity-view"
|
||||
import { collectionInset } from "@/components/collection-list"
|
||||
import { CoverImage } from "@/components/cover-image"
|
||||
@@ -9,7 +8,7 @@ import { formatDuration } from "@/lib/format"
|
||||
import { albumCoverUrl } from "@/lib/urls"
|
||||
import { miniPlayerHeight, spacing, useThemeColors } from "@/lib/theme"
|
||||
import { memo, useCallback } from "react"
|
||||
import { Platform, Pressable, StyleSheet, View } from "react-native"
|
||||
import { Pressable, StyleSheet, Text, View } from "react-native"
|
||||
|
||||
import {
|
||||
MediaContextMenu,
|
||||
@@ -47,27 +46,22 @@ export const SongRow = memo(function SongRow({
|
||||
const content = (
|
||||
<>
|
||||
<View style={styles.rowMeta}>
|
||||
<PaletteText
|
||||
tone={palette ? "foreground" : undefined}
|
||||
<Text
|
||||
style={[styles.rowTitle, { color: foreground }]}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{song.title}
|
||||
</PaletteText>
|
||||
<PaletteText
|
||||
tone={palette ? "secondaryForeground" : undefined}
|
||||
</Text>
|
||||
<Text
|
||||
style={[styles.rowSubtitle, { color: secondaryForeground }]}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{song.artist.name} · {song.album.title}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
</View>
|
||||
<PaletteText
|
||||
tone={palette ? "secondaryForeground" : undefined}
|
||||
style={[styles.duration, { color: secondaryForeground }]}
|
||||
>
|
||||
<Text style={[styles.duration, { color: secondaryForeground }]}>
|
||||
{formatDuration(song.durationSeconds)}
|
||||
</PaletteText>
|
||||
</Text>
|
||||
{trailing}
|
||||
</>
|
||||
)
|
||||
@@ -153,7 +147,6 @@ export const SongListRow = memo(function SongListRow({
|
||||
type: "song",
|
||||
albumId: song.album.id,
|
||||
songId: song.id,
|
||||
title: `${song.title} - ${song.album.title}`,
|
||||
},
|
||||
onAction: (action) => onAction(song, action),
|
||||
}}
|
||||
@@ -162,8 +155,7 @@ export const SongListRow = memo(function SongListRow({
|
||||
})
|
||||
|
||||
export const tabContentBottomInset = spacing.lg
|
||||
export const contentBottomInset =
|
||||
Platform.OS === "android" ? spacing.lg : miniPlayerHeight + spacing.lg
|
||||
export const contentBottomInset = miniPlayerHeight + spacing.lg
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
row: {
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
import { useCallback, useMemo } from "react"
|
||||
import { Platform } from "react-native"
|
||||
import { Stack } from "expo-router"
|
||||
|
||||
import { useDebouncedSearch } from "@/hooks/use-debounced-search"
|
||||
import { useThemeColors } from "@/lib/theme"
|
||||
import type { BrowseSong } from "@otunes/convex/types"
|
||||
|
||||
export function usePlaylistSearch(songs: BrowseSong[]) {
|
||||
const search = useDebouncedSearch()
|
||||
const filteredSongs = useMemo(() => {
|
||||
const query = search.searchQuery.toLowerCase()
|
||||
if (!query) return songs
|
||||
return songs.filter((song) =>
|
||||
[song.title, song.artist.name, song.album.title].some((value) =>
|
||||
value.toLowerCase().includes(query)
|
||||
)
|
||||
)
|
||||
}, [songs, search.searchQuery])
|
||||
|
||||
return { ...search, filteredSongs }
|
||||
}
|
||||
|
||||
export function PlaylistSearchBar({
|
||||
onQueryChange,
|
||||
onSearchSubmit,
|
||||
}: Pick<
|
||||
ReturnType<typeof useDebouncedSearch>,
|
||||
"onQueryChange" | "onSearchSubmit"
|
||||
>) {
|
||||
const colors = useThemeColors()
|
||||
const handleChangeText = useCallback(
|
||||
(event: { nativeEvent: { text: string } }) => {
|
||||
onQueryChange(event.nativeEvent.text)
|
||||
},
|
||||
[onQueryChange]
|
||||
)
|
||||
|
||||
return (
|
||||
<Stack.SearchBar
|
||||
placeholder="Search playlist"
|
||||
onChangeText={handleChangeText}
|
||||
onSearchButtonPress={onSearchSubmit}
|
||||
autoCapitalize="none"
|
||||
{...(Platform.OS === "android"
|
||||
? {
|
||||
barTintColor: colors.background,
|
||||
textColor: colors.foreground,
|
||||
tintColor: colors.primary,
|
||||
hintTextColor: colors.mutedForeground,
|
||||
headerIconColor: colors.foreground,
|
||||
}
|
||||
: {})}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import Reanimated from "react-native-reanimated"
|
||||
import { useEffect, useRef, type ReactNode, type ComponentProps } from "react"
|
||||
import { useEffect, useRef } from "react"
|
||||
import {
|
||||
Animated,
|
||||
ScrollView,
|
||||
@@ -19,30 +18,6 @@ import {
|
||||
useTwoColumnCardWidth,
|
||||
} from "@/lib/theme"
|
||||
|
||||
/** Match the inset-adjusted lists used once screen data is available. */
|
||||
function SkeletonContent({
|
||||
children,
|
||||
embedded = false,
|
||||
}: {
|
||||
children: ReactNode
|
||||
embedded?: boolean
|
||||
}) {
|
||||
const colors = useThemeColors()
|
||||
if (embedded) return <>{children}</>
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
style={{ flex: 1, backgroundColor: colors.background }}
|
||||
contentContainerStyle={{ paddingBottom: contentBottomInset }}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
scrollEnabled={false}
|
||||
accessibilityLabel="Loading"
|
||||
>
|
||||
{children}
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
|
||||
export function Skeleton({ style }: { style?: StyleProp<ViewStyle> }) {
|
||||
const colors = useThemeColors()
|
||||
const opacity = useRef(new Animated.Value(1)).current
|
||||
@@ -99,21 +74,13 @@ export function SongRowSkeleton() {
|
||||
)
|
||||
}
|
||||
|
||||
export function SongListSkeleton({
|
||||
rows = 10,
|
||||
embedded = false,
|
||||
}: {
|
||||
rows?: number
|
||||
embedded?: boolean
|
||||
}) {
|
||||
export function SongListSkeleton({ rows = 10 }: { rows?: number }) {
|
||||
return (
|
||||
<SkeletonContent embedded={embedded}>
|
||||
<View accessibilityLabel="Loading" accessibilityRole="progressbar">
|
||||
{Array.from({ length: rows }, (_, index) => (
|
||||
<SongRowSkeleton key={index} />
|
||||
))}
|
||||
</View>
|
||||
</SkeletonContent>
|
||||
<View accessibilityLabel="Loading" accessibilityRole="progressbar">
|
||||
{Array.from({ length: rows }, (_, index) => (
|
||||
<SongRowSkeleton key={index} />
|
||||
))}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -142,28 +109,24 @@ function CardSkeleton({
|
||||
export function MediaGridSkeleton({
|
||||
items = 6,
|
||||
contentInset = true,
|
||||
embedded = false,
|
||||
}: {
|
||||
items?: number
|
||||
contentInset?: boolean
|
||||
embedded?: boolean
|
||||
}) {
|
||||
const cardWidth = useTwoColumnCardWidth()
|
||||
return (
|
||||
<SkeletonContent embedded={embedded}>
|
||||
<View
|
||||
accessibilityLabel="Loading"
|
||||
accessibilityRole="progressbar"
|
||||
style={[
|
||||
styles.grid,
|
||||
contentInset ? styles.gridInset : styles.gridRowInset,
|
||||
]}
|
||||
>
|
||||
{Array.from({ length: items }, (_, index) => (
|
||||
<CardSkeleton key={index} width={cardWidth} />
|
||||
))}
|
||||
</View>
|
||||
</SkeletonContent>
|
||||
<View
|
||||
accessibilityLabel="Loading"
|
||||
accessibilityRole="progressbar"
|
||||
style={[
|
||||
styles.grid,
|
||||
contentInset ? styles.gridInset : styles.gridRowInset,
|
||||
]}
|
||||
>
|
||||
{Array.from({ length: items }, (_, index) => (
|
||||
<CardSkeleton key={index} width={cardWidth} />
|
||||
))}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -198,25 +161,15 @@ export function HomeSkeleton() {
|
||||
|
||||
/** Album and playlist pages: cover, title, play buttons, then tracks. */
|
||||
export function CollectionDetailSkeleton({
|
||||
style,
|
||||
round = false,
|
||||
backgroundColor,
|
||||
onLayout,
|
||||
}: {
|
||||
style?: ComponentProps<typeof Reanimated.ScrollView>["style"]
|
||||
round?: boolean
|
||||
backgroundColor?: string
|
||||
onLayout?: () => void
|
||||
}) {
|
||||
const colors = useThemeColors()
|
||||
const coverSize = round ? 180 : 210
|
||||
return (
|
||||
<Reanimated.ScrollView
|
||||
onLayout={onLayout}
|
||||
style={[
|
||||
{ flex: 1, backgroundColor: backgroundColor ?? colors.background },
|
||||
style,
|
||||
]}
|
||||
<ScrollView
|
||||
style={{ flex: 1, backgroundColor: colors.background }}
|
||||
contentContainerStyle={{ paddingBottom: contentBottomInset }}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
scrollEnabled={false}
|
||||
@@ -239,30 +192,28 @@ export function CollectionDetailSkeleton({
|
||||
</View>
|
||||
</View>
|
||||
{round ? (
|
||||
<MediaGridSkeleton items={4} contentInset={false} embedded />
|
||||
<MediaGridSkeleton items={4} contentInset={false} />
|
||||
) : (
|
||||
<SongListSkeleton rows={8} embedded />
|
||||
<SongListSkeleton rows={8} />
|
||||
)}
|
||||
</Reanimated.ScrollView>
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
|
||||
export function ArtistListSkeleton({ rows = 12 }: { rows?: number }) {
|
||||
const colors = useThemeColors()
|
||||
return (
|
||||
<SkeletonContent>
|
||||
<View accessibilityLabel="Loading" accessibilityRole="progressbar">
|
||||
{Array.from({ length: rows }, (_, index) => (
|
||||
<View
|
||||
key={index}
|
||||
style={[styles.artistRow, { borderBottomColor: colors.border }]}
|
||||
>
|
||||
<Skeleton style={styles.artistAvatar} />
|
||||
<TextLine width="50%" height={16} />
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</SkeletonContent>
|
||||
<View accessibilityLabel="Loading" accessibilityRole="progressbar">
|
||||
{Array.from({ length: rows }, (_, index) => (
|
||||
<View
|
||||
key={index}
|
||||
style={[styles.artistRow, { borderBottomColor: colors.border }]}
|
||||
>
|
||||
<Skeleton style={styles.artistAvatar} />
|
||||
<TextLine width="50%" height={16} />
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -282,7 +233,7 @@ const styles = StyleSheet.create({
|
||||
grid: { flexDirection: "row", flexWrap: "wrap", gap: spacing.md },
|
||||
gridInset: { padding: spacing.lg },
|
||||
gridRowInset: { paddingHorizontal: spacing.lg },
|
||||
carousel: { gap: spacing.md, overflow: "hidden" },
|
||||
carousel: { gap: spacing.md },
|
||||
carouselRow: { flexDirection: "row", gap: spacing.md },
|
||||
home: { padding: spacing.lg, gap: spacing.xl },
|
||||
hero: { alignItems: "center", padding: spacing.lg, gap: spacing.sm },
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { PaletteText, PaletteIcon } from "@/components/palette-text"
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Platform,
|
||||
Pressable,
|
||||
PressableProps,
|
||||
StyleProp,
|
||||
@@ -74,20 +72,8 @@ export function Button({
|
||||
<ActivityIndicator color={textColor} />
|
||||
) : (
|
||||
<View style={styles.buttonContent}>
|
||||
{icon ? (
|
||||
<PaletteIcon
|
||||
tone={tint ? "accentForeground" : undefined}
|
||||
name={icon}
|
||||
size={18}
|
||||
color={textColor}
|
||||
/>
|
||||
) : null}
|
||||
<PaletteText
|
||||
tone={tint ? "accentForeground" : undefined}
|
||||
style={[styles.buttonText, { color: textColor }]}
|
||||
>
|
||||
{title}
|
||||
</PaletteText>
|
||||
{icon ? <Ionicons name={icon} size={18} color={textColor} /> : null}
|
||||
<Text style={[styles.buttonText, { color: textColor }]}>{title}</Text>
|
||||
</View>
|
||||
)}
|
||||
</Pressable>
|
||||
@@ -99,13 +85,6 @@ export function Input({ style, ...props }: TextInputProps) {
|
||||
return (
|
||||
<TextInput
|
||||
{...props}
|
||||
{...(Platform.OS === "android"
|
||||
? {
|
||||
selectionColor: colors.primary,
|
||||
cursorColor: colors.primary,
|
||||
selectionHandleColor: colors.primary,
|
||||
}
|
||||
: {})}
|
||||
placeholderTextColor={colors.mutedForeground}
|
||||
style={[
|
||||
styles.input,
|
||||
@@ -123,12 +102,7 @@ export function Input({ style, ...props }: TextInputProps) {
|
||||
export function Card({ children }: { children: React.ReactNode }) {
|
||||
const colors = useThemeColors()
|
||||
return (
|
||||
<View
|
||||
style={[
|
||||
styles.card,
|
||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
||||
]}
|
||||
>
|
||||
<View style={[styles.card, { backgroundColor: colors.card, borderColor: colors.border }]}>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { Toaster as SonnerToaster } from "sonner-native"
|
||||
import { useColorScheme } from "react-native"
|
||||
|
||||
import { radius, useIsDark, useThemeColors } from "@/lib/theme"
|
||||
import { colors, radius } from "@/lib/theme"
|
||||
|
||||
export function Toaster() {
|
||||
const isDark = useIsDark()
|
||||
const themeColors = useThemeColors()
|
||||
const scheme = useColorScheme()
|
||||
const themeColors = scheme === "dark" ? colors.dark : colors.light
|
||||
|
||||
return (
|
||||
<SonnerToaster
|
||||
position="top-center"
|
||||
theme={isDark ? "dark" : "light"}
|
||||
theme={scheme === "dark" ? "dark" : "light"}
|
||||
toastOptions={{
|
||||
style: {
|
||||
backgroundColor: themeColors.card,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { AndroidSheet } from "@/components/android-sheet"
|
||||
import { useConvex, useMutation } from "convex/react"
|
||||
import {
|
||||
createContext,
|
||||
@@ -247,53 +246,51 @@ export function AddToPlaylistProvider({ children }: { children: ReactNode }) {
|
||||
transparent
|
||||
onRequestClose={closeAddToPlaylist}
|
||||
>
|
||||
<AndroidSheet>
|
||||
<Pressable style={styles.overlay} onPress={closeAddToPlaylist}>
|
||||
<Pressable
|
||||
style={[
|
||||
styles.sheet,
|
||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
||||
]}
|
||||
onPress={(event) => event.stopPropagation()}
|
||||
>
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>
|
||||
Add to Playlist
|
||||
</Text>
|
||||
<FlatList
|
||||
style={styles.list}
|
||||
data={ownedPlaylists ?? []}
|
||||
keyExtractor={(playlist) => playlist.id}
|
||||
renderItem={({
|
||||
item: playlist,
|
||||
}: {
|
||||
item: OwnedPlaylistForAdd
|
||||
}) => (
|
||||
<Pressable
|
||||
style={[styles.row, { borderBottomColor: colors.border }]}
|
||||
disabled={addingToPlaylistId !== null}
|
||||
onPress={() =>
|
||||
void handleAddToPlaylist(playlist.id, playlist.songIds)
|
||||
}
|
||||
>
|
||||
<Text style={{ color: colors.foreground }}>
|
||||
{playlist.title}
|
||||
</Text>
|
||||
</Pressable>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
title="New Playlist"
|
||||
variant="secondary"
|
||||
onPress={() => {
|
||||
selectionRequestIdRef.current += 1
|
||||
setOpen(false)
|
||||
setNewPlaylistName("")
|
||||
setCreateOpen(true)
|
||||
}}
|
||||
/>
|
||||
</Pressable>
|
||||
<Pressable style={styles.overlay} onPress={closeAddToPlaylist}>
|
||||
<Pressable
|
||||
style={[
|
||||
styles.sheet,
|
||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
||||
]}
|
||||
onPress={(event) => event.stopPropagation()}
|
||||
>
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>
|
||||
Add to Playlist
|
||||
</Text>
|
||||
<FlatList
|
||||
style={styles.list}
|
||||
data={ownedPlaylists ?? []}
|
||||
keyExtractor={(playlist) => playlist.id}
|
||||
renderItem={({
|
||||
item: playlist,
|
||||
}: {
|
||||
item: OwnedPlaylistForAdd
|
||||
}) => (
|
||||
<Pressable
|
||||
style={styles.row}
|
||||
disabled={addingToPlaylistId !== null}
|
||||
onPress={() =>
|
||||
void handleAddToPlaylist(playlist.id, playlist.songIds)
|
||||
}
|
||||
>
|
||||
<Text style={{ color: colors.foreground }}>
|
||||
{playlist.title}
|
||||
</Text>
|
||||
</Pressable>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
title="New Playlist"
|
||||
variant="secondary"
|
||||
onPress={() => {
|
||||
selectionRequestIdRef.current += 1
|
||||
setOpen(false)
|
||||
setNewPlaylistName("")
|
||||
setCreateOpen(true)
|
||||
}}
|
||||
/>
|
||||
</Pressable>
|
||||
</AndroidSheet>
|
||||
</Pressable>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
@@ -302,43 +299,38 @@ export function AddToPlaylistProvider({ children }: { children: ReactNode }) {
|
||||
transparent
|
||||
onRequestClose={() => setCreateOpen(false)}
|
||||
>
|
||||
<AndroidSheet>
|
||||
<Pressable style={styles.overlay} onPress={() => setCreateOpen(false)}>
|
||||
<Pressable
|
||||
style={styles.overlay}
|
||||
onPress={() => setCreateOpen(false)}
|
||||
style={[
|
||||
styles.createSheet,
|
||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
||||
]}
|
||||
onPress={(event) => event.stopPropagation()}
|
||||
>
|
||||
<Pressable
|
||||
style={[
|
||||
styles.createSheet,
|
||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
||||
]}
|
||||
onPress={(event) => event.stopPropagation()}
|
||||
>
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>
|
||||
New Playlist
|
||||
</Text>
|
||||
<Input
|
||||
value={newPlaylistName}
|
||||
onChangeText={setNewPlaylistName}
|
||||
placeholder="Playlist name"
|
||||
autoFocus
|
||||
<Text style={[styles.title, { color: colors.foreground }]}>
|
||||
New Playlist
|
||||
</Text>
|
||||
<Input
|
||||
value={newPlaylistName}
|
||||
onChangeText={setNewPlaylistName}
|
||||
placeholder="Playlist name"
|
||||
autoFocus
|
||||
/>
|
||||
<View style={styles.createActions}>
|
||||
<Button
|
||||
title="Cancel"
|
||||
variant="ghost"
|
||||
onPress={() => setCreateOpen(false)}
|
||||
/>
|
||||
<View style={styles.createActions}>
|
||||
<Button
|
||||
title="Cancel"
|
||||
variant="ghost"
|
||||
onPress={() => setCreateOpen(false)}
|
||||
/>
|
||||
<Button
|
||||
title="Create"
|
||||
loading={submitting}
|
||||
disabled={!newPlaylistName.trim()}
|
||||
onPress={() => void handleCreatePlaylist()}
|
||||
/>
|
||||
</View>
|
||||
</Pressable>
|
||||
<Button
|
||||
title="Create"
|
||||
loading={submitting}
|
||||
disabled={!newPlaylistName.trim()}
|
||||
onPress={() => void handleCreatePlaylist()}
|
||||
/>
|
||||
</View>
|
||||
</Pressable>
|
||||
</AndroidSheet>
|
||||
</Pressable>
|
||||
</Modal>
|
||||
</AddToPlaylistContext.Provider>
|
||||
)
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
import {
|
||||
useIsFocused,
|
||||
useRoute,
|
||||
useNavigation,
|
||||
type NativeStackNavigationProp,
|
||||
} from "expo-router"
|
||||
import {
|
||||
createContext,
|
||||
useCallback,
|
||||
useContext,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
type PropsWithChildren,
|
||||
} from "react"
|
||||
import { Platform, StyleSheet, type HostInstance } from "react-native"
|
||||
import Reanimated, {
|
||||
useSharedValue,
|
||||
useAnimatedStyle,
|
||||
useAnimatedReaction,
|
||||
useAnimatedRef,
|
||||
setNativeProps,
|
||||
processColor,
|
||||
withTiming,
|
||||
type SharedValue,
|
||||
} from "react-native-reanimated"
|
||||
|
||||
import { themeCoverPalette, type CoverPalette } from "@/lib/cover-palette"
|
||||
import { useIsDark, useThemeColors } from "@/lib/theme"
|
||||
|
||||
export type PaletteColor = Exclude<keyof CoverPalette, "isDark">
|
||||
type PaletteColors = Pick<CoverPalette, PaletteColor> & {
|
||||
selectedColor: string
|
||||
}
|
||||
|
||||
type TabTheme = {
|
||||
palette: CoverPalette
|
||||
colors: SharedValue<PaletteColors>
|
||||
hasArtworkPalette: boolean
|
||||
setPalette: (palette: CoverPalette | null, owner: string) => void
|
||||
}
|
||||
const AndroidTabTheme = createContext<TabTheme | null>(null)
|
||||
|
||||
function useDefaultPalette() {
|
||||
const theme = useThemeColors()
|
||||
const isDark = useIsDark()
|
||||
return useMemo(() => themeCoverPalette(theme, isDark), [theme, isDark])
|
||||
}
|
||||
|
||||
export function AndroidTabThemeProvider({ children }: PropsWithChildren) {
|
||||
const defaultPalette = useDefaultPalette()
|
||||
const [screen, setScreen] = useState<{
|
||||
palette: CoverPalette
|
||||
owner: string
|
||||
} | null>(null)
|
||||
const palette = screen?.palette ?? defaultPalette
|
||||
const hasArtwork =
|
||||
palette.background !== defaultPalette.background ||
|
||||
palette.foreground !== defaultPalette.foreground ||
|
||||
palette.secondaryForeground !== defaultPalette.secondaryForeground ||
|
||||
palette.accent !== defaultPalette.accent
|
||||
const { isDark: _defaultIsDark, ...defaultColors } = defaultPalette
|
||||
const animatedColors = useSharedValue<PaletteColors>({
|
||||
...defaultColors,
|
||||
selectedColor: defaultPalette.accentText,
|
||||
})
|
||||
useLayoutEffect(() => {
|
||||
if (Platform.OS !== "android") return
|
||||
const { isDark: _isDark, ...colors } = palette
|
||||
animatedColors.value = withTiming(
|
||||
{
|
||||
...colors,
|
||||
selectedColor: hasArtwork
|
||||
? palette.foreground
|
||||
: defaultPalette.accentText,
|
||||
},
|
||||
{ duration: PALETTE_FADE_MS }
|
||||
)
|
||||
}, [animatedColors, palette, defaultPalette, hasArtwork])
|
||||
const setPalette = useCallback(
|
||||
(palette: CoverPalette | null, owner: string) => {
|
||||
setScreen((current) =>
|
||||
palette ? { palette, owner } : current?.owner === owner ? null : current
|
||||
)
|
||||
},
|
||||
[]
|
||||
)
|
||||
const artworkPalette = hasArtwork ? palette : null
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
palette: artworkPalette ?? defaultPalette,
|
||||
colors: animatedColors,
|
||||
hasArtworkPalette: artworkPalette !== null,
|
||||
setPalette,
|
||||
}),
|
||||
[defaultPalette, artworkPalette, setPalette, animatedColors]
|
||||
)
|
||||
return (
|
||||
<AndroidTabTheme.Provider value={value}>
|
||||
{children}
|
||||
</AndroidTabTheme.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
const theme = useContext(AndroidTabTheme)
|
||||
const defaultPalette = useDefaultPalette()
|
||||
return theme?.palette ?? defaultPalette
|
||||
}
|
||||
|
||||
export function useAndroidTabHasArtworkPalette() {
|
||||
return useContext(AndroidTabTheme)?.hasArtworkPalette ?? false
|
||||
}
|
||||
|
||||
export function useAndroidTabBackgroundStyle() {
|
||||
const theme = useContext(AndroidTabTheme)
|
||||
const fallback = useDefaultPalette().background
|
||||
const colors = theme?.colors
|
||||
return useAnimatedStyle(() =>
|
||||
Platform.OS === "android"
|
||||
? { backgroundColor: colors?.value.background ?? fallback }
|
||||
: {}
|
||||
)
|
||||
}
|
||||
|
||||
/** Color tokens share the background's UI-thread timing. */
|
||||
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() {
|
||||
const style = useAndroidTabBackgroundStyle()
|
||||
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 useAndroidScreenPalette(palette: CoverPalette) {
|
||||
const isFocused = useIsFocused()
|
||||
const owner = useRoute().key
|
||||
const navigation =
|
||||
useNavigation<NativeStackNavigationProp<Record<string, undefined>>>()
|
||||
const [laidOut, setLaidOut] = useState(false)
|
||||
const [closing, setClosing] = useState(false)
|
||||
const onLayout = useCallback(() => setLaidOut(true), [])
|
||||
useLayoutEffect(() => {
|
||||
if (Platform.OS !== "android") return
|
||||
const start = navigation.addListener("transitionStart", ({ data }) => {
|
||||
setClosing(data.closing)
|
||||
})
|
||||
return start
|
||||
}, [navigation])
|
||||
const defaultPalette = useDefaultPalette()
|
||||
const theme = useContext(AndroidTabTheme)
|
||||
const setPalette = theme?.setPalette
|
||||
const target = isFocused && laidOut && !closing ? palette : defaultPalette
|
||||
const backgroundStyle = useAndroidTabBackgroundStyle()
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (
|
||||
Platform.OS !== "android" ||
|
||||
!setPalette ||
|
||||
!isFocused ||
|
||||
!laidOut ||
|
||||
closing
|
||||
)
|
||||
return
|
||||
setPalette(palette, owner)
|
||||
return () => setPalette(null, owner)
|
||||
}, [closing, laidOut, isFocused, owner, palette, setPalette])
|
||||
|
||||
return {
|
||||
palette: Platform.OS === "android" ? target : palette,
|
||||
backgroundStyle,
|
||||
onLayout: Platform.OS === "android" ? onLayout : undefined,
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||
import {
|
||||
createAudioPlaylist,
|
||||
setAudioModeAsync,
|
||||
setIsAudioActiveAsync,
|
||||
type AudioMetadata,
|
||||
type AudioPlaylist,
|
||||
type AudioPlaylistStatus,
|
||||
@@ -21,6 +19,7 @@ import {
|
||||
type ReactNode,
|
||||
} from "react"
|
||||
import { AppState } from "react-native"
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage"
|
||||
|
||||
import {
|
||||
ANONYMOUS_CACHE_SCOPE,
|
||||
@@ -58,6 +57,8 @@ import {
|
||||
const PREVIOUS_TRACK_RESTART_THRESHOLD_SECONDS = 5
|
||||
const PROGRESS_SAVE_INTERVAL_MS = 5000
|
||||
const PREFETCH_UPCOMING_SONGS = 5
|
||||
const VOLUME_STORAGE_KEY = "otunes:volume"
|
||||
const DEFAULT_VOLUME = 0.8
|
||||
|
||||
function lockScreenMetadata(
|
||||
song: BrowseSong,
|
||||
@@ -78,20 +79,18 @@ type PlaybackContextValue = {
|
||||
shuffleEnabled: boolean
|
||||
repeatEnabled: RepeatMode
|
||||
isPlaying: boolean
|
||||
volume: number
|
||||
currentTime: number
|
||||
duration: number
|
||||
seekTo: (seconds: number) => void
|
||||
waitForPlaybackReady: (playing?: boolean) => Promise<void>
|
||||
setIsPlaying: (playing: boolean) => void
|
||||
setVolume: (volume: number) => void
|
||||
playInOrder: (songIds: Id<"songs">[]) => Promise<void>
|
||||
playShuffled: (songIds: Id<"songs">[]) => Promise<void>
|
||||
addToQueueNext: (songIds: Id<"songs">[]) => Promise<void>
|
||||
addToQueueLast: (songIds: Id<"songs">[]) => Promise<void>
|
||||
playFromSong: (
|
||||
songId: Id<"songs">,
|
||||
songIds: Id<"songs">[],
|
||||
origin?: string
|
||||
) => Promise<void>
|
||||
playFromSong: (songId: Id<"songs">, songIds: Id<"songs">[]) => Promise<void>
|
||||
playFromLibrarySong: (
|
||||
songId: Id<"songs">,
|
||||
sort: {
|
||||
@@ -268,16 +267,18 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
const pendingSeekRef = useRef<number | null>(null)
|
||||
const seekInFlightRef = useRef(false)
|
||||
const loadRequestIdRef = useRef(0)
|
||||
const queueOriginRef = useRef<string | undefined>(undefined)
|
||||
const playRequestRef = useRef(0)
|
||||
const volumeRef = useRef(DEFAULT_VOLUME)
|
||||
const volumeChangedRef = useRef(false)
|
||||
const volumeSaveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const ignoreTrackChangeTimerRef = useRef<ReturnType<
|
||||
typeof setTimeout
|
||||
> | null>(null)
|
||||
|
||||
const [queueStartVersion, setQueueStartVersion] = useState(0)
|
||||
const [isPlaying, setIsPlayingState] = useState(false)
|
||||
const [currentTime, setCurrentTime] = useState(0)
|
||||
const [measuredDuration, setDuration] = useState(0)
|
||||
const [volume, setVolumeState] = useState(DEFAULT_VOLUME)
|
||||
const [progressToRestore, setProgressToRestore] = useState<number | null>(
|
||||
null
|
||||
)
|
||||
@@ -321,7 +322,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
? JSON.stringify([
|
||||
user._id,
|
||||
user.playbackQuality,
|
||||
dolbyAtmosSupported && (user.preferAtmos ?? false),
|
||||
user.preferAtmos ?? false,
|
||||
])
|
||||
: ""
|
||||
|
||||
@@ -354,21 +355,6 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
loadedLoadKeyRef.current = null
|
||||
}, [])
|
||||
|
||||
// A new queue must not inherit the native player's position or a pending seek.
|
||||
const resetQueuePlayback = useCallback(() => {
|
||||
loadRequestIdRef.current += 1
|
||||
destroyPlaylist()
|
||||
pendingSeekRef.current = null
|
||||
seekInFlightRef.current = false
|
||||
progressRestoredForSongRef.current = null
|
||||
lastSavedProgressRef.current = -1
|
||||
currentTimeRef.current = 0
|
||||
setCurrentTime(0)
|
||||
setDuration(0)
|
||||
setProgressToRestore(null)
|
||||
setQueueStartVersion((version) => version + 1)
|
||||
}, [destroyPlaylist])
|
||||
|
||||
const handlePlaylistStatusUpdate = useCallback(
|
||||
(status: AudioPlaylistStatus) => {
|
||||
if (!status.isLoaded) return
|
||||
@@ -480,8 +466,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
updateInterval: 500,
|
||||
loop: repeatToPlaylistLoop(storeRef.current.getState().repeatEnabled),
|
||||
})
|
||||
// System volume controls loudness; keep the player gain at full scale.
|
||||
playlist.volume = 1
|
||||
playlist.volume = volumeRef.current
|
||||
statusSubscriptionRef.current = playlist.addListener(
|
||||
"playlistStatusUpdate",
|
||||
handlePlaylistStatusUpdate
|
||||
@@ -513,12 +498,42 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
})
|
||||
|
||||
void AsyncStorage.getItem(VOLUME_STORAGE_KEY)
|
||||
.then((stored) => {
|
||||
if (!cancelled && !volumeChangedRef.current && stored) {
|
||||
const parsed = Number(stored)
|
||||
if (Number.isFinite(parsed)) {
|
||||
const restoredVolume = Math.min(1, Math.max(0, parsed))
|
||||
volumeRef.current = restoredVolume
|
||||
setVolumeState(restoredVolume)
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
|
||||
return () => {
|
||||
cancelled = true
|
||||
if (volumeSaveTimerRef.current) {
|
||||
clearTimeout(volumeSaveTimerRef.current)
|
||||
volumeSaveTimerRef.current = null
|
||||
}
|
||||
if (volumeChangedRef.current) {
|
||||
void AsyncStorage.setItem(
|
||||
VOLUME_STORAGE_KEY,
|
||||
String(volumeRef.current)
|
||||
).catch(() => {})
|
||||
}
|
||||
destroyPlaylist()
|
||||
}
|
||||
}, [destroyPlaylist])
|
||||
|
||||
useEffect(() => {
|
||||
volumeRef.current = volume
|
||||
if (playlistRef.current) {
|
||||
playlistRef.current.volume = volume
|
||||
}
|
||||
}, [volume])
|
||||
|
||||
useEffect(() => {
|
||||
const playlist = playlistRef.current
|
||||
if (playlist) {
|
||||
@@ -538,6 +553,25 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
}, [])
|
||||
|
||||
const setVolume = useCallback((nextVolume: number) => {
|
||||
const clamped = Math.min(1, Math.max(0, nextVolume))
|
||||
volumeChangedRef.current = true
|
||||
volumeRef.current = clamped
|
||||
setVolumeState(clamped)
|
||||
if (volumeSaveTimerRef.current) {
|
||||
clearTimeout(volumeSaveTimerRef.current)
|
||||
}
|
||||
volumeSaveTimerRef.current = setTimeout(() => {
|
||||
volumeSaveTimerRef.current = null
|
||||
void AsyncStorage.setItem(VOLUME_STORAGE_KEY, String(clamped)).catch(
|
||||
() => {}
|
||||
)
|
||||
}, 250)
|
||||
if (playlistRef.current) {
|
||||
playlistRef.current.volume = clamped
|
||||
}
|
||||
}, [])
|
||||
|
||||
const seekTo = useCallback(
|
||||
async (seconds: number) => {
|
||||
const playlist = playlistRef.current
|
||||
@@ -586,12 +620,11 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
if (progressRestoredForSongRef.current === currentSongId) return
|
||||
progressRestoredForSongRef.current = currentSongId
|
||||
lastSavedProgressRef.current = -1
|
||||
pendingSeekRef.current = null
|
||||
currentTimeRef.current = 0
|
||||
setCurrentTime(0)
|
||||
setDuration(0)
|
||||
setProgressToRestore(store.getState().progressSeconds)
|
||||
}, [currentSongId, destroyPlaylist, queueStartVersion, store])
|
||||
}, [currentSongId, destroyPlaylist, store])
|
||||
|
||||
useEffect(() => {
|
||||
if (progressToRestore === null || progressToRestore <= 0) return
|
||||
@@ -649,7 +682,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
if (!isCurrentLoad()) return
|
||||
|
||||
const loadKey = `${user.playbackQuality}:${dolbyAtmosSupported && (user.preferAtmos ?? false)}:${cookieHeader}`
|
||||
const loadKey = `${user.playbackQuality}:${user.preferAtmos ?? false}:${cookieHeader}`
|
||||
const needsRebuild =
|
||||
loadedLoadKeyRef.current !== loadKey ||
|
||||
nativePlaylistNeedsRebuild(
|
||||
@@ -671,6 +704,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
playlist.skipTo(currentIndex)
|
||||
}
|
||||
playlist.loop = repeatToPlaylistLoop(repeatEnabled)
|
||||
playlist.volume = volumeRef.current
|
||||
if (metadata) {
|
||||
updatePlaylistLockScreenMetadata(playlist, metadata)
|
||||
}
|
||||
@@ -691,7 +725,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
const plan = playbackStreamPlan(
|
||||
song.files,
|
||||
user.playbackQuality,
|
||||
dolbyAtmosSupported && (user.preferAtmos ?? false)
|
||||
user.preferAtmos ?? false
|
||||
)
|
||||
sources.set(
|
||||
song.id,
|
||||
@@ -784,6 +818,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
loadedSongIdsRef.current = windowSongIds
|
||||
loadedLoadKeyRef.current = loadKey
|
||||
playlist.volume = volumeRef.current
|
||||
playlist.loop = repeatToPlaylistLoop(repeatEnabled)
|
||||
activatePlaylistLockScreen(
|
||||
playlist,
|
||||
@@ -797,14 +832,6 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
playlist.play()
|
||||
} else {
|
||||
playlist.pause()
|
||||
// Enable audio for the restored queue without starting playback.
|
||||
try {
|
||||
await setIsAudioActiveAsync(true)
|
||||
} catch {
|
||||
if (isCurrentLoad()) {
|
||||
showError("Audio playback could not be initialized.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,7 +856,6 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
handlePlaybackLoadFailure,
|
||||
historySyncKey,
|
||||
queueSyncKey,
|
||||
queueStartVersion,
|
||||
repeatEnabled,
|
||||
scheduleTrackChangeHandling,
|
||||
userPlaybackKey,
|
||||
@@ -850,20 +876,18 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
) => playbackQueue.PlaybackQueueState,
|
||||
recorded: {
|
||||
playlistId?: Id<"playlists">
|
||||
origin?: string
|
||||
entity?: { kind: MusicEntityKind; id: string }
|
||||
} = {}
|
||||
) => {
|
||||
playRequestRef.current += 1
|
||||
queueOriginRef.current =
|
||||
recorded.origin ??
|
||||
(recorded.playlistId ? `playlist:${recorded.playlistId}` : undefined)
|
||||
resetQueuePlayback()
|
||||
store.update(playbackQueue.clearQueue)
|
||||
const previousSongId = store.getState().queue[0]
|
||||
store.update(recipe)
|
||||
const firstSongId = store.getState().queue[0]
|
||||
if (!firstSongId) return
|
||||
|
||||
if (firstSongId === previousSongId) {
|
||||
void seekTo(0)
|
||||
}
|
||||
setIsPlaying(true)
|
||||
void (async () => {
|
||||
const deadline = Date.now() + 20_000
|
||||
@@ -894,7 +918,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
: { songId: firstSongId }
|
||||
)
|
||||
},
|
||||
[store, resetQueuePlayback, setIsPlaying, recordPlay]
|
||||
[store, seekTo, setIsPlaying, recordPlay]
|
||||
)
|
||||
|
||||
const playCollection = useCallback(
|
||||
@@ -903,7 +927,6 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
shuffled: boolean,
|
||||
recorded: {
|
||||
playlistId?: Id<"playlists">
|
||||
origin?: string
|
||||
entity?: { kind: MusicEntityKind; id: string }
|
||||
} = {}
|
||||
) => {
|
||||
@@ -968,19 +991,12 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
)
|
||||
|
||||
const playFromSong = useCallback(
|
||||
async (songId: Id<"songs">, songIds: Id<"songs">[], origin?: string) => {
|
||||
if (
|
||||
origin &&
|
||||
queueOriginRef.current === origin &&
|
||||
store.getState().queue[0] === songId
|
||||
)
|
||||
return
|
||||
startPlayback(
|
||||
(state) => playbackQueue.startQueueFromSong(state, songId, songIds),
|
||||
{ origin }
|
||||
async (songId: Id<"songs">, songIds: Id<"songs">[]) => {
|
||||
startPlayback((state) =>
|
||||
playbackQueue.startQueueFromSong(state, songId, songIds)
|
||||
)
|
||||
},
|
||||
[startPlayback, store]
|
||||
[startPlayback]
|
||||
)
|
||||
|
||||
const playFromLibrarySong = useCallback(
|
||||
@@ -1050,7 +1066,6 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
(albumId: Id<"albums">, songIds?: Id<"songs">[]) =>
|
||||
playCollection(loadAlbumSongIds(albumId, songIds), false, {
|
||||
entity: { kind: "album", id: albumId },
|
||||
origin: `album:${albumId}`,
|
||||
}),
|
||||
[playCollection, loadAlbumSongIds]
|
||||
)
|
||||
@@ -1059,7 +1074,6 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
(albumId: Id<"albums">, songIds?: Id<"songs">[]) =>
|
||||
playCollection(loadAlbumSongIds(albumId, songIds), true, {
|
||||
entity: { kind: "album", id: albumId },
|
||||
origin: `album:${albumId}`,
|
||||
}),
|
||||
[playCollection, loadAlbumSongIds]
|
||||
)
|
||||
@@ -1122,14 +1136,12 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
async (songIds: Id<"songs">[], shuffled: boolean) => {
|
||||
if (songIds.length === 0) return
|
||||
playRequestRef.current += 1
|
||||
queueOriginRef.current = undefined
|
||||
resetQueuePlayback()
|
||||
store.update((state) =>
|
||||
playbackQueue.startQueue(state, songIds, shuffled)
|
||||
)
|
||||
setIsPlaying(false)
|
||||
},
|
||||
[store, resetQueuePlayback, setIsPlaying]
|
||||
[store, setIsPlaying]
|
||||
)
|
||||
|
||||
const startFromSong = useCallback(
|
||||
@@ -1140,20 +1152,17 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
play: boolean
|
||||
) => {
|
||||
playRequestRef.current += 1
|
||||
queueOriginRef.current = undefined
|
||||
resetQueuePlayback()
|
||||
store.update((state) => playbackQueue.setShuffleEnabled(state, shuffled))
|
||||
store.update((state) =>
|
||||
playbackQueue.startQueueFromSong(state, songId, songIds)
|
||||
)
|
||||
setIsPlaying(play)
|
||||
},
|
||||
[store, resetQueuePlayback, setIsPlaying]
|
||||
[store, setIsPlaying]
|
||||
)
|
||||
|
||||
const clearQueue = useCallback(async () => {
|
||||
playRequestRef.current += 1
|
||||
queueOriginRef.current = undefined
|
||||
store.update(playbackQueue.clearQueue)
|
||||
setIsPlaying(false)
|
||||
}, [store, setIsPlaying])
|
||||
@@ -1336,9 +1345,11 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
shuffleEnabled: playback.shuffleEnabled,
|
||||
repeatEnabled,
|
||||
isPlaying: isPlaybackActive,
|
||||
volume,
|
||||
currentTime,
|
||||
duration,
|
||||
seekTo,
|
||||
setVolume,
|
||||
}),
|
||||
[
|
||||
actionsValue,
|
||||
@@ -1352,6 +1363,8 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
queueSongIds,
|
||||
repeatEnabled,
|
||||
seekTo,
|
||||
setVolume,
|
||||
volume,
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@@ -5,22 +5,13 @@
|
||||
},
|
||||
"build": {
|
||||
"development": {
|
||||
"env": {
|
||||
"APP_VARIANT": "development"
|
||||
},
|
||||
"developmentClient": true,
|
||||
"distribution": "internal"
|
||||
},
|
||||
"preview": {
|
||||
"env": {
|
||||
"APP_VARIANT": "preview"
|
||||
},
|
||||
"distribution": "internal"
|
||||
},
|
||||
"production": {
|
||||
"env": {
|
||||
"APP_VARIANT": "production"
|
||||
},
|
||||
"autoIncrement": true
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import { useEffect, useState } from "react"
|
||||
import { Keyboard, Platform } from "react-native"
|
||||
|
||||
export function useAndroidKeyboardVisible() {
|
||||
const [visible, setVisible] = useState(false)
|
||||
useEffect(() => {
|
||||
if (Platform.OS !== "android") return
|
||||
setVisible(Keyboard.isVisible())
|
||||
const show = Keyboard.addListener("keyboardDidShow", () => setVisible(true))
|
||||
const hide = Keyboard.addListener("keyboardDidHide", () =>
|
||||
setVisible(false)
|
||||
)
|
||||
return () => {
|
||||
show.remove()
|
||||
hide.remove()
|
||||
}
|
||||
}, [])
|
||||
return visible
|
||||
}
|
||||
@@ -95,13 +95,6 @@ function extractSwatches(key: string) {
|
||||
return request
|
||||
}
|
||||
|
||||
/** Warm visible artwork colors before a detail page is pushed. */
|
||||
export function prefetchCoverPalette(uri: string) {
|
||||
const key = withCoverImageSize(uri, 64)
|
||||
if (cachedSwatches(key) !== undefined) return
|
||||
void extractSwatches(key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Colors for a screen tinted by `uri`'s cover art. Extraction runs once per
|
||||
* cover and is cached on device. Pass `hasCover` as `undefined` while it isn't
|
||||
@@ -145,10 +138,7 @@ export function useCoverPalette(
|
||||
// case the cover changed.
|
||||
const timer =
|
||||
known === undefined
|
||||
? setTimeout(
|
||||
() => !cancelled && setWaitedKey(key),
|
||||
COVER_PALETTE_WAIT_MS
|
||||
)
|
||||
? setTimeout(() => !cancelled && setWaitedKey(key), COVER_PALETTE_WAIT_MS)
|
||||
: null
|
||||
void extractSwatches(key).then((next) => {
|
||||
if (!cancelled) show(next ?? known ?? null)
|
||||
@@ -161,9 +151,7 @@ export function useCoverPalette(
|
||||
|
||||
const palette = useMemo(() => {
|
||||
const fromArt =
|
||||
hasCover !== false && swatches
|
||||
? deriveCoverPalette(swatches, isDark)
|
||||
: null
|
||||
hasCover !== false && swatches ? deriveCoverPalette(swatches, isDark) : null
|
||||
return fromArt ?? themeCoverPalette(theme, isDark)
|
||||
}, [hasCover, isDark, swatches, theme])
|
||||
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
import { requireOptionalNativeModule, type EventEmitter } from "expo"
|
||||
import { useFocusEffect } from "expo-router"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { AppState, Platform } from "react-native"
|
||||
|
||||
type VolumeState = { volume: number; available: boolean }
|
||||
type VolumeEvents = { onVolumeChange: (state: VolumeState) => void }
|
||||
interface SystemVolumeModule extends EventEmitter<VolumeEvents> {
|
||||
setPlayerVisible?(visible: boolean): Promise<void>
|
||||
getState(): Promise<VolumeState>
|
||||
setVolume(volume: number): Promise<void>
|
||||
}
|
||||
|
||||
const native = requireOptionalNativeModule<SystemVolumeModule>("SystemVolume")
|
||||
|
||||
/** The device owns volume. Never restore an app-specific level on launch. */
|
||||
export function useSystemVolume() {
|
||||
const [state, setState] = useState<VolumeState>({
|
||||
volume: 0,
|
||||
available: false,
|
||||
})
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
if (Platform.OS !== "ios" || !native?.setPlayerVisible) return
|
||||
void native.setPlayerVisible(true).catch(() => {})
|
||||
return () => {
|
||||
void native.setPlayerVisible?.(false).catch(() => {})
|
||||
}
|
||||
}, [])
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!native) return
|
||||
let active = true
|
||||
let revision = 0
|
||||
const listener = native.addListener("onVolumeChange", (next) => {
|
||||
revision++
|
||||
if (active) setState(next)
|
||||
})
|
||||
const refresh = async () => {
|
||||
const requestedRevision = ++revision
|
||||
try {
|
||||
const next = await native.getState()
|
||||
if (active && requestedRevision === revision) setState(next)
|
||||
} catch {
|
||||
if (active && requestedRevision === revision) {
|
||||
setState((value) => ({ ...value, available: false }))
|
||||
}
|
||||
}
|
||||
}
|
||||
void refresh()
|
||||
const foreground = AppState.addEventListener("change", (next) => {
|
||||
if (next === "active") void refresh()
|
||||
})
|
||||
return () => {
|
||||
active = false
|
||||
listener.remove()
|
||||
foreground.remove()
|
||||
}
|
||||
}, [])
|
||||
|
||||
const setVolume = useCallback((value: number) => {
|
||||
if (!native || !Number.isFinite(value)) return
|
||||
const volume = Math.min(1, Math.max(0, value))
|
||||
void native.setVolume(volume).catch(() => {
|
||||
setState((current) => ({ ...current, available: false }))
|
||||
})
|
||||
}, [])
|
||||
|
||||
return { ...state, setVolume }
|
||||
}
|
||||
@@ -38,13 +38,6 @@ export function useAppNavigation() {
|
||||
const router = useRouter()
|
||||
|
||||
const push = useCallback((path: string) => {
|
||||
if (activeSegmentsRef.current.includes("player")) {
|
||||
// Leave the root player modal before navigating into the library stack.
|
||||
router.dismiss()
|
||||
router.navigate(tabPath("library", path))
|
||||
return
|
||||
}
|
||||
|
||||
router.push(tabPath(getActiveTabFromRef(), path))
|
||||
}, [router])
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Keep the destination while server setup or sign-in is on screen.
|
||||
const listeners = new Set<() => void>()
|
||||
|
||||
export function subscribeIncomingMediaLink(listener: () => void) {
|
||||
listeners.add(listener)
|
||||
return () => {
|
||||
listeners.delete(listener)
|
||||
}
|
||||
}
|
||||
|
||||
let pendingLink: { path: string; serverOrigin: string } | null = null
|
||||
|
||||
export function incomingMediaLink(serverUrl: string) {
|
||||
if (!pendingLink) return null
|
||||
return new URL(serverUrl).origin === pendingLink.serverOrigin
|
||||
? pendingLink.path
|
||||
: null
|
||||
}
|
||||
|
||||
export function takeIncomingMediaLink(serverUrl: string) {
|
||||
const path = incomingMediaLink(serverUrl)
|
||||
pendingLink = null
|
||||
for (const listener of listeners) listener()
|
||||
return path
|
||||
}
|
||||
|
||||
export function rememberIncomingMediaLink(path: string, serverOrigin: string) {
|
||||
pendingLink = { path, serverOrigin }
|
||||
for (const listener of listeners) listener()
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
export type MediaShareContext = (
|
||||
export type MediaShareContext =
|
||||
| { type: "album"; albumId: string }
|
||||
| { type: "song"; albumId: string; songId: string }
|
||||
| { type: "playlist"; playlistId: string; isFavorites?: boolean }
|
||||
| { type: "artist"; artistId: string }
|
||||
) & { title: string }
|
||||
|
||||
export function shouldShowShare(
|
||||
share: MediaShareContext | undefined,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { NativeStackNavigationOptions } from "expo-router"
|
||||
import { Platform } from "react-native"
|
||||
import { useColorScheme } from "react-native"
|
||||
|
||||
import { useThemeColors } from "@/lib/theme"
|
||||
import { colors } from "@/lib/theme"
|
||||
|
||||
type StackScreenOptions = NativeStackNavigationOptions
|
||||
|
||||
@@ -18,7 +18,8 @@ export const tabStackScreenTitles: Record<string, string> = {
|
||||
export function useStackScreenOptions(
|
||||
overrides?: StackScreenOptions
|
||||
): StackScreenOptions {
|
||||
const theme = useThemeColors()
|
||||
const scheme = useColorScheme()
|
||||
const theme = scheme === "dark" ? colors.dark : colors.light
|
||||
|
||||
return {
|
||||
headerLargeTitle: true,
|
||||
@@ -26,17 +27,6 @@ export function useStackScreenOptions(
|
||||
headerTintColor: theme.foreground,
|
||||
headerLargeTitleStyle: { color: theme.foreground },
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
...(Platform.OS === "android"
|
||||
? {
|
||||
animation: "slide_from_right",
|
||||
headerLargeTitle: false,
|
||||
headerTransparent: false,
|
||||
headerStyle: { backgroundColor: theme.background },
|
||||
headerShadowVisible: false,
|
||||
statusBarStyle: "light" as const,
|
||||
contentStyle: { backgroundColor: theme.background },
|
||||
}
|
||||
: {}),
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
import { Platform } from "react-native"
|
||||
|
||||
// Android Dolby decoder reports do not reliably indicate working Atmos playback.
|
||||
export const dolbyAtmosSupported = Platform.OS === "ios"
|
||||
@@ -1,4 +1,3 @@
|
||||
import { requireOptionalNativeModule } from "expo"
|
||||
import * as Sharing from "expo-sharing"
|
||||
import { Platform, Share } from "react-native"
|
||||
|
||||
@@ -6,10 +5,6 @@ import type { MediaShareContext } from "@/lib/media-links"
|
||||
import { mediaShareUrl } from "@/lib/media-links"
|
||||
import { showError } from "@/lib/toast"
|
||||
|
||||
const nativeShare = requireOptionalNativeModule<{
|
||||
share: (url: string, artwork: string, title: string) => Promise<void>
|
||||
}>("MediaLinkShare")
|
||||
|
||||
export async function shareMediaLink(
|
||||
serverUrl: string,
|
||||
share: MediaShareContext
|
||||
@@ -22,32 +17,12 @@ export async function shareMediaLink(
|
||||
showError("Sharing is not available on this device")
|
||||
return
|
||||
}
|
||||
await Sharing.shareAsync(url, { dialogTitle: share.title })
|
||||
return
|
||||
}
|
||||
|
||||
if (nativeShare) {
|
||||
const type = share.type === "song" ? "album" : share.type
|
||||
const id =
|
||||
share.type === "album" || share.type === "song"
|
||||
? share.albumId
|
||||
: share.type === "artist"
|
||||
? share.artistId
|
||||
: share.isFavorites
|
||||
? "favorites"
|
||||
: share.playlistId
|
||||
await nativeShare.share(
|
||||
url,
|
||||
`${serverUrl.replace(/\/+$/, "")}/api/${type}/${id}/cover?size=512`,
|
||||
share.title
|
||||
)
|
||||
await Sharing.shareAsync(url, { dialogTitle: "Share" })
|
||||
return
|
||||
}
|
||||
|
||||
await Share.share(
|
||||
Platform.OS === "ios"
|
||||
? { url, title: share.title }
|
||||
: { message: url, title: share.title }
|
||||
Platform.OS === "ios" ? { url } : { message: url }
|
||||
)
|
||||
} catch (error) {
|
||||
if (error instanceof Error && /cancel/i.test(error.message)) {
|
||||
|
||||
@@ -50,12 +50,12 @@ export const colors = {
|
||||
export type ThemeColors = (typeof colors)[keyof typeof colors]
|
||||
|
||||
export function useThemeColors(): ThemeColors {
|
||||
return useIsDark() ? colors.dark : colors.light
|
||||
const scheme = useColorScheme()
|
||||
return scheme === "dark" ? colors.dark : colors.light
|
||||
}
|
||||
|
||||
export function useIsDark(): boolean {
|
||||
const scheme = useColorScheme()
|
||||
return Platform.OS === "android" || scheme === "dark"
|
||||
return useColorScheme() === "dark"
|
||||
}
|
||||
|
||||
export function useBlurTint(): "light" | "dark" {
|
||||
@@ -84,13 +84,13 @@ export const radius = {
|
||||
} as const
|
||||
|
||||
export const miniPlayerHeight = 56
|
||||
export const tabBarHeight = Platform.OS === "ios" ? 49 : 80
|
||||
export const tabBarHeight = Platform.OS === "ios" ? 49 : 56
|
||||
export const playerBarHeight = miniPlayerHeight
|
||||
export const carouselCardWidth = 160
|
||||
|
||||
export function useTwoColumnCardWidth(
|
||||
horizontalPadding = spacing.lg,
|
||||
gap = spacing.md
|
||||
gap = spacing.md,
|
||||
) {
|
||||
const { width } = useWindowDimensions()
|
||||
return Math.floor((width - horizontalPadding * 2 - gap) / 2)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||
import { Platform } from "react-native"
|
||||
import type { AudioSource } from "expo-audio"
|
||||
|
||||
export type PlaybackQuality = "low" | "medium" | "high" | "lossless"
|
||||
@@ -52,9 +50,8 @@ export function songPlayUrl(
|
||||
preferAtmos: boolean | undefined
|
||||
) {
|
||||
const params = new URLSearchParams()
|
||||
if (Platform.OS === "ios") params.set("losslessFormat", "alac")
|
||||
if (quality) params.set("quality", quality)
|
||||
if (dolbyAtmosSupported && preferAtmos) params.set("preferAtmos", "true")
|
||||
if (preferAtmos) params.set("preferAtmos", "true")
|
||||
const query = params.toString()
|
||||
return `${serverUrl}/api/song/${songId}/play${query ? `?${query}` : ""}`
|
||||
}
|
||||
@@ -67,7 +64,7 @@ export function songHlsPlaylistUrl(
|
||||
) {
|
||||
const params = new URLSearchParams()
|
||||
if (quality) params.set("quality", quality)
|
||||
if (dolbyAtmosSupported && preferAtmos) params.set("preferAtmos", "true")
|
||||
if (preferAtmos) params.set("preferAtmos", "true")
|
||||
const query = params.toString()
|
||||
return `${serverUrl}/api/song/${songId}/play/hls${query ? `?${query}` : ""}`
|
||||
}
|
||||
@@ -89,13 +86,8 @@ export function songAudioSource(
|
||||
: undefined
|
||||
const name = options?.songTitle
|
||||
|
||||
if (headers || name || useHls) {
|
||||
return {
|
||||
uri,
|
||||
...(useHls ? { mimeType: "application/x-mpegURL" } : {}),
|
||||
...(name ? { name } : {}),
|
||||
...(headers ? { headers } : {}),
|
||||
}
|
||||
if (headers || name) {
|
||||
return { uri, ...(name ? { name } : {}), ...(headers ? { headers } : {}) }
|
||||
}
|
||||
|
||||
return uri
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/android/build/
|
||||
@@ -1,15 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'expo-module-gradle-plugin'
|
||||
}
|
||||
|
||||
group = 'expo.modules.audiooutput'
|
||||
version = '1.0.0'
|
||||
|
||||
android {
|
||||
namespace 'expo.modules.audiooutput'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.mediarouter:mediarouter:1.8.1'
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Android 13's switcher helper checks for a system broadcast receiver. -->
|
||||
<queries>
|
||||
<package android:name="com.android.systemui" />
|
||||
<intent>
|
||||
<action android:name="com.android.settings.panel.action.MEDIA_OUTPUT" />
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
||||
@@ -1,23 +0,0 @@
|
||||
package expo.modules.audiooutput
|
||||
|
||||
import android.os.Build
|
||||
import androidx.mediarouter.app.SystemOutputSwitcherDialogController
|
||||
import expo.modules.kotlin.functions.Queues
|
||||
import expo.modules.kotlin.modules.Module
|
||||
import expo.modules.kotlin.modules.ModuleDefinition
|
||||
|
||||
class AudioOutputModule : Module() {
|
||||
override fun definition() = ModuleDefinition {
|
||||
Name("AudioOutput")
|
||||
|
||||
AsyncFunction("showPicker") {
|
||||
val activity = appContext.currentActivity
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || activity == null) {
|
||||
false
|
||||
} else {
|
||||
// AndroidX handles Android 13's system intent and Android 14+'s public API.
|
||||
SystemOutputSwitcherDialogController.showDialog(activity)
|
||||
}
|
||||
}.runOnQueue(Queues.MAIN)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"platforms": ["apple", "android"],
|
||||
"apple": {
|
||||
"modules": ["AudioOutputModule"]
|
||||
},
|
||||
"android": {
|
||||
"modules": ["expo.modules.audiooutput.AudioOutputModule"]
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'AudioOutput'
|
||||
s.version = '1.0.0'
|
||||
s.summary = 'Native audio output selection for oTunes'
|
||||
s.description = s.summary
|
||||
s.license = { :type => 'MIT' }
|
||||
s.author = 'oTunes'
|
||||
s.homepage = 'https://otunes.abunchofknowitalls.com'
|
||||
s.platforms = { :ios => '16.4' }
|
||||
s.swift_version = '5.9'
|
||||
s.source = { :git => '' }
|
||||
s.static_framework = true
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
||||
s.dependency 'ExpoModulesCore'
|
||||
s.frameworks = 'AVKit'
|
||||
s.source_files = '**/*.swift'
|
||||
end
|
||||
@@ -1,44 +0,0 @@
|
||||
import AVKit
|
||||
import ExpoModulesCore
|
||||
|
||||
public class AudioOutputModule: Module {
|
||||
public func definition() -> ModuleDefinition {
|
||||
Name("AudioOutput")
|
||||
|
||||
View(AudioOutputView.self) {
|
||||
Prop("tint") { (view: AudioOutputView, color: UIColor) in
|
||||
view.icon.tintColor = color
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class AudioOutputView: ExpoView {
|
||||
private let picker = AVRoutePickerView()
|
||||
let icon = UIImageView(
|
||||
image: UIImage(
|
||||
systemName: "airplay.audio",
|
||||
withConfiguration: UIImage.SymbolConfiguration(pointSize: 27, weight: .semibold)
|
||||
)
|
||||
)
|
||||
|
||||
required init(appContext: AppContext? = nil) {
|
||||
super.init(appContext: appContext)
|
||||
picker.prioritizesVideoDevices = false
|
||||
picker.backgroundColor = .clear
|
||||
// Hide only the native glyph. Making the picker transparent prevents taps.
|
||||
picker.tintColor = .clear
|
||||
picker.activeTintColor = .clear
|
||||
addSubview(picker)
|
||||
icon.contentMode = .center
|
||||
icon.isUserInteractionEnabled = false
|
||||
icon.isAccessibilityElement = false
|
||||
addSubview(icon)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
picker.frame = bounds
|
||||
icon.frame = bounds
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "otunes-audio-output",
|
||||
"version": "1.0.0",
|
||||
"private": true
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.abunchofknowitalls.otunes
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.Intent
|
||||
import androidx.core.content.FileProvider
|
||||
import expo.modules.kotlin.modules.Module
|
||||
import expo.modules.kotlin.modules.ModuleDefinition
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
|
||||
class MediaLinkShare : Module() {
|
||||
override fun definition() = ModuleDefinition {
|
||||
Name("MediaLinkShare")
|
||||
AsyncFunction("share") { link: String, artwork: String, title: String ->
|
||||
val context = requireNotNull(appContext.reactContext)
|
||||
val intent = Intent(Intent.ACTION_SEND).apply {
|
||||
type = "text/plain"
|
||||
putExtra(Intent.EXTRA_TEXT, link)
|
||||
putExtra(Intent.EXTRA_TITLE, title)
|
||||
putExtra(Intent.EXTRA_SUBJECT, title)
|
||||
}
|
||||
// ClipData supplies the chooser thumbnail while the shared item stays a URL.
|
||||
try {
|
||||
val connection = URL(artwork).openConnection().apply {
|
||||
connectTimeout = 8000
|
||||
readTimeout = 8000
|
||||
}
|
||||
context.cacheDir.listFiles()?.filter {
|
||||
it.name.startsWith("media-link-cover-") && it.lastModified() < System.currentTimeMillis() - 86400000
|
||||
}?.forEach { it.delete() }
|
||||
val extension = when (connection.contentType?.substringBefore(";")) {
|
||||
"image/webp" -> "webp"
|
||||
"image/png" -> "png"
|
||||
"image/jpeg" -> "jpg"
|
||||
"image/gif" -> "gif"
|
||||
else -> error("Artwork format is not supported")
|
||||
}
|
||||
val file = File(context.cacheDir, "media-link-cover-${java.util.UUID.randomUUID()}.${extension}")
|
||||
connection.getInputStream().use { input ->
|
||||
file.outputStream().use { output -> input.copyTo(output) }
|
||||
}
|
||||
val uri = FileProvider.getUriForFile(context, context.packageName + ".SharingFileProvider", file)
|
||||
intent.clipData = ClipData.newUri(context.contentResolver, "Artwork", uri)
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
} catch (_: Exception) {
|
||||
// A failed artwork download must not prevent sharing the link.
|
||||
}
|
||||
appContext.throwingActivity.runOnUiThread {
|
||||
appContext.throwingActivity.startActivity(Intent.createChooser(intent, "Share"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
import UIKit
|
||||
import LinkPresentation
|
||||
internal import ExpoModulesCore
|
||||
|
||||
private final class MediaLinkItem: NSObject, UIActivityItemSource {
|
||||
let url: URL
|
||||
let image: UIImage?
|
||||
let title: String
|
||||
init(url: URL, image: UIImage?, title: String) {
|
||||
self.url = url
|
||||
self.image = image
|
||||
self.title = title
|
||||
}
|
||||
func activityViewControllerPlaceholderItem(_ controller: UIActivityViewController) -> Any { url }
|
||||
func activityViewController(_ controller: UIActivityViewController, itemForActivityType: UIActivity.ActivityType?) -> Any? { url }
|
||||
func activityViewControllerLinkMetadata(_ controller: UIActivityViewController) -> LPLinkMetadata? {
|
||||
let metadata = LPLinkMetadata()
|
||||
metadata.originalURL = url
|
||||
metadata.url = url
|
||||
metadata.title = title
|
||||
if let image {
|
||||
metadata.imageProvider = NSItemProvider(object: image)
|
||||
metadata.iconProvider = NSItemProvider(object: image)
|
||||
}
|
||||
return metadata
|
||||
}
|
||||
}
|
||||
|
||||
final class MediaLinkShare: Module {
|
||||
public func definition() -> ExpoModulesCore.ModuleDefinition {
|
||||
Name("MediaLinkShare")
|
||||
AsyncFunction("share") { (link: String, artwork: String, title: String) in
|
||||
guard let url = URL(string: link), let artworkURL = URL(string: artwork) else { return }
|
||||
var image: UIImage?
|
||||
var request = URLRequest(url: artworkURL)
|
||||
request.timeoutInterval = 8
|
||||
if let (data, response) = try? await URLSession.shared.data(for: request),
|
||||
(response as? HTTPURLResponse)?.statusCode == 200 {
|
||||
image = UIImage(data: data)
|
||||
}
|
||||
let artworkImage = image
|
||||
await MainActor.run {
|
||||
guard let presenter = self.appContext?.utilities?.currentViewController() else { return }
|
||||
let controller = UIActivityViewController(
|
||||
activityItems: [MediaLinkItem(url: url, image: artworkImage, title: title)], applicationActivities: nil)
|
||||
if let popover = controller.popoverPresentationController {
|
||||
popover.sourceView = presenter.view
|
||||
popover.sourceRect = CGRect(x: presenter.view.bounds.midX, y: presenter.view.bounds.midY, width: 0, height: 0)
|
||||
popover.permittedArrowDirections = []
|
||||
}
|
||||
presenter.present(controller, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.abunchofknowitalls.otunes
|
||||
|
||||
import android.content.Context
|
||||
import android.database.ContentObserver
|
||||
import android.media.AudioManager
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Settings
|
||||
import expo.modules.kotlin.functions.Queues
|
||||
import expo.modules.kotlin.modules.Module
|
||||
import expo.modules.kotlin.modules.ModuleDefinition
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class SystemVolume : Module() {
|
||||
private val context get() = requireNotNull(appContext.reactContext)
|
||||
private val audio get() = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
private var observer: ContentObserver? = null
|
||||
private var lastState: Map<String, Any>? = null
|
||||
|
||||
override fun definition() = ModuleDefinition {
|
||||
Name("SystemVolume")
|
||||
Events("onVolumeChange")
|
||||
|
||||
AsyncFunction("getState") { state() }.runOnQueue(Queues.MAIN)
|
||||
|
||||
AsyncFunction("setVolume") { value: Double ->
|
||||
if (value.isFinite() && available()) {
|
||||
val maximum = audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||
val minimum = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
audio.getStreamMinVolume(AudioManager.STREAM_MUSIC)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
val index = (value.coerceIn(0.0, 1.0) * maximum).roundToInt().coerceIn(minimum, maximum)
|
||||
audio.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0)
|
||||
publishState()
|
||||
}
|
||||
}.runOnQueue(Queues.MAIN)
|
||||
|
||||
OnStartObserving {
|
||||
lastState = null
|
||||
observer = object : ContentObserver(Handler(Looper.getMainLooper())) {
|
||||
override fun onChange(selfChange: Boolean) = publishState()
|
||||
}.also {
|
||||
context.contentResolver.registerContentObserver(Settings.System.CONTENT_URI, true, it)
|
||||
}
|
||||
}
|
||||
|
||||
OnStopObserving { stopObserving() }
|
||||
OnDestroy { stopObserving() }
|
||||
}
|
||||
|
||||
private fun available(): Boolean =
|
||||
!audio.isVolumeFixed && audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC) > 0
|
||||
|
||||
private fun state(): Map<String, Any> {
|
||||
val maximum = audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||
return mapOf(
|
||||
"volume" to if (maximum > 0) audio.getStreamVolume(AudioManager.STREAM_MUSIC).toDouble() / maximum else 0.0,
|
||||
"available" to available()
|
||||
)
|
||||
}
|
||||
|
||||
private fun publishState() {
|
||||
val next = state()
|
||||
if (next != lastState) {
|
||||
lastState = next
|
||||
sendEvent("onVolumeChange", next)
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopObserving() {
|
||||
observer?.let { context.contentResolver.unregisterContentObserver(it) }
|
||||
observer = null
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
import AVFAudio
|
||||
import MediaPlayer
|
||||
import UIKit
|
||||
internal import ExpoModulesCore
|
||||
|
||||
/// Bridges system volume without changing the playback audio session or player gain.
|
||||
final class SystemVolume: Module {
|
||||
private var volumeView: MPVolumeView?
|
||||
private var observation: NSKeyValueObservation?
|
||||
|
||||
public func definition() -> ExpoModulesCore.ModuleDefinition {
|
||||
Name("SystemVolume")
|
||||
Events("onVolumeChange")
|
||||
|
||||
AsyncFunction("getState") { () -> [String: Any] in
|
||||
return self.state()
|
||||
}.runOnQueue(.main)
|
||||
|
||||
AsyncFunction("setPlayerVisible") { (visible: Bool) in
|
||||
if visible {
|
||||
self.prepareVolumeView()
|
||||
} else {
|
||||
self.volumeView?.removeFromSuperview()
|
||||
self.volumeView = nil
|
||||
}
|
||||
}.runOnQueue(.main)
|
||||
|
||||
AsyncFunction("setVolume") { (value: Double) in
|
||||
guard value.isFinite, self.volumeView?.window != nil,
|
||||
let slider = self.volumeView?.subviews.compactMap({ $0 as? UISlider }).first
|
||||
else { return }
|
||||
slider.setValue(Float(min(1, max(0, value))), animated: false)
|
||||
slider.sendActions(for: .valueChanged)
|
||||
slider.sendActions(for: .touchUpInside)
|
||||
}.runOnQueue(.main)
|
||||
|
||||
OnStartObserving {
|
||||
self.observation = AVAudioSession.sharedInstance().observe(
|
||||
\.outputVolume, options: [.new]
|
||||
) { [weak self] _, _ in
|
||||
guard let self else { return }
|
||||
self.sendEvent("onVolumeChange", self.state())
|
||||
}
|
||||
}
|
||||
|
||||
OnStopObserving {
|
||||
self.observation = nil
|
||||
}
|
||||
|
||||
OnDestroy {
|
||||
self.observation = nil
|
||||
let view = self.volumeView
|
||||
self.volumeView = nil
|
||||
DispatchQueue.main.async { view?.removeFromSuperview() }
|
||||
}
|
||||
}
|
||||
|
||||
private func prepareVolumeView() {
|
||||
#if !targetEnvironment(simulator)
|
||||
if volumeView == nil {
|
||||
// MPVolumeView must belong to a window to control the device's volume.
|
||||
let view = MPVolumeView(frame: CGRect(x: -200, y: -200, width: 120, height: 30))
|
||||
view.showsRouteButton = false
|
||||
volumeView = view
|
||||
}
|
||||
if volumeView?.window == nil {
|
||||
let window = UIApplication.shared.connectedScenes
|
||||
.compactMap { $0 as? UIWindowScene }
|
||||
.flatMap { $0.windows }
|
||||
.first { $0.isKeyWindow }
|
||||
if let volumeView { window?.addSubview(volumeView) }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private func state() -> [String: Any] {
|
||||
#if targetEnvironment(simulator)
|
||||
// Simulator's host audio controls do not update AVAudioSession.outputVolume.
|
||||
let available = false
|
||||
#else
|
||||
// The control remains visible on physical iPhones, including during route changes.
|
||||
let available = true
|
||||
#endif
|
||||
return ["volume": AVAudioSession.sharedInstance().outputVolume, "available": available]
|
||||
}
|
||||
}
|
||||
@@ -34,14 +34,12 @@
|
||||
"expo-image": "~58.0.16",
|
||||
"expo-image-picker": "~58.0.10",
|
||||
"expo-linking": "~58.0.14",
|
||||
"expo-navigation-bar": "~58.0.4",
|
||||
"expo-router": "~58.0.25",
|
||||
"expo-secure-store": "~58.0.2",
|
||||
"expo-sharing": "~58.0.20",
|
||||
"expo-splash-screen": "~58.0.11",
|
||||
"expo-status-bar": "~58.0.4",
|
||||
"expo-symbols": "~58.0.4",
|
||||
"expo-system-ui": "~58.0.6",
|
||||
"react": "19.3.0",
|
||||
"react-dom": "19.3.0",
|
||||
"react-native": "0.88.0",
|
||||
@@ -59,12 +57,5 @@
|
||||
"@types/react": "~19.3.0",
|
||||
"babel-preset-expo": "^58.0.18",
|
||||
"typescript": "~6.0.3"
|
||||
},
|
||||
"expo": {
|
||||
"autolinking": {
|
||||
"buildFromSource": [
|
||||
"expo-audio"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
const { withAndroidStyles } = require("expo/config-plugins")
|
||||
|
||||
// Native controls and system bars must never fall back to device theme colors.
|
||||
module.exports = (config) =>
|
||||
withAndroidStyles(config, (config) => {
|
||||
const theme = config.modResults.resources.style.find(
|
||||
(style) => style.$.name === "AppTheme"
|
||||
)
|
||||
const colors = {
|
||||
colorPrimary: "#FA2D48",
|
||||
colorPrimaryDark: "#000000",
|
||||
colorAccent: "#FA2D48",
|
||||
"android:windowBackground": "#000000",
|
||||
"android:statusBarColor": "#000000",
|
||||
"android:navigationBarColor": "#000000",
|
||||
"android:windowLightStatusBar": "false",
|
||||
"android:windowLightNavigationBar": "false",
|
||||
"android:enforceStatusBarContrast": "false",
|
||||
"android:enforceNavigationBarContrast": "false",
|
||||
}
|
||||
for (const [name, value] of Object.entries(colors)) {
|
||||
theme.item = theme.item.filter((item) => item.$.name !== name)
|
||||
theme.item.push({ $: { name }, _: value })
|
||||
}
|
||||
return config
|
||||
})
|
||||
@@ -1,7 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import { PageHeader } from "@/components/library-skeletons"
|
||||
|
||||
import Link from "next/link"
|
||||
import { Home, Search } from "lucide-react"
|
||||
|
||||
@@ -10,7 +8,6 @@ import { Button } from "@/components/ui/button"
|
||||
export default function Page() {
|
||||
return (
|
||||
<div className="flex h-svh flex-col">
|
||||
<PageHeader />
|
||||
<div className="flex flex-1 items-center justify-center px-6 pb-28">
|
||||
<div className="flex max-w-md flex-col items-center text-center">
|
||||
<p className="text-sm font-medium text-muted-foreground">404</p>
|
||||
|
||||
@@ -5,8 +5,6 @@ import { PlayerBar } from "@/components/player-bar"
|
||||
import { LazyQueuePanel } from "@/components/lazy-queue-panel"
|
||||
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar"
|
||||
import { AppSidebar } from "@/components/app-sidebar"
|
||||
import { ScrollRestoration } from "@/components/scroll-restoration"
|
||||
import { Suspense } from "react"
|
||||
|
||||
export default function AppLayout({
|
||||
children,
|
||||
@@ -20,11 +18,7 @@ export default function AppLayout({
|
||||
<FavoritesProvider>
|
||||
<AppSidebar />
|
||||
<div className="flex min-h-svh min-w-0 flex-1">
|
||||
<SidebarInset className="min-w-0 flex-1">
|
||||
<Suspense>
|
||||
<ScrollRestoration>{children}</ScrollRestoration>
|
||||
</Suspense>
|
||||
</SidebarInset>
|
||||
<SidebarInset className="min-w-0 flex-1">{children}</SidebarInset>
|
||||
<LazyQueuePanel />
|
||||
</div>
|
||||
<PlayerBar />
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||
import { Plus } from "lucide-react"
|
||||
|
||||
import { useAddToPlaylist } from "@/components/add-to-playlist-provider"
|
||||
@@ -18,10 +17,7 @@ export default function Page() {
|
||||
return (
|
||||
<div className="flex h-svh flex-col">
|
||||
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<MobileSidebarTrigger />
|
||||
<h1 className="text-lg font-semibold">Playlists</h1>
|
||||
</div>
|
||||
<h1 className="text-lg font-semibold">Playlists</h1>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import { useSearchParams } from "next/navigation"
|
||||
|
||||
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||
import { SearchResultsSkeleton } from "@/components/library-skeletons"
|
||||
import { SearchPrompt } from "@/components/search-prompt"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
@@ -12,8 +11,7 @@ export default function Loading() {
|
||||
|
||||
return (
|
||||
<div className="flex h-svh flex-col">
|
||||
<header className="flex items-center justify-center gap-2 border-b px-4 py-3">
|
||||
<MobileSidebarTrigger />
|
||||
<header className="flex items-center justify-center border-b px-4 py-3">
|
||||
<Skeleton className="h-10 w-full max-w-xl rounded-full" />
|
||||
</header>
|
||||
{hasQuery ? <SearchResultsSkeleton /> : <SearchPrompt />}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||
import { Suspense, useCallback, useEffect, useRef, useState } from "react"
|
||||
import { SearchIcon } from "lucide-react"
|
||||
import { usePathname, useSearchParams } from "next/navigation"
|
||||
@@ -213,8 +212,7 @@ function SearchPageContent() {
|
||||
|
||||
return (
|
||||
<div className="flex h-svh flex-col">
|
||||
<header className="flex items-center justify-center gap-2 border-b px-4 py-3">
|
||||
<MobileSidebarTrigger />
|
||||
<header className="flex items-center justify-center border-b px-4 py-3">
|
||||
<div className="relative w-full max-w-xl">
|
||||
<SearchIcon className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<input
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import type { Id } from "@otunes/convex/_generated/dataModel"
|
||||
import { audioContentTypeForPath } from "@/lib/audio-content-type"
|
||||
import { seekableLosslessFile } from "@/lib/server-lossless"
|
||||
import { getConvexClient } from "@/lib/convex-server"
|
||||
import { ffmpegToReadableStream, streamFile } from "@/lib/server-audio-stream"
|
||||
import { NextRequest, NextResponse, userAgent } from "next/server"
|
||||
@@ -123,7 +122,11 @@ export async function GET(
|
||||
}))!
|
||||
|
||||
const quality = request.nextUrl.searchParams.get("quality") as
|
||||
"low" | "medium" | "high" | "lossless" | null
|
||||
| "low"
|
||||
| "medium"
|
||||
| "high"
|
||||
| "lossless"
|
||||
| null
|
||||
|
||||
const preferAtmos =
|
||||
request.nextUrl.searchParams.get("preferAtmos") === "true"
|
||||
@@ -154,11 +157,7 @@ export async function GET(
|
||||
const metadata = await music.parseFile(song.files[originalCodec])
|
||||
|
||||
if (!transcodeNeeded && originalCodec === "lossless") {
|
||||
// Native iOS playback does not identify itself as Safari.
|
||||
const acceptsAlac =
|
||||
browser.name === "Safari" ||
|
||||
request.nextUrl.searchParams.get("losslessFormat") === "alac"
|
||||
if (acceptsAlac && metadata.format.codec === "ALAC") {
|
||||
if (browser.name === "Safari" && metadata.format.codec === "ALAC") {
|
||||
try {
|
||||
return await streamFileResponse(
|
||||
request,
|
||||
@@ -170,9 +169,26 @@ export async function GET(
|
||||
}
|
||||
}
|
||||
|
||||
const ffmpegArgs = [
|
||||
"-nostdin",
|
||||
"-i",
|
||||
song.files[originalCodec],
|
||||
"-f",
|
||||
"flac",
|
||||
"pipe:1",
|
||||
]
|
||||
|
||||
try {
|
||||
const file = await seekableLosslessFile(song.files[originalCodec])
|
||||
return await streamFileResponse(request, file, "audio/flac")
|
||||
const ffmpegProcess = spawn("ffmpeg", ffmpegArgs)
|
||||
const stream = ffmpegToReadableStream(ffmpegProcess)
|
||||
|
||||
return new NextResponse(stream, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "audio/flac",
|
||||
"Cache-Control": "no-cache",
|
||||
},
|
||||
})
|
||||
} catch {
|
||||
return new Response("Server Error", { status: 500 })
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 35 KiB |
@@ -1,12 +1,10 @@
|
||||
"use client"
|
||||
|
||||
import { PageHeader } from "@/components/library-skeletons"
|
||||
import * as React from "react"
|
||||
import Image from "next/image"
|
||||
import Link from "next/link"
|
||||
import { Play, Share2, Shuffle, Star } from "lucide-react"
|
||||
|
||||
import { AudioFormatBadge } from "@/components/audio-format-badge"
|
||||
import { MediaCollectionFooter } from "@/components/media-collection-footer"
|
||||
import { TrackNumberPlayButton } from "@/components/track-number-play-button"
|
||||
|
||||
@@ -22,8 +20,6 @@ import {
|
||||
} from "@/components/media-context-menu"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { ScrollArea } from "@/components/ui/scroll-area"
|
||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import { useQueueMediaActions } from "@/hooks/use-queue-media-actions"
|
||||
import { useTrackSelection } from "@/hooks/use-track-selection"
|
||||
import { cn } from "@/lib/utils"
|
||||
@@ -276,20 +272,6 @@ export function AlbumView({
|
||||
[album.tracks]
|
||||
)
|
||||
|
||||
// Older servers do not include album format availability yet.
|
||||
const formatTracks = useCachedQuery(
|
||||
api.library.getSongsForPlayback,
|
||||
album.hasLossless === undefined || album.hasAtmos === undefined
|
||||
? { ids: albumSongIds }
|
||||
: "skip"
|
||||
)
|
||||
const hasLossless =
|
||||
album.hasLossless ??
|
||||
formatTracks?.some((track) => track && "lossless" in track.files)
|
||||
const hasAtmos =
|
||||
album.hasAtmos ??
|
||||
formatTracks?.some((track) => track && "atmos" in track.files)
|
||||
|
||||
React.useEffect(() => {
|
||||
rememberSongs(albumDetailSongs(album))
|
||||
}, [album])
|
||||
@@ -389,8 +371,7 @@ export function AlbumView({
|
||||
|
||||
return (
|
||||
<div className="flex h-svh flex-col">
|
||||
<PageHeader openApp />
|
||||
<ScrollArea className="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:block!">
|
||||
<ScrollArea className="min-h-0 flex-1">
|
||||
<div className="pb-28">
|
||||
<div className="mx-auto w-full min-w-0 max-w-9/10">
|
||||
<div className="flex flex-col gap-8 pt-6 pb-8 sm:flex-row sm:items-end">
|
||||
@@ -419,23 +400,9 @@ export function AlbumView({
|
||||
>
|
||||
{album.artist.name}
|
||||
</Link>
|
||||
<div className="flex flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground sm:justify-start">
|
||||
{metadata ? <span>{metadata}</span> : null}
|
||||
{hasLossless ? (
|
||||
<>
|
||||
{metadata ? <span aria-hidden>·</span> : null}
|
||||
<AudioFormatBadge format="lossless" />
|
||||
</>
|
||||
) : null}
|
||||
{hasAtmos ? (
|
||||
<>
|
||||
{metadata || hasLossless ? (
|
||||
<span aria-hidden>·</span>
|
||||
) : null}
|
||||
<AudioFormatBadge format="atmos" />
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
{metadata ? (
|
||||
<p className="text-sm text-muted-foreground">{metadata}</p>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center justify-center gap-2 sm:justify-start">
|
||||
@@ -547,8 +514,7 @@ export function AlbumView({
|
||||
onPlay={() =>
|
||||
void playFromSong(
|
||||
track.id as Id<"songs">,
|
||||
albumSongIds,
|
||||
`album:${album.id}`
|
||||
albumSongIds
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -35,7 +35,6 @@ import {
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
useSidebar,
|
||||
} from "@/components/ui/sidebar"
|
||||
import { ThemeToggle } from "@/components/theme-toggle"
|
||||
import Image from "next/image"
|
||||
@@ -64,7 +63,6 @@ const library = [
|
||||
]
|
||||
|
||||
export function AppSidebar() {
|
||||
const { setOpenMobile } = useSidebar()
|
||||
const pathname = usePathname()
|
||||
const router = useRouter()
|
||||
const { signOut } = useAuthActions()
|
||||
@@ -122,7 +120,7 @@ export function AppSidebar() {
|
||||
{browse.map((item) => (
|
||||
<SidebarMenuItem key={item.title}>
|
||||
<SidebarMenuButton isActive={pathname === item.path} asChild>
|
||||
<Link href={item.path} onClick={() => setOpenMobile(false)}>
|
||||
<Link href={item.path}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
</Link>
|
||||
@@ -146,7 +144,7 @@ export function AppSidebar() {
|
||||
}
|
||||
asChild
|
||||
>
|
||||
<Link href={item.path} onClick={() => setOpenMobile(false)}>
|
||||
<Link href={item.path}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
</Link>
|
||||
@@ -164,7 +162,7 @@ export function AppSidebar() {
|
||||
{playlistNav.map((item) => (
|
||||
<SidebarMenuItem key={item.path}>
|
||||
<SidebarMenuButton isActive={pathname === item.path} asChild>
|
||||
<Link href={item.path} onClick={() => setOpenMobile(false)}>
|
||||
<Link href={item.path}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
</Link>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import { PageHeader } from "@/components/library-skeletons"
|
||||
import * as React from "react"
|
||||
import Image from "next/image"
|
||||
import { Play, Shuffle } from "lucide-react"
|
||||
@@ -65,7 +64,6 @@ export function ArtistView({
|
||||
|
||||
return (
|
||||
<div className="flex h-svh flex-col">
|
||||
<PageHeader openApp />
|
||||
<ScrollArea className="min-h-0 flex-1">
|
||||
<div className="pb-28">
|
||||
<div className="flex min-w-0 items-center gap-4 px-6 pt-6 pb-8 sm:gap-6">
|
||||
|
||||