fix colors for chapter and stream select in audio mode

This commit is contained in:
Christian Schabesberger 2024-09-23 18:21:55 +02:00
parent de507b2291
commit 642e5e78db
8 changed files with 40 additions and 30 deletions

View File

@ -42,7 +42,6 @@ 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
@ -55,8 +54,8 @@ import net.newpipe.newplayer.model.NewPlayerViewModel
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
import net.newpipe.newplayer.model.UIModeState
import net.newpipe.newplayer.ui.common.NewPlayerSeeker
import net.newpipe.newplayer.ui.streamselect.ChapterSelectUI
import net.newpipe.newplayer.ui.streamselect.StreamSelectUI
import net.newpipe.newplayer.ui.selection_ui.ChapterSelectUI
import net.newpipe.newplayer.ui.selection_ui.StreamSelectUI
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.utils.Thumbnail
import net.newpipe.newplayer.utils.getInsets
@ -86,7 +85,7 @@ fun AudioPlayerUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
enter = UI_ENTER_ANIMATION,
exit = UI_EXIT_ANIMATION
) {
ChapterSelectUI(viewModel = viewModel, uiState = uiState)
ChapterSelectUI(viewModel = viewModel, uiState = uiState, shownInAudioPlayer = true)
}
AnimatedVisibility(
@ -94,7 +93,7 @@ fun AudioPlayerUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
enter = UI_ENTER_ANIMATION,
exit = UI_EXIT_ANIMATION
) {
StreamSelectUI(viewModel = viewModel, uiState = uiState)
StreamSelectUI(viewModel = viewModel, uiState = uiState, shownInAudioPlayer = true)
}
AnimatedVisibility(

View File

@ -19,7 +19,7 @@
*/
package net.newpipe.newplayer.ui.streamselect
package net.newpipe.newplayer.ui.selection_ui
import android.net.Uri
import androidx.compose.animation.AnimatedVisibility

View File

@ -19,7 +19,7 @@
*/
package net.newpipe.newplayer.ui.streamselect
package net.newpipe.newplayer.ui.selection_ui
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.icons.Icons

View File

@ -18,7 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/
package net.newpipe.newplayer.ui.streamselect
package net.newpipe.newplayer.ui.selection_ui
import android.app.Activity
import androidx.annotation.OptIn
@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
@ -47,7 +48,11 @@ import net.newpipe.newplayer.utils.getInsets
@OptIn(UnstableApi::class)
@Composable
fun ChapterSelectUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
fun ChapterSelectUI(
viewModel: NewPlayerViewModel,
uiState: NewPlayerUIState,
shownInAudioPlayer: Boolean
) {
val insets = getInsets()
val embeddedUiConfig = if (LocalContext.current is Activity)
@ -59,7 +64,10 @@ fun ChapterSelectUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(insets),
containerColor = Color.Transparent,
containerColor = if (shownInAudioPlayer)
MaterialTheme.colorScheme.background
else
Color.Transparent,
topBar = {
ChapterSelectTopBar(
onClose = {
@ -109,7 +117,8 @@ fun VideoPlayerChannelSelectUIPreview() {
Surface(modifier = Modifier.fillMaxSize(), color = Color.Red) {
ChapterSelectUI(
viewModel = NewPlayerViewModelDummy(),
uiState = NewPlayerUIState.DUMMY
uiState = NewPlayerUIState.DUMMY,
shownInAudioPlayer = false
)
}
}

View File

@ -18,7 +18,7 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/
package net.newpipe.newplayer.ui.streamselect
package net.newpipe.newplayer.ui.selection_ui
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn

View File

@ -18,16 +18,13 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/
package net.newpipe.newplayer.ui.streamselect
package net.newpipe.newplayer.ui.selection_ui
import android.app.Activity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.PlaylistAdd
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Repeat
import androidx.compose.material.icons.filled.RepeatOn
import androidx.compose.material.icons.filled.RepeatOneOn
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@ -44,7 +41,6 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.R
import net.newpipe.newplayer.RepeatMode
import net.newpipe.newplayer.model.EmbeddedUiConfig
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.model.NewPlayerViewModel

View File

@ -18,9 +18,8 @@
* along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
*/
package net.newpipe.newplayer.ui.streamselect
package net.newpipe.newplayer.ui.selection_ui
import android.app.Activity
import androidx.annotation.OptIn
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@ -32,23 +31,20 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
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
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
import net.newpipe.newplayer.ui.videoplayer.STREAMSELECT_UI_BACKGROUND_COLOR
import net.newpipe.newplayer.utils.ReorderHapticFeedbackType
import net.newpipe.newplayer.utils.getEmbeddedUiConfig
import net.newpipe.newplayer.utils.getInsets
import net.newpipe.newplayer.utils.rememberReorderHapticFeedback
import sh.calvin.reorderable.ReorderableItem
@ -60,7 +56,8 @@ val ITEM_CORNER_SHAPE = RoundedCornerShape(10.dp)
@Composable
fun StreamSelectUI(
viewModel: NewPlayerViewModel,
uiState: NewPlayerUIState
uiState: NewPlayerUIState,
shownInAudioPlayer: Boolean
) {
val insets = getInsets()
@ -68,7 +65,10 @@ fun StreamSelectUI(
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(insets),
containerColor = Color.Transparent,
containerColor = if (shownInAudioPlayer)
MaterialTheme.colorScheme.background
else
Color.Transparent,
topBar = {
StreamSelectTopBar(viewModel = viewModel, uiState = uiState)
}
@ -138,7 +138,8 @@ fun VideoPlayerStreamSelectUIPreview() {
Surface(modifier = Modifier.fillMaxSize(), color = Color.Red) {
StreamSelectUI(
viewModel = NewPlayerViewModelDummy(),
uiState = NewPlayerUIState.DUMMY
uiState = NewPlayerUIState.DUMMY,
shownInAudioPlayer = false
)
}
}

View File

@ -45,9 +45,9 @@ import androidx.media3.common.util.UnstableApi
import net.newpipe.newplayer.model.NewPlayerUIState
import net.newpipe.newplayer.model.NewPlayerViewModel
import net.newpipe.newplayer.ui.PlaySurface
import net.newpipe.newplayer.ui.streamselect.StreamSelectUI
import net.newpipe.newplayer.ui.selection_ui.StreamSelectUI
import androidx.lifecycle.LifecycleEventObserver
import net.newpipe.newplayer.ui.streamselect.ChapterSelectUI
import net.newpipe.newplayer.ui.selection_ui.ChapterSelectUI
@OptIn(UnstableApi::class)
@Composable
@ -117,6 +117,7 @@ fun VideoPlayerUi(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
StreamSelectUI(
viewModel = viewModel,
uiState = uiState,
shownInAudioPlayer = false
)
}
}
@ -125,7 +126,11 @@ fun VideoPlayerUi(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
modifier = Modifier.fillMaxSize(),
color = STREAMSELECT_UI_BACKGROUND_COLOR
) {
ChapterSelectUI(viewModel = viewModel, uiState = uiState)
ChapterSelectUI(
viewModel = viewModel,
uiState = uiState,
shownInAudioPlayer = false
)
}
}
}