import { useAtomValue } from 'jotai/utils' import React, { useState } from 'react' import { ActivityIndicator, LayoutChangeEvent, StyleSheet, View } from 'react-native' import FastImage from 'react-native-fast-image' import LinearGradient from 'react-native-linear-gradient' import { artistArtAtomFamily } from '@app/state/music' import colors from '@app/styles/colors' import CoverArt from '@app/components/CoverArt' import IconFA5 from 'react-native-vector-icons/FontAwesome5' interface ArtistArtSizeProps { height: number width: number } interface ArtistArtXUpProps extends ArtistArtSizeProps { coverArtUris: string[] } interface ArtistArtProps extends ArtistArtSizeProps { id: string } const PlaceholderContainer: React.FC = ({ height, width, children }) => { const [layout, setLayout] = useState({ x: 0, y: 0, width: 0, height: 0 }) const onLayout = (event: LayoutChangeEvent) => { setLayout(event.nativeEvent.layout) } return ( {children} ) } const FourUp = React.memo(({ height, width, coverArtUris }) => { const halfHeight = height / 2 const halfWidth = width / 2 return ( ) }) const ThreeUp = React.memo(({ height, width, coverArtUris }) => { const halfHeight = height / 2 const halfWidth = width / 2 return ( ) }) const TwoUp = React.memo(({ height, width, coverArtUris }) => { const halfHeight = height / 2 return ( ) }) const OneUp = React.memo(({ height, width, coverArtUris }) => ( )) const NoneUp = React.memo(({ height, width }) => ( )) const ArtistArt = React.memo(({ id, height, width }) => { const artistArt = useAtomValue(artistArtAtomFamily(id)) const Placeholder = () => { const none = if (!artistArt || !artistArt.coverArtUris) { return none } const { coverArtUris } = artistArt if (coverArtUris.length >= 4) { return } if (coverArtUris.length === 3) { return } if (coverArtUris.length === 2) { return } if (coverArtUris.length === 1) { return } return none } 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)