Reorganize actions location in LocalPlaylistSongs
This commit is contained in:
@@ -39,6 +39,8 @@ import it.vfsfitvnm.vimusic.ui.components.themed.Header
|
|||||||
import it.vfsfitvnm.vimusic.ui.components.themed.HeaderIconButton
|
import it.vfsfitvnm.vimusic.ui.components.themed.HeaderIconButton
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.IconButton
|
import it.vfsfitvnm.vimusic.ui.components.themed.IconButton
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.InPlaylistMediaItemMenu
|
import it.vfsfitvnm.vimusic.ui.components.themed.InPlaylistMediaItemMenu
|
||||||
|
import it.vfsfitvnm.vimusic.ui.components.themed.Menu
|
||||||
|
import it.vfsfitvnm.vimusic.ui.components.themed.MenuEntry
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.PrimaryButton
|
import it.vfsfitvnm.vimusic.ui.components.themed.PrimaryButton
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.SecondaryTextButton
|
import it.vfsfitvnm.vimusic.ui.components.themed.SecondaryTextButton
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.TextFieldDialog
|
import it.vfsfitvnm.vimusic.ui.components.themed.TextFieldDialog
|
||||||
@@ -163,47 +165,64 @@ fun LocalPlaylistSongs(
|
|||||||
.weight(1f)
|
.weight(1f)
|
||||||
)
|
)
|
||||||
|
|
||||||
playlistWithSongs?.playlist?.browseId?.let { browseId ->
|
HeaderIconButton(
|
||||||
HeaderIconButton(
|
icon = R.drawable.ellipsis_horizontal,
|
||||||
icon = R.drawable.sync,
|
color = colorPalette.text,
|
||||||
color = colorPalette.text,
|
onClick = {
|
||||||
onClick = {
|
menuState.display {
|
||||||
transaction {
|
Menu {
|
||||||
runBlocking(Dispatchers.IO) {
|
playlistWithSongs?.playlist?.browseId?.let { browseId ->
|
||||||
withContext(Dispatchers.IO) {
|
MenuEntry(
|
||||||
Innertube.playlistPage(BrowseBody(browseId = browseId))
|
icon = R.drawable.sync,
|
||||||
?.completed()
|
text = "Sync",
|
||||||
}
|
onClick = {
|
||||||
}?.getOrNull()?.let { remotePlaylist ->
|
menuState.hide()
|
||||||
Database.clearPlaylist(playlistId)
|
transaction {
|
||||||
|
runBlocking(Dispatchers.IO) {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
Innertube.playlistPage(BrowseBody(browseId = browseId))
|
||||||
|
?.completed()
|
||||||
|
}
|
||||||
|
}?.getOrNull()?.let { remotePlaylist ->
|
||||||
|
Database.clearPlaylist(playlistId)
|
||||||
|
|
||||||
remotePlaylist.songsPage
|
remotePlaylist.songsPage
|
||||||
?.items
|
?.items
|
||||||
?.map(Innertube.SongItem::asMediaItem)
|
?.map(Innertube.SongItem::asMediaItem)
|
||||||
?.onEach(Database::insert)
|
?.onEach(Database::insert)
|
||||||
?.mapIndexed { position, mediaItem ->
|
?.mapIndexed { position, mediaItem ->
|
||||||
SongPlaylistMap(
|
SongPlaylistMap(
|
||||||
songId = mediaItem.mediaId,
|
songId = mediaItem.mediaId,
|
||||||
playlistId = playlistId,
|
playlistId = playlistId,
|
||||||
position = position
|
position = position
|
||||||
)
|
)
|
||||||
}?.let(Database::insertSongPlaylistMaps)
|
}?.let(Database::insertSongPlaylistMaps)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuEntry(
|
||||||
|
icon = R.drawable.pencil,
|
||||||
|
text = "Rename",
|
||||||
|
onClick = {
|
||||||
|
menuState.hide()
|
||||||
|
isRenaming = true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
MenuEntry(
|
||||||
|
icon = R.drawable.trash,
|
||||||
|
text = "Delete",
|
||||||
|
onClick = {
|
||||||
|
menuState.hide()
|
||||||
|
isDeleting = true
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
HeaderIconButton(
|
|
||||||
icon = R.drawable.pencil,
|
|
||||||
color = colorPalette.text,
|
|
||||||
onClick = { isRenaming = true }
|
|
||||||
)
|
|
||||||
|
|
||||||
HeaderIconButton(
|
|
||||||
icon = R.drawable.trash,
|
|
||||||
color = colorPalette.text,
|
|
||||||
onClick = { isDeleting = true }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user