EntryDeckChrome.kt

4.6 KB · raw

1package com.peachpasswords.ui.vault23import androidx.compose.foundation.background4import androidx.compose.foundation.border5import androidx.compose.foundation.clickable6import androidx.compose.foundation.gestures.detectVerticalDragGestures7import androidx.compose.foundation.layout.Arrangement8import androidx.compose.foundation.layout.Box9import androidx.compose.foundation.layout.Row10import androidx.compose.foundation.layout.Spacer11import androidx.compose.foundation.layout.fillMaxWidth12import androidx.compose.foundation.layout.height13import androidx.compose.foundation.layout.padding14import androidx.compose.foundation.layout.offset15import androidx.compose.foundation.layout.size16import androidx.compose.foundation.layout.width17import androidx.compose.foundation.shape.RoundedCornerShape18import androidx.compose.material.icons.Icons19import androidx.compose.material.icons.outlined.Description20import androidx.compose.material.icons.outlined.Lock21import androidx.compose.material.icons.outlined.Settings22import androidx.compose.material.icons.rounded.Add23import androidx.compose.material.icons.rounded.Search24import androidx.compose.material3.Icon25import androidx.compose.material3.Text26import androidx.compose.runtime.Composable27import androidx.compose.ui.Alignment28import androidx.compose.ui.Modifier29import androidx.compose.ui.graphics.Color30import androidx.compose.ui.graphics.vector.ImageVector31import androidx.compose.ui.input.pointer.pointerInput32import androidx.compose.ui.unit.dp33import androidx.compose.ui.unit.em34import com.peachpasswords.ui.components.PeachWordmark35import com.peachpasswords.ui.theme.LocalPeachAccent36import com.peachpasswords.ui.theme.PeachRadius37import com.peachpasswords.ui.theme.PeachSpacing38import com.peachpasswords.ui.theme.PeachType39import com.peachpasswords.ui.theme.peachColors4041@Composable42internal fun PeachVaultIdentity(section: String, modifier: Modifier = Modifier, onHome: () -> Unit) {43    Row(44        modifier.fillMaxWidth().height(64.dp),45        verticalAlignment = Alignment.CenterVertically,46    ) {47        Box(Modifier.clickable(onClickLabel = "Open vault") { onHome() }) {48            PeachWordmark()49        }50        Spacer(Modifier.width(PeachSpacing.md))51        Text(section.uppercase(), color = peachColors.T2, style = PeachType.labelMono.copy(letterSpacing = 0.08.em))52    }53}5455@Composable56internal fun PeachDeckBottomBar(57    onSearch: () -> Unit,58    onAdd: () -> Unit,59    onNotes: () -> Unit,60    onSettings: () -> Unit,61    onLock: () -> Unit,62    onSwipeUp: () -> Unit,63    notesSelected: Boolean = false,64    modifier: Modifier = Modifier,65) {66    val accent = LocalPeachAccent.current67    Row(68        modifier.fillMaxWidth()69            .padding(horizontal = PeachSpacing.xl, vertical = PeachSpacing.sm)70            .height(64.dp)71            .background(peachColors.S1, RoundedCornerShape(PeachRadius.Pill))72            .border(1.dp, peachColors.T3, RoundedCornerShape(PeachRadius.Pill))73            .pointerInput(onSwipeUp) {74                var opened = false75                detectVerticalDragGestures(76                    onDragEnd = { opened = false },77                    onDragCancel = { opened = false },78                ) { _, dragAmount ->79                    if (!opened && dragAmount < -4f) {80                        opened = true81                        onSwipeUp()82                    }83                }84            }85            .padding(horizontal = PeachSpacing.md),86        horizontalArrangement = Arrangement.SpaceBetween,87        verticalAlignment = Alignment.CenterVertically,88    ) {89        DeckAction(Icons.Rounded.Search, "search", accent, onSearch, offsetX = 1.dp)90        // Material's Add path has substantially less visual mass than the91        // outlined glyphs beside it, so it needs a larger box to read as the92        // same optical size.93        DeckAction(Icons.Rounded.Add, "new", peachColors.T0, onAdd, iconSize = 28.dp)94        DeckAction(Icons.Outlined.Description, "Notes", if (notesSelected) accent else peachColors.T0, onNotes)95        DeckAction(Icons.Outlined.Settings, "settings", peachColors.T0, onSettings)96        DeckAction(Icons.Outlined.Lock, "Lock vault", accent, onLock)97    }98}99100@Composable101private fun DeckAction(102    icon: ImageVector,103    label: String,104    tint: Color,105    onClick: () -> Unit,106    iconSize: androidx.compose.ui.unit.Dp = 22.dp,107    offsetX: androidx.compose.ui.unit.Dp = 0.dp,108) {109    Box(110        Modifier.size(48.dp).clickable(onClick = onClick),111        contentAlignment = Alignment.Center,112    ) {113        Icon(114            icon,115            contentDescription = label,116            tint = tint,117            modifier = Modifier.size(iconSize).offset(x = offsetX),118        )119    }120}