import CoverArt from '@app/components/CoverArt' import { artistArtAtomFamily } from '@app/state/music' import colors from '@app/styles/colors' import { useLayout } from '@react-native-community/hooks' import { useAtomValue } from 'jotai/utils' import React from 'react' import { ActivityIndicator, StyleSheet, View } from 'react-native' import FastImage from 'react-native-fast-image' import LinearGradient from 'react-native-linear-gradient' import IconFA5 from 'react-native-vector-icons/FontAwesome5' interface ArtistArtSizeProps { height: number width: number } interface ArtistArtXUpProps extends ArtistArtSizeProps { albumCoverUris: string[] } interface ArtistArtProps extends ArtistArtSizeProps { id: string round?: boolean } const PlaceholderContainer: React.FC = ({ height, width, children }) => { const layout = useLayout() return ( {children} ) } const FourUp = React.memo(({ height, width, albumCoverUris }) => { const halfHeight = height / 2 const halfWidth = width / 2 return ( ) }) const ThreeUp = React.memo(({ height, width, albumCoverUris }) => { const halfHeight = height / 2 const halfWidth = width / 2 return ( ) }) const TwoUp = React.memo(({ height, width, albumCoverUris }) => { const halfHeight = height / 2 return ( ) }) const OneUp = React.memo(({ height, width, albumCoverUris }) => ( )) const NoneUp = React.memo(({ height, width }) => ( )) const ArtistArt = React.memo(({ id, height, width, round }) => { const artistArt = useAtomValue(artistArtAtomFamily(id)) round = round === undefined ? true : round const Placeholder = () => { if (!artistArt) { return } const { albumCoverUris } = artistArt if (albumCoverUris.length >= 4) { return } if (albumCoverUris.length === 3) { return } if (albumCoverUris.length === 2) { return } if (albumCoverUris.length === 1) { return } return } return ( ) }) const ArtistArtFallback = React.memo(({ height, width }) => ( )) const ArtistArtLoader: React.FC = props => ( }> ) const styles = StyleSheet.create({ placeholderContainer: { alignItems: 'center', justifyContent: 'center', }, placeholderIcon: { position: 'absolute', }, artRow: { flexDirection: 'row', }, container: { overflow: 'hidden', }, fallback: { alignItems: 'center', justifyContent: 'center', }, }) export default React.memo(ArtistArtLoader)