diff --git a/apps/mobile/app/(app)/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/_layout.tsx index 6bca97e..075ee6e 100644 --- a/apps/mobile/app/(app)/(tabs)/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/_layout.tsx @@ -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 ( - + Home Library @@ -103,7 +114,10 @@ export default function TabsLayout() { More diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index d4159c8..bec7d39 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -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() { <> ( setActionsOpen(true)} hitSlop={8}> @@ -82,10 +83,10 @@ export default function AlbumScreen() { contentInsetAdjustmentBehavior="automatic" > - {album.title} 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" }, diff --git a/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx index 5c727dc..263a923 100644 --- a/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx @@ -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() { <> ( setActionsOpen(true)} hitSlop={8}> @@ -73,10 +74,10 @@ export default function ArtistScreen() { contentInsetAdjustmentBehavior="automatic" > - {data.artist.name} @@ -92,20 +93,7 @@ export default function ArtistScreen() { - {data.recentlyPlayed.length > 0 ? ( - - - - ) : null} - - {data.recentlyAdded.length > 0 ? ( - - - - ) : null} - - Albums @@ -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 }, diff --git a/apps/mobile/app/(app)/(tabs)/home/browse/artists.tsx b/apps/mobile/app/(app)/(tabs)/home/browse/artists.tsx index e46ab8c..627a8d5 100644 --- a/apps/mobile/app/(app)/(tabs)/home/browse/artists.tsx +++ b/apps/mobile/app/(app)/(tabs)/home/browse/artists.tsx @@ -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}`)} > - {artist.name} @@ -58,7 +59,6 @@ const styles = StyleSheet.create({ width: 44, height: 44, borderRadius: 22, - backgroundColor: "#eee", }, name: { fontSize: 16, fontWeight: "600" }, }) diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx index dd0d0af..4439153 100644 --- a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx @@ -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" > - {playlist.title} {playlist.owner.name} @@ -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 }, diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/favorites.tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/favorites.tsx index c6f33d9..5b162e2 100644 --- a/apps/mobile/app/(app)/(tabs)/home/playlist/favorites.tsx +++ b/apps/mobile/app/(app)/(tabs)/home/playlist/favorites.tsx @@ -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 ( - Sign in to view your favorites. + + Sign in to view your favorites. + ) } @@ -68,11 +74,23 @@ export default function FavoritesScreen() { contentInsetAdjustmentBehavior="automatic" > - + + + {favorites.title} @@ -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 }, diff --git a/apps/mobile/app/(app)/(tabs)/search/_layout.tsx b/apps/mobile/app/(app)/(tabs)/search/_layout.tsx index 6a64c63..66257ab 100644 --- a/apps/mobile/app/(app)/(tabs)/search/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/search/_layout.tsx @@ -14,7 +14,7 @@ export default function SearchLayout() { initialRouteName="index" screenOptions={({ route }) => ({ ...baseOptions, - title: tabStackScreenTitles[route.name] ?? baseOptions.title, + title: tabStackScreenTitles[route.name] ?? "Search", })} /> ) diff --git a/apps/mobile/app/(app)/(tabs)/search/index.tsx b/apps/mobile/app/(app)/(tabs)/search/index.tsx index f5d73a1..2a2c895 100644 --- a/apps/mobile/app/(app)/(tabs)/search/index.tsx +++ b/apps/mobile/app/(app)/(tabs)/search/index.tsx @@ -17,7 +17,7 @@ export default function SearchScreen() { return ( <> - {Platform.OS === "ios" ? ( <> @@ -124,7 +127,7 @@ export default function PlayerScreen() { - + diff --git a/apps/mobile/components/cover-image.tsx b/apps/mobile/components/cover-image.tsx new file mode 100644 index 0000000..61c0811 --- /dev/null +++ b/apps/mobile/components/cover-image.tsx @@ -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 + 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 ( + + {placeholderVariant === "icon" ? ( + + ) : null} + + ) + } + + return ( + + ) +} diff --git a/apps/mobile/components/media-cards.tsx b/apps/mobile/components/media-cards.tsx index 9201d36..bb7958a 100644 --- a/apps/mobile/components/media-cards.tsx +++ b/apps/mobile/components/media-cards.tsx @@ -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 ( - - ) -} - export function AlbumCard({ album, width = carouselCardWidth, @@ -50,7 +27,11 @@ export function AlbumCard({ style={[styles.card, { width }]} onPress={() => push(`/album/${album.id}`)} > - + {album.title} @@ -78,7 +59,11 @@ export function ArtistCard({ style={[styles.card, { width }]} onPress={() => push(`/artist/${artist.id}`)} > - + {artist.name} @@ -103,7 +88,11 @@ export function PlaylistCard({ style={[styles.card, { width }]} onPress={() => push(`/playlist/${playlist.id}`)} > - + {playlist.title} diff --git a/apps/mobile/components/mini-player.tsx b/apps/mobile/components/mini-player.tsx index 7a850ef..b36d377 100644 --- a/apps/mobile/components/mini-player.tsx +++ b/apps/mobile/components/mini-player.tsx @@ -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 ( - - - diff --git a/apps/mobile/components/search-results.tsx b/apps/mobile/components/search-results.tsx index eadb407..cc790d3 100644 --- a/apps/mobile/components/search-results.tsx +++ b/apps/mobile/components/search-results.tsx @@ -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 ( - - - Find your favorite music - - - ) + 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, + }, }) diff --git a/apps/mobile/lib/theme.ts b/apps/mobile/lib/theme.ts index 3e6b3bf..739bc0a 100644 --- a/apps/mobile/lib/theme.ts +++ b/apps/mobile/lib/theme.ts @@ -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