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>
<DialogSelection />
</SelectionState>
<SelectionState runConfigName="VideoPlayerControllerDropDownPreview">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

View File

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

View File

@ -20,6 +20,7 @@
package net.newpipe.newplayer.ui.videoplayer
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
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.VideoPlayerViewModel
import net.newpipe.newplayer.model.VideoPlayerViewModelDummy
import net.newpipe.newplayer.model.VideoPlayerViewModelImpl
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
@Composable
@ -59,34 +59,33 @@ fun CenterUI(
horizontalArrangement = Arrangement.SpaceBetween,
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(
buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(60.dp),
icon = if (uiState.playing) Icons.Filled.Pause else Icons.Filled.PlayArrow,
contentDescriptoion = stringResource(
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.SkipPrevious,
contentDescription = stringResource(R.string.widget_description_previous_stream),
onClick = viewModel::prevStream
)
CenterControllButton(
buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(40.dp),
icon = Icons.Filled.SkipNext,
contentDescriptoion = stringResource(R.string.widget_description_next_stream),
onClick = viewModel::nextStream
)
}
CenterControllButton(
buttonModifier = Modifier.size(80.dp),
iconModifier = Modifier.size(60.dp),
icon = if (uiState.playing) Icons.Filled.Pause else Icons.Filled.PlayArrow,
contentDescription = stringResource(
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,
iconModifier: Modifier,
icon: ImageVector,
contentDescriptoion: String?,
contentDescription: String?,
onClick: () -> Unit
) {
Button(
@ -107,7 +106,7 @@ private fun CenterControllButton(
modifier = buttonModifier
) {
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
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.VolumeUp
import androidx.compose.material.icons.filled.FitScreen
@ -42,6 +43,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.focusModifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.onPlaced
import androidx.compose.ui.platform.LocalDensity
@ -129,14 +131,17 @@ fun DropDownMenu() {
}
}
///////////////////////////////////////////////////////////////////
// Preview
///////////////////////////////////////////////////////////////////
@Preview(device = "spec:width=1080px,height=600px,dpi=440,orientation=landscape")
@Preview(device = "spec:width=1080px,height=1080px,dpi=440,orientation=landscape")
@Composable
fun VideoPlayerControllerDropDownPreview() {
VideoPlayerTheme {
DropDownMenu()
Box(Modifier.fillMaxSize()){
DropDownMenu()
}
}
}