fix theme preview
This commit is contained in:
parent
5046122732
commit
522eb3ee4e
|
@ -22,6 +22,7 @@
|
|||
package net.newpipe.newplayer.ui.audioplayer
|
||||
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
|
@ -36,6 +37,7 @@ import androidx.compose.material3.Text
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
@ -52,7 +54,7 @@ import net.newpipe.newplayer.utils.getInsets
|
|||
|
||||
@Composable
|
||||
fun lightAudioControlButtonColorScheme() = ButtonDefaults.buttonColors().copy(
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
containerColor = Color.Transparent,
|
||||
contentColor = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
|
||||
|
@ -60,77 +62,95 @@ fun lightAudioControlButtonColorScheme() = ButtonDefaults.buttonColors().copy(
|
|||
@Composable
|
||||
fun AudioPlayerUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
|
||||
val insets = getInsets()
|
||||
Scaffold(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.windowInsetsPadding(insets),
|
||||
topBar = { AudioPlayerTopBar(viewModel = viewModel, uiState = uiState) }) { innerPadding ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding)
|
||||
) {
|
||||
Column(
|
||||
Box(modifier = Modifier.fillMaxSize().background(color = Color.Green)) {
|
||||
Scaffold(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.windowInsetsPadding(insets),
|
||||
topBar = {
|
||||
AudioPlayerTopBar(
|
||||
viewModel = viewModel,
|
||||
uiState = uiState
|
||||
)
|
||||
}) { innerPadding ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(20.dp)
|
||||
.weight(1f),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Box(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(1f))
|
||||
Box {
|
||||
Card(
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp),
|
||||
) {
|
||||
Thumbnail(
|
||||
thumbnail = uiState.currentlyPlaying?.mediaMetadata?.artworkUri,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.stream_thumbnail
|
||||
),
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(20.dp)
|
||||
.weight(1f),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(1f)
|
||||
)
|
||||
Box {
|
||||
Card(
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp),
|
||||
) {
|
||||
Thumbnail(
|
||||
thumbnail = uiState.currentlyPlaying?.mediaMetadata?.artworkUri,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.stream_thumbnail
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Box(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(1f))
|
||||
Text(
|
||||
text = uiState.currentlyPlaying?.mediaMetadata?.title.toString(),
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
fontSize = 6.em
|
||||
)
|
||||
Text(
|
||||
text = uiState.currentlyPlaying?.mediaMetadata?.artist.toString(),
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
fontSize = 4.em
|
||||
)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(1f)
|
||||
)
|
||||
Text(
|
||||
text = uiState.currentlyPlaying?.mediaMetadata?.title.toString(),
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
fontSize = 6.em
|
||||
)
|
||||
Text(
|
||||
text = uiState.currentlyPlaying?.mediaMetadata?.artist.toString(),
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
fontSize = 4.em
|
||||
)
|
||||
|
||||
Box(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(0.2f))
|
||||
NewPlayerSeeker(viewModel = viewModel, uiState = uiState)
|
||||
Box(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(0.2f))
|
||||
AudioPlaybackController(viewModel = viewModel, uiState = uiState)
|
||||
Box(modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(0.2f))
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(0.2f)
|
||||
)
|
||||
NewPlayerSeeker(viewModel = viewModel, uiState = uiState)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(0.2f)
|
||||
)
|
||||
AudioPlaybackController(viewModel = viewModel, uiState = uiState)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(0.2f)
|
||||
)
|
||||
}
|
||||
AudioBottomUI(viewModel, uiState)
|
||||
Box(modifier = Modifier.fillMaxSize().weight(0.025f))
|
||||
}
|
||||
AudioBottomUI(viewModel, uiState)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(UnstableApi::class)
|
||||
@Preview(device = "id:pixel_6")
|
||||
@Preview(device = "id:pixel_6", showSystemUi = true)
|
||||
@Composable
|
||||
fun AudioPlayerUIPreview() {
|
||||
// VideoPlayerTheme {
|
||||
|
|
|
@ -28,9 +28,13 @@ import androidx.compose.foundation.layout.Box
|
|||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.List
|
||||
import androidx.compose.material.icons.automirrored.filled.MenuBook
|
||||
import androidx.compose.material.icons.automirrored.filled.Notes
|
||||
import androidx.compose.material.icons.filled.ArtTrack
|
||||
import androidx.compose.material.icons.filled.Language
|
||||
import androidx.compose.material.icons.filled.LiveTv
|
||||
import androidx.compose.material.icons.filled.MenuBook
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material.icons.filled.PictureInPicture
|
||||
import androidx.compose.material.icons.filled.Share
|
||||
|
@ -74,7 +78,7 @@ fun AudioBottomUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
|
|||
colors = lightAudioControlButtonColorScheme()
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.Notes,
|
||||
imageVector = Icons.Filled.ArtTrack,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.details_view_button_description
|
||||
)
|
||||
|
@ -90,9 +94,17 @@ fun AudioBottomUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
|
|||
}
|
||||
Button(onClick = { /*TODO*/ }, colors = lightAudioControlButtonColorScheme()) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.PictureInPicture,
|
||||
imageVector = Icons.AutoMirrored.Filled.MenuBook,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.pip_button_description
|
||||
id = R.string.chapter
|
||||
)
|
||||
)
|
||||
}
|
||||
Button(onClick = { /*TODO*/ }, colors = lightAudioControlButtonColorScheme()) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.List,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.widget_descriptoin_playlist_item_selection
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -147,6 +159,14 @@ private fun Menu() {
|
|||
)
|
||||
},
|
||||
onClick = { /*TODO*/ showMenu = false })
|
||||
DropdownMenuItem(text = { Text(stringResource(R.string.pip_button_description)) }, onClick = { /*TODO*/ }, leadingIcon = {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.PictureInPicture,
|
||||
contentDescription = stringResource(
|
||||
id = R.string.pip_button_description
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,15 @@
|
|||
|
||||
package net.newpipe.newplayer.ui.theme
|
||||
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import net.newpipe.newplayer.model.UIModeState
|
||||
import net.newpipe.newplayer.model.NewPlayerUIState
|
||||
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
|
||||
import net.newpipe.newplayer.ui.audioplayer.AudioPlayerUI
|
||||
import net.newpipe.newplayer.ui.videoplayer.PreviewBackgroundSurface
|
||||
import net.newpipe.newplayer.ui.videoplayer.VideoPlayerControllerUI
|
||||
|
||||
|
@ -70,6 +73,7 @@ val video_player_surfaceTint = Color(0xFFFFB951)
|
|||
val video_player_outlineVariant = Color(0xFF4F4539)
|
||||
val video_player_scrim = Color(0xFF000000)
|
||||
|
||||
@OptIn(UnstableApi::class)
|
||||
@Preview(device = "spec:width=1080px,height=600px,dpi=440,orientation=landscape")
|
||||
@Composable
|
||||
fun VideoPlayerControllerUIPreviewEmbeddedColorPreview() {
|
||||
|
@ -77,7 +81,31 @@ fun VideoPlayerControllerUIPreviewEmbeddedColorPreview() {
|
|||
PreviewBackgroundSurface {
|
||||
VideoPlayerControllerUI(
|
||||
viewModel = NewPlayerViewModelDummy(),
|
||||
uiState = NewPlayerUIState.DEFAULT.copy(
|
||||
uiState = NewPlayerUIState.DUMMY.copy(
|
||||
uiMode = UIModeState.EMBEDDED_VIDEO_CONTROLLER_UI,
|
||||
playing = true,
|
||||
seekerPosition = 0.3f,
|
||||
isLoading = false,
|
||||
durationInMs = 9 * 60 * 1000,
|
||||
playbackPositionInMs = 6 * 60 * 1000,
|
||||
bufferedPercentage = 0.4f,
|
||||
fastSeekSeconds = 10,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OptIn(UnstableApi::class)
|
||||
@Preview(device = "id:pixel_6")
|
||||
@Composable
|
||||
fun AudioPlayerUIPreviewEmbeddedColorPreview() {
|
||||
VideoPlayerTheme {
|
||||
PreviewBackgroundSurface {
|
||||
AudioPlayerUI(
|
||||
viewModel = NewPlayerViewModelDummy(),
|
||||
uiState = NewPlayerUIState.DUMMY.copy(
|
||||
uiMode = UIModeState.EMBEDDED_VIDEO_CONTROLLER_UI,
|
||||
playing = true,
|
||||
seekerPosition = 0.3f,
|
||||
|
|
|
@ -50,6 +50,7 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.compose.ui.unit.sp
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import net.newpipe.newplayer.R
|
||||
import net.newpipe.newplayer.model.EmbeddedUiConfig
|
||||
import net.newpipe.newplayer.model.NewPlayerUIState
|
||||
import net.newpipe.newplayer.model.NewPlayerViewModel
|
||||
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
|
||||
|
@ -63,7 +64,12 @@ import net.newpipe.newplayer.utils.getEmbeddedUiConfig
|
|||
fun TopUI(
|
||||
modifier: Modifier, viewModel: NewPlayerViewModel, uiState: NewPlayerUIState
|
||||
) {
|
||||
val embeddedUiConfig = getEmbeddedUiConfig(activity = LocalContext.current as Activity)
|
||||
val embeddedUiConfig =
|
||||
if (LocalContext.current is Activity)
|
||||
getEmbeddedUiConfig(activity = LocalContext.current as Activity)
|
||||
else
|
||||
EmbeddedUiConfig.DUMMY
|
||||
|
||||
Row(
|
||||
modifier = modifier,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
|
@ -40,6 +40,7 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import net.newpipe.newplayer.model.EmbeddedUiConfig
|
||||
import net.newpipe.newplayer.model.NewPlayerUIState
|
||||
import net.newpipe.newplayer.model.NewPlayerViewModel
|
||||
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
|
||||
|
@ -59,7 +60,10 @@ fun EmbeddedGestureUI(
|
|||
mutableStateOf(false)
|
||||
}
|
||||
|
||||
val embeddedUiConfig = getEmbeddedUiConfig(LocalContext.current as Activity)
|
||||
val embeddedUiConfig = if (LocalContext.current is Activity)
|
||||
getEmbeddedUiConfig(LocalContext.current as Activity)
|
||||
else
|
||||
EmbeddedUiConfig.DUMMY
|
||||
|
||||
val handleMovement = { movement: TouchedPosition ->
|
||||
Log.d(TAG, "${movement.x}:${movement.y}")
|
||||
|
|
Loading…
Reference in New Issue