diff --git a/navi-uitron/src/main/java/com/navi/uitron/helpers/animationHelper/CreateAnimationProperty.kt b/navi-uitron/src/main/java/com/navi/uitron/helpers/animationHelper/CreateAnimationProperty.kt index 9693d18..520521c 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/helpers/animationHelper/CreateAnimationProperty.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/helpers/animationHelper/CreateAnimationProperty.kt @@ -7,14 +7,12 @@ package com.navi.uitron.helpers.animationHelper -import android.util.Size import androidx.compose.animation.core.updateTransition import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue +import androidx.compose.runtime.State import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.navi.uitron.model.animations.AnimateProperty import com.navi.uitron.model.animations.AnimatedProperties @@ -31,13 +29,11 @@ import com.navi.uitron.model.ui.BaseProperty import com.navi.uitron.model.ui.TextProperty import com.navi.uitron.utils.IS_ANIMATION_RUNNING import com.navi.uitron.utils.hexToComposeColor -import com.navi.uitron.utils.toPx import com.navi.uitron.viewmodel.UiTronViewModel @Composable fun createAnimationProperty( viewModel: UiTronViewModel = hiltViewModel(), - composableDimension: Size? = null, baseProperty: BaseProperty? = null, ): AnimatedProperties { @@ -56,7 +52,7 @@ fun createAnimationProperty( ) LaunchedEffect(transitions.currentState) { - if (transitions.currentState) { + if (transitions.currentState == transitions.targetState) { viewModel.handleActions(baseProperty?.animate?.onAnimationEnd) } } @@ -67,7 +63,7 @@ fun createAnimationProperty( in animateFloatSet -> { val floatData = propertyAnimator as? FloatInterpolator floatData?.let { - val targetValue by + val targetValue = transitions.anFloat( initToTargetAnimSpec = propertyAnimator.initToTargetAnimSpec, targetToInitAnimSpec = propertyAnimator.targetToInitAnimSpec, @@ -75,18 +71,17 @@ fun createAnimationProperty( targetValue = floatData.targetFloatValue ?: 0f, defaultValue = floatData.initialFloatValue ?: 0f ) - SetAnimatedProperty( + SetFloatProperty( propertyName = propertyName, animatedProperties = animatedProperties, - value = targetValue, - composableDimension = composableDimension + value = targetValue ) } } in animateOffsetSet -> { val offsetData = propertyAnimator as? OffsetInterpolator offsetData?.let { - val targetOffset by + val targetOffset = transitions.anOffset( initToTargetAnimSpec = propertyAnimator.initToTargetAnimSpec, targetToInitAnimSpec = propertyAnimator.targetToInitAnimSpec, @@ -102,18 +97,17 @@ fun createAnimationProperty( offsetData.initialOffset?.y ?: 0f ) ) - SetAnimatedProperty( + SetOffsetProperty( propertyName = propertyName, animatedProperties = animatedProperties, - value = targetOffset, - composableDimension = composableDimension + value = targetOffset ) } } in animateColorSet -> { val colorData = propertyAnimator as? ColorInterpolator colorData?.let { - val targetColorValue by + val targetColorValue = transitions.anColor( initToTargetAnimSpec = propertyAnimator.initToTargetAnimSpec, targetToInitAnimSpec = propertyAnimator.targetToInitAnimSpec, @@ -132,18 +126,17 @@ fun createAnimationProperty( else -> Color.Transparent } ) - SetAnimatedProperty( + SetColorProperty( propertyName = propertyName, animatedProperties = animatedProperties, - value = targetColorValue, - composableDimension = composableDimension + value = targetColorValue ) } } in animateIntSet -> { val intData = propertyAnimator as? IntInterpolator intData?.let { - val targetValue by + val targetValue = transitions.anInt( initToTargetAnimSpec = propertyAnimator.initToTargetAnimSpec, targetToInitAnimSpec = propertyAnimator.targetToInitAnimSpec, @@ -154,11 +147,10 @@ fun createAnimationProperty( ?: (baseProperty as? TextProperty)?.fontSize ?: 0 ) - SetAnimatedProperty( + SetIntProperty( propertyName = propertyName, animatedProperties = animatedProperties, - value = targetValue, - composableDimension = composableDimension + value = targetValue ) } } @@ -171,39 +163,60 @@ fun createAnimationProperty( } @Composable -fun SetAnimatedProperty( +fun SetFloatProperty( propertyName: AnimateProperty?, animatedProperties: AnimatedProperties, - value: Any?, - composableDimension: Size? = null + value: State ) { - propertyName ?: return when (propertyName) { - AnimateProperty.RotationZ -> animatedProperties.rotationZ = value as Float - AnimateProperty.RotationX -> animatedProperties.rotationX = value as Float - AnimateProperty.RotationY -> animatedProperties.rotationY = value as Float - AnimateProperty.Alpha -> animatedProperties.alpha = value as Float - AnimateProperty.ScaleX -> animatedProperties.scaleX = value as Float - AnimateProperty.ScaleY -> animatedProperties.scaleY = value as Float - AnimateProperty.TranslationX -> animatedProperties.translationX = (value as Float).dp.toPx() - AnimateProperty.TranslationY -> animatedProperties.translationY = (value as Float).dp.toPx() - AnimateProperty.ShadowElevation -> animatedProperties.shadowElevation = value as Float - AnimateProperty.HorizontalBrush -> - animatedProperties.horizontalBrush = - (value as Float).times(composableDimension?.width?.toFloat() ?: 1f) - AnimateProperty.VerticalBrush -> - animatedProperties.verticalBrush = - (value as Float).times(composableDimension?.height?.toFloat() ?: 1f) - AnimateProperty.LinearBrush -> - animatedProperties.linearBrush = - (value as Offset).let { - Offset( - it.x.times(composableDimension?.width?.toFloat() ?: 1f), - it.y.times(composableDimension?.height?.toFloat() ?: 1f) - ) - } - AnimateProperty.BackgroundColor -> animatedProperties.backgroundColor = value as Color - AnimateProperty.TextColor -> animatedProperties.textColor = value as Color - AnimateProperty.FontSize -> animatedProperties.fontSize = value as Int + AnimateProperty.RotationZ -> animatedProperties.rotationZ = value + AnimateProperty.RotationX -> animatedProperties.rotationX = value + AnimateProperty.RotationY -> animatedProperties.rotationY = value + AnimateProperty.Alpha -> animatedProperties.alpha = value + AnimateProperty.ScaleX -> animatedProperties.scaleX = value + AnimateProperty.ScaleY -> animatedProperties.scaleY = value + AnimateProperty.TranslationX -> animatedProperties.translationX = value + AnimateProperty.TranslationY -> animatedProperties.translationY = value + AnimateProperty.ShadowElevation -> animatedProperties.shadowElevation = value + AnimateProperty.HorizontalBrush -> animatedProperties.horizontalBrush = value + AnimateProperty.VerticalBrush -> animatedProperties.verticalBrush = value + else -> {} + } +} + +@Composable +fun SetIntProperty( + propertyName: AnimateProperty?, + animatedProperties: AnimatedProperties, + value: State +) { + when (propertyName) { + AnimateProperty.FontSize -> animatedProperties.fontSize = value + else -> {} + } +} + +@Composable +fun SetColorProperty( + propertyName: AnimateProperty?, + animatedProperties: AnimatedProperties, + value: State +) { + when (propertyName) { + AnimateProperty.BackgroundColor -> animatedProperties.backgroundColor = value + AnimateProperty.TextColor -> animatedProperties.textColor = value + else -> {} + } +} + +@Composable +fun SetOffsetProperty( + propertyName: AnimateProperty?, + animatedProperties: AnimatedProperties, + value: State +) { + when (propertyName) { + AnimateProperty.LinearBrush -> animatedProperties.linearBrush = value + else -> {} } } diff --git a/navi-uitron/src/main/java/com/navi/uitron/model/animations/AnimateProperty.kt b/navi-uitron/src/main/java/com/navi/uitron/model/animations/AnimateProperty.kt index 4ed84f7..3ce108f 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/model/animations/AnimateProperty.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/model/animations/AnimateProperty.kt @@ -8,6 +8,7 @@ package com.navi.uitron.model.animations import android.os.Parcelable +import androidx.compose.runtime.State import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color import com.navi.uitron.model.ui.OffSetData @@ -41,21 +42,21 @@ data class OffsetInterpolator( ) : PropertyAnimator() data class AnimatedProperties( - var backgroundColor: Color? = null, - var textColor: Color? = null, - var fontSize: Int? = null, - var rotationZ: Float? = null, - var rotationX: Float? = null, - var rotationY: Float? = null, - var alpha: Float? = null, - var scaleX: Float? = null, - var scaleY: Float? = null, - var translationX: Float? = null, - var translationY: Float? = null, - var shadowElevation: Float? = null, - var horizontalBrush: Float? = null, - var verticalBrush: Float? = null, - var linearBrush: Offset? = null + var backgroundColor: State? = null, + var textColor: State? = null, + var fontSize: State? = null, + var rotationZ: State? = null, + var rotationX: State? = null, + var rotationY: State? = null, + var alpha: State? = null, + var scaleX: State? = null, + var scaleY: State? = null, + var translationX: State? = null, + var translationY: State? = null, + var shadowElevation: State? = null, + var horizontalBrush: State? = null, + var verticalBrush: State? = null, + var linearBrush: State? = null ) enum class AnimateProperty { diff --git a/navi-uitron/src/main/java/com/navi/uitron/modifer/AnimatedVisibilityModifierBuilder.kt b/navi-uitron/src/main/java/com/navi/uitron/modifer/AnimatedVisibilityModifierBuilder.kt index 56dc3be..a6aa37a 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/modifer/AnimatedVisibilityModifierBuilder.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/modifer/AnimatedVisibilityModifierBuilder.kt @@ -8,13 +8,10 @@ package com.navi.uitron.modifer import android.annotation.SuppressLint -import android.util.Size -import androidx.compose.runtime.MutableIntState import androidx.compose.ui.Modifier import com.navi.uitron.model.animations.AnimatedProperties import com.navi.uitron.model.data.UiTronData import com.navi.uitron.model.ui.AnimatedVisibilityProperty -import com.navi.uitron.utils.orZero import com.navi.uitron.viewmodel.UiTronViewModel @SuppressLint("ModifierFactoryExtensionFunction") @@ -23,20 +20,16 @@ class AnimatedVisibilityModifierBuilder( private val property: AnimatedVisibilityProperty, uiTronData: UiTronData?, uiTronViewModel: UiTronViewModel, - animatedProperties: AnimatedProperties? = null, - private val containerWidth: MutableIntState? = null, - private val containerHeight: MutableIntState? = null, + animatedProperties: AnimatedProperties? = null ) : ModifierBuilder( modifier, property, uiTronData, uiTronViewModel, - animatedProperties, - Size(containerWidth?.intValue.orZero(), containerHeight?.intValue.orZero()) + animatedProperties ) { override fun build(): Modifier { - setOnGloballyPositioned(containerWidth, containerHeight) setDefaultModifiers() setGraphicsLayer() return finalModifier diff --git a/navi-uitron/src/main/java/com/navi/uitron/modifer/BoxModifierBuilder.kt b/navi-uitron/src/main/java/com/navi/uitron/modifer/BoxModifierBuilder.kt index ab2f194..cbe390f 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/modifer/BoxModifierBuilder.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/modifer/BoxModifierBuilder.kt @@ -8,8 +8,6 @@ package com.navi.uitron.modifer import android.annotation.SuppressLint -import android.util.Size -import androidx.compose.runtime.MutableIntState import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Color @@ -29,22 +27,18 @@ class BoxModifierBuilder( private val property: BoxProperty, uiTronData: UiTronData?, uiTronViewModel: UiTronViewModel, - animatedProperties: AnimatedProperties? = null, - private val boxWidth: MutableIntState? = null, - private val boxHeight: MutableIntState? = null + animatedProperties: AnimatedProperties? = null ) : ModifierBuilder( modifier, property, uiTronData, uiTronViewModel, - animatedProperties, - Size(boxWidth?.intValue ?: 0, boxHeight?.intValue ?: 0) + animatedProperties ) { override fun build(): Modifier { setIdModifiers() - setOnGloballyPositioned(boxWidth, boxHeight) setSizeModifiers() finalModifier = finalModifier diff --git a/navi-uitron/src/main/java/com/navi/uitron/modifer/ButtonModifierBuilder.kt b/navi-uitron/src/main/java/com/navi/uitron/modifer/ButtonModifierBuilder.kt index e47d5b8..2326fbb 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/modifer/ButtonModifierBuilder.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/modifer/ButtonModifierBuilder.kt @@ -8,37 +8,30 @@ package com.navi.uitron.modifer import android.annotation.SuppressLint -import android.util.Size -import androidx.compose.runtime.MutableIntState import androidx.compose.ui.Modifier import com.navi.uitron.model.animations.AnimatedProperties import com.navi.uitron.model.data.UiTronData import com.navi.uitron.model.ui.ButtonProperty -import com.navi.uitron.utils.orZero import com.navi.uitron.viewmodel.UiTronViewModel @SuppressLint("ModifierFactoryExtensionFunction") class ButtonModifierBuilder( modifier: Modifier, - private val property: ButtonProperty, + property: ButtonProperty, uiTronData: UiTronData?, uiTronViewModel: UiTronViewModel, - animatedProperties: AnimatedProperties? = null, - private val buttonWidth: MutableIntState? = null, - private val buttonHeight: MutableIntState? = null, + animatedProperties: AnimatedProperties? = null ) : ModifierBuilder( modifier, property, uiTronData, uiTronViewModel, - animatedProperties, - Size(buttonWidth?.intValue.orZero(), buttonHeight?.intValue.orZero()) + animatedProperties ) { override fun build(): Modifier { setIdModifiers() - setOnGloballyPositioned(buttonWidth, buttonHeight) setSizeModifiers() setGraphicsLayer() setMargin() diff --git a/navi-uitron/src/main/java/com/navi/uitron/modifer/CardModifierBuilder.kt b/navi-uitron/src/main/java/com/navi/uitron/modifer/CardModifierBuilder.kt index 9b03c37..c0734a5 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/modifer/CardModifierBuilder.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/modifer/CardModifierBuilder.kt @@ -8,8 +8,6 @@ package com.navi.uitron.modifer import android.annotation.SuppressLint -import android.util.Size -import androidx.compose.runtime.MutableIntState import androidx.compose.ui.Modifier import androidx.compose.ui.composed import androidx.compose.ui.draw.shadow @@ -28,22 +26,18 @@ class CardModifierBuilder( private val property: CardProperty, uiTronData: UiTronData?, uiTronViewModel: UiTronViewModel, - animatedProperties: AnimatedProperties? = null, - private val cardWidth: MutableIntState? = null, - private val cardHeight: MutableIntState? = null + animatedProperties: AnimatedProperties? = null ) : ModifierBuilder( modifier, property, uiTronData, uiTronViewModel, - animatedProperties, - Size(cardWidth?.intValue ?: 0, cardHeight?.intValue ?: 0) + animatedProperties ) { override fun build(): Modifier { setIdModifiers() - setOnGloballyPositioned(cardWidth, cardHeight) setSizeModifiers() setGraphicsLayer() setPadding() diff --git a/navi-uitron/src/main/java/com/navi/uitron/modifer/ColumnModifierBuilder.kt b/navi-uitron/src/main/java/com/navi/uitron/modifer/ColumnModifierBuilder.kt index 0be4f8c..8da5760 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/modifer/ColumnModifierBuilder.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/modifer/ColumnModifierBuilder.kt @@ -8,8 +8,6 @@ package com.navi.uitron.modifer import android.annotation.SuppressLint -import android.util.Size -import androidx.compose.runtime.MutableIntState import androidx.compose.ui.Modifier import com.navi.uitron.model.animations.AnimatedProperties import com.navi.uitron.model.data.UiTronData @@ -24,22 +22,18 @@ class ColumnModifierBuilder( private val property: ColumnProperty, uiTronData: UiTronData?, uiTronViewModel: UiTronViewModel, - animatedProperties: AnimatedProperties? = null, - private val width: MutableIntState? = null, - private val height: MutableIntState? = null + animatedProperties: AnimatedProperties? = null ) : ModifierBuilder( modifier, property, uiTronData, uiTronViewModel, - animatedProperties, - Size(width?.intValue ?: 0, height?.intValue ?: 0) + animatedProperties ) { override fun build(): Modifier { setIdModifiers() - setOnGloballyPositioned(width, height) setSizeModifiers() finalModifier = finalModifier diff --git a/navi-uitron/src/main/java/com/navi/uitron/modifer/ModifierBuilder.kt b/navi-uitron/src/main/java/com/navi/uitron/modifer/ModifierBuilder.kt index d6ab0e5..3997bea 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/modifer/ModifierBuilder.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/modifer/ModifierBuilder.kt @@ -8,8 +8,6 @@ package com.navi.uitron.modifer import android.annotation.SuppressLint -import android.util.Size -import androidx.compose.runtime.MutableIntState import androidx.compose.ui.Modifier import androidx.compose.ui.composed import androidx.compose.ui.draw.alpha @@ -30,7 +28,6 @@ import com.navi.uitron.utils.setBlur import com.navi.uitron.utils.setBorderStroke import com.navi.uitron.utils.setHeight import com.navi.uitron.utils.setHeightRange -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setPadding import com.navi.uitron.utils.setTag import com.navi.uitron.utils.setWidth @@ -43,8 +40,7 @@ open class ModifierBuilder>( private val property: BaseProperty, open val uiTronData: UiTronData?, open val uiTronViewModel: UiTronViewModel, - private val animatedProperties: AnimatedProperties? = null, - private val composableDimensions: Size? = null + private val animatedProperties: AnimatedProperties? = null ) { open var finalModifier = modifier @@ -85,8 +81,7 @@ open class ModifierBuilder>( property.backgroundColor, property.shape, property.backGroundBrushData, - animatedProperties, - composableDimensions, + animatedProperties ) return this as T } @@ -97,12 +92,7 @@ open class ModifierBuilder>( } fun setBorderStroke(): T { - finalModifier = - finalModifier.setBorderStroke( - property.borderStrokeData, - animatedProperties, - composableDimensions - ) + finalModifier = finalModifier.setBorderStroke(property.borderStrokeData, animatedProperties) return this as T } @@ -171,16 +161,6 @@ open class ModifierBuilder>( return this as T } - fun setOnGloballyPositioned(width: MutableIntState?, height: MutableIntState?): T { - finalModifier = - finalModifier.setOnGloballyPosition( - animate = property.animate, - width = width, - height = height - ) - return this as T - } - fun setIdModifiers(): T { setTag() setLayoutId() diff --git a/navi-uitron/src/main/java/com/navi/uitron/modifer/RowModifierBuilder.kt b/navi-uitron/src/main/java/com/navi/uitron/modifer/RowModifierBuilder.kt index 9d0c8aa..7d6f52d 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/modifer/RowModifierBuilder.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/modifer/RowModifierBuilder.kt @@ -8,8 +8,6 @@ package com.navi.uitron.modifer import android.annotation.SuppressLint -import android.util.Size -import androidx.compose.runtime.MutableIntState import androidx.compose.ui.Modifier import com.navi.uitron.model.animations.AnimatedProperties import com.navi.uitron.model.data.UiTronData @@ -24,22 +22,18 @@ class RowModifierBuilder( private val property: RowProperty, uiTronData: UiTronData?, uiTronViewModel: UiTronViewModel, - animatedProperties: AnimatedProperties? = null, - private val rowWidth: MutableIntState? = null, - private val rowHeight: MutableIntState? = null + animatedProperties: AnimatedProperties? = null ) : ModifierBuilder( modifier = modifier, property = property, uiTronData = uiTronData, uiTronViewModel = uiTronViewModel, - animatedProperties = animatedProperties, - composableDimensions = Size(rowWidth?.intValue ?: 0, rowHeight?.intValue ?: 0) + animatedProperties = animatedProperties ) { override fun build(): Modifier { setIdModifiers() - setOnGloballyPositioned(rowWidth, rowHeight) setSizeModifiers() finalModifier = finalModifier diff --git a/navi-uitron/src/main/java/com/navi/uitron/modifer/TextModifierBuilder.kt b/navi-uitron/src/main/java/com/navi/uitron/modifer/TextModifierBuilder.kt index 388c7d2..b038034 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/modifer/TextModifierBuilder.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/modifer/TextModifierBuilder.kt @@ -8,7 +8,6 @@ package com.navi.uitron.modifer import android.annotation.SuppressLint -import android.util.Size import androidx.compose.runtime.MutableIntState import androidx.compose.ui.Modifier import com.navi.uitron.model.animations.AnimatedProperties @@ -31,12 +30,10 @@ class TextModifierBuilder( property, uiTronData, uiTronViewModel, - animatedProperties, - Size(textWidth?.intValue ?: 0, textHeight?.intValue ?: 0) + animatedProperties ) { override fun build(): Modifier { - setOnGloballyPositioned(textWidth, textHeight) setDefaultModifiers() setGraphicsLayer() return finalModifier diff --git a/navi-uitron/src/main/java/com/navi/uitron/render/AnimatedVisibilityRenderer.kt b/navi-uitron/src/main/java/com/navi/uitron/render/AnimatedVisibilityRenderer.kt index 24ae419..93edb56 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/render/AnimatedVisibilityRenderer.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/render/AnimatedVisibilityRenderer.kt @@ -7,12 +7,9 @@ package com.navi.uitron.render -import android.util.Size import androidx.compose.animation.AnimatedVisibility import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.layout.layoutId @@ -39,7 +36,6 @@ import com.navi.uitron.utils.setBackground import com.navi.uitron.utils.setBlur import com.navi.uitron.utils.setHeight import com.navi.uitron.utils.setHeightRange -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setPadding import com.navi.uitron.utils.setTag import com.navi.uitron.utils.setWidth @@ -60,9 +56,6 @@ class AnimatedVisibilityRenderer( super.Render(property, uiTronData, uiTronViewModel, modifier) val rootView = LocalView.current.rootView val context = LocalContext.current - val containerWidth = remember { mutableIntStateOf(0) } - val containerHeight = remember { mutableIntStateOf(0) } - val containerSize = Size(containerWidth.intValue, containerHeight.intValue) if (property.isStateFul.orFalse()) { val state = @@ -87,14 +80,11 @@ class AnimatedVisibilityRenderer( property, uiTronData, uiTronViewModel, - animatedProperties, - containerWidth, - containerHeight + animatedProperties ) .build() } else { (modifier ?: Modifier) - .setOnGloballyPosition(property.animate, containerWidth, containerHeight) .customOffset(property.offset) .setWidth(property.width) .setHeight(property.height) @@ -110,8 +100,7 @@ class AnimatedVisibilityRenderer( animatedProperties.backgroundColor ?: property.backgroundColor, property.shape, property.backGroundBrushData, - animatedProperties, - containerSize + animatedProperties ) .clip(property.clipShape) .setPadding(property.padding) @@ -125,7 +114,7 @@ class AnimatedVisibilityRenderer( .customCombinedClick(property, uiTronData) { uiTronViewModel.handleActions(it) } - .alpha(animatedProperties.alpha ?: property.alpha ?: 1.0f) + .alpha(animatedProperties.alpha?.value ?: property.alpha ?: 1.0f) .setBlur(property.blurData) .alfredMaskSensitiveComposable( isSensitive = property.isSensitive.orFalse(), diff --git a/navi-uitron/src/main/java/com/navi/uitron/render/BoxRenderer.kt b/navi-uitron/src/main/java/com/navi/uitron/render/BoxRenderer.kt index 5a0c220..0fe43b8 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/render/BoxRenderer.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/render/BoxRenderer.kt @@ -7,12 +7,9 @@ package com.navi.uitron.render -import android.util.Size import androidx.compose.foundation.layout.Box import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.shadow @@ -49,7 +46,6 @@ import com.navi.uitron.utils.setBorderStroke import com.navi.uitron.utils.setHeight import com.navi.uitron.utils.setHeightRange import com.navi.uitron.utils.setHorizontalScroll -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setPadding import com.navi.uitron.utils.setShimmerEffect import com.navi.uitron.utils.setTag @@ -103,16 +99,9 @@ class BoxRenderer( if (property.visible.orTrue()) { val rootView = LocalView.current.rootView - val boxHeight = remember { mutableIntStateOf(0) } - val boxWidth = remember { mutableIntStateOf(0) } - val boxDimension = Size(boxWidth.intValue, boxHeight.intValue) val animatedProperties = - property.animate?.let { - createAnimationProperty( - composableDimension = boxDimension, - baseProperty = property - ) - } ?: AnimatedProperties() + property.animate?.let { createAnimationProperty(baseProperty = property) } + ?: AnimatedProperties() Box( contentAlignment = @@ -125,20 +114,13 @@ class BoxRenderer( property, updatedData, uiTronViewModel, - animatedProperties, - boxWidth, - boxHeight + animatedProperties ) .build() } else { (modifier ?: Modifier) .setTag(property) .layoutId(property.layoutId.orEmpty()) - .setOnGloballyPosition( - animate = property.animate, - width = boxWidth, - height = boxHeight - ) .customOffset(property.offset) .setVerticalScroll(property.verticalScroll) .setHorizontalScroll(property.horizontalScroll) @@ -156,16 +138,11 @@ class BoxRenderer( animatedProperties.backgroundColor ?: property.backgroundColor, property.shape, property.backGroundBrushData, - animatedProperties, - boxDimension + animatedProperties ) .clip(property.clipShape) .setPadding(property.padding) - .setBorderStroke( - property.borderStrokeData, - animatedProperties, - boxDimension - ) + .setBorderStroke(property.borderStrokeData, animatedProperties) .setShimmerEffect(property.isShimmerEnabled) .customClickable( { uiTronViewModel.handleActions(updatedData?.onClick) }, @@ -175,7 +152,7 @@ class BoxRenderer( .customCombinedClick(property, updatedData) { uiTronViewModel.handleActions(it) } - .alpha(animatedProperties.alpha ?: property.alpha ?: 1.0f) + .alpha(animatedProperties.alpha?.value ?: property.alpha ?: 1.0f) .shadow( elevation = property.elevation?.toInt()?.dp ?: 0.dp, shape = ShapeUtil.getShape(shape = property.shape), diff --git a/navi-uitron/src/main/java/com/navi/uitron/render/ButtonRenderer.kt b/navi-uitron/src/main/java/com/navi/uitron/render/ButtonRenderer.kt index 5c87b60..178b789 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/render/ButtonRenderer.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/render/ButtonRenderer.kt @@ -7,7 +7,6 @@ package com.navi.uitron.render -import android.util.Size import androidx.compose.foundation.BorderStroke import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults @@ -16,7 +15,6 @@ import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableLongStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -48,7 +46,6 @@ import com.navi.uitron.utils.setAnimatedGraphicsLayer import com.navi.uitron.utils.setButtonElevation import com.navi.uitron.utils.setHeight import com.navi.uitron.utils.setHeightRange -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setPadding import com.navi.uitron.utils.setTag import com.navi.uitron.utils.setWidth @@ -87,23 +84,16 @@ class ButtonRenderer( if (property.visible.orTrue()) { val rootView = LocalView.current.rootView - val buttonWidth = remember { mutableIntStateOf(0) } - val buttonHeight = remember { mutableIntStateOf(0) } - val buttonSize = Size(buttonWidth.intValue, buttonHeight.intValue) val animatedProperties = - property.animate?.let { - createAnimationProperty( - composableDimension = buttonSize, - baseProperty = property - ) - } ?: AnimatedProperties() + property.animate?.let { createAnimationProperty(baseProperty = property) } + ?: AnimatedProperties() Button( shape = ShapeUtil.getShape(shape = property.shape), colors = ButtonDefaults.buttonColors( backgroundColor = - animatedProperties.backgroundColor + animatedProperties.backgroundColor?.value ?: property.colors?.backgroundColor?.hexToComposeColor ?: Color.Red, contentColor = @@ -124,11 +114,7 @@ class ButtonRenderer( BorderStroke( width = property.borderStrokeData?.width?.dp ?: 0.dp, brush = - getBorderStrokeBrushData( - property.borderStrokeData, - animatedProperties, - buttonSize - ) + getBorderStrokeBrushData(property.borderStrokeData, animatedProperties) ), elevation = setButtonElevation(property), modifier = @@ -138,19 +124,12 @@ class ButtonRenderer( property, updatedData, uiTronViewModel, - animatedProperties, - buttonWidth, - buttonHeight + animatedProperties ) .build() } else { (modifier ?: Modifier) .setTag(property) - .setOnGloballyPosition( - animate = property.animate, - width = buttonWidth, - height = buttonHeight - ) .customOffset(property.offset) .setHeight(property.height) .setWidth(property.width) @@ -164,7 +143,7 @@ class ButtonRenderer( ) .setPadding(property.padding) .layoutId(property.layoutId.orEmpty()) - .alpha(animatedProperties.alpha ?: property.alpha ?: 1.0f) + .alpha(animatedProperties.alpha?.value ?: property.alpha ?: 1.0f) .alfredMaskSensitiveComposable( isSensitive = property.isSensitive.orFalse(), rootView = rootView, diff --git a/navi-uitron/src/main/java/com/navi/uitron/render/CardRenderer.kt b/navi-uitron/src/main/java/com/navi/uitron/render/CardRenderer.kt index aaa10d2..346c0d8 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/render/CardRenderer.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/render/CardRenderer.kt @@ -7,13 +7,10 @@ package com.navi.uitron.render -import android.util.Size import androidx.compose.foundation.BorderStroke import androidx.compose.material.Card import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.shadow @@ -47,7 +44,6 @@ import com.navi.uitron.utils.orTrue import com.navi.uitron.utils.setAnimatedGraphicsLayer import com.navi.uitron.utils.setHeight import com.navi.uitron.utils.setHeightRange -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setPadding import com.navi.uitron.utils.setTag import com.navi.uitron.utils.setWidth @@ -103,16 +99,9 @@ class CardRenderer( if (property.visible.orTrue()) { val rootView = LocalView.current.rootView - val cardWidth = remember { mutableIntStateOf(0) } - val cardHeight = remember { mutableIntStateOf(0) } - val cardDimensions = Size(cardWidth.intValue, cardHeight.intValue) val animatedProperties = - property.animate?.let { - createAnimationProperty( - composableDimension = cardDimensions, - baseProperty = property - ) - } ?: AnimatedProperties() + property.animate?.let { createAnimationProperty(baseProperty = property) } + ?: AnimatedProperties() Card( modifier = if (UiTronSdkManager.isModifierBuilderEnabled()) { @@ -121,16 +110,13 @@ class CardRenderer( property, updatedData, uiTronViewModel, - animatedProperties, - cardWidth, - cardHeight + animatedProperties ) .build() } else { (modifier ?: Modifier) .setTag(property) .layoutId(property.layoutId.orEmpty()) - .setOnGloballyPosition(property.animate, cardWidth, cardHeight) .customOffset(property.offset) .setWidth(property.width) .setHeight(property.height) @@ -159,7 +145,7 @@ class CardRenderer( .customCombinedClick(property, updatedData) { uiTronViewModel.handleActions(it) } - .alpha(animatedProperties.alpha ?: property.alpha ?: 1.0f) + .alpha(animatedProperties.alpha?.value ?: property.alpha ?: 1.0f) .alfredMaskSensitiveComposable( isSensitive = property.isSensitive.orFalse(), rootView = rootView, @@ -169,18 +155,14 @@ class CardRenderer( shape = ShapeUtil.getShape(shape = property.shape), elevation = 0.dp, backgroundColor = - animatedProperties.backgroundColor + animatedProperties.backgroundColor?.value ?: property.backgroundColor?.hexToComposeColor ?: Color.White, border = BorderStroke( width = property.borderStrokeData?.width?.dp ?: 0.dp, brush = - getBorderStrokeBrushData( - property.borderStrokeData, - animatedProperties, - cardDimensions - ) + getBorderStrokeBrushData(property.borderStrokeData, animatedProperties) ) ) { childrenComposeViews.forEach { diff --git a/navi-uitron/src/main/java/com/navi/uitron/render/ColumnRenderer.kt b/navi-uitron/src/main/java/com/navi/uitron/render/ColumnRenderer.kt index 91171c3..e84810a 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/render/ColumnRenderer.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/render/ColumnRenderer.kt @@ -7,14 +7,11 @@ package com.navi.uitron.render -import android.util.Size import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.layout.layoutId @@ -48,7 +45,6 @@ import com.navi.uitron.utils.setBorderStroke import com.navi.uitron.utils.setHeight import com.navi.uitron.utils.setHeightRange import com.navi.uitron.utils.setHorizontalScroll -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setTag import com.navi.uitron.utils.setVerticalArrangement import com.navi.uitron.utils.setVerticalScroll @@ -101,15 +97,9 @@ class ColumnRenderer( if (property.visible.orTrue()) { val rootView = LocalView.current.rootView - val columnWidth = remember { mutableIntStateOf(0) } - val columnHeight = remember { mutableIntStateOf(0) } val animatedProperties = - property.animate?.let { - createAnimationProperty( - composableDimension = Size(columnWidth.intValue, columnHeight.intValue), - baseProperty = property - ) - } ?: AnimatedProperties() + property.animate?.let { createAnimationProperty(baseProperty = property) } + ?: AnimatedProperties() Column( verticalArrangement = Arrangement.setVerticalArrangement(arrangementData = property.arrangementData), @@ -122,20 +112,13 @@ class ColumnRenderer( property, updatedData, uiTronViewModel, - animatedProperties, - columnWidth, - columnHeight + animatedProperties ) .build() } else { (modifier ?: Modifier) .setTag(property) .layoutId(property.layoutId.orEmpty()) - .setOnGloballyPosition( - animate = property.animate, - width = columnWidth, - height = columnHeight - ) .customOffset(property.offset) .setVerticalScroll(property.verticalScroll) .setHorizontalScroll(property.horizontalScroll) @@ -158,8 +141,7 @@ class ColumnRenderer( property.backgroundColor, property.shape, property.backGroundBrushData, - animatedProperties, - Size(columnWidth.intValue, columnHeight.intValue) + animatedProperties ) .clip(property.clipShape) .padding( @@ -168,11 +150,7 @@ class ColumnRenderer( top = property.padding?.top?.dp ?: 0.dp, bottom = property.padding?.bottom?.dp ?: 0.dp ) - .setBorderStroke( - property.borderStrokeData, - animatedProperties, - Size(columnWidth.intValue, columnHeight.intValue) - ) + .setBorderStroke(property.borderStrokeData, animatedProperties) .customClickable( { uiTronViewModel.handleActions(updatedData?.onClick) }, actions = updatedData?.onClick?.actions, @@ -181,7 +159,7 @@ class ColumnRenderer( .customCombinedClick(property, updatedData) { uiTronViewModel.handleActions(it) } - .alpha(animatedProperties.alpha ?: property.alpha ?: 1.0f) + .alpha(animatedProperties.alpha?.value ?: property.alpha ?: 1.0f) .setBlur(property.blurData) .alfredMaskSensitiveComposable( isSensitive = property.isSensitive.orFalse(), diff --git a/navi-uitron/src/main/java/com/navi/uitron/render/ImageRenderer.kt b/navi-uitron/src/main/java/com/navi/uitron/render/ImageRenderer.kt index 654e2a8..1afc52b 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/render/ImageRenderer.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/render/ImageRenderer.kt @@ -7,11 +7,9 @@ package com.navi.uitron.render -import android.util.Size as DimensionSize import androidx.compose.foundation.Image import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha @@ -49,7 +47,6 @@ import com.navi.uitron.utils.setBackground import com.navi.uitron.utils.setBlur import com.navi.uitron.utils.setHeight import com.navi.uitron.utils.setHeightRange -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setPadding import com.navi.uitron.utils.setTag import com.navi.uitron.utils.setWidth @@ -110,16 +107,9 @@ class ImageRenderer : Renderer { if (property.visible.orTrue()) { val rootView = LocalView.current.rootView - val imageWidth = remember { mutableIntStateOf(0) } - val imageHeight = remember { mutableIntStateOf(0) } - val imageDimensions = DimensionSize(imageWidth.intValue, imageHeight.intValue) val animatedProperties = - property.animate?.let { - createAnimationProperty( - composableDimension = imageDimensions, - baseProperty = property - ) - } ?: AnimatedProperties() + property.animate?.let { createAnimationProperty(baseProperty = property) } + ?: AnimatedProperties() UiTronSdkManager.getDependencyProvider() .getIconResourceId(uiTronImageData?.iconUrl) ?.let { iconCode -> @@ -136,17 +126,11 @@ class ImageRenderer : Renderer { uiTronViewModel, animatedProperties ) - .setOnGloballyPositioned(imageWidth, imageHeight) .setDefaultModifiers() .build() } else { (modifier ?: Modifier) .setTag(property) - .setOnGloballyPosition( - property.animate, - imageWidth, - imageHeight - ) .customOffset(property.offset) .setWidth(property.width) .setHeight(property.height) @@ -163,8 +147,7 @@ class ImageRenderer : Renderer { property.backgroundColor, property.shape, property.backGroundBrushData, - animatedProperties, - imageDimensions + animatedProperties ) .clip(property.clipShape) .setPadding(property.padding) @@ -176,7 +159,9 @@ class ImageRenderer : Renderer { .customCombinedClick(property, uiTronImageData) { uiTronViewModel.handleActions(it) } - .alpha(animatedProperties.alpha ?: property.alpha ?: 1.0f) + .alpha( + animatedProperties.alpha?.value ?: property.alpha ?: 1.0f + ) .setBlur(property.blurData) .alfredMaskSensitiveComposable( isSensitive = property.isSensitive.orFalse(), @@ -209,7 +194,6 @@ class ImageRenderer : Renderer { (modifier ?: Modifier) .setTag(property) .customOffset(property.offset) - .setOnGloballyPosition(property.animate, imageWidth, imageHeight) .setWidth(property.width) .setHeight(property.height) .setHeightRange(property.heightRange) @@ -225,8 +209,7 @@ class ImageRenderer : Renderer { property.backgroundColor, property.shape, property.backGroundBrushData, - animatedProperties, - imageDimensions + animatedProperties ) .setPadding(property.padding) .customClickable( @@ -237,7 +220,7 @@ class ImageRenderer : Renderer { .customCombinedClick(property, uiTronImageData) { uiTronViewModel.handleActions(it) } - .alpha(animatedProperties.alpha ?: property.alpha ?: 1.0f) + .alpha(animatedProperties.alpha?.value ?: property.alpha ?: 1.0f) .setBlur(property.blurData) .alfredMaskSensitiveComposable( isSensitive = property.isSensitive.orFalse(), diff --git a/navi-uitron/src/main/java/com/navi/uitron/render/RowRenderer.kt b/navi-uitron/src/main/java/com/navi/uitron/render/RowRenderer.kt index 8749112..64e24b4 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/render/RowRenderer.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/render/RowRenderer.kt @@ -7,14 +7,11 @@ package com.navi.uitron.render -import android.util.Size import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.layout.layoutId @@ -48,7 +45,6 @@ import com.navi.uitron.utils.setHeight import com.navi.uitron.utils.setHeightRange import com.navi.uitron.utils.setHorizontalArrangement import com.navi.uitron.utils.setHorizontalScroll -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setTag import com.navi.uitron.utils.setVerticalScroll import com.navi.uitron.utils.setWidth @@ -100,16 +96,9 @@ class RowRenderer( if (property.visible.orTrue()) { val rootView = LocalView.current.rootView - val rowWidth = remember { mutableIntStateOf(0) } - val rowHeight = remember { mutableIntStateOf(0) } - val rowDimensions = Size(rowWidth.intValue, rowHeight.intValue) val animatedProperties = - property.animate?.let { - createAnimationProperty( - composableDimension = rowDimensions, - baseProperty = property - ) - } ?: AnimatedProperties() + property.animate?.let { createAnimationProperty(baseProperty = property) } + ?: AnimatedProperties() Row( horizontalArrangement = Arrangement.setHorizontalArrangement( @@ -124,20 +113,13 @@ class RowRenderer( property, rowData, uiTronViewModel, - animatedProperties, - rowWidth, - rowHeight + animatedProperties ) .build() } else { (modifier ?: Modifier) .setTag(property) .layoutId(property.layoutId.orEmpty()) - .setOnGloballyPosition( - animate = property.animate, - width = rowWidth, - height = rowHeight - ) .customOffset(property.offset) .setVerticalScroll(property.verticalScroll) .setHorizontalScroll(property.horizontalScroll) @@ -161,8 +143,7 @@ class RowRenderer( property.backgroundColor, property.shape, property.backGroundBrushData, - animatedProperties, - rowDimensions + animatedProperties ) .padding( start = property.padding?.start?.dp ?: 0.dp, @@ -171,11 +152,7 @@ class RowRenderer( bottom = property.padding?.bottom?.dp ?: 0.dp ) .alpha(property.alpha ?: 1.0f) - .setBorderStroke( - property.borderStrokeData, - animatedProperties, - rowDimensions - ) + .setBorderStroke(property.borderStrokeData, animatedProperties) .customClickable( onClick = { uiTronViewModel.handleActions(rowData?.onClick) }, actions = rowData?.onClick?.actions, diff --git a/navi-uitron/src/main/java/com/navi/uitron/render/SpannableTextRenderer.kt b/navi-uitron/src/main/java/com/navi/uitron/render/SpannableTextRenderer.kt index c9b2330..dd6d2c0 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/render/SpannableTextRenderer.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/render/SpannableTextRenderer.kt @@ -7,13 +7,10 @@ package com.navi.uitron.render -import android.util.Size import androidx.compose.foundation.text.BasicText import androidx.compose.foundation.text.ClickableText import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.Color @@ -36,9 +33,9 @@ import com.navi.uitron.model.ui.SpannableProperty import com.navi.uitron.model.ui.TextProperty import com.navi.uitron.modifer.ModifierBuilder import com.navi.uitron.utils.EMPTY +import com.navi.uitron.utils.UiTronBrush import com.navi.uitron.utils.alfredMaskSensitiveComposable import com.navi.uitron.utils.clip -import com.navi.uitron.utils.getBrush import com.navi.uitron.utils.getText import com.navi.uitron.utils.getTextAlignment import com.navi.uitron.utils.getTextDecoration @@ -48,7 +45,6 @@ import com.navi.uitron.utils.isNotNull import com.navi.uitron.utils.orFalse import com.navi.uitron.utils.orTrue import com.navi.uitron.utils.setBackground -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setPadding import com.navi.uitron.utils.setTag import com.navi.uitron.viewmodel.UiTronViewModel @@ -91,9 +87,6 @@ class SpannableTextRenderer : Renderer { // ifVisible if (property.visible.orTrue()) { val text = java.lang.StringBuilder() - val textHeight = remember { mutableIntStateOf(0) } - val textWidth = remember { mutableIntStateOf(0) } - val textComponentSize = Size(textWidth.intValue, textHeight.intValue) val textStyle = TextStyle( textAlign = getTextAlignment(property.textAlign), @@ -103,19 +96,14 @@ class SpannableTextRenderer : Renderer { // Animate val animatedProperties = - property.animate?.let { - createAnimationProperty( - composableDimension = textComponentSize, - baseProperty = property - ) - } ?: AnimatedProperties() + property.animate?.let { createAnimationProperty(baseProperty = property) } + ?: AnimatedProperties() val textModifier = if (UiTronSdkManager.isModifierBuilderEnabled()) { ModifierBuilder(modifier ?: Modifier, property, uiTronData, uiTronViewModel) .apply { setIdModifiers() - setOnGloballyPositioned(textWidth, textHeight) setBorderModifiers() setEffectModifiers() } @@ -124,18 +112,16 @@ class SpannableTextRenderer : Renderer { (modifier ?: Modifier) .setTag(property) .layoutId(property.layoutId.orEmpty()) - .setOnGloballyPosition(property.animate, textWidth, textHeight) .setPadding(property.margin) .setBackground( property.backgroundColor, property.shape, property.backGroundBrushData, - animatedProperties, - textComponentSize + animatedProperties ) .clip(property.clipShape) .setPadding(property.padding) - .alpha(animatedProperties.alpha ?: property.alpha ?: 1.0f) + .alpha(animatedProperties.alpha?.value ?: property.alpha ?: 1.0f) .alfredMaskSensitiveComposable( isSensitive = property.isSensitive.orFalse(), rootView = rootView, @@ -147,15 +133,7 @@ class SpannableTextRenderer : Renderer { // Build Spannable val annotatedString = - buildSpannable( - animatedProperties, - brushData, - spannableData, - spanProperties, - text, - textHeight.intValue, - textWidth.intValue - ) + buildSpannable(animatedProperties, brushData, spannableData, spanProperties, text) // Render if (spannableData?.textMap.isNotNull()) { @@ -186,14 +164,13 @@ class SpannableTextRenderer : Renderer { } } + @Composable private fun buildSpannable( animatedProperties: AnimatedProperties?, brushData: BrushData?, spannableData: SpannableTextData?, spanProperties: List, - text: StringBuilder, - textHeight: Int, - textWidth: Int, + text: StringBuilder ) = buildAnnotatedString { spannableData?.let { data -> data.textMap?.let { textMap -> @@ -209,8 +186,6 @@ class SpannableTextRenderer : Renderer { getSpanTextStyle( brushData, spanProperty.property, - textHeight, - textWidth, animatedProperties ), start = start, @@ -239,8 +214,6 @@ class SpannableTextRenderer : Renderer { getSpanTextStyle( brushData, spanProperty.property, - textHeight, - textWidth, animatedProperties ) ) { @@ -253,8 +226,6 @@ class SpannableTextRenderer : Renderer { getSpanTextStyle( brushData, spanProperty.property, - textHeight, - textWidth, animatedProperties ) ) { @@ -267,11 +238,10 @@ class SpannableTextRenderer : Renderer { } } + @Composable private fun getSpanTextStyle( brushData: BrushData? = null, textProperty: TextProperty, - textHeight: Int?, - textWidth: Int?, animatedProperties: AnimatedProperties? ): SpanStyle { val uiTronDependencyProvider = UiTronSdkManager.getDependencyProvider() @@ -282,12 +252,11 @@ class SpannableTextRenderer : Renderer { fontSize = textProperty.fontSize?.sp ?: 14.sp, brush = brushData?.let { - getBrush( - animatedProperties = animatedProperties, - brushData = it, - height = textHeight?.toFloat(), - width = textWidth?.toFloat() - ) + UiTronBrush( + it, + animatedProperties, + ) + .getBrush() }, textDecoration = getTextDecoration(textProperty.textDecoration), letterSpacing = textProperty.letterSpacing?.sp ?: 0.sp, diff --git a/navi-uitron/src/main/java/com/navi/uitron/render/TextRenderer.kt b/navi-uitron/src/main/java/com/navi/uitron/render/TextRenderer.kt index 84a5d20..4e99e9b 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/render/TextRenderer.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/render/TextRenderer.kt @@ -7,12 +7,9 @@ package com.navi.uitron.render -import android.util.Size import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.geometry.Offset @@ -37,13 +34,13 @@ import com.navi.uitron.modifer.TextModifierBuilder import com.navi.uitron.utils.KEY_MVEL_ACTION import com.navi.uitron.utils.KEY_PROPERTY import com.navi.uitron.utils.KEY_UI_TRON_DATA +import com.navi.uitron.utils.UiTronBrush import com.navi.uitron.utils.alfredMaskSensitiveComposable import com.navi.uitron.utils.clip import com.navi.uitron.utils.customClickable import com.navi.uitron.utils.customCombinedClick import com.navi.uitron.utils.customOffset import com.navi.uitron.utils.dpToPx -import com.navi.uitron.utils.getBrush import com.navi.uitron.utils.getText import com.navi.uitron.utils.getTextAlignment import com.navi.uitron.utils.getTextDecoration @@ -58,7 +55,6 @@ import com.navi.uitron.utils.setBackground import com.navi.uitron.utils.setBlur import com.navi.uitron.utils.setHeight import com.navi.uitron.utils.setHeightRange -import com.navi.uitron.utils.setOnGloballyPosition import com.navi.uitron.utils.setPadding import com.navi.uitron.utils.setTag import com.navi.uitron.utils.setWidth @@ -112,16 +108,9 @@ class TextRenderer : Renderer { } if (property.visible.orTrue()) { val rootView = LocalView.current.rootView - val textHeight = remember { mutableIntStateOf(0) } - val textWidth = remember { mutableIntStateOf(0) } - val textComponentSize = Size(textWidth.intValue, textHeight.intValue) val animatedProperties = - property.animate?.let { - createAnimationProperty( - composableDimension = textComponentSize, - baseProperty = property - ) - } ?: AnimatedProperties() + property.animate?.let { createAnimationProperty(baseProperty = property) } + ?: AnimatedProperties() Text( text = (getTransformedText( @@ -135,9 +124,11 @@ class TextRenderer : Renderer { fontWeight = UiTronSdkManager.getDependencyProvider().getFontWeight(property.fontWeight), fontSize = - animatedProperties.fontSize?.sp ?: property.fontSize?.sp ?: defaultFontSize, + animatedProperties.fontSize?.value?.sp + ?: property.fontSize?.sp + ?: defaultFontSize, color = - animatedProperties.textColor + animatedProperties.textColor?.value ?: property.textColor?.hexToComposeColor ?: Color.Black, textDecoration = getTextDecoration(property.textDecoration), @@ -151,12 +142,8 @@ class TextRenderer : Renderer { TextStyle( brush = property.textBrushData?.let { - getBrush( - it, - width = textWidth.intValue.toFloat(), - height = textHeight.intValue.toFloat(), - animatedProperties = animatedProperties - ) + UiTronBrush(brushData = it, animatedProperties = animatedProperties) + .getBrush() }, fontStyle = getFontStyle(property.fontStyle), shadow = @@ -182,14 +169,11 @@ class TextRenderer : Renderer { property, uiTronTextData, uiTronViewModel, - animatedProperties, - textWidth, - textHeight + animatedProperties ) .build() } else { (modifier ?: Modifier) - .setOnGloballyPosition(property.animate, textWidth, textHeight) .customOffset(property.offset) .setWidth(property.width) .setHeight(property.height) @@ -205,8 +189,7 @@ class TextRenderer : Renderer { animatedProperties.backgroundColor ?: property.backgroundColor, property.shape, property.backGroundBrushData, - animatedProperties, - textComponentSize + animatedProperties ) .clip(property.clipShape) .setPadding(property.padding) @@ -220,7 +203,7 @@ class TextRenderer : Renderer { .customCombinedClick(property, uiTronTextData) { uiTronViewModel.handleActions(it) } - .alpha(animatedProperties.alpha ?: property.alpha ?: 1.0f) + .alpha(animatedProperties.alpha?.value ?: property.alpha ?: 1.0f) .setBlur(property.blurData) .alfredMaskSensitiveComposable( isSensitive = property.isSensitive.orFalse(), diff --git a/navi-uitron/src/main/java/com/navi/uitron/utils/Ext.kt b/navi-uitron/src/main/java/com/navi/uitron/utils/Ext.kt index 73bea47..648f7c9 100644 --- a/navi-uitron/src/main/java/com/navi/uitron/utils/Ext.kt +++ b/navi-uitron/src/main/java/com/navi/uitron/utils/Ext.kt @@ -11,7 +11,6 @@ import KeyboardUtil import android.annotation.SuppressLint import android.content.Context import android.content.res.Resources -import android.util.Size import android.view.Gravity import android.view.View import androidx.compose.animation.core.LinearEasing @@ -53,7 +52,6 @@ import androidx.compose.material3.FloatingActionButtonDefaults import androidx.compose.material3.FloatingActionButtonElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.MutableIntState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableLongStateOf import androidx.compose.runtime.mutableStateOf @@ -109,7 +107,6 @@ import com.navi.uitron.model.ui.BlurType import com.navi.uitron.model.ui.BorderStrokeData import com.navi.uitron.model.ui.BoxConstraints import com.navi.uitron.model.ui.BrushData -import com.navi.uitron.model.ui.BrushType import com.navi.uitron.model.ui.ButtonProperty import com.navi.uitron.model.ui.ColumnConstraints import com.navi.uitron.model.ui.ComposePadding @@ -457,19 +454,14 @@ fun Modifier.setBackground( backgroundColor: Any?, uiTronShape: UiTronShape?, brushData: BrushData?, - animatedProperties: AnimatedProperties? = null, - composableDimension: Size? = null + animatedProperties: AnimatedProperties? = null ): Modifier = composed { this.then( if (brushData != null) { background( brush = - getBrush( - animatedProperties = animatedProperties, - brushData = brushData, - width = composableDimension?.width?.toFloat(), - height = composableDimension?.height?.toFloat() - ), + UiTronBrush(brushData = brushData, animatedProperties = animatedProperties) + .getBrush(), shape = ShapeUtil.getShape(shape = uiTronShape) ) } else if (backgroundColor.isNotNull()) { @@ -477,7 +469,7 @@ fun Modifier.setBackground( color = when (backgroundColor) { is String -> backgroundColor.hexToComposeColor - is Color -> animatedProperties?.backgroundColor ?: backgroundColor + is Color -> animatedProperties?.backgroundColor?.value ?: backgroundColor else -> Color.Transparent }, shape = ShapeUtil.getShape(shape = uiTronShape) @@ -498,121 +490,6 @@ fun getTileMode(tileMode: String?): TileMode { } } -fun getBrush( - brushData: BrushData, - height: Float? = Float.POSITIVE_INFINITY, - width: Float? = Float.POSITIVE_INFINITY, - animatedProperties: AnimatedProperties? = null -): Brush { - val colorStops: Array>? = - brushData.colorStops?.map { Pair(it.first, it.second.hexToComposeColor) }?.toTypedArray() - - val finalColorStops = colorStops as Array> - - return when (brushData.brushType) { - BrushType.HORIZONTAL.name -> - horizontalBrush(finalColorStops, width, animatedProperties, brushData) - BrushType.LINEAR.name -> - linearBrush(finalColorStops, width, height, animatedProperties, brushData) - BrushType.RADIAL.name -> radialBrush(finalColorStops, brushData) - BrushType.SWEEP.name -> sweepBrush(finalColorStops, brushData) - BrushType.VERTICAL.name -> - verticalBrush(finalColorStops, height, animatedProperties, brushData) - else -> - Brush.verticalGradient( - colorStops = finalColorStops, - tileMode = getTileMode(brushData.tileMode) - ) - } -} - -private fun horizontalBrush( - colorStops: Array>, - width: Float?, - animatedProperties: AnimatedProperties?, - brushData: BrushData? -): Brush { - val startX = animatedProperties?.horizontalBrush - val endX = startX?.plus(width?.times(brushData?.horizontalEdge ?: 1f) ?: 0f) - return Brush.horizontalGradient( - colorStops = colorStops, - startX = startX ?: 0f, - endX = endX ?: Float.POSITIVE_INFINITY, - tileMode = getTileMode(brushData?.tileMode) - ) -} - -private fun verticalBrush( - colorStops: Array>, - height: Float?, - animatedProperties: AnimatedProperties?, - brushData: BrushData? -): Brush { - val startY = animatedProperties?.verticalBrush - val endY = startY?.plus(height?.times(brushData?.verticalEdge ?: 1f) ?: 0f) - return Brush.verticalGradient( - colorStops = colorStops, - startY = startY ?: 0f, - endY = endY ?: Float.POSITIVE_INFINITY, - tileMode = getTileMode(brushData?.tileMode) - ) -} - -private fun linearBrush( - colorStops: Array>, - width: Float?, - height: Float?, - animatedProperties: AnimatedProperties?, - brushData: BrushData? -): Brush { - val startOffset = - Offset( - x = brushData?.startOffSetData?.x ?: animatedProperties?.linearBrush?.x ?: 0f, - y = brushData?.startOffSetData?.y ?: animatedProperties?.linearBrush?.y ?: 0f - ) - val endOffset = - Offset( - x = - brushData?.endOffSetData?.x - ?: width?.times(brushData?.horizontalEdge ?: 1f) - ?: Float.POSITIVE_INFINITY, - y = - brushData?.endOffSetData?.y - ?: height?.times(brushData?.verticalEdge ?: 1f) - ?: Float.POSITIVE_INFINITY - ) - .plus( - Offset( - x = animatedProperties?.linearBrush?.x ?: 0f, - y = animatedProperties?.linearBrush?.y ?: 0f - ) - ) - return Brush.linearGradient( - colorStops = colorStops, - tileMode = getTileMode(brushData?.tileMode), - start = startOffset, - end = endOffset - ) -} - -private fun radialBrush(colorStops: Array>, brushData: BrushData?): Brush { - return Brush.radialGradient( - colorStops = colorStops, - tileMode = getTileMode(brushData?.tileMode), - center = - Offset(brushData?.offSetData?.x ?: Float.NaN, brushData?.offSetData?.y ?: Float.NaN), - radius = brushData?.radius ?: Float.POSITIVE_INFINITY - ) -} - -private fun sweepBrush(colorStops: Array>, brushData: BrushData?): Brush { - return Brush.sweepGradient( - colorStops = colorStops, - center = - Offset(brushData?.offSetData?.x ?: Float.NaN, brushData?.offSetData?.y ?: Float.NaN) - ) -} - @Composable fun setButtonElevation(property: ButtonProperty): ButtonElevation { return if (property.elevation.isNull()) { @@ -911,35 +788,32 @@ fun BoxScope.boxConstraintsToModifier(boxConstraints: BoxConstraints?): Modifier } } +@Composable fun getBorderStrokeBrushData( borderStrokeData: BorderStrokeData?, - animatedProperties: AnimatedProperties? = null, - composableDimension: Size? = null + animatedProperties: AnimatedProperties? = null ): Brush { return when { borderStrokeData?.color?.hexToComposeColor != null -> SolidColor(borderStrokeData.color?.hexToComposeColor ?: Color.White) borderStrokeData?.brushData != null -> - getBrush( - borderStrokeData.brushData, - animatedProperties = animatedProperties, - width = composableDimension?.width?.toFloat(), - height = composableDimension?.height?.toFloat() - ) + UiTronBrush( + brushData = borderStrokeData.brushData, + animatedProperties = animatedProperties + ) + .getBrush() else -> SolidColor(Color.Transparent) } } fun Modifier.setBorderStroke( borderStrokeData: BorderStrokeData?, - animatedProperties: AnimatedProperties? = null, - composableDimension: Size? = null + animatedProperties: AnimatedProperties? = null ): Modifier = composed { this.then( border( width = borderStrokeData?.width?.dp ?: 0.dp, - brush = - getBorderStrokeBrushData(borderStrokeData, animatedProperties, composableDimension), + brush = getBorderStrokeBrushData(borderStrokeData, animatedProperties), shape = ShapeUtil.getShape(shape = borderStrokeData?.shape) ) ) @@ -971,15 +845,15 @@ fun Modifier.setAnimatedGraphicsLayer( conditional(animatedProperties != null && animate.isNotNull()) { graphicsLayer { animatedProperties?.let { - scaleX = it.scaleX ?: 1f - scaleY = it.scaleY ?: 1f - alpha = it.alpha ?: 1f - rotationX = it.rotationX ?: 0f - rotationY = it.rotationY ?: 0f - rotationZ = it.rotationZ ?: 0f - translationX = it.translationX ?: 0f - translationY = it.translationY ?: 0f - shadowElevation = it.shadowElevation ?: 0f + scaleX = it.scaleX?.value ?: 1f + scaleY = it.scaleY?.value ?: 1f + alpha = it.alpha?.value ?: 1f + rotationX = it.rotationX?.value ?: 0f + rotationY = it.rotationY?.value ?: 0f + rotationZ = it.rotationZ?.value ?: 0f + translationX = it.translationX?.value?.dp?.toPx() ?: 0f + translationY = it.translationY?.value?.dp?.toPx() ?: 0f + shadowElevation = it.shadowElevation?.value?.dp?.toPx() ?: 0f } transformOrigin?.let { this.transformOrigin = @@ -991,18 +865,6 @@ fun Modifier.setAnimatedGraphicsLayer( } } -fun Modifier.setOnGloballyPosition( - animate: Animate? = null, - width: MutableIntState?, - height: MutableIntState? -): Modifier = - conditional(animate.isNotNull()) { - onGloballyPositioned { - width?.intValue = it.size.width - height?.intValue = it.size.height - } - } - fun getBlurEdgeTreatment(edgeTreatment: String?): BlurredEdgeTreatment { return when (edgeTreatment) { BlurType.Rectangle.name -> BlurredEdgeTreatment.Rectangle @@ -1021,14 +883,6 @@ fun String.isInvalidInput(invalidCharRegex: String?): Boolean { return matcher.find() } -fun String.toNearestInt(): Int { - return try { - toFloat().roundToInt() - } catch (e: Exception) { - 0 - } -} - fun Float.toNearestInt(): Int { return try { roundToInt() @@ -1148,9 +1002,9 @@ inline fun Any?.appendIndexToLayoutId(index: Int, gson: Gson): T? { val key = iterator.next() when (val value = currentObject.opt(key)) { is JSONArray -> { - (0 until value.length()).forEach { index -> - if (value.opt(index) is JSONObject) { - val childObject = value.optJSONObject(index) + (0 until value.length()).forEach { arrIndex -> + if (value.opt(arrIndex) is JSONObject) { + val childObject = value.optJSONObject(arrIndex) stack.push(childObject) } } diff --git a/navi-uitron/src/main/java/com/navi/uitron/utils/UiTronBrush.kt b/navi-uitron/src/main/java/com/navi/uitron/utils/UiTronBrush.kt new file mode 100644 index 0000000..ff5f0b8 --- /dev/null +++ b/navi-uitron/src/main/java/com/navi/uitron/utils/UiTronBrush.kt @@ -0,0 +1,208 @@ +/* + * + * * Copyright © 2024 by Navi Technologies Limited + * * All rights reserved. Strictly confidential + * + */ + +package com.navi.uitron.utils + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.State +import androidx.compose.runtime.remember +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.LinearGradientShader +import androidx.compose.ui.graphics.RadialGradientShader +import androidx.compose.ui.graphics.Shader +import androidx.compose.ui.graphics.ShaderBrush +import androidx.compose.ui.graphics.SweepGradientShader +import com.navi.uitron.model.animations.AnimatedProperties +import com.navi.uitron.model.ui.BrushData +import com.navi.uitron.model.ui.BrushType +import com.navi.uitron.model.ui.OffSetData + +class UiTronBrush( + private val brushData: BrushData?, + private val animatedProperties: AnimatedProperties? = null +) { + /** + * This method is used to get the brush based on the brush type + * + * @return ShaderBrush + */ + @Composable + fun getBrush() = + when (brushData?.brushType) { + BrushType.HORIZONTAL.name -> + if (animatedProperties.isNull()) getHorizontalBrush() + else getAnimatedHorizontalBrush { animatedProperties?.horizontalBrush } + BrushType.VERTICAL.name -> + if (animatedProperties.isNull()) getVerticalBrush() + else getAnimatedVerticalBrush { animatedProperties?.verticalBrush } + BrushType.LINEAR.name -> + if (animatedProperties.isNull()) getLinearBrush() + else getAnimatedLinearBrush { animatedProperties?.linearBrush } + BrushType.RADIAL.name -> getRadialBrush(brushData.offSetData, brushData.radius) + BrushType.SWEEP.name -> getSweepBrush(brushData.offSetData) + else -> getVerticalBrush() + } + + @Composable + internal fun getHorizontalBrush() = remember { + object : ShaderBrush() { + override fun createShader(size: Size): Shader { + return LinearGradientShader( + colors = gradientColors, + colorStops = gradientColorStops, + from = Offset.Zero, + to = Offset(size.width.times(gradientWidthMultiplier), 0f), + tileMode = tileMode + ) + } + } + } + + @Composable + internal fun getAnimatedHorizontalBrush(animatedHorizontalBrush: () -> State?) = + remember(animatedHorizontalBrush()?.value) { + object : ShaderBrush() { + override fun createShader(size: Size): Shader { + val widthOffset = size.width * (animatedHorizontalBrush()?.value ?: 0f) + return LinearGradientShader( + colors = gradientColors, + colorStops = gradientColorStops, + from = Offset(widthOffset, 0f), + to = + Offset(widthOffset.plus(size.width.times(gradientWidthMultiplier)), 0f), + tileMode = tileMode + ) + } + } + } + + @Composable + internal fun getVerticalBrush() = remember { + object : ShaderBrush() { + override fun createShader(size: Size): Shader { + return LinearGradientShader( + colors = gradientColors, + colorStops = gradientColorStops, + from = Offset.Zero, + to = Offset(0f, size.height.times(gradientHeightMultiplier)), + tileMode = tileMode + ) + } + } + } + + @Composable + internal fun getAnimatedVerticalBrush(animatedVerticalBrush: () -> State?) = + remember(animatedVerticalBrush()?.value) { + object : ShaderBrush() { + override fun createShader(size: Size): Shader { + val heightOffset = size.height * (animatedVerticalBrush()?.value ?: 0f) + return LinearGradientShader( + colors = gradientColors, + colorStops = gradientColorStops, + from = Offset(0f, heightOffset), + to = + Offset( + 0f, + heightOffset.plus(size.height.times(gradientHeightMultiplier)) + ), + tileMode = tileMode + ) + } + } + } + + @Composable + internal fun getLinearBrush() = remember { + object : ShaderBrush() { + override fun createShader(size: Size): Shader { + return LinearGradientShader( + colors = gradientColors, + colorStops = gradientColorStops, + from = + Offset( + brushData?.startOffSetData?.x ?: 0f, + brushData?.startOffSetData?.y ?: 0f + ), + to = + Offset( + brushData?.endOffSetData?.x + ?: size.width.times(gradientWidthMultiplier), + brushData?.endOffSetData?.y + ?: size.height.times(gradientHeightMultiplier) + ), + tileMode = tileMode + ) + } + } + } + + @Composable + internal fun getAnimatedLinearBrush(animatedLinearBrush: () -> State?) = + remember(animatedLinearBrush()?.value) { + object : ShaderBrush() { + override fun createShader(size: Size): Shader { + val widthOffset = size.width * (animatedLinearBrush()?.value?.x ?: 0f) + val heightOffset = size.height * (animatedLinearBrush()?.value?.y ?: 0f) + return LinearGradientShader( + colors = gradientColors, + colorStops = gradientColorStops, + from = Offset(widthOffset, heightOffset), + to = + Offset( + widthOffset.plus(size.width.times(gradientWidthMultiplier)), + heightOffset.plus(size.height.times(gradientHeightMultiplier)) + ), + tileMode = tileMode + ) + } + } + } + + @Composable + internal fun getSweepBrush(center: OffSetData?) = remember { + object : ShaderBrush() { + override fun createShader(size: Size): Shader { + return SweepGradientShader( + colors = gradientColors, + colorStops = gradientColorStops, + center = Offset(center?.x ?: (size.width / 2), center?.y ?: (size.height / 2)) + ) + } + } + } + + @Composable + internal fun getRadialBrush(offSetData: OffSetData?, radius: Float?) = remember { + object : ShaderBrush() { + override fun createShader(size: Size): Shader { + return RadialGradientShader( + colors = gradientColors, + colorStops = gradientColorStops, + center = + Offset( + offSetData?.x ?: (size.width / 2), + offSetData?.y ?: (size.height / 2) + ), + radius = radius ?: (size.width / 2), + tileMode = tileMode + ) + } + } + } + + private val colorData: Array>? = + brushData?.colorStops?.map { Pair(it.first, it.second.hexToComposeColor) }?.toTypedArray() + private val processedColorStops = colorData as Array> + private val tileMode = getTileMode(brushData?.tileMode) + private val gradientColors = processedColorStops.map { it.second } + private val gradientColorStops = processedColorStops.map { it.first } + private val gradientWidthMultiplier = brushData?.horizontalEdge ?: 1f + private val gradientHeightMultiplier = brushData?.verticalEdge ?: 1f +}