import { AlbumContextPressable } from '@app/components/ContextMenu' import CoverArt from '@app/components/CoverArt' import GradientScrollView from '@app/components/GradientScrollView' import Header from '@app/components/Header' import NothingHere from '@app/components/NothingHere' import { withSuspenseMemo } from '@app/components/withSuspense' import { useQueryHomeLists } from '@app/hooks/query' import { Album } from '@app/models/library' import { useStoreDeep } from '@app/state/store' import colors from '@app/styles/colors' import font from '@app/styles/font' import { GetAlbumList2TypeBase } from '@app/subsonic/params' import { useNavigation } from '@react-navigation/native' import equal from 'fast-deep-equal/es6/react' import React from 'react' import { useTranslation } from 'react-i18next' import { RefreshControl, ScrollView, StyleSheet, Text, View } from 'react-native' import { useSafeAreaInsets } from 'react-native-safe-area-context' const AlbumItem = React.memo<{ album: Album }>(({ album }) => { const navigation = useNavigation() return ( navigation.navigate('album', { id: album.id, title: album.name, album })}> {album.name} {album.artist} ) }, equal) const CategoryHeader = withSuspenseMemo<{ type: string }>(({ type }) => { const { t } = useTranslation('resources.album.lists') console.log('type', type, t(type)) return
{t(type)}
}) const Category = React.memo<{ type: string albums: Album[] }>(({ type, albums }) => { const Albums = () => ( {albums.map(a => ( ))} ) const Nothing = () => ( ) return ( {albums.length > 0 ? : } ) }, equal) const Home = () => { const types = useStoreDeep(store => store.settings.screens.home.listTypes) const listQueries = useQueryHomeLists(types as GetAlbumList2TypeBase[], 20) const paddingTop = useSafeAreaInsets().top return ( q.isLoading)} onRefresh={() => listQueries.forEach(q => q.refetch())} colors={[colors.accent, colors.accentLow]} progressViewOffset={paddingTop} /> }> {types.map(type => { const query = listQueries.find(list => list.data?.type === type) return })} ) } const styles = StyleSheet.create({ scroll: { flex: 1, }, content: { paddingBottom: 20, }, header: { paddingHorizontal: 20, }, category: { // marginTop: 12, }, nothingHereContent: { width: '100%', height: 190, justifyContent: 'center', alignItems: 'center', }, artScroll: { height: 190, }, artScrollContent: { paddingLeft: 20, }, item: { flex: 1, marginRight: 10, width: 150, }, 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