import CoverArt from '@app/components/CoverArt'
import GradientScrollView from '@app/components/GradientScrollView'
import PressableOpacity from '@app/components/PressableOpacity'
import { AlbumListItem } from '@app/models/music'
import { homeListsAtom, homeListsUpdatingAtom, useUpdateHomeLists } from '@app/state/music'
import { homeListTypesAtom, useActiveServerRefresh } from '@app/state/settings'
import colors from '@app/styles/colors'
import font from '@app/styles/font'
import { useNavigation } from '@react-navigation/native'
import { useAtomValue } from 'jotai/utils'
import React from 'react'
import { RefreshControl, ScrollView, StatusBar, StyleSheet, Text, View } from 'react-native'
const AlbumItem = React.memo<{
album: AlbumListItem
}>(({ album }) => {
const navigation = useNavigation()
return (
navigation.navigate('AlbumView', { id: album.id, title: album.name })}
key={album.id}
style={styles.item}>
{album.name}
{album.artist}
)
})
const Category = React.memo<{
name: string
data: AlbumListItem[]
}>(({ name, data }) => {
return (
{name}
{data.map(album => (
))}
)
})
const Home = () => {
const types = useAtomValue(homeListTypesAtom)
const lists = useAtomValue(homeListsAtom)
const updating = useAtomValue(homeListsUpdatingAtom)
const update = useUpdateHomeLists()
useActiveServerRefresh(update)
return (
}>
{types.map(type => (
))}
)
}
const styles = StyleSheet.create({
scroll: {
flex: 1,
},
scrollContentContainer: {
paddingTop: StatusBar.currentHeight,
},
content: {
paddingBottom: 20,
},
category: {
marginTop: 12,
},
header: {
fontFamily: font.bold,
fontSize: 24,
color: colors.text.primary,
paddingHorizontal: 20,
marginTop: 4,
},
artScroll: {
marginTop: 10,
height: 190,
},
artScrollContent: {
paddingLeft: 20,
},
item: {
marginRight: 10,
width: 150,
alignItems: 'flex-start',
},
title: {
fontFamily: font.semiBold,
fontSize: 13,
color: colors.text.primary,
marginTop: 4,
},
subtitle: {
fontFamily: font.regular,
fontSize: 12,
color: colors.text.secondary,
},
})
export default Home