EntryDeckChrome.kt

4.1 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.size15import androidx.compose.foundation.layout.width16import androidx.compose.foundation.shape.RoundedCornerShape17import androidx.compose.material.icons.Icons18import androidx.compose.material.icons.outlined.Description19import androidx.compose.material.icons.outlined.Lock20import androidx.compose.material.icons.outlined.Settings21import androidx.compose.material.icons.rounded.Add22import androidx.compose.material.icons.rounded.Search23import androidx.compose.material3.Icon24import androidx.compose.material3.Text25import androidx.compose.runtime.Composable26import androidx.compose.ui.Alignment27import androidx.compose.ui.Modifier28import androidx.compose.ui.graphics.Color29import androidx.compose.ui.graphics.vector.ImageVector30import androidx.compose.ui.input.pointer.pointerInput31import androidx.compose.ui.unit.dp32import androidx.compose.ui.unit.em33import com.peachpasswords.ui.components.PeachWordmark34import com.peachpasswords.ui.theme.LocalPeachAccent35import com.peachpasswords.ui.theme.PeachRadius36import com.peachpasswords.ui.theme.PeachSpacing37import com.peachpasswords.ui.theme.PeachType38import com.peachpasswords.ui.theme.peachColors3940@Composable41internal fun PeachVaultIdentity(section: String, onHome: () -> Unit) {42    Row(43        Modifier.fillMaxWidth().height(64.dp),44        verticalAlignment = Alignment.CenterVertically,45    ) {46        Box(Modifier.clickable(onClickLabel = "Open vault") { onHome() }) {47            PeachWordmark()48        }49        Spacer(Modifier.width(PeachSpacing.md))50        Text(section.uppercase(), color = peachColors.T2, style = PeachType.labelMono.copy(letterSpacing = 0.08.em))51    }52}5354@Composable55internal fun PeachDeckBottomBar(56    onSearch: () -> Unit,57    onAdd: () -> Unit,58    onNotes: () -> Unit,59    onSettings: () -> Unit,60    onLock: () -> Unit,61    onSwipeUp: () -> Unit,62    notesSelected: Boolean = false,63    modifier: Modifier = Modifier,64) {65    val accent = LocalPeachAccent.current66    Row(67        modifier.fillMaxWidth()68            .padding(horizontal = PeachSpacing.xl, vertical = PeachSpacing.sm)69            .height(64.dp)70            .background(peachColors.S1, RoundedCornerShape(PeachRadius.Pill))71            .border(1.dp, peachColors.T3, RoundedCornerShape(PeachRadius.Pill))72            .pointerInput(onSwipeUp) {73                var opened = false74                detectVerticalDragGestures(75                    onDragEnd = { opened = false },76                    onDragCancel = { opened = false },77                ) { _, dragAmount ->78                    if (!opened && dragAmount < -4f) {79                        opened = true80                        onSwipeUp()81                    }82                }83            }84            .padding(horizontal = PeachSpacing.md),85        horizontalArrangement = Arrangement.SpaceBetween,86        verticalAlignment = Alignment.CenterVertically,87    ) {88        DeckAction(Icons.Rounded.Search, "search", accent, onSearch)89        DeckAction(Icons.Rounded.Add, "new", peachColors.T0, onAdd)90        DeckAction(Icons.Outlined.Description, "Notes", if (notesSelected) accent else peachColors.T0, onNotes)91        DeckAction(Icons.Outlined.Settings, "settings", peachColors.T0, onSettings)92        DeckAction(Icons.Outlined.Lock, "Lock vault", accent, onLock)93    }94}9596@Composable97private fun DeckAction(icon: ImageVector, label: String, tint: Color, onClick: () -> Unit) {98    Box(99        Modifier.size(48.dp).clickable(onClick = onClick),100        contentAlignment = Alignment.Center,101    ) {102        Icon(icon, contentDescription = label, tint = tint, modifier = Modifier.size(22.dp))103    }104}