mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
switch to new album list/cover art, remove old
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
import { useAtomValue } from 'jotai/utils'
|
||||
import React from 'react'
|
||||
import { ActivityIndicator, View } from 'react-native'
|
||||
import FastImage from 'react-native-fast-image'
|
||||
import LinearGradient from 'react-native-linear-gradient'
|
||||
import { albumArtAtomFamily } from '@app/state/music'
|
||||
import colors from '@app/styles/colors'
|
||||
import CoverArt from '@app/components/CoverArt'
|
||||
|
||||
interface AlbumArtProps {
|
||||
id: string
|
||||
height: string | number
|
||||
width: string | number
|
||||
}
|
||||
|
||||
const AlbumArt: React.FC<AlbumArtProps> = ({ id, height, width }) => {
|
||||
const albumArt = useAtomValue(albumArtAtomFamily(id))
|
||||
|
||||
const Placeholder = () => (
|
||||
<LinearGradient colors={[colors.accent, colors.accentLow]}>
|
||||
<FastImage
|
||||
source={require('@res/icons/record.png')}
|
||||
style={{ height, width }}
|
||||
resizeMode={FastImage.resizeMode.contain}
|
||||
/>
|
||||
</LinearGradient>
|
||||
)
|
||||
|
||||
return (
|
||||
<CoverArt
|
||||
PlaceholderComponent={Placeholder}
|
||||
height={height}
|
||||
width={width}
|
||||
coverArtUri={width > 200 ? albumArt?.uri : albumArt?.thumbUri}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const AlbumArtFallback: React.FC<AlbumArtProps> = ({ height, width }) => (
|
||||
<View
|
||||
style={{
|
||||
height,
|
||||
width,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}>
|
||||
<ActivityIndicator size="small" color={colors.accent} />
|
||||
</View>
|
||||
)
|
||||
|
||||
const AlbumArtLoader: React.FC<AlbumArtProps> = props => (
|
||||
<React.Suspense fallback={<AlbumArtFallback {...props} />}>
|
||||
<AlbumArt {...props} />
|
||||
</React.Suspense>
|
||||
)
|
||||
|
||||
export default React.memo(AlbumArtLoader)
|
||||
@@ -4,7 +4,7 @@ import FastImage from 'react-native-fast-image'
|
||||
import colors from '@app/styles/colors'
|
||||
|
||||
const CoverArt: React.FC<{
|
||||
PlaceholderComponent: () => JSX.Element
|
||||
PlaceholderComponent?: () => JSX.Element
|
||||
height?: string | number
|
||||
width?: string | number
|
||||
coverArtUri?: string
|
||||
@@ -25,6 +25,7 @@ const CoverArt: React.FC<{
|
||||
resizeMode={FastImage.resizeMode.contain}
|
||||
onError={() => {
|
||||
setLoading(false)
|
||||
console.log('asdfdsaf')
|
||||
setPlaceholderVisible(true)
|
||||
}}
|
||||
onLoadEnd={() => setLoading(false)}
|
||||
@@ -35,7 +36,7 @@ const CoverArt: React.FC<{
|
||||
<View style={{ ...styles.container, height, width }}>
|
||||
{coverArtUri ? <Image /> : <></>}
|
||||
<View style={{ ...styles.placeholderContainer, opacity: placeholderVisible ? 1 : 0 }}>
|
||||
<PlaceholderComponent />
|
||||
{PlaceholderComponent ? <PlaceholderComponent /> : <></>}
|
||||
</View>
|
||||
<ActivityIndicator style={styles.indicator} animating={loading} size={'large'} color={colors.accent} />
|
||||
</View>
|
||||
|
||||
@@ -69,7 +69,6 @@ const NowPlayingBar = () => {
|
||||
<ProgressBar />
|
||||
<View style={styles.subContainer}>
|
||||
<CoverArt
|
||||
PlaceholderComponent={() => <Text>hi</Text>}
|
||||
height={styles.subContainer.height}
|
||||
width={styles.subContainer.height}
|
||||
coverArtUri={track?.artworkThumb}
|
||||
|
||||
Reference in New Issue
Block a user