TP-29335 | Margin support to renderers (#69)

This commit is contained in:
shreyansu raj
2023-05-24 14:09:14 +05:30
committed by GitHub Enterprise
parent 75893d18ca
commit f2a424f2d7
20 changed files with 61 additions and 134 deletions

View File

@@ -31,6 +31,7 @@ import orFalse
import orTrue
import setBackground
import setHeight
import setPadding
import setWidth
@OptIn(ExperimentalAnimationApi::class)
@@ -76,17 +77,13 @@ class AutoScrollViewRenderer(
.layoutId(property.layoutId.orEmpty())
.setHeight(property.height)
.setWidth(property.width)
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(updatedData?.onClick)

View File

@@ -27,6 +27,7 @@ import orTrue
import setBackground
import setHeight
import setHorizontalScroll
import setPadding
import setVerticalScroll
import setWidth
@@ -67,17 +68,13 @@ class BoxRenderer(
.setHorizontalScroll(property.horizontalScroll)
.setHeight(property.height)
.setWidth(property.width)
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(updatedData?.onClick)

View File

@@ -33,6 +33,7 @@ import orFalse
import orTrue
import setButtonElevation
import setHeight
import setPadding
import setWidth
class ButtonRenderer(
@@ -85,12 +86,8 @@ class ButtonRenderer(
modifier = Modifier
.setHeight(property.height)
.setWidth(property.width)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.margin)
.setPadding(property.padding)
.layoutId(property.layoutId.orEmpty())
.alpha(property.alpha ?: 1.0f),
onClick = {

View File

@@ -34,6 +34,7 @@ import hexToComposeColor
import orFalse
import orTrue
import setHeight
import setPadding
import setWidth
class CardRenderer(
@@ -80,12 +81,7 @@ class CardRenderer(
.layoutId(property.layoutId.orEmpty())
.setWidth(property.width)
.setHeight(property.height)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.shadow(
elevation = property.elevation?.dp ?: 0.dp,
ambientColor = property.ambientColor?.hexToComposeColor

View File

@@ -29,6 +29,7 @@ import orFalse
import orTrue
import setBackground
import setHeight
import setPadding
import setWidth
class CheckBoxRenderer :
@@ -73,15 +74,11 @@ class CheckBoxRenderer :
property.checkmarkColor?.hexToComposeColor ?: Color.Black
),
modifier = Modifier
.padding(
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp,
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp
)
.setPadding(property.margin)
.setBackground(
property.backgroundColor, property.shape, property.backGroundBrushData
)
.setPadding(property.padding)
.setWidth(property.width)
.setHeight(property.height)
.layoutId(property.layoutId.orEmpty())

View File

@@ -26,6 +26,7 @@ import hexToComposeColor
import orFalse
import orTrue
import setHeight
import setPadding
import setWidth
class DividerRenderer : Renderer<DividerProperty> {
@@ -50,12 +51,8 @@ class DividerRenderer : Renderer<DividerProperty> {
.setHeight(property.height)
.setWidth(property.width)
.layoutId(property.layoutId.orEmpty())
.padding(
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp,
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp
)
.setPadding(property.margin)
.setPadding(property.padding)
.alpha(property.alpha ?: 1.0f),
color = property.color?.hexToComposeColor ?: Color.Black,
thickness = property.thickness?.dp ?: 1.dp

View File

@@ -21,6 +21,7 @@ import orFalse
import orTrue
import setBackground
import setHeight
import setPadding
import setWidth
class GridRenderer(
@@ -55,15 +56,11 @@ class GridRenderer(
.layoutId(property.layoutId.orEmpty())
.setHeight(property.height)
.setWidth(property.width)
.setPadding(property.margin)
.setBackground(
property.backgroundColor, property.shape, property.backGroundBrushData
)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(updatedData?.onClick)

View File

@@ -31,6 +31,7 @@ import orFalse
import orTrue
import setBackground
import setHeight
import setPadding
import setWidth
@@ -66,18 +67,14 @@ class ImageRenderer : Renderer<ImageProperty> {
modifier = Modifier
.setWidth(property.width)
.setHeight(property.height)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.layoutId(property.layoutId.orEmpty())
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(uiTronData?.onClick)
@@ -104,18 +101,14 @@ class ImageRenderer : Renderer<ImageProperty> {
modifier = Modifier
.setWidth(property.width)
.setHeight(property.height)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.margin)
.layoutId(property.layoutId.orEmpty())
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(uiTronData?.onClick)

View File

@@ -29,6 +29,7 @@ import getTextDecoration
import hexToComposeColor
import orFalse
import setBackground
import setPadding
@OptIn(ExperimentalAnimationApi::class)
class JackpotTextRenderer : Renderer<TextProperty> {
@@ -62,17 +63,13 @@ class JackpotTextRenderer : Renderer<TextProperty> {
}
Row(
Modifier
.padding(
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp,
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp
)
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.setPadding(property.padding)
.alpha(property.alpha ?: 1.0f)
) {
val countString =

View File

@@ -30,6 +30,7 @@ import orFalse
import orTrue
import setBackground
import setHeight
import setPadding
import setVerticalArrangement
import setWidth
@@ -73,17 +74,13 @@ class LazyColumnRenderer(
.layoutId(property.layoutId.orEmpty())
.setHeight(property.height)
.setWidth(property.width)
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(uiTronData?.onClick)

View File

@@ -27,6 +27,7 @@ import orVal
import setBackground
import setHeight
import setHorizontalArrangement
import setPadding
import setVerticalArrangement
import setWidth
@@ -63,15 +64,11 @@ class LazyGridRenderer(
.layoutId(property.layoutId.orEmpty())
.setHeight(property.height)
.setWidth(property.width)
.setPadding(property.margin)
.setBackground(
property.backgroundColor, property.shape, property.backGroundBrushData
)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(uiTronData?.onClick)

View File

@@ -31,6 +31,7 @@ import orTrue
import setBackground
import setHeight
import setHorizontalArrangement
import setPadding
import setWidth
@@ -74,17 +75,13 @@ class LazyRowRenderer(
.layoutId(property.layoutId.orEmpty())
.setHeight(property.height)
.setWidth(property.width)
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(uiTronData?.onClick)

View File

@@ -35,6 +35,7 @@ import orFalse
import orTrue
import setBackground
import setHeight
import setPadding
import setWidth
@OptIn(ExperimentalPagerApi::class)
@@ -109,17 +110,13 @@ class PagerIndicatorRenderer : Renderer<PagerIndicatorProperty> {
.setHeight(property.height)
.setWidth(property.width)
.alpha(property.alpha ?: 1.0f)
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(updatedData?.onClick)

View File

@@ -38,6 +38,7 @@ import orTrue
import orZero
import setBackground
import setHeight
import setPadding
import setWidth
@OptIn(ExperimentalPagerApi::class)
@@ -87,12 +88,7 @@ class PagerRenderer(
property.shape,
property.backGroundBrushData
)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(uiTronData?.onClick)
@@ -134,12 +130,7 @@ class PagerRenderer(
property.shape,
property.backGroundBrushData
)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.customClickable(
{
uiTronViewModel.handleActions(uiTronData?.onClick)

View File

@@ -27,6 +27,7 @@ import orFalse
import orTrue
import setBackground
import setHeight
import setPadding
import setWidth
class RadioButtonRenderer :
@@ -63,17 +64,13 @@ class RadioButtonRenderer :
property.unselectedColor?.hexToComposeColor ?: Color.Black
),
modifier = Modifier
.padding(
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp,
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp
)
.setWidth(property.width)
.setHeight(property.height)
.setPadding(property.margin)
.setBackground(
property.backgroundColor, property.shape, property.backGroundBrushData
)
.setWidth(property.width)
.setHeight(property.height)
.setPadding(property.padding)
.layoutId(property.layoutId.orEmpty())
.customClickable(
{

View File

@@ -40,6 +40,7 @@ import orFalse
import orTrue
import orZero
import setHeight
import setPadding
import setWidth
import kotlin.math.floor
@@ -216,12 +217,7 @@ class SliderRenderer :
.setWidth(property.width)
.setHeight(property.height)
.layoutId(property.layoutId.orEmpty())
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.setPadding(property.padding)
.rotate(property.rotation ?: 0f)
.alpha(property.alpha ?: 1.0f),
colors = SliderDefaults.colors(

View File

@@ -24,6 +24,7 @@ import orFalse
import orTrue
import setBackground
import setHeight
import setPadding
import setWidth
class SpacerRenderer : Renderer<SpacerProperty> {
@@ -54,12 +55,6 @@ class SpacerRenderer : Renderer<SpacerProperty> {
modifier = Modifier
.setHeight(property.height)
.setWidth(property.width)
.padding(
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp,
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp
)
.customClickable(
{
uiTronViewModel.handleActions(updatedData?.onClick)
@@ -67,11 +62,13 @@ class SpacerRenderer : Renderer<SpacerProperty> {
actions = updatedData?.onClick?.actions
)
.alpha(property.alpha ?: 1.0f)
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.setPadding(property.padding)
.layoutId(property.layoutId.orEmpty())
)
}

View File

@@ -21,6 +21,7 @@ import getTextDecoration
import hexToComposeColor
import orFalse
import setBackground
import setPadding
/**
* this is simple Spannable text renderer. It doesn't handle clicks
@@ -75,17 +76,13 @@ class SpannableTextRenderer : Renderer<SpannableProperty> {
ClickableText(text = annotatedString,
modifier = Modifier
.layoutId(property.layoutId.orEmpty())
.padding(
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp,
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp
)
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.setPadding(property.padding)
.alpha(property.alpha ?: 1.0f),
onClick = {

View File

@@ -30,6 +30,7 @@ import com.navi.uitron.viewmodel.UiTronViewModel
import hexToComposeColor
import orFalse
import orTrue
import setPadding
class SwitchRenderer :
Renderer<SwitchProperty> {
@@ -71,12 +72,7 @@ class SwitchRenderer :
}
},
modifier = Modifier
.padding(
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp,
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp
)
.setPadding(property.padding)
.scale(property.scaleData?.x ?: 1.0f, property.scaleData?.y ?: 1.0f)
.layoutId(property.layoutId.orEmpty())
.alpha(property.alpha ?: 1.0f),

View File

@@ -41,6 +41,7 @@ import orFalse
import orTrue
import setBackground
import setHeight
import setPadding
import setWidth
class TextRenderer : Renderer<TextProperty> {
@@ -102,17 +103,13 @@ class TextRenderer : Renderer<TextProperty> {
modifier = Modifier
.setWidth(property.width)
.setHeight(property.height)
.padding(
top = property.padding?.top?.dp ?: 0.dp,
bottom = property.padding?.bottom?.dp ?: 0.dp,
start = property.padding?.start?.dp ?: 0.dp,
end = property.padding?.end?.dp ?: 0.dp
)
.setPadding(property.margin)
.setBackground(
property.backgroundColor,
property.shape,
property.backGroundBrushData
)
.setPadding(property.padding)
.layoutId(property.layoutId.orEmpty())
.customClickable(
{