feat (mobile): fix cover placeholders, tab bar, headers

This commit is contained in:
joshuafhiggins authored and Joshua Higgins committed 2026-08-02 04:14:01 +00:00
1 parent 482bec1fd1
commit 8987163281
15 files changed
+197 -115

No files matched your search

+24 -10
View File
@@ -54,11 +54,21 @@ function useNativeTabColors() {
iconColor,
labelStyle: {
default: { color: labelColor, fontSize: 10 },
selected: { color: appleMusic.pink, fontSize: 10, fontWeight: "600" as const },
selected: {
color: appleMusic.pink,
fontSize: 10,
fontWeight: "600" as const,
},
},
blurEffect: isDark ? "systemChromeMaterialDark" : "systemChromeMaterialLight",
blurEffect: isDark
? "systemChromeMaterialDark"
: "systemChromeMaterialLight",
backgroundColor:
Platform.OS === "ios" ? undefined : isDark ? appleMusic.background : colors.light.background,
Platform.OS === "ios"
? undefined
: isDark
? appleMusic.background
: colors.light.background,
}
}
@@ -69,7 +79,11 @@ export default function TabsLayout() {
return (
<ThemeProvider value={routerTheme}>
<NativeTabs
blurEffect={tabColors.blurEffect as "systemChromeMaterialDark" | "systemChromeMaterialLight"}
blurEffect={
tabColors.blurEffect as
| "systemChromeMaterialDark"
| "systemChromeMaterialLight"
}
backgroundColor={tabColors.backgroundColor}
iconColor={tabColors.iconColor}
labelStyle={tabColors.labelStyle}
@@ -81,16 +95,13 @@ export default function TabsLayout() {
</NativeTabs.BottomAccessory>
<NativeTabs.Trigger name="home" disableTransparentOnScrollEdge>
<NativeTabs.Trigger.Icon
sf={{ default: "house", selected: "house.fill" }}
md="home"
/>
<NativeTabs.Trigger.Icon sf="house.fill" md="home" />
<NativeTabs.Trigger.Label>Home</NativeTabs.Trigger.Label>
</NativeTabs.Trigger>
<NativeTabs.Trigger name="library" disableTransparentOnScrollEdge>
<NativeTabs.Trigger.Icon
sf={{ default: "square.stack", selected: "square.stack.fill" }}
sf="music.note.square.stack.fill"
md="library_music"
/>
<NativeTabs.Trigger.Label>Library</NativeTabs.Trigger.Label>
@@ -103,7 +114,10 @@ export default function TabsLayout() {
<NativeTabs.Trigger name="more" disableTransparentOnScrollEdge>
<NativeTabs.Trigger.Icon
sf={{ default: "ellipsis.circle", selected: "ellipsis.circle.fill" }}
sf={{
default: "ellipsis.circle",
selected: "ellipsis.circle.fill",
}}
md="more_horiz"
/>
<NativeTabs.Trigger.Label>More</NativeTabs.Trigger.Label>
@@ -1,10 +1,11 @@
import { useQuery } from "convex/react"
import { Image } from "expo-image"
import { Stack, useLocalSearchParams } from "expo-router"
import { useState } from "react"
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
import { Ionicons } from "@expo/vector-icons"
import { CoverImage } from "@/components/cover-image"
import { MediaActionsSheet, type MediaAction } from "@/components/media-actions-sheet"
import { Button, LoadingView } from "@/components/ui/primitives"
import { contentBottomInset } from "@/components/player"
@@ -67,7 +68,7 @@ export default function AlbumScreen() {
<>
<Stack.Screen
options={{
title: album.title,
title: "",
headerLargeTitle: false,
headerRight: () => (
<Pressable onPress={() => setActionsOpen(true)} hitSlop={8}>
@@ -82,10 +83,10 @@ export default function AlbumScreen() {
contentInsetAdjustmentBehavior="automatic"
>
<View style={styles.hero}>
<Image
source={{ uri: albumCoverUrl(config.serverUrl, album.id) }}
<CoverImage
uri={albumCoverUrl(config.serverUrl, album.id)}
hasCover={album.cover != null}
style={styles.cover}
contentFit="cover"
/>
<Text style={[styles.title, { color: colors.foreground }]}>{album.title}</Text>
<Pressable onPress={() => push(`/artist/${album.artist.id}`)}>
@@ -156,7 +157,6 @@ const styles = StyleSheet.create({
width: 220,
height: 220,
borderRadius: radius.lg,
backgroundColor: "#ddd",
},
title: { fontSize: 24, fontWeight: "800", textAlign: "center" },
artist: { fontSize: 16, fontWeight: "600" },
@@ -1,11 +1,12 @@
import { useQuery } from "convex/react"
import { Image } from "expo-image"
import { Stack, useLocalSearchParams } from "expo-router"
import { useState } from "react"
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
import { Ionicons } from "@expo/vector-icons"
import { ContentCarousel, MediaGrid } from "@/components/media-cards"
import { CoverImage } from "@/components/cover-image"
import { MediaGrid } from "@/components/media-cards"
import { MediaActionsSheet, type MediaAction } from "@/components/media-actions-sheet"
import { Button, LoadingView } from "@/components/ui/primitives"
import { contentBottomInset } from "@/components/player"
@@ -16,7 +17,7 @@ import { useServerConfig } from "@/contexts/server-config"
import { api } from "@otunes/convex/_generated/api"
import type { Id } from "@otunes/convex/_generated/dataModel"
import { artistCoverUrl } from "@/lib/urls"
import { radius, spacing, useThemeColors } from "@/lib/theme"
import { spacing, useThemeColors } from "@/lib/theme"
export default function ArtistScreen() {
const { id } = useLocalSearchParams<{ id: string }>()
@@ -58,7 +59,7 @@ export default function ArtistScreen() {
<>
<Stack.Screen
options={{
title: data.artist.name,
title: "",
headerLargeTitle: false,
headerRight: () => (
<Pressable onPress={() => setActionsOpen(true)} hitSlop={8}>
@@ -73,10 +74,10 @@ export default function ArtistScreen() {
contentInsetAdjustmentBehavior="automatic"
>
<View style={styles.hero}>
<Image
source={{ uri: artistCoverUrl(config.serverUrl, data.artist.id) }}
<CoverImage
uri={artistCoverUrl(config.serverUrl, data.artist.id)}
hasCover={data.artist.photo != null}
style={styles.avatar}
contentFit="cover"
/>
<Text style={[styles.title, { color: colors.foreground }]}>{data.artist.name}</Text>
<View style={styles.actions}>
@@ -92,20 +93,7 @@ export default function ArtistScreen() {
</View>
</View>
{data.recentlyPlayed.length > 0 ? (
<View style={styles.section}>
<ContentCarousel title="Recently Played" content={data.recentlyPlayed} />
</View>
) : null}
{data.recentlyAdded.length > 0 ? (
<View style={styles.section}>
<ContentCarousel title="Recently Added" content={data.recentlyAdded} />
</View>
) : null}
<View style={styles.section}>
<Text style={[styles.sectionTitle, { color: colors.foreground }]}>Albums</Text>
<MediaGrid content={data.albums} />
</View>
</ScrollView>
@@ -128,7 +116,6 @@ const styles = StyleSheet.create({
width: 180,
height: 180,
borderRadius: 90,
backgroundColor: "#ddd",
},
title: { fontSize: 28, fontWeight: "800", textAlign: "center" },
actions: { flexDirection: "row", alignItems: "center", gap: spacing.sm, marginTop: spacing.sm },
@@ -1,6 +1,7 @@
import { useQuery } from "convex/react"
import { Pressable, ScrollView, StyleSheet, Text } from "react-native"
import { Image } from "expo-image"
import { CoverImage } from "@/components/cover-image"
import { LoadingView } from "@/components/ui/primitives"
import { contentBottomInset } from "@/components/player"
@@ -9,7 +10,7 @@ import { useAppNavigation } from "@/lib/app-navigation"
import { api } from "@otunes/convex/_generated/api"
import type { BrowseArtist } from "@otunes/convex/types"
import { artistCoverUrl } from "@/lib/urls"
import { radius, spacing, useThemeColors } from "@/lib/theme"
import { spacing, useThemeColors } from "@/lib/theme"
export default function ArtistsScreen() {
const { push } = useAppNavigation()
@@ -33,10 +34,10 @@ export default function ArtistsScreen() {
style={[styles.row, { borderBottomColor: colors.border }]}
onPress={() => push(`/artist/${artist.id}`)}
>
<Image
source={{ uri: artistCoverUrl(config.serverUrl, artist.id) }}
<CoverImage
uri={artistCoverUrl(config.serverUrl, artist.id)}
hasCover={artist.photo != null}
style={styles.avatar}
contentFit="cover"
/>
<Text style={[styles.name, { color: colors.foreground }]}>{artist.name}</Text>
</Pressable>
@@ -58,7 +59,6 @@ const styles = StyleSheet.create({
width: 44,
height: 44,
borderRadius: 22,
backgroundColor: "#eee",
},
name: { fontSize: 16, fontWeight: "600" },
})
@@ -1,10 +1,11 @@
import { useMutation, useQuery } from "convex/react"
import { Image } from "expo-image"
import { Stack, useLocalSearchParams, useRouter } from "expo-router"
import { useState } from "react"
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
import { Ionicons } from "@expo/vector-icons"
import { CoverImage } from "@/components/cover-image"
import { MediaActionsSheet, type MediaAction } from "@/components/media-actions-sheet"
import { Button, LoadingView } from "@/components/ui/primitives"
import { contentBottomInset, SongRow } from "@/components/player"
@@ -111,10 +112,10 @@ export default function PlaylistScreen() {
contentInsetAdjustmentBehavior="automatic"
>
<View style={styles.hero}>
<Image
source={{ uri: playlistCoverUrl(config.serverUrl, playlist.id ?? "favorites") }}
<CoverImage
uri={playlistCoverUrl(config.serverUrl, playlist.id ?? "favorites")}
hasCover={playlist.cover != null}
style={styles.cover}
contentFit="cover"
/>
<Text style={[styles.title, { color: colors.foreground }]}>{playlist.title}</Text>
<Text style={{ color: colors.mutedForeground }}>{playlist.owner.name}</Text>
@@ -191,7 +192,6 @@ const styles = StyleSheet.create({
width: 200,
height: 200,
borderRadius: radius.lg,
backgroundColor: "#ddd",
},
title: { fontSize: 24, fontWeight: "800", textAlign: "center" },
actions: { flexDirection: "row", gap: spacing.sm, marginTop: spacing.sm },
@@ -1,9 +1,13 @@
import { useQuery } from "convex/react"
import { Image } from "expo-image"
import { useState } from "react"
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
import { MediaActionsSheet, type MediaAction } from "@/components/media-actions-sheet"
import { CoverImage } from "@/components/cover-image"
import {
MediaActionsSheet,
type MediaAction,
} from "@/components/media-actions-sheet"
import { Button, LoadingView } from "@/components/ui/primitives"
import { contentBottomInset, SongRow } from "@/components/player"
import { useAddToPlaylist } from "@/contexts/add-to-playlist"
@@ -33,7 +37,9 @@ export default function FavoritesScreen() {
if (favorites === null) {
return (
<View style={[styles.empty, { backgroundColor: colors.background }]}>
<Text style={{ color: colors.mutedForeground }}>Sign in to view your favorites.</Text>
<Text style={{ color: colors.mutedForeground }}>
Sign in to view your favorites.
</Text>
</View>
)
}
@@ -68,11 +74,23 @@ export default function FavoritesScreen() {
contentInsetAdjustmentBehavior="automatic"
>
<View style={styles.hero}>
<Image
source={{ uri: playlistCoverUrl(config.serverUrl, "favorites") }}
style={styles.cover}
contentFit="cover"
/>
<View
style={[
styles.cover,
{
backgroundColor: colors.coverPlaceholder,
alignItems: "center",
justifyContent: "center",
overflow: "hidden",
},
]}
>
<Ionicons
name="star"
size={120}
color={colors.primary}
/>
</View>
<Text style={[styles.title, { color: colors.foreground }]}>
{favorites.title}
</Text>
@@ -114,7 +132,6 @@ const styles = StyleSheet.create({
width: 200,
height: 200,
borderRadius: radius.lg,
backgroundColor: "#ddd",
},
title: { fontSize: 24, fontWeight: "800" },
actions: { flexDirection: "row", gap: spacing.sm, marginTop: spacing.sm },
@@ -14,7 +14,7 @@ export default function SearchLayout() {
initialRouteName="index"
screenOptions={({ route }) => ({
...baseOptions,
title: tabStackScreenTitles[route.name] ?? baseOptions.title,
title: tabStackScreenTitles[route.name] ?? "Search",
})}
/>
)
@@ -17,7 +17,7 @@ export default function SearchScreen() {
return (
<>
<Stack.SearchBar
placeholder="Artists, Songs, Lyrics, and More"
placeholder="Artists, Alubms, Songs, and More"
onChangeText={handleChangeText}
onSearchButtonPress={onSearchSubmit}
autoCapitalize="none"
+7 -4
View File
@@ -1,7 +1,6 @@
import { Ionicons } from "@expo/vector-icons"
import Slider from "@react-native-community/slider"
import { BlurView } from "expo-blur"
import { Image } from "expo-image"
import { useRouter } from "expo-router"
import * as Haptics from "expo-haptics"
import { useState } from "react"
@@ -16,6 +15,7 @@ import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context"
import { StatusBar } from "expo-status-bar"
import { MediaActionsSheet, type MediaAction } from "@/components/media-actions-sheet"
import { CoverImage } from "@/components/cover-image"
import { useFavorites } from "@/contexts/favorites"
import { usePlayback } from "@/contexts/playback"
import { useServerConfig } from "@/contexts/server-config"
@@ -57,6 +57,7 @@ export default function PlayerScreen() {
return null
}
const hasCover = currentSong.album.cover != null
const coverUri = albumCoverUrl(config.serverUrl, currentSong.album.id)
const favorited = isSongFavorite(currentSong.id)
const bottomInset = Math.max(insets.bottom, spacing.md) + spacing.lg
@@ -96,11 +97,13 @@ export default function PlayerScreen() {
return (
<View style={[styles.root, { backgroundColor: colors.background }]}>
<StatusBar style={player.statusBar} />
<Image
source={{ uri: coverUri }}
<CoverImage
uri={coverUri}
hasCover={hasCover}
style={[styles.backgroundImage, { opacity: player.backgroundImageOpacity }]}
contentFit="cover"
blurRadius={60}
placeholderVariant="solid"
/>
{Platform.OS === "ios" ? (
<>
@@ -124,7 +127,7 @@ export default function PlayerScreen() {
<View style={styles.upper}>
<View style={styles.artworkWrap}>
<Image source={{ uri: coverUri }} style={styles.artwork} contentFit="cover" />
<CoverImage uri={coverUri} hasCover={hasCover} style={styles.artwork} />
</View>
</View>
+70
View File
@@ -0,0 +1,70 @@
import { Ionicons } from "@expo/vector-icons"
import { Image, type ImageContentFit, type ImageStyle } from "expo-image"
import { StyleProp, StyleSheet, View, type ViewStyle } from "react-native"
import { useThemeColors } from "@/lib/theme"
function placeholderIconSize(style: ImageStyle): number {
const { width, height, maxWidth } = style
if (typeof width === "number" && typeof height === "number") {
return Math.min(width, height) * 0.38
}
if (typeof width === "number") {
return width * 0.38
}
if (typeof maxWidth === "number") {
return maxWidth * 0.38
}
return 48
}
export function CoverImage({
uri,
hasCover,
style,
contentFit = "cover",
blurRadius,
placeholderVariant = "icon",
}: {
uri: string
hasCover: boolean
style?: StyleProp<ImageStyle>
contentFit?: ImageContentFit
blurRadius?: number
placeholderVariant?: "icon" | "solid"
}) {
const colors = useThemeColors()
const flatStyle = StyleSheet.flatten(style) ?? {}
if (!hasCover) {
const placeholderStyle: ViewStyle = {
backgroundColor: colors.coverPlaceholder,
alignItems: "center",
justifyContent: "center",
overflow: "hidden",
}
return (
<View style={[style, placeholderStyle]}>
{placeholderVariant === "icon" ? (
<Ionicons
name="musical-note"
size={placeholderIconSize(flatStyle)}
color={colors.coverPlaceholderIcon}
/>
) : null}
</View>
)
}
return (
<Image
source={{ uri }}
style={[style, { backgroundColor: colors.coverPlaceholder }]}
contentFit={contentFit}
transition={150}
blurRadius={blurRadius}
cachePolicy="disk"
/>
)
}
+16 -27
View File
@@ -1,7 +1,7 @@
import { Ionicons } from "@expo/vector-icons"
import { Image } from "expo-image"
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
import { CoverImage } from "@/components/cover-image"
import { useServerConfig } from "@/contexts/server-config"
import { useAppNavigation } from "@/lib/app-navigation"
import type { BrowseAlbum, BrowseArtist, PlaylistSummary } from "@otunes/convex/types"
@@ -10,29 +10,6 @@ import { carouselCardWidth, radius, spacing, useThemeColors, useTwoColumnCardWid
type MediaItem = BrowseAlbum | BrowseArtist | PlaylistSummary
function CoverImage({
uri,
size,
rounded,
}: {
uri: string
size: number
rounded?: boolean
}) {
const colors = useThemeColors()
return (
<Image
source={{ uri }}
style={[
{ width: size, height: size, borderRadius: rounded ? size / 2 : radius.sm },
{ backgroundColor: colors.muted },
]}
contentFit="cover"
transition={150}
/>
)
}
export function AlbumCard({
album,
width = carouselCardWidth,
@@ -50,7 +27,11 @@ export function AlbumCard({
style={[styles.card, { width }]}
onPress={() => push(`/album/${album.id}`)}
>
<CoverImage uri={albumCoverUrl(config.serverUrl, album.id)} size={width} />
<CoverImage
uri={albumCoverUrl(config.serverUrl, album.id)}
hasCover={album.cover != null}
style={{ width, height: width, borderRadius: radius.md }}
/>
<Text style={[styles.title, { color: colors.foreground }]} numberOfLines={2}>
{album.title}
</Text>
@@ -78,7 +59,11 @@ export function ArtistCard({
style={[styles.card, { width }]}
onPress={() => push(`/artist/${artist.id}`)}
>
<CoverImage uri={artistCoverUrl(config.serverUrl, artist.id)} size={width} rounded />
<CoverImage
uri={artistCoverUrl(config.serverUrl, artist.id)}
hasCover={artist.photo != null}
style={{ width, height: width, borderRadius: width / 2 }}
/>
<Text style={[styles.title, { color: colors.foreground }]} numberOfLines={2}>
{artist.name}
</Text>
@@ -103,7 +88,11 @@ export function PlaylistCard({
style={[styles.card, { width }]}
onPress={() => push(`/playlist/${playlist.id}`)}
>
<CoverImage uri={playlistCoverUrl(config.serverUrl, playlist.id)} size={width} />
<CoverImage
uri={playlistCoverUrl(config.serverUrl, playlist.id)}
hasCover={playlist.cover != null}
style={{ width, height: width, borderRadius: radius.md }}
/>
<Text style={[styles.title, { color: colors.foreground }]} numberOfLines={2}>
{playlist.title}
</Text>
+8 -7
View File
@@ -1,9 +1,10 @@
import { Ionicons } from "@expo/vector-icons"
import { Image } from "expo-image"
import { NativeTabs } from "expo-router/unstable-native-tabs"
import { useRouter } from "expo-router"
import { Platform, Pressable, StyleSheet, Text, View } from "react-native"
import { CoverImage } from "@/components/cover-image"
import { usePlayback } from "@/contexts/playback"
import { useServerConfig } from "@/contexts/server-config"
import { albumCoverUrl } from "@/lib/urls"
@@ -39,10 +40,10 @@ function MiniPlayerContent({
if (compact) {
return (
<Pressable style={rowStyle} onPress={onOpenPlayer}>
<Image
source={{ uri: albumCoverUrl(config.serverUrl, currentSong.album.id) }}
<CoverImage
uri={albumCoverUrl(config.serverUrl, currentSong.album.id)}
hasCover={currentSong.album.cover != null}
style={isAccessory ? styles.accessoryInlineArtwork : styles.inlineArtwork}
contentFit="cover"
/>
<View style={isAccessory ? styles.accessoryInlineMeta : styles.inlineMeta}>
<Text
@@ -75,10 +76,10 @@ function MiniPlayerContent({
return (
<Pressable style={rowStyle} onPress={onOpenPlayer}>
<Image
source={{ uri: albumCoverUrl(config.serverUrl, currentSong.album.id) }}
<CoverImage
uri={albumCoverUrl(config.serverUrl, currentSong.album.id)}
hasCover={currentSong.album.cover != null}
style={artworkStyle}
contentFit="cover"
/>
<View style={isAccessory ? styles.accessoryMeta : styles.meta}>
<Text
+5 -6
View File
@@ -1,6 +1,4 @@
import { Image } from "expo-image"
import { Pressable, StyleSheet, Text, View } from "react-native"
import { CoverImage } from "@/components/cover-image"
import { useServerConfig } from "@/contexts/server-config"
import type { BrowseSong } from "@otunes/convex/types"
import { formatDuration } from "@/lib/format"
@@ -11,6 +9,7 @@ import {
tabBarHeight,
useThemeColors,
} from "@/lib/theme"
import { Pressable, StyleSheet, Text, View } from "react-native"
export function SongRow({
song,
@@ -33,10 +32,10 @@ export function SongRow({
onPress={onPress}
onLongPress={onLongPress}
>
<Image
source={{ uri: albumCoverUrl(config.serverUrl, song.album.id) }}
<CoverImage
uri={albumCoverUrl(config.serverUrl, song.album.id)}
hasCover={song.album.cover != null}
style={styles.rowArtwork}
contentFit="cover"
/>
<View style={styles.rowMeta}>
<Text style={[styles.rowTitle, { color: colors.foreground }]} numberOfLines={1}>
+10 -12
View File
@@ -30,10 +30,10 @@ function SearchResultsBody({ searchQuery }: { searchQuery: string }) {
() =>
Boolean(
results &&
(results.topResults.length > 0 ||
results.artists.length > 0 ||
results.albums.length > 0 ||
results.songs.length > 0)
(results.topResults.length > 0 ||
results.artists.length > 0 ||
results.albums.length > 0 ||
results.songs.length > 0)
),
[results]
)
@@ -43,13 +43,7 @@ function SearchResultsBody({ searchQuery }: { searchQuery: string }) {
}
if (!hasQuery) {
return (
<View style={styles.empty}>
<Text style={[styles.emptyText, { color: colors.mutedForeground }]}>
Find your favorite music
</Text>
</View>
)
return <></>
}
return (
@@ -110,5 +104,9 @@ export const SearchResults = memo(SearchResultsBody)
const styles = StyleSheet.create({
empty: { padding: spacing.xl, alignItems: "center" },
emptyText: { fontSize: 16 },
section: { paddingHorizontal: spacing.lg, paddingBottom: spacing.lg, gap: spacing.md },
section: {
paddingHorizontal: spacing.lg,
paddingBottom: spacing.lg,
gap: spacing.md,
},
})
+4
View File
@@ -27,6 +27,8 @@ export const colors = {
destructive: "#dc2626",
accent: "#f4f4f5",
accentForeground: appleMusic.pink,
coverPlaceholder: "#e3e3e3",
coverPlaceholderIcon: "rgba(60, 60, 67, 0.18)",
},
dark: {
background: appleMusic.background,
@@ -40,6 +42,8 @@ export const colors = {
destructive: "#FF453A",
accent: appleMusic.secondary,
accentForeground: appleMusic.pink,
coverPlaceholder: "#323232",
coverPlaceholderIcon: "rgba(235, 235, 245, 0.16)",
},
} as const