diff --git a/apps/mobile/app/(app)/(tabs)/home/recently-added.tsx b/apps/mobile/app/(app)/(tabs)/home/recently-added.tsx
index d15b47e..9f37171 100644
--- a/apps/mobile/app/(app)/(tabs)/home/recently-added.tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/recently-added.tsx
@@ -5,7 +5,7 @@ import { LoadingView } from "@/components/ui/primitives"
import { contentBottomInset } from "@/components/player"
import { api } from "@otunes/convex/_generated/api"
-const PAGE_SIZE = 50
+const PAGE_SIZE = 16
export default function RecentlyAddedScreen() {
const { results, status, loadMore } = usePaginatedQuery(
diff --git a/apps/mobile/app/(app)/(tabs)/library/index.tsx b/apps/mobile/app/(app)/(tabs)/library/index.tsx
index 76b2ef0..4ff128e 100644
--- a/apps/mobile/app/(app)/(tabs)/library/index.tsx
+++ b/apps/mobile/app/(app)/(tabs)/library/index.tsx
@@ -1,17 +1,18 @@
import { usePaginatedQuery } from "convex/react"
-import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
+import { useMemo } from "react"
+import { Pressable, StyleSheet, Text, View } from "react-native"
import { SymbolView } from "expo-symbols"
import { Platform } from "react-native"
import { Ionicons } from "@expo/vector-icons"
-import { MediaGrid } from "@/components/media-cards"
+import { MediaGridList } from "@/components/media-cards"
import { tabContentBottomInset } from "@/components/player"
import { LoadingView } from "@/components/ui/primitives"
import { useAppNavigation } from "@/lib/app-navigation"
import { api } from "@otunes/convex/_generated/api"
import { appleMusic, spacing, useThemeColors } from "@/lib/theme"
-const RECENTLY_ADDED_PREVIEW_SIZE = 4
+const PAGE_SIZE = 16
const links = [
{ title: "Playlists", href: "/browse/playlists", icon: "music.note.list" as const },
@@ -48,43 +49,59 @@ function LibraryIcon({ name }: { name: (typeof links)[number]["icon"] }) {
export default function LibraryScreen() {
const { push } = useAppNavigation()
const colors = useThemeColors()
- const { results: recentlyAdded } = usePaginatedQuery(
+ const { results, status, loadMore } = usePaginatedQuery(
api.library.browseRecentlyAddedPaginated,
{},
- { initialNumItems: RECENTLY_ADDED_PREVIEW_SIZE }
+ { initialNumItems: PAGE_SIZE }
)
- return (
-
- {links.map((link) => (
- push(link.href)}
- >
-
- {link.title}
-
-
- ))}
+ const listHeader = useMemo(
+ () => (
+
+ {links.map((link) => (
+ push(link.href)}
+ >
+
+ {link.title}
+
+
+ ))}
-
- push("/recently-added")}>
+ push("/recently-added")}
+ >
Recently Added
- {recentlyAdded === undefined ? (
-
- ) : (
-
- )}
-
+ ),
+ [colors.border, colors.foreground, colors.mutedForeground, push]
+ )
+
+ if (results === undefined) {
+ return (
+
+ {listHeader}
+
+
+ )
+ }
+
+ return (
+ {
+ if (status === "CanLoadMore") loadMore(PAGE_SIZE)
+ }}
+ />
)
}
@@ -104,8 +121,7 @@ const styles = StyleSheet.create({
},
section: {
paddingTop: spacing.xl,
- paddingHorizontal: spacing.lg,
- gap: spacing.md,
+ paddingBottom: spacing.md,
},
sectionTitle: {
fontSize: 22,
diff --git a/apps/mobile/components/media-cards.tsx b/apps/mobile/components/media-cards.tsx
index 522af1a..deb1e00 100644
--- a/apps/mobile/components/media-cards.tsx
+++ b/apps/mobile/components/media-cards.tsx
@@ -1,5 +1,5 @@
import { Ionicons } from "@expo/vector-icons"
-import { memo, useCallback } from "react"
+import { memo, useCallback, type ReactElement } from "react"
import { FlatList, Pressable, ScrollView, StyleSheet, Text, View } from "react-native"
import { CoverImage } from "@/components/cover-image"
@@ -179,10 +179,14 @@ export function MediaGridList({
content,
paddingBottom,
onEndReached,
+ ListHeaderComponent,
+ contentInset = true,
}: {
content: MediaItem[]
paddingBottom: number
onEndReached?: () => void
+ ListHeaderComponent?: ReactElement | null
+ contentInset?: boolean
}) {
const cardWidth = useTwoColumnCardWidth()
const colors = useThemeColors()
@@ -193,9 +197,16 @@ export function MediaGridList({
keyExtractor={(item) => item.id}
numColumns={2}
style={{ flex: 1, backgroundColor: colors.background }}
- contentContainerStyle={[styles.gridListContent, { paddingBottom }]}
- columnWrapperStyle={styles.gridListRow}
+ contentContainerStyle={[
+ contentInset ? styles.gridListContent : styles.gridListContentInset,
+ { paddingBottom },
+ ]}
+ columnWrapperStyle={[
+ styles.gridListRow,
+ !contentInset && styles.gridListRowInset,
+ ]}
contentInsetAdjustmentBehavior="automatic"
+ ListHeaderComponent={ListHeaderComponent}
onEndReached={onEndReached}
onEndReachedThreshold={0.5}
renderItem={({ item }) => (
@@ -286,7 +297,13 @@ const styles = StyleSheet.create({
padding: spacing.lg,
gap: spacing.md,
},
+ gridListContentInset: {
+ gap: spacing.md,
+ },
gridListRow: {
gap: spacing.md,
},
+ gridListRowInset: {
+ paddingHorizontal: spacing.lg,
+ },
})