package com.peachpasswords.ui.components import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.peachpasswords.ui.theme.PeachSpacing import com.peachpasswords.ui.theme.PeachType @Composable fun PeachTopBar( title: String, modifier: Modifier = Modifier, leading: (@Composable RowScope.() -> Unit)? = null, actions: (@Composable RowScope.() -> Unit)? = null, ) { Surface( modifier = modifier.fillMaxWidth(), // Gate 1: route through colorScheme for the roles PeachTheme already // maps 1:1 to these exact peachColors values (surface/onSurface), so // this primitive doesn't silently bypass the theme. color = MaterialTheme.colorScheme.surface, contentColor = MaterialTheme.colorScheme.onSurface, shape = RoundedCornerShape(18.dp), tonalElevation = 1.dp, ) { Row( modifier = Modifier .height(56.dp) .padding(horizontal = PeachSpacing.md), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(PeachSpacing.sm), ) { if (leading != null) { Row(verticalAlignment = Alignment.CenterVertically, content = leading) } Text( text = title, color = MaterialTheme.colorScheme.onSurface, style = PeachType.wordmark, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f), ) if (actions != null) { Row( modifier = Modifier.widthIn(min = 40.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(PeachSpacing.xs), content = actions, ) } else { Box(Modifier.widthIn(min = 40.dp)) } } } }