Use Dimensions in AppBar

This commit is contained in:
Andrew 2024-06-17 14:09:30 +09:30
parent 3a75f2a303
commit e2eea61c68
2 changed files with 6 additions and 5 deletions

View File

@ -18,4 +18,5 @@ data class Dimensions(
val marginMedium: Dp = 32.dp, val marginMedium: Dp = 32.dp,
val marginLarge: Dp = 64.dp, val marginLarge: Dp = 64.dp,
val dividerIndent: Dp = 80.dp, val dividerIndent: Dp = 80.dp,
val appBarHeight: Dp = 64.dp
) )

View File

@ -14,11 +14,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import network.loki.messenger.R import network.loki.messenger.R
import org.thoughtcrime.securesms.ui.color.Colors import org.thoughtcrime.securesms.ui.LocalDimensions
import org.thoughtcrime.securesms.ui.PreviewTheme import org.thoughtcrime.securesms.ui.PreviewTheme
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
import org.thoughtcrime.securesms.ui.color.Colors
import org.thoughtcrime.securesms.ui.h4 import org.thoughtcrime.securesms.ui.h4
@Preview @Preview
@ -33,8 +33,8 @@ fun AppBarPreview(
@Composable @Composable
fun AppBar(title: String, onClose: () -> Unit = {}, onBack: (() -> Unit)? = null) { fun AppBar(title: String, onClose: () -> Unit = {}, onBack: (() -> Unit)? = null) {
Row(modifier = Modifier.height(64.dp), verticalAlignment = Alignment.CenterVertically) { Row(modifier = Modifier.height(LocalDimensions.current.appBarHeight), verticalAlignment = Alignment.CenterVertically) {
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(64.dp)) { Box(contentAlignment = Alignment.Center, modifier = Modifier.size(LocalDimensions.current.appBarHeight)) {
onBack?.let { onBack?.let {
IconButton(onClick = it) { IconButton(onClick = it) {
Icon(painter = painterResource(id = R.drawable.ic_prev), contentDescription = "back") Icon(painter = painterResource(id = R.drawable.ic_prev), contentDescription = "back")
@ -44,7 +44,7 @@ fun AppBar(title: String, onClose: () -> Unit = {}, onBack: (() -> Unit)? = null
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
Text(text = title, style = h4) Text(text = title, style = h4)
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(64.dp)) { Box(contentAlignment = Alignment.Center, modifier = Modifier.size(LocalDimensions.current.appBarHeight)) {
IconButton(onClick = onClose) { IconButton(onClick = onClose) {
Icon(painter = painterResource(id = R.drawable.ic_x), contentDescription = "close") Icon(painter = painterResource(id = R.drawable.ic_x), contentDescription = "close")
} }