mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-29 09:29:29 +01:00
fixed song list and album list sort order
sort first by name, then by year tweak cover art scaling/size
This commit is contained in:
parent
efc7e5c799
commit
e15a2ebcfc
@ -6,6 +6,7 @@ import font from '@app/styles/font'
|
|||||||
import { useNavigation } from '@react-navigation/native'
|
import { useNavigation } from '@react-navigation/native'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { GestureResponderEvent, StyleSheet, Text, View } from 'react-native'
|
import { GestureResponderEvent, StyleSheet, Text, View } from 'react-native'
|
||||||
|
import FastImage from 'react-native-fast-image'
|
||||||
import IconFA from 'react-native-vector-icons/FontAwesome'
|
import IconFA from 'react-native-vector-icons/FontAwesome'
|
||||||
import IconFA5 from 'react-native-vector-icons/FontAwesome5'
|
import IconFA5 from 'react-native-vector-icons/FontAwesome5'
|
||||||
import IconMat from 'react-native-vector-icons/MaterialIcons'
|
import IconMat from 'react-native-vector-icons/MaterialIcons'
|
||||||
@ -83,7 +84,15 @@ const ListItem: React.FC<{
|
|||||||
return (
|
return (
|
||||||
<View style={[styles.container, sizeStyle.container]}>
|
<View style={[styles.container, sizeStyle.container]}>
|
||||||
<PressableOpacity onPress={onPress} style={styles.item}>
|
<PressableOpacity onPress={onPress} style={styles.item}>
|
||||||
{showArt ? <CoverArt {...artSource} style={{ ...styles.art, ...sizeStyle.art }} resizeMode="cover" /> : <></>}
|
{showArt ? (
|
||||||
|
<CoverArt
|
||||||
|
{...artSource}
|
||||||
|
style={{ ...styles.art, ...sizeStyle.art }}
|
||||||
|
resizeMode={FastImage.resizeMode.cover}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
<View style={styles.text}>
|
<View style={styles.text}>
|
||||||
{item.itemType === 'song' ? (
|
{item.itemType === 'song' ? (
|
||||||
<TitleTextSong id={item.id} title={item.title} />
|
<TitleTextSong id={item.id} title={item.title} />
|
||||||
|
|||||||
@ -25,7 +25,7 @@ const AlbumItem = React.memo<{
|
|||||||
<PressableOpacity
|
<PressableOpacity
|
||||||
onPress={() => navigation.navigate('album', { id: album.id, title: album.name })}
|
onPress={() => navigation.navigate('album', { id: album.id, title: album.name })}
|
||||||
style={[styles.albumItem, { width }]}>
|
style={[styles.albumItem, { width }]}>
|
||||||
<CoverArt coverArt={album.coverArt} style={{ height, width }} />
|
<CoverArt coverArt={album.coverArt} style={{ height, width }} resizeMode={FastImage.resizeMode.cover} />
|
||||||
<Text style={styles.albumTitle}>{album.name}</Text>
|
<Text style={styles.albumTitle}>{album.name}</Text>
|
||||||
<Text style={styles.albumYear}> {album.year ? album.year : ''}</Text>
|
<Text style={styles.albumYear}> {album.year ? album.year : ''}</Text>
|
||||||
</PressableOpacity>
|
</PressableOpacity>
|
||||||
@ -65,6 +65,10 @@ const ArtistDetails: React.FC<{ id: string }> = ({ id }) => {
|
|||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const _albums = [...artist.albums]
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
.sort((a, b) => (b.year || 0) - (a.year || 0))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GradientScrollView
|
<GradientScrollView
|
||||||
onLayout={coverLayout.onLayout}
|
onLayout={coverLayout.onLayout}
|
||||||
@ -85,7 +89,7 @@ const ArtistDetails: React.FC<{ id: string }> = ({ id }) => {
|
|||||||
{artist.topSongs.length > 0 ? <TopSongs songs={artist.topSongs} name={artist.name} /> : <></>}
|
{artist.topSongs.length > 0 ? <TopSongs songs={artist.topSongs} name={artist.name} /> : <></>}
|
||||||
<Header>Albums</Header>
|
<Header>Albums</Header>
|
||||||
<View style={styles.albums} onLayout={albumsLayout.onLayout}>
|
<View style={styles.albums} onLayout={albumsLayout.onLayout}>
|
||||||
{artist.albums.map(a => (
|
{_albums.map(a => (
|
||||||
<AlbumItem key={a.id} album={a} height={albumSize} width={albumSize} />
|
<AlbumItem key={a.id} album={a} height={albumSize} width={albumSize} />
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import font from '@app/styles/font'
|
|||||||
import { useNavigation } from '@react-navigation/native'
|
import { useNavigation } from '@react-navigation/native'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { StyleSheet, Text, useWindowDimensions, View } from 'react-native'
|
import { StyleSheet, Text, useWindowDimensions, View } from 'react-native'
|
||||||
|
import FastImage from 'react-native-fast-image'
|
||||||
|
|
||||||
const AlbumItem = React.memo<{
|
const AlbumItem = React.memo<{
|
||||||
id: string
|
id: string
|
||||||
@ -25,7 +26,7 @@ const AlbumItem = React.memo<{
|
|||||||
<PressableOpacity
|
<PressableOpacity
|
||||||
style={[styles.item, { maxWidth: size, height }]}
|
style={[styles.item, { maxWidth: size, height }]}
|
||||||
onPress={() => navigation.navigate('album', { id, title: name })}>
|
onPress={() => navigation.navigate('album', { id, title: name })}>
|
||||||
<CoverArt coverArt={coverArt} style={{ height: size, width: size }} />
|
<CoverArt coverArt={coverArt} style={{ height: size, width: size }} resizeMode={FastImage.resizeMode.cover} />
|
||||||
<View style={styles.itemDetails}>
|
<View style={styles.itemDetails}>
|
||||||
<Text style={styles.title} numberOfLines={1}>
|
<Text style={styles.title} numberOfLines={1}>
|
||||||
{name}
|
{name}
|
||||||
@ -61,7 +62,7 @@ const AlbumsList = () => {
|
|||||||
const layout = useWindowDimensions()
|
const layout = useWindowDimensions()
|
||||||
|
|
||||||
const size = layout.width / 3 - styles.item.marginHorizontal * 2
|
const size = layout.width / 3 - styles.item.marginHorizontal * 2
|
||||||
const height = size + 38
|
const height = size + 36
|
||||||
|
|
||||||
const albumsList = list.map(album => ({ album, size, height }))
|
const albumsList = list.map(album => ({ album, size, height }))
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ const styles = StyleSheet.create({
|
|||||||
item: {
|
item: {
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
marginVertical: 4,
|
marginVertical: 4,
|
||||||
marginHorizontal: 2,
|
marginHorizontal: 3,
|
||||||
flex: 1 / 3,
|
flex: 1 / 3,
|
||||||
},
|
},
|
||||||
itemDetails: {
|
itemDetails: {
|
||||||
|
|||||||
@ -33,13 +33,9 @@ const Songs = React.memo<{
|
|||||||
|
|
||||||
if (type === 'album') {
|
if (type === 'album') {
|
||||||
typeName = 'Album'
|
typeName = 'Album'
|
||||||
_songs.sort((a, b) => {
|
_songs
|
||||||
if (b.track && a.track) {
|
.sort((a, b) => a.title.localeCompare(b.title)) //
|
||||||
return a.track - b.track
|
.sort((a, b) => (a.track || 0) - (b.track || 0))
|
||||||
} else {
|
|
||||||
return a.title.localeCompare(b.title)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
typeName = 'Playlist'
|
typeName = 'Playlist'
|
||||||
}
|
}
|
||||||
@ -150,8 +146,8 @@ const styles = StyleSheet.create({
|
|||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
},
|
},
|
||||||
cover: {
|
cover: {
|
||||||
height: 220,
|
height: 240,
|
||||||
width: 220,
|
width: 240,
|
||||||
},
|
},
|
||||||
songs: {
|
songs: {
|
||||||
marginTop: 26,
|
marginTop: 26,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user