Skip to content

Commit

Permalink
feat(songs): long press on song item #51
Browse files Browse the repository at this point in the history
  • Loading branch information
Malopieds committed Apr 8, 2024
1 parent 31eab06 commit d382f52
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 112 deletions.
33 changes: 22 additions & 11 deletions app/src/main/java/com/zionhuang/music/ui/screens/AlbumScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,30 @@ fun AlbumScreen(
},
modifier = Modifier
.fillMaxWidth()
.combinedClickable {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
ListQueue(
title = albumWithSongs.album.title,
items = albumWithSongs.songs.map { it.toMediaItem() },
startIndex = index
.combinedClickable(
onClick = {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
ListQueue(
title = albumWithSongs.album.title,
items = albumWithSongs.songs.map { it.toMediaItem() },
startIndex = index
)
)
)
}
},
onLongClick = {
menuState.show {
SongMenu(
originalSong = song,
navController = navController,
onDismiss = menuState::dismiss
)
}
}
}
)
)
}
} else {
Expand Down
32 changes: 22 additions & 10 deletions app/src/main/java/com/zionhuang/music/ui/screens/HistoryScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,30 @@ fun HistoryScreen(
},
modifier = Modifier
.fillMaxWidth()
.combinedClickable {
if (event.song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
YouTubeQueue(
endpoint = WatchEndpoint(videoId = event.song.id),
preloadItem = event.song.toMediaMetadata()
.combinedClickable (
onClick = {
if (event.song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
YouTubeQueue(
endpoint = WatchEndpoint(videoId = event.song.id),
preloadItem = event.song.toMediaMetadata()
)
)
)
}
},
onLongClick = {
menuState.show {
SongMenu(
originalSong = event.song,
event = event.event,
navController = navController,
onDismiss = menuState::dismiss
)
}
}
}
)
.animateItemPlacement()

)
Expand Down
62 changes: 42 additions & 20 deletions app/src/main/java/com/zionhuang/music/ui/screens/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,29 @@ fun HomeScreen(
},
modifier = Modifier
.width(horizontalLazyGridItemWidth)
.clickable {
if (song!!.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
YouTubeQueue(
WatchEndpoint(videoId = song!!.id),
song!!.toMediaMetadata()
.combinedClickable (
onClick = {
if (song!!.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
YouTubeQueue(
WatchEndpoint(videoId = song!!.id),
song!!.toMediaMetadata()
)
)
)
}
},
onLongClick = {
menuState.show {
SongMenu(
originalSong = song!!,
navController = navController,
onDismiss = menuState::dismiss
)
}
}
}
)
)
}
}
Expand Down Expand Up @@ -440,18 +451,29 @@ fun HomeScreen(
},
modifier = Modifier
.width(horizontalLazyGridItemWidth)
.clickable {
if (song!!.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
YouTubeQueue(
WatchEndpoint(videoId = song!!.id),
song!!.toMediaMetadata()
.combinedClickable(
onClick = {
if (song!!.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
YouTubeQueue(
WatchEndpoint(videoId = song!!.id),
song!!.toMediaMetadata()
)
)
)
}
},
onLongClick = {
menuState.show {
SongMenu(
originalSong = song!!,
navController = navController,
onDismiss = menuState::dismiss
)
}
}
}
)
)
}
}
Expand Down
31 changes: 21 additions & 10 deletions app/src/main/java/com/zionhuang/music/ui/screens/StatsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,29 @@ fun StatsScreen(
},
modifier = Modifier
.fillMaxWidth()
.combinedClickable {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
YouTubeQueue(
endpoint = WatchEndpoint(song.id),
preloadItem = song.toMediaMetadata()
.combinedClickable (
onClick = {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
YouTubeQueue(
endpoint = WatchEndpoint(song.id),
preloadItem = song.toMediaMetadata()
)
)
)
}
},
onLongClick = {
menuState.show {
SongMenu(
originalSong = song,
navController = navController,
onDismiss = menuState::dismiss
)
}
}
}
)
.animateItemPlacement()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,30 @@ fun ArtistScreen(
},
modifier = Modifier
.fillMaxWidth()
.combinedClickable {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(YouTubeQueue(WatchEndpoint(videoId = song.id), song.toMediaMetadata()))
.combinedClickable (
onClick = {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
YouTubeQueue(
WatchEndpoint(
videoId = song.id
), song.toMediaMetadata()
)
)
}
},
onLongClick = {
menuState.show {
SongMenu(
originalSong = song,
navController = navController,
onDismiss = menuState::dismiss
)
}
}
}
)
.animateItemPlacement()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,30 @@ fun ArtistSongsScreen(
},
modifier = Modifier
.fillMaxWidth()
.combinedClickable {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
ListQueue(
title = context.getString(R.string.queue_all_songs),
items = songs.map { it.toMediaItem() },
startIndex = index
.combinedClickable (
onClick = {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
ListQueue(
title = context.getString(R.string.queue_all_songs),
items = songs.map { it.toMediaItem() },
startIndex = index
)
)
}
},
onLongClick = {
menuState.show {
SongMenu(
originalSong = song,
navController = navController,
onDismiss = menuState::dismiss
)
)
}
}
}
)
.animateItemPlacement()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,30 @@ fun LibrarySongsScreen(
},
modifier = Modifier
.fillMaxWidth()
.combinedClickable {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
ListQueue(
title = context.getString(R.string.queue_all_songs),
items = songs.map { it.toMediaItem() },
startIndex = index
.combinedClickable (
onClick = {
if (song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
ListQueue(
title = context.getString(R.string.queue_all_songs),
items = songs.map { it.toMediaItem() },
startIndex = index
)
)
}
},
onLongClick = {
menuState.show {
SongMenu(
originalSong = song,
navController = navController,
onDismiss = menuState::dismiss
)
)
}
}
}
)
.animateItemPlacement()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,30 @@ fun AutoPlaylistScreen(
},
modifier = Modifier
.fillMaxWidth()
.combinedClickable {
if (song.song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
ListQueue(
title = playlist + "Playlist",
items = songs!!.map { it.toMediaItem() },
startIndex = index
.combinedClickable (
onClick = {
if (song.song.id == mediaMetadata?.id) {
playerConnection.player.togglePlayPause()
} else {
playerConnection.playQueue(
ListQueue(
title = playlist + "Playlist",
items = songs!!.map { it.toMediaItem() },
startIndex = index
)
)
)
}
},
onLongClick = {
menuState.show {
SongMenu(
originalSong = song,
navController = navController,
onDismiss = menuState::dismiss
)
}
}
}
)
)
}
}
Expand Down
Loading

0 comments on commit d382f52

Please sign in to comment.