mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
UI updates
This commit is contained in:
parent
9fb77854e4
commit
4de4144648
4 changed files with 70 additions and 33 deletions
|
|
@ -22,6 +22,7 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
|
|
@ -123,9 +124,20 @@ class AlbumViewModel
|
|||
val album = itemDeferred.await()
|
||||
val songs = songsDeferred.await()
|
||||
val imageUrl = imageUrlService.getItemImageUrl(album, ImageType.PRIMARY)
|
||||
val allArtists =
|
||||
album.data.artists.orEmpty() +
|
||||
album.data.albumArtists
|
||||
?.map { it.name }
|
||||
.orEmpty()
|
||||
val isVariousArtists =
|
||||
allArtists.firstOrNull { it?.lowercase() == "various artists" } != null ||
|
||||
album.data.artists
|
||||
.orEmpty()
|
||||
.size > 1
|
||||
_state.update {
|
||||
AlbumState(
|
||||
album = album,
|
||||
isVariousArtists = isVariousArtists,
|
||||
imageUrl = imageUrl,
|
||||
songs = songs,
|
||||
loading = LoadingState.Success,
|
||||
|
|
@ -177,12 +189,13 @@ class AlbumViewModel
|
|||
|
||||
data class AlbumState(
|
||||
val album: BaseItem?,
|
||||
val isVariousArtists: Boolean,
|
||||
val imageUrl: String?,
|
||||
val songs: List<BaseItem?>,
|
||||
val loading: LoadingState,
|
||||
) {
|
||||
companion object {
|
||||
val EMPTY = AlbumState(null, null, emptyList(), LoadingState.Pending)
|
||||
val EMPTY = AlbumState(null, false, null, emptyList(), LoadingState.Pending)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -302,29 +315,38 @@ fun AlbumDetailsPage(
|
|||
)
|
||||
}
|
||||
itemsIndexed(state.songs) { index, song ->
|
||||
SongListItem(
|
||||
song = song,
|
||||
onClick = { viewModel.play(false, index) },
|
||||
onLongClick = {
|
||||
if (song != null) {
|
||||
moreDialog =
|
||||
DialogParams(
|
||||
fromLongClick = true,
|
||||
title = song.name ?: "",
|
||||
items =
|
||||
buildMoreDialogForMusic(
|
||||
context = context,
|
||||
actions = moreDialogActions,
|
||||
item = song,
|
||||
index = index,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
showArtist = false,
|
||||
isPlaying = song != null && currentMusic.currentItemId == song.id,
|
||||
)
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
SongListItem(
|
||||
song = song,
|
||||
onClick = { viewModel.play(false, index) },
|
||||
onLongClick = {
|
||||
if (song != null) {
|
||||
moreDialog =
|
||||
DialogParams(
|
||||
fromLongClick = true,
|
||||
title = song.name ?: "",
|
||||
items =
|
||||
buildMoreDialogForMusic(
|
||||
context = context,
|
||||
actions = moreDialogActions,
|
||||
item = song,
|
||||
index = index,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
showArtist = state.isVariousArtists,
|
||||
isPlaying = song != null && currentMusic.currentItemId == song.id,
|
||||
modifier =
|
||||
Modifier
|
||||
// .padding(horizontal = 16.dp)
|
||||
.fillMaxWidth(.75f)
|
||||
.align(Alignment.Center),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,7 +251,9 @@ fun NowPlayingOverlay(
|
|||
modifier =
|
||||
Modifier
|
||||
.weight(1f)
|
||||
.ifElse(
|
||||
.onFocusChanged {
|
||||
controllerViewState.pulseControls()
|
||||
}.ifElse(
|
||||
index == 0,
|
||||
Modifier.focusRequester(firstFocusRequester),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -32,12 +32,11 @@ import androidx.media3.common.util.UnstableApi
|
|||
import coil3.compose.AsyncImage
|
||||
import com.github.damontecres.wholphin.preferences.AppPreferences
|
||||
import com.github.damontecres.wholphin.preferences.UserPreferences
|
||||
import com.github.damontecres.wholphin.preferences.skipBackOnResume
|
||||
import com.github.damontecres.wholphin.services.rememberQueue
|
||||
import com.github.damontecres.wholphin.ui.AppColors
|
||||
import com.github.damontecres.wholphin.ui.playback.PlaybackKeyHandler
|
||||
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@OptIn(UnstableApi::class)
|
||||
@Composable
|
||||
|
|
@ -67,17 +66,19 @@ fun NowPlayingPage(
|
|||
PlaybackKeyHandler(
|
||||
player = player,
|
||||
controlsEnabled = true,
|
||||
skipWithLeftRight = true,
|
||||
seekForward = preferences.playbackPreferences.skipForwardMs.milliseconds,
|
||||
seekBack = preferences.playbackPreferences.skipBackMs.milliseconds,
|
||||
skipWithLeftRight = false,
|
||||
seekForward = 30.seconds,
|
||||
seekBack = 10.seconds,
|
||||
// seekForward = preferences.playbackPreferences.skipForwardMs.milliseconds,
|
||||
// seekBack = preferences.playbackPreferences.skipBackMs.milliseconds,
|
||||
controllerViewState = controllerViewState,
|
||||
updateSkipIndicator = {},
|
||||
skipBackOnResume = preferences.playbackPreferences.skipBackOnResume,
|
||||
skipBackOnResume = null,
|
||||
// skipBackOnResume = preferences.playbackPreferences.skipBackOnResume,
|
||||
onInteraction = viewModel::reportInteraction,
|
||||
oneClickPause = preferences.playbackPreferences.oneClickPause,
|
||||
onStop = {
|
||||
player.stop()
|
||||
// viewModel.navigationManager.goBack()
|
||||
viewModel.stop()
|
||||
},
|
||||
onPlaybackDialogTypeClick = { },
|
||||
getDurationMs = { player.duration },
|
||||
|
|
|
|||
|
|
@ -79,6 +79,13 @@ class NowPlayingViewModel
|
|||
state.update { it.copy(musicServiceState = musicServiceState) }
|
||||
}
|
||||
}
|
||||
viewModelScope.launchDefault {
|
||||
viewModelScope
|
||||
.launchDefault {
|
||||
controllerViewState.observe()
|
||||
}.join()
|
||||
controllerViewState.pulseControls()
|
||||
}
|
||||
playbackLoop()
|
||||
}
|
||||
|
||||
|
|
@ -170,4 +177,9 @@ class NowPlayingViewModel
|
|||
index: Int,
|
||||
direction: MoveDirection,
|
||||
) = viewModelScope.launchDefault { musicService.moveQueue(index, direction) }
|
||||
|
||||
fun stop() {
|
||||
player.stop()
|
||||
navigationManager.goBack()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue