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,12 +91,14 @@ fun VideoPlayerControllerUI(
AnimatedVisibility(uiState.uiMode.controllerUiVisible) { AnimatedVisibility(uiState.uiMode.controllerUiVisible) {
Box(modifier = Modifier.fillMaxSize()) { AnimatedVisibility(visible = !uiState.isLoading) {
CenterUI( Box(modifier = Modifier.fillMaxSize()) {
modifier = Modifier.align(Alignment.Center), CenterUI(
viewModel = viewModel, modifier = Modifier.align(Alignment.Center),
uiState = uiState viewModel = viewModel,
) uiState = uiState
)
}
} }
Box( Box(
@ -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,34 +59,33 @@ fun CenterUI(
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
modifier = modifier, modifier = modifier,
) { ) {
if (!uiState.isLoading) {
CenterControllButton(
buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(40.dp),
icon = Icons.Filled.SkipPrevious,
contentDescriptoion = stringResource(R.string.widget_description_previous_stream),
onClick = viewModel::prevStream
)
CenterControllButton( CenterControllButton(
buttonModifier = Modifier.size(80.dp), buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(60.dp), iconModifier = Modifier.size(40.dp),
icon = if (uiState.playing) Icons.Filled.Pause else Icons.Filled.PlayArrow, icon = Icons.Filled.SkipPrevious,
contentDescriptoion = stringResource( contentDescription = stringResource(R.string.widget_description_previous_stream),
if (uiState.playing) R.string.widget_description_pause onClick = viewModel::prevStream
else R.string.widget_description_play )
),
onClick = if (uiState.playing) viewModel::pause else viewModel::play
)
CenterControllButton( CenterControllButton(
buttonModifier = Modifier.size(80.dp), buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(40.dp), iconModifier = Modifier.size(60.dp),
icon = Icons.Filled.SkipNext, icon = if (uiState.playing) Icons.Filled.Pause else Icons.Filled.PlayArrow,
contentDescriptoion = stringResource(R.string.widget_description_next_stream), contentDescription = stringResource(
onClick = viewModel::nextStream if (uiState.playing) R.string.widget_description_pause
) else R.string.widget_description_play
} ),
onClick = if (uiState.playing) viewModel::pause else viewModel::play
)
CenterControllButton(
buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(40.dp),
icon = Icons.Filled.SkipNext,
contentDescription = stringResource(R.string.widget_description_next_stream),
onClick = viewModel::nextStream
)
} }
} }
@ -95,7 +94,7 @@ 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 {
DropDownMenu() Box(Modifier.fillMaxSize()){
DropDownMenu()
}
} }
} }