EntryDeckChrome.kt

4.0 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) {42    Row(43        Modifier.fillMaxWidth().height(64.dp),44        verticalAlignment = Alignment.CenterVertically,45    ) {46        PeachWordmark()47        Spacer(Modifier.width(PeachSpacing.md))48        Text(section.uppercase(), color = peachColors.T2, style = PeachType.labelMono.copy(letterSpacing = 0.08.em))49    }50}5152@Composable53internal fun PeachDeckBottomBar(54    onSearch: () -> Unit,55    onAdd: () -> Unit,56    onNotes: () -> Unit,57    onSettings: () -> Unit,58    onLock: () -> Unit,59    onSwipeUp: () -> Unit,60    notesSelected: Boolean = false,61    modifier: Modifier = Modifier,62) {63    val accent = LocalPeachAccent.current64    Row(65        modifier.fillMaxWidth()66            .padding(horizontal = PeachSpacing.xl, vertical = PeachSpacing.sm)67            .height(64.dp)68            .background(peachColors.S1, RoundedCornerShape(PeachRadius.Pill))69            .border(1.dp, peachColors.T3, RoundedCornerShape(PeachRadius.Pill))70            .pointerInput(onSwipeUp) {71                var opened = false72                detectVerticalDragGestures(73                    onDragEnd = { opened = false },74                    onDragCancel = { opened = false },75                ) { _, dragAmount ->76                    if (!opened && dragAmount < -4f) {77                        opened = true78                        onSwipeUp()79                    }80                }81            }82            .padding(horizontal = PeachSpacing.md),83        horizontalArrangement = Arrangement.SpaceBetween,84        verticalAlignment = Alignment.CenterVertically,85    ) {86        DeckAction(Icons.Rounded.Search, "search", accent, onSearch)87        DeckAction(Icons.Rounded.Add, "new", peachColors.T0, onAdd)88        DeckAction(Icons.Outlined.Description, "Notes", if (notesSelected) accent else peachColors.T0, onNotes)89        DeckAction(Icons.Outlined.Settings, "settings", peachColors.T0, onSettings)90        DeckAction(Icons.Outlined.Lock, "Lock vault", accent, onLock)91    }92}9394@Composable95private fun DeckAction(icon: ImageVector, label: String, tint: Color, onClick: () -> Unit) {96    Box(97        Modifier.size(48.dp).clickable(onClick = onClick),98        contentAlignment = Alignment.Center,99    ) {100        Icon(icon, contentDescription = label, tint = tint, modifier = Modifier.size(22.dp))101    }102}