Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions platform/android/lui/src/main/kotlin/dev/lui/LuiNodeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2230,21 +2230,38 @@ private fun LuiToolbar(
* Modal surfaces (dialog, sheet): shown while the node exists; dismissal
* emits Dismiss so the model drops the node.
*/
@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
@Composable
private fun LuiModalSurface(backend: LuiBackend, node: LuiNodeLike, id: Long) {
val onDismiss = { backend.emit(LuiEvent.Dismiss(id)) }
when (node.kind) {
LuiNodeKind.dialog -> AlertDialog(
onDismissRequest = onDismiss,
confirmButton = {},
text = {
Column {
node.children.forEachNode { LuiNodeView(backend, it) }
}
},
)
LuiNodeKind.dialog -> {
val actions = node.children.filter { backend.node(it)?.kind == LuiNodeKind.button }
val iconId = node.children.firstOrNull { backend.node(it)?.kind == LuiNodeKind.icon }
val body = node.children.filter { it != iconId && backend.node(it)?.kind != LuiNodeKind.button }
AlertDialog(
modifier = Modifier.luiChrome(node),
onDismissRequest = onDismiss,
icon = if (iconId == null) null else { { LuiNodeView(backend, iconId) } },
title = if (node.text().isEmpty()) null else { { Text(node.text()) } },
confirmButton = { actions.lastOrNull()?.let { LuiNodeView(backend, it) } },
dismissButton = if (actions.size <= 1) null else {
{
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End)) {
actions.dropLast(1).forEachNode { LuiNodeView(backend, it) }
}
}
},
text = {
Column(Modifier.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(16.dp)) {
body.forEachNode { LuiNodeView(backend, it) }
}
},
)
}
LuiNodeKind.sheet -> ModalBottomSheet(
modifier = Modifier.luiChrome(node),
onDismissRequest = onDismiss,
sheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = node.prop("detents")?.stringValue
Expand Down
Loading