Skip to content

Commit

Permalink
Add scaffold preview, use container color in about screen and scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Sep 16, 2024
1 parent 4c4fe3f commit d462fb5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package org.schabi.newpipe.ui.components.common

import android.content.res.Configuration
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -24,6 +28,9 @@ fun ScaffoldWithToolbar(
topBar = {
TopAppBar(
title = { Text(text = title) },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primaryContainer
),
navigationIcon = {
IconButton(onClick = onBackClick) {
Icon(
Expand All @@ -38,3 +45,14 @@ fun ScaffoldWithToolbar(
content = content
)
}

@Preview(name = "Light mode", uiMode = Configuration.UI_MODE_NIGHT_NO)
@Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun ScaffoldWithToolbarPreview() {
ScaffoldWithToolbar(
title = "Example",
onBackClick = {},
content = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ fun AboutScreen(padding: PaddingValues) {
tabIndex = pagerState.currentPage
}

TabRow(selectedTabIndex = tabIndex) {
TabRow(
selectedTabIndex = tabIndex,
containerColor = MaterialTheme.colorScheme.primaryContainer
) {
TITLES.forEachIndexed { index, titleId ->
Tab(
text = { Text(text = stringResource(titleId), color = Color.White) },
Expand Down

0 comments on commit d462fb5

Please sign in to comment.