diff --git a/apps/mobile/app.json b/apps/mobile/app.json
index f02ab5d..bfa807e 100644
--- a/apps/mobile/app.json
+++ b/apps/mobile/app.json
@@ -9,11 +9,18 @@
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.abunchofknowitalls.otunes",
- "infoPlist": {}
+ "infoPlist": {
+ "ITSAppUsesNonExemptEncryption": false
+ }
},
"android": {
"package": "com.abunchofknowitalls.otunes",
- "predictiveBackGestureEnabled": false
+ "predictiveBackGestureEnabled": false,
+ "permissions": [
+ "android.permission.MODIFY_AUDIO_SETTINGS",
+ "android.permission.FOREGROUND_SERVICE",
+ "android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"
+ ]
},
"plugins": [
"expo-router",
@@ -28,6 +35,13 @@
],
"experiments": {
"typedRoutes": true
- }
+ },
+ "extra": {
+ "router": {},
+ "eas": {
+ "projectId": "98b83584-d757-4da0-9bec-050c8336643f"
+ }
+ },
+ "owner": "joshuafhiggins"
}
}
diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx
index 70e6724..aa2e497 100644
--- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx
@@ -38,14 +38,34 @@ export default function AlbumScreen() {
useMediaMenuActions()
if (album === undefined || !config) {
- return
+ return (
+ <>
+
+
+ >
+ )
}
if (album === null) {
return (
-
- Album not found.
-
+ <>
+
+
+
+ Album not found.
+
+
+ >
)
}
diff --git a/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx
index d927a10..04c11ce 100644
--- a/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/artist/[id].tsx
@@ -28,14 +28,34 @@ export default function ArtistScreen() {
const { handleArtistAction, isArtistFavorite: isArtistFav } = useMediaMenuActions()
if (data === undefined || !config) {
- return
+ return (
+ <>
+
+
+ >
+ )
}
if (data === null) {
return (
-
- Artist not found.
-
+ <>
+
+
+
+ Artist not found.
+
+
+ >
)
}
diff --git a/apps/mobile/app/(app)/(tabs)/library/playlists/index.tsx b/apps/mobile/app/(app)/(tabs)/home/browse/playlists.tsx
similarity index 73%
rename from apps/mobile/app/(app)/(tabs)/library/playlists/index.tsx
rename to apps/mobile/app/(app)/(tabs)/home/browse/playlists.tsx
index 04c6b64..abc6123 100644
--- a/apps/mobile/app/(app)/(tabs)/library/playlists/index.tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/browse/playlists.tsx
@@ -17,7 +17,30 @@ export default function PlaylistsTabScreen() {
const { openCreatePlaylist } = useAddToPlaylist()
if (playlists === undefined) {
- return
+ return (
+ <>
+ (
+
+
+
+ ),
+ }}
+ />
+
+ >
+ )
}
return (
diff --git a/apps/mobile/app/(app)/(tabs)/home/index.tsx b/apps/mobile/app/(app)/(tabs)/home/index.tsx
index f0e09a3..c558f8e 100644
--- a/apps/mobile/app/(app)/(tabs)/home/index.tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/index.tsx
@@ -1,27 +1,23 @@
import { useQuery } from "convex/react"
+import { memo, useRef } from "react"
import { ScrollView, StyleSheet } from "react-native"
import { ContentCarousel } from "@/components/media-cards"
import { LoadingView } from "@/components/ui/primitives"
import { tabContentBottomInset } from "@/components/player"
import { api } from "@otunes/convex/_generated/api"
+import type { BrowseAlbum, PlaylistSummary } from "@otunes/convex/types"
import { spacing, useThemeColors } from "@/lib/theme"
-export default function HomeScreen() {
- const colors = useThemeColors()
- const recentlyAdded = useQuery(api.library.browseRecentlyAdded)
- const recentlyPlayed = useQuery(api.library.browseRecentlyPlayed)
-
- if (recentlyAdded === undefined || recentlyPlayed === undefined) {
- return
- }
-
+const HomeCarousels = memo(function HomeCarousels({
+ recentlyAdded,
+ recentlyPlayed,
+}: {
+ recentlyAdded: BrowseAlbum[]
+ recentlyPlayed: (BrowseAlbum | PlaylistSummary)[]
+}) {
return (
-
+ <>
{recentlyPlayed.length > 0 ? (
+ >
+ )
+})
+
+export default function HomeScreen() {
+ const colors = useThemeColors()
+ const recentlyAdded = useQuery(api.library.browseRecentlyAdded)
+ const recentlyPlayed = useQuery(api.library.browseRecentlyPlayed)
+ const cachedData = useRef<{
+ recentlyAdded?: BrowseAlbum[]
+ recentlyPlayed?: (BrowseAlbum | PlaylistSummary)[]
+ }>({})
+
+ if (recentlyAdded !== undefined) {
+ cachedData.current.recentlyAdded = recentlyAdded
+ }
+ if (recentlyPlayed !== undefined) {
+ cachedData.current.recentlyPlayed = recentlyPlayed
+ }
+
+ const added = recentlyAdded ?? cachedData.current.recentlyAdded
+ const played = recentlyPlayed ?? cachedData.current.recentlyPlayed
+
+ if (added === undefined || played === undefined) {
+ return
+ }
+
+ return (
+
+
)
}
diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx
index c53c1e1..e0aded9 100644
--- a/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/playlist/[id].tsx
@@ -36,14 +36,34 @@ export default function PlaylistScreen() {
const removeSongs = useMutation(api.playlists.removeSongsFromPlaylist)
if (playlist === undefined || !config) {
- return
+ return (
+ <>
+
+
+ >
+ )
}
if (playlist === null) {
return (
-
- Playlist not found.
-
+ <>
+
+
+
+ Playlist not found.
+
+
+ >
)
}
diff --git a/apps/mobile/app/(app)/(tabs)/home/playlist/favorites.tsx b/apps/mobile/app/(app)/(tabs)/home/playlist/favorites.tsx
index f0f8541..e43af71 100644
--- a/apps/mobile/app/(app)/(tabs)/home/playlist/favorites.tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/playlist/favorites.tsx
@@ -22,16 +22,34 @@ export default function FavoritesScreen() {
const { handleSongAction } = useMediaMenuActions()
if (favorites === undefined || !config) {
- return
+ return (
+ <>
+
+
+ >
+ )
}
if (favorites === null) {
return (
-
-
- Sign in to view your favorites.
-
-
+ <>
+
+
+
+ Sign in to view your favorites.
+
+
+ >
)
}
diff --git a/apps/mobile/app/(app)/(tabs)/library/browse/playlists.tsx b/apps/mobile/app/(app)/(tabs)/library/browse/playlists.tsx
new file mode 100644
index 0000000..3ce10c7
--- /dev/null
+++ b/apps/mobile/app/(app)/(tabs)/library/browse/playlists.tsx
@@ -0,0 +1 @@
+export { default } from "../../home/browse/playlists"
diff --git a/apps/mobile/app/(app)/(tabs)/library/index.tsx b/apps/mobile/app/(app)/(tabs)/library/index.tsx
index d5fe525..af035e4 100644
--- a/apps/mobile/app/(app)/(tabs)/library/index.tsx
+++ b/apps/mobile/app/(app)/(tabs)/library/index.tsx
@@ -12,7 +12,7 @@ import { api } from "@otunes/convex/_generated/api"
import { appleMusic, spacing, useThemeColors } from "@/lib/theme"
const links = [
- { title: "Playlists", href: "/playlists", icon: "music.note.list" as const },
+ { title: "Playlists", href: "/browse/playlists", icon: "music.note.list" as const },
{ title: "Artists", href: "/browse/artists", icon: "mic.fill" as const },
{ title: "Albums", href: "/browse/albums", icon: "square.stack" as const },
{ title: "Songs", href: "/browse/songs", icon: "music.note" as const },
diff --git a/apps/mobile/app/(app)/_layout.tsx b/apps/mobile/app/(app)/_layout.tsx
index 382428a..9091dd0 100644
--- a/apps/mobile/app/(app)/_layout.tsx
+++ b/apps/mobile/app/(app)/_layout.tsx
@@ -12,6 +12,7 @@ import { FavoritesProvider } from "@/contexts/favorites"
import { PlaybackProvider } from "@/contexts/playback"
import { useServerConfig } from "@/contexts/server-config"
import { useStackScreenOptions } from "@/lib/navigation"
+import { AppNavigationSync } from "@/lib/app-navigation"
const AUTH_HANDSHAKE_TIMEOUT_MS = 15_000
@@ -61,6 +62,7 @@ export default function AppLayout() {
return (
+
diff --git a/apps/mobile/components/cover-image.tsx b/apps/mobile/components/cover-image.tsx
index 61c0811..250b5f9 100644
--- a/apps/mobile/components/cover-image.tsx
+++ b/apps/mobile/components/cover-image.tsx
@@ -1,5 +1,6 @@
import { Ionicons } from "@expo/vector-icons"
import { Image, type ImageContentFit, type ImageStyle } from "expo-image"
+import { memo } from "react"
import { StyleProp, StyleSheet, View, type ViewStyle } from "react-native"
import { useThemeColors } from "@/lib/theme"
@@ -18,7 +19,7 @@ function placeholderIconSize(style: ImageStyle): number {
return 48
}
-export function CoverImage({
+export const CoverImage = memo(function CoverImage({
uri,
hasCover,
style,
@@ -67,4 +68,4 @@ export function CoverImage({
cachePolicy="disk"
/>
)
-}
+})
diff --git a/apps/mobile/components/media-cards.tsx b/apps/mobile/components/media-cards.tsx
index 05d697c..6e63957 100644
--- a/apps/mobile/components/media-cards.tsx
+++ b/apps/mobile/components/media-cards.tsx
@@ -1,4 +1,5 @@
import { Ionicons } from "@expo/vector-icons"
+import { memo, useCallback } from "react"
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
import { CoverImage } from "@/components/cover-image"
@@ -12,7 +13,7 @@ import { carouselCardWidth, radius, spacing, useThemeColors, useTwoColumnCardWid
type MediaItem = BrowseAlbum | BrowseArtist | PlaylistSummary
-export function AlbumCard({
+export const AlbumCard = memo(function AlbumCard({
album,
width = carouselCardWidth,
}: {
@@ -23,12 +24,15 @@ export function AlbumCard({
const { config } = useServerConfig()
const colors = useThemeColors()
const { handleAlbumAction, isAlbumFavorite } = useMediaMenuActions()
+ const onPress = useCallback(() => {
+ push(`/album/${album.id}`)
+ }, [push, album.id])
if (!config) return null
const card = (
push(`/album/${album.id}`)}
+ onPress={onPress}
>
)
-}
+})
-export function ArtistCard({
+export const ArtistCard = memo(function ArtistCard({
artist,
width = carouselCardWidth,
}: {
@@ -67,12 +71,15 @@ export function ArtistCard({
const { config } = useServerConfig()
const colors = useThemeColors()
const { handleArtistAction, isArtistFavorite } = useMediaMenuActions()
+ const onPress = useCallback(() => {
+ push(`/artist/${artist.id}`)
+ }, [push, artist.id])
if (!config) return null
const card = (
push(`/artist/${artist.id}`)}
+ onPress={onPress}
>
)
-}
+})
-export function PlaylistCard({
+export const PlaylistCard = memo(function PlaylistCard({
playlist,
width = carouselCardWidth,
}: {
@@ -107,12 +114,15 @@ export function PlaylistCard({
const { config } = useServerConfig()
const colors = useThemeColors()
const { handlePlaylistAction } = useMediaMenuActions()
+ const onPress = useCallback(() => {
+ push(`/playlist/${playlist.id}`)
+ }, [push, playlist.id])
if (!config) return null
const card = (
push(`/playlist/${playlist.id}`)}
+ onPress={onPress}
>
)
-}
+})
-function renderMediaItem(item: MediaItem, width: number) {
+const CarouselCard = memo(function CarouselCard({
+ item,
+ width,
+}: {
+ item: MediaItem
+ width: number
+}) {
if ("owner" in item) return
if ("artist" in item) return
return
-}
+})
export function MediaGrid({ content }: { content: MediaItem[] }) {
const cardWidth = useTwoColumnCardWidth()
@@ -152,14 +168,14 @@ export function MediaGrid({ content }: { content: MediaItem[] }) {
{content.map((item) => (
- {renderMediaItem(item, cardWidth)}
+
))}
)
}
-export function ContentCarousel({
+function ContentCarouselBody({
title,
href,
content,
@@ -170,12 +186,17 @@ export function ContentCarousel({
}) {
const { push } = useAppNavigation()
const colors = useThemeColors()
+ const onHeaderPress = useCallback(() => {
+ if (href) {
+ push(href)
+ }
+ }, [href, push])
return (
href && push(href)}
+ onPress={onHeaderPress}
style={styles.sectionHeader}
>
{title}
@@ -187,13 +208,17 @@ export function ContentCarousel({
contentContainerStyle={styles.carouselContent}
>
{content.map((item) => (
- {renderMediaItem(item, carouselCardWidth)}
+
+
+
))}
)
}
+export const ContentCarousel = memo(ContentCarouselBody)
+
const styles = StyleSheet.create({
card: {
gap: spacing.xs,
diff --git a/apps/mobile/contexts/playback.tsx b/apps/mobile/contexts/playback.tsx
index de29b83..df05584 100644
--- a/apps/mobile/contexts/playback.tsx
+++ b/apps/mobile/contexts/playback.tsx
@@ -85,7 +85,13 @@ type PlaybackContextValue = {
skipPrevious: () => Promise
}
+type PlaybackActionsValue = Pick<
+ PlaybackContextValue,
+ "addToQueueNext" | "addToQueueLast" | "playShuffled"
+>
+
const PlaybackContext = createContext(null)
+const PlaybackActionsContext = createContext(null)
export function usePlayback() {
const context = useContext(PlaybackContext)
@@ -95,6 +101,14 @@ export function usePlayback() {
return context
}
+export function usePlaybackActions() {
+ const context = useContext(PlaybackActionsContext)
+ if (!context) {
+ throw new Error("usePlaybackActions must be used within PlaybackProvider")
+ }
+ return context
+}
+
export function PlaybackProvider({ children }: { children: ReactNode }) {
const convex = useConvex()
const { config } = useServerConfig()
@@ -589,6 +603,15 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
[convex, playShuffledMutation, setIsPlaying]
)
+ const actionsValue = useMemo(
+ () => ({
+ addToQueueNext,
+ addToQueueLast,
+ playShuffled,
+ }),
+ [addToQueueNext, addToQueueLast, playShuffled]
+ )
+
const value = useMemo(
() => ({
queueSongIds: playback?.queueSongIds ?? [],
@@ -675,6 +698,8 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
)
return (
- {children}
+
+ {children}
+
)
}
diff --git a/apps/mobile/eas.json b/apps/mobile/eas.json
new file mode 100644
index 0000000..741ab79
--- /dev/null
+++ b/apps/mobile/eas.json
@@ -0,0 +1,21 @@
+{
+ "cli": {
+ "version": ">= 18.12.3",
+ "appVersionSource": "remote"
+ },
+ "build": {
+ "development": {
+ "developmentClient": true,
+ "distribution": "internal"
+ },
+ "preview": {
+ "distribution": "internal"
+ },
+ "production": {
+ "autoIncrement": true
+ }
+ },
+ "submit": {
+ "production": {}
+ }
+}
diff --git a/apps/mobile/hooks/use-media-menu-actions.ts b/apps/mobile/hooks/use-media-menu-actions.ts
index 8c6b451..73e692c 100644
--- a/apps/mobile/hooks/use-media-menu-actions.ts
+++ b/apps/mobile/hooks/use-media-menu-actions.ts
@@ -4,7 +4,7 @@ import { useCallback } from "react"
import type { MediaAction } from "@/components/media-context-menu"
import { useAddToPlaylist } from "@/contexts/add-to-playlist"
import { useFavorites } from "@/contexts/favorites"
-import { usePlayback } from "@/contexts/playback"
+import { usePlaybackActions } from "@/contexts/playback"
import { useAppNavigation } from "@/lib/app-navigation"
import { showSuccess } from "@/lib/toast"
import { api } from "@otunes/convex/_generated/api"
@@ -30,7 +30,7 @@ export function useMediaMenuActions() {
toggleArtistFavorite,
toggleSongFavorite,
} = useFavorites()
- const { addToQueueNext, addToQueueLast, playShuffled } = usePlayback()
+ const { addToQueueNext, addToQueueLast, playShuffled } = usePlaybackActions()
const favoriteSongs = useMutation(api.favorites.favoriteSongs)
const runQueueAction = useCallback(
diff --git a/apps/mobile/lib/app-navigation.ts b/apps/mobile/lib/app-navigation.ts
index 3f11d25..acdfef5 100644
--- a/apps/mobile/lib/app-navigation.ts
+++ b/apps/mobile/lib/app-navigation.ts
@@ -1,10 +1,13 @@
import { useRouter, useSegments, type Href } from "expo-router"
+import { useCallback } from "react"
export const APP_TABS = ["home", "library", "search"] as const
export type AppTab = (typeof APP_TABS)[number]
const TAB_SET = new Set(APP_TABS)
+const activeSegmentsRef: { current: string[] } = { current: [] }
+
export function getActiveTab(segments: string[]): AppTab {
for (const segment of segments) {
if (TAB_SET.has(segment)) {
@@ -20,15 +23,39 @@ export function tabPath(tab: AppTab, path: string): Href {
return `/(app)/(tabs)/${tab}${normalized}` as Href
}
+function getActiveTabFromRef(): AppTab {
+ return getActiveTab(activeSegmentsRef.current)
+}
+
+/** Mount once in the app shell so navigation helpers can read the active tab without re-rendering consumers. */
+export function AppNavigationSync() {
+ const segments = useSegments()
+ activeSegmentsRef.current = segments as string[]
+ return null
+}
+
export function useAppNavigation() {
const router = useRouter()
- const segments = useSegments()
- const tab = getActiveTab(segments)
+
+ const push = useCallback((path: string) => {
+ router.push(tabPath(getActiveTabFromRef(), path))
+ }, [router])
+
+ const replace = useCallback((path: string) => {
+ router.replace(tabPath(getActiveTabFromRef(), path))
+ }, [router])
+
+ const href = useCallback(
+ (path: string) => tabPath(getActiveTabFromRef(), path),
+ []
+ )
return {
- tab,
- href: (path: string) => tabPath(tab, path),
- push: (path: string) => router.push(tabPath(tab, path)),
- replace: (path: string) => router.replace(tabPath(tab, path)),
+ get tab() {
+ return getActiveTabFromRef()
+ },
+ href,
+ push,
+ replace,
}
}
diff --git a/apps/mobile/lib/navigation.ts b/apps/mobile/lib/navigation.ts
index 06b2889..1eaedd8 100644
--- a/apps/mobile/lib/navigation.ts
+++ b/apps/mobile/lib/navigation.ts
@@ -20,9 +20,9 @@ export const tabStackScreenTitles: Record = {
"browse/albums": "Albums",
"browse/artists": "Artists",
"browse/songs": "Songs",
+ "browse/playlists": "Playlists",
"recently-played": "Recently Played",
"recently-added": "Recently Added",
- playlists: "Playlists",
settings: "Settings",
}