Improve theming

This commit is contained in:
andrew 2023-06-29 19:14:47 +09:30
parent 0c2682fe47
commit d5b3d9bcf9
2 changed files with 15 additions and 8 deletions

View File

@ -14,10 +14,13 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Divider import androidx.compose.material.Divider
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -81,8 +84,8 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
TitledText("Duration:", "N/A"), TitledText("Duration:", "N/A"),
) )
val sent = TitledText("Sent:", "6:12 AM Tue, 09/08/2022 ") val sent = TitledText("Sent:", "6:12 AM Tue, 09/08/2022")
val received = TitledText("Received:", "6:12 AM Tue, 09/08/2022 ") val received = TitledText("Received:", "6:12 AM Tue, 09/08/2022")
val user = TitledText("Connor", "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg") val user = TitledText("Connor", "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg")
AppTheme { AppTheme {
@ -109,7 +112,7 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
.width(60.dp) .width(60.dp)
.height(60.dp)) .height(60.dp))
Column { Column {
titledText(user) titledText(user, valueStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace))
} }
} }
} }
@ -134,10 +137,10 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
} }
@Composable @Composable
fun titledText(titledText: TitledText, modifier: Modifier = Modifier) { fun titledText(titledText: TitledText, modifier: Modifier = Modifier, valueStyle: TextStyle = LocalTextStyle.current) {
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(4.dp)) { Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(4.dp)) {
Title(titledText.title) Title(titledText.title)
Text(titledText.value) Text(titledText.value, style = valueStyle)
} }
} }

View File

@ -10,7 +10,9 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ButtonColors import androidx.compose.material.ButtonColors
import androidx.compose.material.Card
import androidx.compose.material.Icon import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.material.TextButton import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -55,13 +57,15 @@ fun Cell(content: @Composable () -> Unit) {
@Composable @Composable
fun CellWithPadding(padding: Dp = 24.dp, content: @Composable () -> Unit) { fun CellWithPadding(padding: Dp = 24.dp, content: @Composable () -> Unit) {
androidx.compose.material.Card( Card(
shape = RoundedCornerShape(16.dp), shape = RoundedCornerShape(16.dp),
elevation = 0.dp, elevation = 0.dp,
modifier = Modifier modifier = Modifier
.wrapContentHeight() .wrapContentHeight()
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 32.dp), .padding(horizontal = 32.dp),
backgroundColor = LocalExtraColors.current.settingsBackground backgroundColor = LocalExtraColors.current.settingsBackground,
// probably wrong
contentColor = MaterialTheme.colors.onSurface
) { Box(Modifier.padding(padding)) { content() } } ) { Box(Modifier.padding(padding)) { content() } }
} }