impl shuffle, controls are temp

This commit is contained in:
austinried
2021-07-20 13:02:42 +09:00
parent df783a074b
commit f859be51a5
5 changed files with 89 additions and 41 deletions

View File

@@ -26,7 +26,8 @@ const AlbumDetails: React.FC<{
const Songs = () => (
<>
<View style={styles.controls}>
<Button title="Play Album" onPress={() => setQueue(album.songs, album.name, album.songs[0].id)} />
<Button title="Play Album" onPress={() => setQueue(album.songs, album.name, undefined, false)} />
<Button title="Shuffle" onPress={() => setQueue(album.songs, album.name, undefined, true)} />
</View>
<View style={styles.songs}>
{album.songs
@@ -37,8 +38,8 @@ const AlbumDetails: React.FC<{
return a.title.localeCompare(b.title)
}
})
.map(s => (
<SongItem key={s.id} song={s} onPress={() => setQueue(album.songs, album.name, s.id)} />
.map((s, i) => (
<SongItem key={i} song={s} onPress={() => setQueue(album.songs, album.name, i)} />
))}
</View>
</>

View File

@@ -48,13 +48,13 @@ const ArtistDetails: React.FC<{ id: string }> = ({ id }) => {
const TopSongs = () => (
<>
<Text style={styles.header}>Top Songs</Text>
{artist.topSongs.map(s => (
{artist.topSongs.map((s, i) => (
<SongItem
key={s.id}
key={i}
song={s}
showArt={true}
subtitle="album"
onPress={() => setQueue(artist.topSongs, `Top Songs: ${artist.name}`, s.id)}
onPress={() => setQueue(artist.topSongs, `Top Songs: ${artist.name}`, i)}
/>
))}
</>

View File

@@ -26,11 +26,11 @@ const PlaylistDetails: React.FC<{
const Songs = () => (
<>
<View style={styles.controls}>
<Button title="Play Playlist" onPress={() => setQueue(playlist.songs, playlist.name, playlist.songs[0].id)} />
<Button title="Play Playlist" onPress={() => setQueue(playlist.songs, playlist.name)} />
</View>
<View style={styles.songs}>
{playlist.songs.map((s, index) => (
<SongItem key={index} song={s} showArt={true} onPress={() => setQueue(playlist.songs, playlist.name, s.id)} />
{playlist.songs.map((s, i) => (
<SongItem key={i} song={s} showArt={true} onPress={() => setQueue(playlist.songs, playlist.name, i)} />
))}
</View>
</>