mirror of
https://github.com/Jellify-Music/App.git
synced 2026-04-25 20:39:23 -05:00
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { useFavoriteAlbums } from "../../api/queries/favorites";
|
|
import { AlbumsProps } from "../types";
|
|
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
import { ItemCard } from "../Global/components/item-card";
|
|
import { FlatList, RefreshControl } from "react-native";
|
|
|
|
export default function Albums({ navigation }: AlbumsProps) : React.JSX.Element {
|
|
const { data: albums, refetch, isPending } = useFavoriteAlbums();
|
|
|
|
const { width } = useSafeAreaFrame();
|
|
|
|
return (
|
|
<FlatList
|
|
contentInsetAdjustmentBehavior="automatic"
|
|
numColumns={2}
|
|
data={albums}
|
|
refreshControl={
|
|
<RefreshControl
|
|
refreshing={isPending}
|
|
onRefresh={refetch}
|
|
/>
|
|
}
|
|
renderItem={({ index, item: album}) => {
|
|
return (
|
|
<ItemCard
|
|
item={album}
|
|
caption={album.Name ?? "Untitled Album"}
|
|
subCaption={album.ProductionYear?.toString() ?? ""}
|
|
cornered
|
|
onPress={() => {
|
|
navigation.push("Album", { album })
|
|
}}
|
|
width={width / 2.1}
|
|
/>
|
|
)
|
|
}}
|
|
/>
|
|
)
|
|
} |