PeachTopBar.kt

2.4 KB · raw

1package com.peachpasswords.ui.components23import androidx.compose.foundation.layout.Arrangement4import androidx.compose.foundation.layout.Box5import androidx.compose.foundation.layout.Row6import androidx.compose.foundation.layout.RowScope7import androidx.compose.foundation.layout.fillMaxWidth8import androidx.compose.foundation.layout.height9import androidx.compose.foundation.layout.padding10import androidx.compose.foundation.layout.widthIn11import androidx.compose.foundation.shape.RoundedCornerShape12import androidx.compose.material3.Surface13import androidx.compose.material3.Text14import androidx.compose.runtime.Composable15import androidx.compose.ui.Alignment16import androidx.compose.ui.Modifier17import androidx.compose.ui.text.style.TextOverflow18import androidx.compose.ui.unit.dp19import com.peachpasswords.ui.theme.PeachSpacing20import com.peachpasswords.ui.theme.PeachType21import com.peachpasswords.ui.theme.peachColors2223@Composable24fun PeachTopBar(25    title: String,26    modifier: Modifier = Modifier,27    leading: (@Composable RowScope.() -> Unit)? = null,28    actions: (@Composable RowScope.() -> Unit)? = null,29) {30    Surface(31        modifier = modifier.fillMaxWidth(),32        color = peachColors.S1,33        contentColor = peachColors.T0,34        shape = RoundedCornerShape(18.dp),35        tonalElevation = 1.dp,36    ) {37        Row(38            modifier = Modifier39                .height(56.dp)40                .padding(horizontal = PeachSpacing.md),41            verticalAlignment = Alignment.CenterVertically,42            horizontalArrangement = Arrangement.spacedBy(PeachSpacing.sm),43        ) {44            if (leading != null) {45                Row(verticalAlignment = Alignment.CenterVertically, content = leading)46            }47            Text(48                text = title,49                color = peachColors.T0,50                style = PeachType.wordmark,51                maxLines = 1,52                overflow = TextOverflow.Ellipsis,53                modifier = Modifier.weight(1f),54            )55            if (actions != null) {56                Row(57                    modifier = Modifier.widthIn(min = 40.dp),58                    verticalAlignment = Alignment.CenterVertically,59                    horizontalArrangement = Arrangement.spacedBy(PeachSpacing.xs),60                    content = actions,61                )62            } else {63                Box(Modifier.widthIn(min = 40.dp))64            }65        }66    }67}