add chapter/stream selection to audio ui

This commit is contained in:
Christian Schabesberger 2024-09-23 15:07:37 +02:00
parent afceb43308
commit a4f8e490ae
5 changed files with 170 additions and 130 deletions

View File

@ -96,7 +96,7 @@ fun AudioPlaybackController(viewModel: NewPlayerViewModel, uiState: NewPlayerUIS
.fillMaxWidth()
.aspectRatio(1f),
onClick = {
viewModel.fastSeek(1)
viewModel.fastSeek(-1)
viewModel.finishFastSeek()
},
colors = lightAudioControlButtonColorScheme(),

View File

@ -22,6 +22,10 @@
package net.newpipe.newplayer.ui.audioplayer
import androidx.annotation.OptIn
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@ -49,11 +53,17 @@ import net.newpipe.newplayer.R
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.model.NewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
import net.newpipe.newplayer.model.UIModeState
import net.newpipe.newplayer.ui.common.NewPlayerSeeker
import net.newpipe.newplayer.ui.streamselect.StreamSelectUI
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.utils.Thumbnail
import net.newpipe.newplayer.utils.getInsets
private val UI_ENTER_ANIMATION = fadeIn(tween(200))
private val UI_EXIT_ANIMATION = fadeOut(tween(200))
@Composable
fun lightAudioControlButtonColorScheme() = ButtonDefaults.buttonColors().copy(
containerColor = MaterialTheme.colorScheme.background,
@ -69,6 +79,27 @@ fun AudioPlayerUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
modifier = Modifier
.fillMaxSize()
.background(color = MaterialTheme.colorScheme.background)
) {
AnimatedVisibility(
visible = uiState.uiMode == UIModeState.AUDIO_CHAPTER_SELECT,
enter = UI_ENTER_ANIMATION,
exit = UI_EXIT_ANIMATION
) {
StreamSelectUI(viewModel = viewModel, uiState = uiState, isChapterSelect = true)
}
AnimatedVisibility(
visible = uiState.uiMode == UIModeState.AUDIO_STREAM_SELECT,
enter = UI_ENTER_ANIMATION,
exit = UI_EXIT_ANIMATION
) {
StreamSelectUI(viewModel = viewModel, uiState = uiState, isChapterSelect = false)
}
AnimatedVisibility(
uiState.uiMode == UIModeState.FULLSCREEN_AUDIO,
enter = UI_ENTER_ANIMATION,
exit = UI_EXIT_ANIMATION
) {
Scaffold(modifier = Modifier
.fillMaxSize()
@ -156,6 +187,7 @@ fun AudioPlayerUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
}
}
}
}
}
@OptIn(UnstableApi::class)

View File

@ -102,7 +102,10 @@ fun StreamSelectTopBar(
IconButton(
onClick = {
viewModel.changeUiMode(uiState.uiMode.getUiHiddenState(), embeddedUiConfig)
viewModel.changeUiMode(
uiState.uiMode.getNextModeWhenBackPressed() ?: uiState.uiMode,
embeddedUiConfig
)
}
) {
Icon(

View File

@ -70,10 +70,6 @@ fun StreamSelectUI(
else
EmbeddedUiConfig.DUMMY
Surface(
modifier = Modifier.fillMaxSize(),
color = STREAMSELECT_UI_BACKGROUND_COLOR
) {
Scaffold(
modifier = Modifier
.fillMaxSize()
@ -84,7 +80,7 @@ fun StreamSelectUI(
ChapterSelectTopBar(
onClose = {
viewModel.changeUiMode(
uiState.uiMode.getUiHiddenState(),
uiState.uiMode.getNextModeWhenBackPressed() ?: uiState.uiMode,
embeddedUiConfig
)
}
@ -130,7 +126,7 @@ fun StreamSelectUI(
}
}
}
}
}
@OptIn(UnstableApi::class)

View File

@ -109,15 +109,24 @@ fun VideoPlayerUi(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
)
AnimatedVisibility(visible = uiState.uiMode.isStreamSelect) {
Surface(
modifier = Modifier.fillMaxSize(),
color = STREAMSELECT_UI_BACKGROUND_COLOR
) {
StreamSelectUI(
viewModel = viewModel,
uiState = uiState,
isChapterSelect = false
)
}
}
AnimatedVisibility(visible = uiState.uiMode.isChapterSelect) {
Surface(
modifier = Modifier.fillMaxSize(),
color = STREAMSELECT_UI_BACKGROUND_COLOR
) {
StreamSelectUI(viewModel = viewModel, uiState = uiState, isChapterSelect = true)
}
}
}
}