TP-32198 | column scope properties support (#103)
This commit is contained in:
committed by
GitHub Enterprise
parent
1ab69be112
commit
d7a4d8a62c
@@ -8642,5 +8642,66 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"columnConstraintsMock": {
|
||||
"parentComposeView": [
|
||||
{
|
||||
"property": {
|
||||
"viewType": "Column",
|
||||
"layoutId": "column",
|
||||
"width": "200",
|
||||
"height": "MATCH_PARENT",
|
||||
"backgroundColor": "#639227",
|
||||
"arrangementData": {
|
||||
"arrangementType": "Top"
|
||||
}
|
||||
},
|
||||
"childrenViews": [
|
||||
{
|
||||
"property": {
|
||||
"viewType": "Text",
|
||||
"layoutId": "text_1",
|
||||
"width": "WRAP_CONTENT",
|
||||
"height": "MATCH_PARENT",
|
||||
"parentConstraints": {
|
||||
"columnConstraints": {
|
||||
"columnWeight": {
|
||||
"weight": 4
|
||||
},
|
||||
"horizontalAlignment": "End"
|
||||
}
|
||||
},
|
||||
"backgroundColor": "#983643"
|
||||
}
|
||||
},
|
||||
{
|
||||
"property": {
|
||||
"viewType": "Text",
|
||||
"layoutId": "text_2",
|
||||
"width": "WRAP_CONTENT",
|
||||
"height": "MATCH_PARENT",
|
||||
"parentConstraints": {
|
||||
"columnConstraints": {
|
||||
"columnWeight": {
|
||||
"weight": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
"backgroundColor": "#123874"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"data": {
|
||||
"text_1": {
|
||||
"viewType": "Text",
|
||||
"text": "Text 1"
|
||||
},
|
||||
"text_2": {
|
||||
"viewType": "Text",
|
||||
"text": "Text 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
package com.navi.uitron.model.ui
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
/**
|
||||
* Copyright © 2021 by Navi Technologies Private Limited
|
||||
* All rights reserved. Strictly confidential
|
||||
@@ -32,3 +35,15 @@ data class ColumnProperty(
|
||||
data class ScrollData(
|
||||
val enabled: Boolean? = null
|
||||
)
|
||||
|
||||
@Parcelize
|
||||
data class ColumnConstraints(
|
||||
val columnWeight: ColumnWeight? = null,
|
||||
val horizontalAlignment: String? = null
|
||||
): Parcelable
|
||||
|
||||
@Parcelize
|
||||
data class ColumnWeight(
|
||||
var weight: Float? = null,
|
||||
var fill: Boolean? = null
|
||||
): Parcelable
|
||||
@@ -36,7 +36,8 @@ data class ArrangementData(
|
||||
|
||||
@Parcelize
|
||||
data class ParentConstraints(
|
||||
var rowConstraints: RowConstraints? = null
|
||||
var rowConstraints: RowConstraints? = null,
|
||||
var columnConstraints: ColumnConstraints? = null
|
||||
): Parcelable
|
||||
|
||||
@Parcelize
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.navi.uitron.model.ui.ColumnProperty
|
||||
import com.navi.uitron.model.ui.UiTronView
|
||||
import com.navi.uitron.utils.ShapeUtil
|
||||
import com.navi.uitron.viewmodel.UiTronViewModel
|
||||
import constraintsToModifier
|
||||
import customClickable
|
||||
import getBorderStrokeBrushData
|
||||
import getHorizontalAlignment
|
||||
@@ -102,14 +103,18 @@ class ColumnRenderer(
|
||||
.alpha(property.alpha ?: 1.0f)
|
||||
) {
|
||||
if (property.repeat == null || (property.repeat ?: 0) <= 1) {
|
||||
childrenComposeViews.forEach {
|
||||
if (it.data.isNullOrEmpty()) {
|
||||
uiTronRenderer.Render(composeViews = listOf(it))
|
||||
childrenComposeViews.forEach {childrenView ->
|
||||
if (childrenView.data.isNullOrEmpty()) {
|
||||
uiTronRenderer.Render(
|
||||
composeViews = listOf(childrenView),
|
||||
constraintsToModifier(childrenView.property?.parentConstraints?.columnConstraints)
|
||||
)
|
||||
} else {
|
||||
UiTronRenderer(it.data, uiTronViewModel).Render(
|
||||
UiTronRenderer(childrenView.data, uiTronViewModel).Render(
|
||||
composeViews = listOf(
|
||||
it
|
||||
)
|
||||
childrenView
|
||||
),
|
||||
constraintsToModifier(childrenView.property?.parentConstraints?.columnConstraints)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -127,10 +132,14 @@ class ColumnRenderer(
|
||||
childrenComposeViews.getOrNull(0)?.childrenViews
|
||||
)
|
||||
if (childComposeView.data.isNullOrEmpty()) {
|
||||
uiTronRenderer.Render(listOf(childComposeView))
|
||||
uiTronRenderer.Render(
|
||||
listOf(childComposeView),
|
||||
constraintsToModifier(childComposeView.property?.parentConstraints?.columnConstraints)
|
||||
)
|
||||
} else {
|
||||
UiTronRenderer(childComposeView.data, uiTronViewModel).Render(
|
||||
composeViews = listOf(childComposeView)
|
||||
composeViews = listOf(childComposeView),
|
||||
constraintsToModifier(childComposeView.property?.parentConstraints?.columnConstraints)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -598,6 +598,16 @@ fun RowScope.constraintsToModifier(rowConstraints: RowConstraints?): Modifier {
|
||||
}
|
||||
}
|
||||
|
||||
fun ColumnScope.constraintsToModifier(columnConstraints: ColumnConstraints?): Modifier {
|
||||
return Modifier
|
||||
.conditional(columnConstraints?.columnWeight != null) {
|
||||
weight(columnConstraints?.columnWeight?.weight ?: 0f, columnConstraints?.columnWeight?.fill ?: true)
|
||||
}
|
||||
.conditional(columnConstraints?.horizontalAlignment != null) {
|
||||
align(getHorizontalAlignment(columnConstraints?.horizontalAlignment))
|
||||
}
|
||||
}
|
||||
|
||||
fun getBorderStrokeBrushData(borderStrokeData: BorderStrokeData?): Brush {
|
||||
return when {
|
||||
borderStrokeData?.color != null -> SolidColor(borderStrokeData.color.hexToComposeColor)
|
||||
|
||||
Reference in New Issue
Block a user