mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +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.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
|
|
@ -123,9 +124,20 @@ class AlbumViewModel
|
||||||
val album = itemDeferred.await()
|
val album = itemDeferred.await()
|
||||||
val songs = songsDeferred.await()
|
val songs = songsDeferred.await()
|
||||||
val imageUrl = imageUrlService.getItemImageUrl(album, ImageType.PRIMARY)
|
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 {
|
_state.update {
|
||||||
AlbumState(
|
AlbumState(
|
||||||
album = album,
|
album = album,
|
||||||
|
isVariousArtists = isVariousArtists,
|
||||||
imageUrl = imageUrl,
|
imageUrl = imageUrl,
|
||||||
songs = songs,
|
songs = songs,
|
||||||
loading = LoadingState.Success,
|
loading = LoadingState.Success,
|
||||||
|
|
@ -177,12 +189,13 @@ class AlbumViewModel
|
||||||
|
|
||||||
data class AlbumState(
|
data class AlbumState(
|
||||||
val album: BaseItem?,
|
val album: BaseItem?,
|
||||||
|
val isVariousArtists: Boolean,
|
||||||
val imageUrl: String?,
|
val imageUrl: String?,
|
||||||
val songs: List<BaseItem?>,
|
val songs: List<BaseItem?>,
|
||||||
val loading: LoadingState,
|
val loading: LoadingState,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
val EMPTY = AlbumState(null, null, emptyList(), LoadingState.Pending)
|
val EMPTY = AlbumState(null, false, null, emptyList(), LoadingState.Pending)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -302,6 +315,10 @@ fun AlbumDetailsPage(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
itemsIndexed(state.songs) { index, song ->
|
itemsIndexed(state.songs) { index, song ->
|
||||||
|
Box(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
) {
|
||||||
SongListItem(
|
SongListItem(
|
||||||
song = song,
|
song = song,
|
||||||
onClick = { viewModel.play(false, index) },
|
onClick = { viewModel.play(false, index) },
|
||||||
|
|
@ -321,15 +338,20 @@ fun AlbumDetailsPage(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
showArtist = state.isVariousArtists,
|
||||||
showArtist = false,
|
|
||||||
isPlaying = song != null && currentMusic.currentItemId == song.id,
|
isPlaying = song != null && currentMusic.currentItemId == song.id,
|
||||||
|
modifier =
|
||||||
|
Modifier
|
||||||
|
// .padding(horizontal = 16.dp)
|
||||||
|
.fillMaxWidth(.75f)
|
||||||
|
.align(Alignment.Center),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
moreDialog?.let { params ->
|
moreDialog?.let { params ->
|
||||||
DialogPopup(
|
DialogPopup(
|
||||||
showDialog = true,
|
showDialog = true,
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,9 @@ fun NowPlayingOverlay(
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
.ifElse(
|
.onFocusChanged {
|
||||||
|
controllerViewState.pulseControls()
|
||||||
|
}.ifElse(
|
||||||
index == 0,
|
index == 0,
|
||||||
Modifier.focusRequester(firstFocusRequester),
|
Modifier.focusRequester(firstFocusRequester),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,11 @@ import androidx.media3.common.util.UnstableApi
|
||||||
import coil3.compose.AsyncImage
|
import coil3.compose.AsyncImage
|
||||||
import com.github.damontecres.wholphin.preferences.AppPreferences
|
import com.github.damontecres.wholphin.preferences.AppPreferences
|
||||||
import com.github.damontecres.wholphin.preferences.UserPreferences
|
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.services.rememberQueue
|
||||||
import com.github.damontecres.wholphin.ui.AppColors
|
import com.github.damontecres.wholphin.ui.AppColors
|
||||||
import com.github.damontecres.wholphin.ui.playback.PlaybackKeyHandler
|
import com.github.damontecres.wholphin.ui.playback.PlaybackKeyHandler
|
||||||
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -67,17 +66,19 @@ fun NowPlayingPage(
|
||||||
PlaybackKeyHandler(
|
PlaybackKeyHandler(
|
||||||
player = player,
|
player = player,
|
||||||
controlsEnabled = true,
|
controlsEnabled = true,
|
||||||
skipWithLeftRight = true,
|
skipWithLeftRight = false,
|
||||||
seekForward = preferences.playbackPreferences.skipForwardMs.milliseconds,
|
seekForward = 30.seconds,
|
||||||
seekBack = preferences.playbackPreferences.skipBackMs.milliseconds,
|
seekBack = 10.seconds,
|
||||||
|
// seekForward = preferences.playbackPreferences.skipForwardMs.milliseconds,
|
||||||
|
// seekBack = preferences.playbackPreferences.skipBackMs.milliseconds,
|
||||||
controllerViewState = controllerViewState,
|
controllerViewState = controllerViewState,
|
||||||
updateSkipIndicator = {},
|
updateSkipIndicator = {},
|
||||||
skipBackOnResume = preferences.playbackPreferences.skipBackOnResume,
|
skipBackOnResume = null,
|
||||||
|
// skipBackOnResume = preferences.playbackPreferences.skipBackOnResume,
|
||||||
onInteraction = viewModel::reportInteraction,
|
onInteraction = viewModel::reportInteraction,
|
||||||
oneClickPause = preferences.playbackPreferences.oneClickPause,
|
oneClickPause = preferences.playbackPreferences.oneClickPause,
|
||||||
onStop = {
|
onStop = {
|
||||||
player.stop()
|
viewModel.stop()
|
||||||
// viewModel.navigationManager.goBack()
|
|
||||||
},
|
},
|
||||||
onPlaybackDialogTypeClick = { },
|
onPlaybackDialogTypeClick = { },
|
||||||
getDurationMs = { player.duration },
|
getDurationMs = { player.duration },
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,13 @@ class NowPlayingViewModel
|
||||||
state.update { it.copy(musicServiceState = musicServiceState) }
|
state.update { it.copy(musicServiceState = musicServiceState) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
viewModelScope.launchDefault {
|
||||||
|
viewModelScope
|
||||||
|
.launchDefault {
|
||||||
|
controllerViewState.observe()
|
||||||
|
}.join()
|
||||||
|
controllerViewState.pulseControls()
|
||||||
|
}
|
||||||
playbackLoop()
|
playbackLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,4 +177,9 @@ class NowPlayingViewModel
|
||||||
index: Int,
|
index: Int,
|
||||||
direction: MoveDirection,
|
direction: MoveDirection,
|
||||||
) = viewModelScope.launchDefault { musicService.moveQueue(index, direction) }
|
) = viewModelScope.launchDefault { musicService.moveQueue(index, direction) }
|
||||||
|
|
||||||
|
fun stop() {
|
||||||
|
player.stop()
|
||||||
|
navigationManager.goBack()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue