animate centerui visibility

This commit is contained in:
Christian Schabesberger 2024-09-04 11:49:38 +02:00
parent 26cb3cf749
commit d97ecc7519
4 changed files with 47 additions and 43 deletions

View File

@ -13,6 +13,9 @@
</DropdownSelection> </DropdownSelection>
<DialogSelection /> <DialogSelection />
</SelectionState> </SelectionState>
<SelectionState runConfigName="VideoPlayerControllerDropDownPreview">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates> </selectionStates>
</component> </component>
</project> </project>

View File

@ -77,7 +77,7 @@ fun VideoPlayerControllerUI(
modifier = Modifier.fillMaxSize(), viewModel = viewModel, uiState = uiState modifier = Modifier.fillMaxSize(), viewModel = viewModel, uiState = uiState
) )
if (uiState.isLoading) { AnimatedVisibility(uiState.isLoading) {
Box(modifier = Modifier.fillMaxSize()) { Box(modifier = Modifier.fillMaxSize()) {
CircularProgressIndicator( CircularProgressIndicator(
modifier = Modifier modifier = Modifier
@ -91,6 +91,7 @@ fun VideoPlayerControllerUI(
AnimatedVisibility(uiState.uiMode.controllerUiVisible) { AnimatedVisibility(uiState.uiMode.controllerUiVisible) {
AnimatedVisibility(visible = !uiState.isLoading) {
Box(modifier = Modifier.fillMaxSize()) { Box(modifier = Modifier.fillMaxSize()) {
CenterUI( CenterUI(
modifier = Modifier.align(Alignment.Center), modifier = Modifier.align(Alignment.Center),
@ -98,6 +99,7 @@ fun VideoPlayerControllerUI(
uiState = uiState uiState = uiState
) )
} }
}
Box( Box(
modifier = if (uiState.uiMode.fullscreen) Modifier.windowInsetsPadding(insets) else Modifier modifier = if (uiState.uiMode.fullscreen) Modifier.windowInsetsPadding(insets) else Modifier
@ -129,11 +131,6 @@ fun VideoPlayerControllerUI(
// Utils // Utils
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@Composable
private fun ViewInFullScreen() {
//LockScreenOrientation(orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
}
@Composable @Composable
fun PreviewBackgroundSurface( fun PreviewBackgroundSurface(
content: @Composable () -> Unit content: @Composable () -> Unit

View File

@ -20,6 +20,7 @@
package net.newpipe.newplayer.ui.videoplayer package net.newpipe.newplayer.ui.videoplayer
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
@ -45,7 +46,6 @@ import net.newpipe.newplayer.R
import net.newpipe.newplayer.model.VideoPlayerUIState import net.newpipe.newplayer.model.VideoPlayerUIState
import net.newpipe.newplayer.model.VideoPlayerViewModel import net.newpipe.newplayer.model.VideoPlayerViewModel
import net.newpipe.newplayer.model.VideoPlayerViewModelDummy import net.newpipe.newplayer.model.VideoPlayerViewModelDummy
import net.newpipe.newplayer.model.VideoPlayerViewModelImpl
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
@Composable @Composable
@ -59,12 +59,12 @@ fun CenterUI(
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
modifier = modifier, modifier = modifier,
) { ) {
if (!uiState.isLoading) {
CenterControllButton( CenterControllButton(
buttonModifier = Modifier.size(80.dp), buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(40.dp), iconModifier = Modifier.size(40.dp),
icon = Icons.Filled.SkipPrevious, icon = Icons.Filled.SkipPrevious,
contentDescriptoion = stringResource(R.string.widget_description_previous_stream), contentDescription = stringResource(R.string.widget_description_previous_stream),
onClick = viewModel::prevStream onClick = viewModel::prevStream
) )
@ -72,7 +72,7 @@ fun CenterUI(
buttonModifier = Modifier.size(80.dp), buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(60.dp), iconModifier = Modifier.size(60.dp),
icon = if (uiState.playing) Icons.Filled.Pause else Icons.Filled.PlayArrow, icon = if (uiState.playing) Icons.Filled.Pause else Icons.Filled.PlayArrow,
contentDescriptoion = stringResource( contentDescription = stringResource(
if (uiState.playing) R.string.widget_description_pause if (uiState.playing) R.string.widget_description_pause
else R.string.widget_description_play else R.string.widget_description_play
), ),
@ -83,19 +83,18 @@ fun CenterUI(
buttonModifier = Modifier.size(80.dp), buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(40.dp), iconModifier = Modifier.size(40.dp),
icon = Icons.Filled.SkipNext, icon = Icons.Filled.SkipNext,
contentDescriptoion = stringResource(R.string.widget_description_next_stream), contentDescription = stringResource(R.string.widget_description_next_stream),
onClick = viewModel::nextStream onClick = viewModel::nextStream
) )
} }
} }
}
@Composable @Composable
private fun CenterControllButton( private fun CenterControllButton(
buttonModifier: Modifier, buttonModifier: Modifier,
iconModifier: Modifier, iconModifier: Modifier,
icon: ImageVector, icon: ImageVector,
contentDescriptoion: String?, contentDescription: String?,
onClick: () -> Unit onClick: () -> Unit
) { ) {
Button( Button(
@ -107,7 +106,7 @@ private fun CenterControllButton(
modifier = buttonModifier modifier = buttonModifier
) { ) {
Icon( Icon(
imageVector = icon, modifier = iconModifier, contentDescription = contentDescriptoion imageVector = icon, modifier = iconModifier, contentDescription = contentDescription
) )
} }
} }

View File

@ -21,6 +21,7 @@
package net.newpipe.newplayer.ui.videoplayer package net.newpipe.newplayer.ui.videoplayer
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.VolumeUp import androidx.compose.material.icons.automirrored.filled.VolumeUp
import androidx.compose.material.icons.filled.FitScreen import androidx.compose.material.icons.filled.FitScreen
@ -42,6 +43,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.focusModifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.onPlaced import androidx.compose.ui.layout.onPlaced
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
@ -129,14 +131,17 @@ fun DropDownMenu() {
} }
} }
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
// Preview // Preview
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@Preview(device = "spec:width=1080px,height=600px,dpi=440,orientation=landscape") @Preview(device = "spec:width=1080px,height=1080px,dpi=440,orientation=landscape")
@Composable @Composable
fun VideoPlayerControllerDropDownPreview() { fun VideoPlayerControllerDropDownPreview() {
VideoPlayerTheme { VideoPlayerTheme {
Box(Modifier.fillMaxSize()){
DropDownMenu() DropDownMenu()
} }
} }
}