🛠️ Add secondary action to Dialog
* Added optional secondary action to dialog (e.g. "Edit")
This commit is contained in:
parent
0791223bc6
commit
d707aeaa23
1 changed files with 56 additions and 29 deletions
|
|
@ -61,6 +61,8 @@ fun Dialog(
|
||||||
actionEnabled: Boolean?,
|
actionEnabled: Boolean?,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
onAction: () -> Unit,
|
onAction: () -> Unit,
|
||||||
|
secondaryAction: String? = null,
|
||||||
|
onSecondaryAction: (() -> Unit)? = null,
|
||||||
withContent: Boolean,
|
withContent: Boolean,
|
||||||
items: (LazyListScope.() -> Unit) = {}
|
items: (LazyListScope.() -> Unit) = {}
|
||||||
) {
|
) {
|
||||||
|
|
@ -150,7 +152,31 @@ fun Dialog(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 24.dp),
|
.padding(horizontal = 24.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp, Alignment.End)
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
if (secondaryAction != null && onSecondaryAction != null) {
|
||||||
|
TextButton(
|
||||||
|
onClick = {
|
||||||
|
if (disableOnClick) {
|
||||||
|
actionClicked = true
|
||||||
|
}
|
||||||
|
onSecondaryAction()
|
||||||
|
},
|
||||||
|
enabled = !actionClicked
|
||||||
|
) {
|
||||||
|
StyledText(
|
||||||
|
text = secondaryAction,
|
||||||
|
style = MaterialTheme.typography.labelLarge.copy(
|
||||||
|
color = MaterialTheme.colorScheme.primary
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(4.dp, Alignment.End),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
|
|
@ -192,3 +218,4 @@ fun Dialog(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue