feat(scripting/ib): fill max size attributes
This commit is contained in:
@@ -20,6 +20,16 @@ open class Node(
|
||||
attributes[key] = value
|
||||
}
|
||||
|
||||
fun fillMaxWidth(): Node {
|
||||
attributes["fillMaxWidth"] = true
|
||||
return this
|
||||
}
|
||||
|
||||
fun fillMaxHeight(): Node {
|
||||
attributes["fillMaxHeight"] = true
|
||||
return this
|
||||
}
|
||||
|
||||
fun label(text: String): Node {
|
||||
attributes["label"] = text
|
||||
return this
|
||||
|
||||
@@ -93,11 +93,15 @@ class ScriptsSection : Section() {
|
||||
}
|
||||
}
|
||||
|
||||
val padding = cachedAttributes["padding"]?.toString()?.toInt()?.let { abs(it) } ?: 2
|
||||
val arrangement = cachedAttributes["arrangement"]
|
||||
val alignment = cachedAttributes["alignment"]
|
||||
val spacing = cachedAttributes["spacing"]?.toString()?.toInt()?.let { abs(it) }
|
||||
|
||||
val rowColumnModifier = Modifier
|
||||
.then(if (cachedAttributes["fillMaxWidth"] as? Boolean == true) Modifier.fillMaxWidth() else Modifier)
|
||||
.then(if (cachedAttributes["fillMaxHeight"] as? Boolean == true) Modifier.fillMaxHeight() else Modifier)
|
||||
.padding((cachedAttributes["padding"]?.toString()?.toInt()?.let { abs(it) } ?: 2).dp)
|
||||
|
||||
fun runCallbackSafe(callback: () -> Unit) {
|
||||
runCatching {
|
||||
callback()
|
||||
@@ -120,9 +124,7 @@ class ScriptsSection : Section() {
|
||||
Column(
|
||||
verticalArrangement = arrangement as? Arrangement.Vertical ?: spacing?.let { Arrangement.spacedBy(it.dp) } ?: Arrangement.Top,
|
||||
horizontalAlignment = alignment as? Alignment.Horizontal ?: Alignment.Start,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(padding.dp)
|
||||
modifier = rowColumnModifier
|
||||
) {
|
||||
node.children.forEach { child ->
|
||||
DrawNode(child)
|
||||
@@ -133,9 +135,7 @@ class ScriptsSection : Section() {
|
||||
Row(
|
||||
horizontalArrangement = arrangement as? Arrangement.Horizontal ?: spacing?.let { Arrangement.spacedBy(it.dp) } ?: Arrangement.SpaceBetween,
|
||||
verticalAlignment = alignment as? Alignment.Vertical ?: Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(padding.dp)
|
||||
modifier = rowColumnModifier
|
||||
) {
|
||||
node.children.forEach { child ->
|
||||
DrawNode(child)
|
||||
|
||||
Reference in New Issue
Block a user