On-device review fixes: FloretMenu everywhere, edit-layout drag shadow, tidier menus (#59)

This commit is contained in:
makiolaj committed 2026-12-02 16:31:34 +01:00
1 parent 3b418076f1
commit 2f75202db5
8 files changed
+142 -156

No files matched your search

@@ -51,8 +51,8 @@ import androidx.compose.material.icons.rounded.Notifications
import androidx.compose.material.icons.rounded.Repeat
import androidx.compose.material.icons.rounded.MoreVert
import androidx.compose.material3.AlertDialog
import de.jeanlucmakiola.floret.components.FloretDropdownMenu
import androidx.compose.material3.DropdownMenuItem
import de.jeanlucmakiola.floret.components.FloretMenu
import de.jeanlucmakiola.floret.components.FloretMenuItem
import androidx.compose.material3.Checkbox
import androidx.compose.material3.TextButton
import androidx.compose.ui.platform.LocalContext
@@ -80,10 +80,10 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.text.input.ImeAction
@@ -177,27 +177,24 @@ fun TaskDetailScreen(
contentDescription = stringResource(R.string.more_options),
onClick = { menuOpen = true },
)
FloretDropdownMenu(expanded = menuOpen, onDismissRequest = { menuOpen = false }) {
val cancelled = task.status == TaskStatus.CANCELLED
DropdownMenuItem(
text = {
Text(stringResource(if (cancelled) R.string.detail_restore else R.string.detail_cancel_task))
},
onClick = {
menuOpen = false
viewModel.setCancelled(task, !cancelled)
},
)
if (writable) {
DropdownMenuItem(
text = { Text(stringResource(R.string.detail_duplicate)) },
onClick = {
menuOpen = false
viewModel.duplicate(task, onDuplicated)
val cancelled = task.status == TaskStatus.CANCELLED
FloretMenu(
expanded = menuOpen,
onDismissRequest = { menuOpen = false },
groups = listOf(
listOfNotNull(
FloretMenuItem(
stringResource(if (cancelled) R.string.detail_restore else R.string.detail_cancel_task),
onClick = { viewModel.setCancelled(task, !cancelled) },
),
if (writable) {
FloretMenuItem(stringResource(R.string.detail_duplicate), onClick = { viewModel.duplicate(task, onDuplicated) })
} else {
null
},
)
}
}
),
),
)
}
}
},
@@ -19,8 +19,8 @@ import androidx.compose.material.icons.rounded.Close
import androidx.compose.material.icons.rounded.Delete
import androidx.compose.material.icons.rounded.DoNotDisturbOn
import androidx.compose.material.icons.rounded.MoreVert
import androidx.compose.material3.DropdownMenuItem
import de.jeanlucmakiola.floret.components.FloretDropdownMenu
import de.jeanlucmakiola.floret.components.FloretMenu
import de.jeanlucmakiola.floret.components.FloretMenuItem
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
@@ -29,9 +29,9 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
@@ -255,26 +255,20 @@ private fun GroupHeader(
IconButton(onClick = { menuOpen = true }) {
Icon(Icons.Rounded.MoreVert, contentDescription = stringResource(R.string.filter_group_menu))
}
FloretDropdownMenu(expanded = menuOpen, onDismissRequest = { menuOpen = false }) {
DropdownMenuItem(
text = { Text(stringResource(if (negated) R.string.filter_group_negate_off else R.string.filter_group_negate)) },
leadingIcon = { Icon(Icons.Rounded.DoNotDisturbOn, contentDescription = null) },
onClick = {
menuOpen = false
onToggleNot()
},
)
if (deletable) {
DropdownMenuItem(
text = { Text(stringResource(R.string.filter_group_delete)) },
leadingIcon = { Icon(Icons.Rounded.Delete, contentDescription = null) },
onClick = {
menuOpen = false
onDelete()
},
)
}
}
FloretMenu(
expanded = menuOpen,
onDismissRequest = { menuOpen = false },
groups = listOf(
listOfNotNull(
FloretMenuItem(
stringResource(if (negated) R.string.filter_group_negate_off else R.string.filter_group_negate),
Icons.Rounded.DoNotDisturbOn,
onClick = onToggleNot,
),
if (deletable) FloretMenuItem(stringResource(R.string.filter_group_delete), Icons.Rounded.Delete, onClick = onDelete) else null,
),
),
)
}
}
}
@@ -56,6 +56,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.PathEffect
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.vector.ImageVector
@@ -94,6 +96,7 @@ import de.jeanlucmakiola.floret.components.GroupedSwitchRow
import de.jeanlucmakiola.floret.components.OptionPicker
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.ReorderableGrid
import de.jeanlucmakiola.floret.components.inset
import de.jeanlucmakiola.floret.components.SelectedCheck
import de.jeanlucmakiola.floret.components.positionOf
import de.jeanlucmakiola.floret.identity.FloretDensity
@@ -177,6 +180,10 @@ internal fun EditLayoutContent(
onReorder = { blocks -> onMove(blocks.map { it.id }) },
canDrag = { it.type != BlockType.TASK_LIST },
scrollState = scroll,
dragShape = { block, column ->
val (start, end) = blockInsets(block, column)
RoundedCornerShape(if (block.type in TILES) 22.dp else SectionCardRadius).inset(start, end)
},
moveEarlierLabel = stringResource(R.string.block_move_earlier),
moveLaterLabel = stringResource(R.string.block_move_later),
) { block, column, dragHandle, dragging ->
@@ -225,19 +232,30 @@ private fun EditBlockFrame(
BlockControls(block, dragHandle, onResize, onRemove)
}
if (block.type in TILES) {
val inset = when {
block.width == BlockWidth.FULL -> Modifier.padding(horizontal = GroupedListInset)
column == 0 -> Modifier.padding(start = GroupedListInset)
else -> Modifier.padding(end = GroupedListInset)
}
Box(inset) {
val (start, end) = blockInsets(block, column)
Box(Modifier.padding(start = start, end = end)) {
Box(Modifier.clearAndSetSemantics {}) { Tile(block, state, actions, Modifier.fillMaxWidth()) }
Box(Modifier.matchParentSize().clip(RoundedCornerShape(22.dp)).then(tapTarget))
Row(Modifier.align(Alignment.TopEnd).padding(4.dp)) { controls() }
}
return
}
Column {
// A held section is lifted as a card, so the shadow has something to sit under.
val card = MaterialTheme.colorScheme.surfaceContainerLow
val lifted = if (dragging) {
Modifier.drawBehind {
val inset = SectionCardInset.toPx()
drawRoundRect(
color = card,
topLeft = Offset(inset, 0f),
size = Size(size.width - 2 * inset, size.height),
cornerRadius = CornerRadius(SectionCardRadius.toPx()),
)
}
} else {
Modifier
}
Column(lifted.padding(bottom = if (dragging) 8.dp else 0.dp)) {
Row(
modifier = Modifier.fillMaxWidth().padding(start = 28.dp, end = 12.dp, top = 4.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -260,6 +278,17 @@ private fun EditBlockFrame(
}
}
/** How far a block's card sits in from the sides of its grid slot. */
private fun blockInsets(block: Block, column: Int): Pair<Dp, Dp> = when {
block.type !in TILES -> SectionCardInset to SectionCardInset
block.width == BlockWidth.FULL -> GroupedListInset to GroupedListInset
column == 0 -> GroupedListInset to 0.dp
else -> 0.dp to GroupedListInset
}
private val SectionCardInset = 8.dp
private val SectionCardRadius = 28.dp
/** A block's drag handle, its half/full switch where its type has both, and ✕. */
@Composable
private fun BlockControls(
@@ -32,7 +32,6 @@ import androidx.compose.material.icons.rounded.Search
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material.icons.rounded.Tune
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
@@ -42,13 +41,13 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalHapticFeedback
@@ -91,7 +90,8 @@ import de.jeanlucmakiola.agendula.ui.views.ScopeChipRow
import de.jeanlucmakiola.agendula.ui.views.ViewSwitcher
import de.jeanlucmakiola.agendula.ui.views.viewName
import de.jeanlucmakiola.floret.components.ActionButton
import de.jeanlucmakiola.floret.components.FloretDropdownMenu
import de.jeanlucmakiola.floret.components.FloretMenu
import de.jeanlucmakiola.floret.components.FloretMenuItem
import de.jeanlucmakiola.floret.components.SnackChip
import de.jeanlucmakiola.floret.components.SnackChipHeight
import de.jeanlucmakiola.floret.components.SnackChipMargin
@@ -396,6 +396,13 @@ fun ListsScreen(
receipt != null -> ({ homeTaskModel.undo() })
else -> null
},
// A quick add's receipt goes to the list the task landed in.
onClick = (notShown?.listId ?: addedUnseen?.task?.listId)?.let { listId ->
{
quickAdd.dismissReceipt()
onOpenFilter(TaskFilter.OfList(listId), null)
}
},
)
}
}
@@ -589,21 +596,26 @@ private fun ListsContent(
)
}
}
rows.forEach { row ->
rows.forEachIndexed { rowIndex, row ->
val block = row.first()
if (block.type in TILES) {
item(key = "row-${block.id}") {
// A full tile stands alone, as the Today hero always has; half ones share a row.
if (row.size == 1 && block.width == BlockWidth.FULL) {
val gap = if (block.type == BlockType.PROGRESS) 0.dp else FloretDensity.tileGap
// Only a hero heading the view sits flush under the top bar.
val gap = if (block.type == BlockType.PROGRESS && rowIndex == 0) 0.dp else FloretDensity.tileGap
Tile(block, state, actions, longPress.fillMaxWidth().padding(horizontal = 16.dp).padding(top = gap))
} else {
HalfRow(row, state, actions, longPress)
}
}
return@forEach
return@forEachIndexed
}
if (block.type == BlockType.TASK_LIST) {
// Tiles bring their gap above, not below; the tasks under them need one of their own.
if (rowIndex > 0 && rows[rowIndex - 1].first().type in TILES) {
item(key = "${block.id}-gap") { Spacer(Modifier.height(FloretDensity.tileGap)) }
}
if (block.id in state.goneSources) {
item(key = "${block.id}-gone") { BlockBody(block, state, actions, editing = false) }
} else if (taskBlock?.block?.id == block.id && taskRows != null && blockState != null) {
@@ -618,7 +630,7 @@ private fun ListsContent(
keyPrefix = "${block.id}-",
)
}
return@forEach
return@forEachIndexed
}
if (block.type in BROWSE && block.id !in state.goneSources) {
// A long press on a list being dragged into place is the drag's.
@@ -631,7 +643,7 @@ private fun ListsContent(
onToggleReorderLists = { reordering = if (reorderingThis) null else block.id },
rowModifier = if (reorderingThis) Modifier else longPress,
)
return@forEach
return@forEachIndexed
}
item(key = "block-${block.id}") {
androidx.compose.foundation.layout.Column(longPress) {
@@ -697,15 +709,17 @@ private fun HomeTopBar(
verticalAlignment = Alignment.CenterVertically,
) {
if (!searchActive && viewTitle != null) {
ViewSwitcher(
title = viewTitle,
views = views,
activeViewId = activeViewId,
onSwitchView = onSwitchView,
onListsAndFilters = onListsAndFilters,
onManageViews = onManageViews,
modifier = Modifier.weight(1f, fill = false),
)
// Takes its whole share, so what the switcher leaves over isn't left at the bar's end.
Box(Modifier.weight(1f)) {
ViewSwitcher(
title = viewTitle,
views = views,
activeViewId = activeViewId,
onSwitchView = onSwitchView,
onListsAndFilters = onListsAndFilters,
onManageViews = onManageViews,
)
}
}
// Search occupies the flexible space left of settings. Pulled into its
// own composable so AnimatedVisibility resolves to the plain overload —
@@ -735,24 +749,12 @@ private fun HomeTopBar(
onClick = { menuOpen = true },
size = 48.dp,
)
FloretDropdownMenu(expanded = menuOpen, onDismissRequest = { menuOpen = false }) {
DropdownMenuItem(
text = { Text(stringResource(R.string.view_edit_layout)) },
leadingIcon = { Icon(Icons.Rounded.Dashboard, contentDescription = null) },
onClick = {
menuOpen = false
onEditLayout()
},
)
DropdownMenuItem(
text = { Text(stringResource(R.string.view_edit_title)) },
leadingIcon = { Icon(Icons.Rounded.Tune, contentDescription = null) },
onClick = {
menuOpen = false
onEditView()
},
)
}
FloretMenu(
expanded = menuOpen,
onDismissRequest = { menuOpen = false },
FloretMenuItem(stringResource(R.string.view_edit_layout), Icons.Rounded.Dashboard, onClick = onEditLayout),
FloretMenuItem(stringResource(R.string.view_edit_title), Icons.Rounded.Tune, onClick = onEditView),
)
}
}
}
@@ -353,6 +353,7 @@ fun QuickAddReceiptChip(receipt: QuickAddReceipt, onOpenList: (Long) -> Unit) {
message = stringResource(R.string.quick_add_not_shown, receipt.listName),
actionLabel = stringResource(R.string.quick_add_open),
onAction = { onOpenList(receipt.listId) },
onClick = { onOpenList(receipt.listId) },
)
is QuickAddReceipt.Added -> SnackChip(visible = true, message = stringResource(R.string.quick_add_added, receipt.listName))
is QuickAddReceipt.Failed -> SnackChip(visible = true, message = stringResource(R.string.edit_save_failed))
@@ -49,8 +49,8 @@ import androidx.compose.material.icons.rounded.ExpandMore
import androidx.compose.material.icons.rounded.Flag
import androidx.compose.material.icons.rounded.MoreVert
import androidx.compose.material.icons.rounded.PushPin
import de.jeanlucmakiola.floret.components.FloretDropdownMenu
import androidx.compose.material3.DropdownMenuItem
import de.jeanlucmakiola.floret.components.FloretMenu
import de.jeanlucmakiola.floret.components.FloretMenuItem
import androidx.compose.material3.Checkbox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExtendedFloatingActionButton
@@ -81,12 +81,12 @@ import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberSwipeToDismissBoxState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import kotlinx.coroutines.delay
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -315,16 +315,11 @@ fun TaskListScreen(
contentDescription = stringResource(R.string.more_options),
onClick = { menuOpen = true },
)
FloretDropdownMenu(expanded = menuOpen, onDismissRequest = { menuOpen = false }) {
DropdownMenuItem(
text = { Text(stringResource(R.string.view_pin)) },
leadingIcon = { Icon(Icons.Rounded.PushPin, contentDescription = null) },
onClick = {
menuOpen = false
viewModel.pinAsView(onPinned)
},
)
}
FloretMenu(
expanded = menuOpen,
onDismissRequest = { menuOpen = false },
FloretMenuItem(stringResource(R.string.view_pin), Icons.Rounded.PushPin, onClick = { viewModel.pinAsView(onPinned) }),
)
}
}
},
@@ -2,30 +2,23 @@ package de.jeanlucmakiola.agendula.ui.views
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Check
import androidx.compose.material.icons.rounded.Dashboard
import androidx.compose.material.icons.rounded.ExpandMore
import androidx.compose.material.icons.rounded.Checklist
import androidx.compose.material3.DropdownMenuGroup
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MenuDefaults
import androidx.compose.material3.SelectableDropdownMenuItem
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -37,7 +30,8 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import de.jeanlucmakiola.agendula.R
import de.jeanlucmakiola.agendula.domain.View
import de.jeanlucmakiola.floret.components.FloretDropdownMenuPopup
import de.jeanlucmakiola.floret.components.FloretMenu
import de.jeanlucmakiola.floret.components.FloretMenuItem
/**
* The view's name in the home top bar, which opens the view menu: every view,
@@ -78,49 +72,23 @@ fun ViewSwitcher(
Icon(Icons.Rounded.ExpandMore, contentDescription = switcherLabel)
}
}
FloretDropdownMenuPopup(expanded = open, onDismissRequest = { open = false }) {
DropdownMenuGroup(shapes = MenuDefaults.groupShape(0, 2)) {
views.forEachIndexed { index, view ->
val selected = view.id == activeViewId
SelectableDropdownMenuItem(
selected = selected,
onClick = {
open = false
onSwitchView(view.id)
},
text = { Text(viewName(view.name, view.id)) },
shapes = MenuDefaults.itemShape(index, views.size),
leadingIcon = { Icon(view.icon.vector, contentDescription = null) },
selectedLeadingIcon = { Icon(view.icon.vector, contentDescription = null) },
trailingContent = if (selected) {
{ Icon(Icons.Rounded.Check, contentDescription = null) }
} else {
null
},
FloretMenu(
expanded = open,
onDismissRequest = { open = false },
groups = listOf(
views.map { view ->
FloretMenuItem(
text = viewName(view.name, view.id),
icon = view.icon.vector,
selected = view.id == activeViewId,
onClick = { onSwitchView(view.id) },
)
}
}
Spacer(Modifier.height(MenuDefaults.GroupSpacing))
DropdownMenuGroup(shapes = MenuDefaults.groupShape(1, 2)) {
DropdownMenuItem(
onClick = {
open = false
onListsAndFilters()
},
text = { Text(stringResource(R.string.view_lists_and_filters_menu)) },
shape = MenuDefaults.leadingItemShape,
leadingIcon = { Icon(Icons.Rounded.Checklist, contentDescription = null) },
)
DropdownMenuItem(
onClick = {
open = false
onManageViews()
},
text = { Text(stringResource(R.string.view_manage)) },
shape = MenuDefaults.trailingItemShape,
leadingIcon = { Icon(Icons.Rounded.Dashboard, contentDescription = null) },
)
}
}
},
listOf(
FloretMenuItem(stringResource(R.string.view_lists_and_filters_menu), Icons.Rounded.Checklist, onClick = onListsAndFilters),
FloretMenuItem(stringResource(R.string.view_manage), Icons.Rounded.Dashboard, onClick = onManageViews),
),
),
)
}
}