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() .fillMaxWidth()
.aspectRatio(1f), .aspectRatio(1f),
onClick = { onClick = {
viewModel.fastSeek(1) viewModel.fastSeek(-1)
viewModel.finishFastSeek() viewModel.finishFastSeek()
}, },
colors = lightAudioControlButtonColorScheme(), colors = lightAudioControlButtonColorScheme(),

View File

@ -22,6 +22,10 @@
package net.newpipe.newplayer.ui.audioplayer package net.newpipe.newplayer.ui.audioplayer
import androidx.annotation.OptIn 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.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column 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.NewPlayerUIState
import net.newpipe.newplayer.model.NewPlayerViewModel import net.newpipe.newplayer.model.NewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModelDummy import net.newpipe.newplayer.model.NewPlayerViewModelDummy
import net.newpipe.newplayer.model.UIModeState
import net.newpipe.newplayer.ui.common.NewPlayerSeeker 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.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.utils.Thumbnail import net.newpipe.newplayer.utils.Thumbnail
import net.newpipe.newplayer.utils.getInsets import net.newpipe.newplayer.utils.getInsets
private val UI_ENTER_ANIMATION = fadeIn(tween(200))
private val UI_EXIT_ANIMATION = fadeOut(tween(200))
@Composable @Composable
fun lightAudioControlButtonColorScheme() = ButtonDefaults.buttonColors().copy( fun lightAudioControlButtonColorScheme() = ButtonDefaults.buttonColors().copy(
containerColor = MaterialTheme.colorScheme.background, containerColor = MaterialTheme.colorScheme.background,
@ -69,6 +79,27 @@ fun AudioPlayerUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.background(color = MaterialTheme.colorScheme.background) .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 Scaffold(modifier = Modifier
.fillMaxSize() .fillMaxSize()
@ -157,6 +188,7 @@ fun AudioPlayerUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
} }
} }
} }
}
@OptIn(UnstableApi::class) @OptIn(UnstableApi::class)
@Preview(device = "id:pixel_6", showSystemUi = true) @Preview(device = "id:pixel_6", showSystemUi = true)

View File

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

View File

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

View File

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