diff --git a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/Popover.kt b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/Popover.kt index defa0b7065..99a7e63db4 100644 --- a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/Popover.kt +++ b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/Popover.kt @@ -80,7 +80,7 @@ fun Popover( show = show, onDismissRequest = onDismissRequest, triggerInfo = { triggerInfo }, - shape = style.shape, + shape = style.shapes, shadow = style.shadow, dimensions = style.dimensions, colors = style.colors, @@ -145,7 +145,7 @@ fun Popover( show = show, onDismissRequest = onDismissRequest, triggerInfo = { triggerInfo }, - shape = style.shape, + shape = style.shapes, shadow = style.shadow, dimensions = style.dimensions, colors = style.colors, diff --git a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/PopoverStyle.kt b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/PopoverStyle.kt index e6e28cdc6d..32eb582b2e 100644 --- a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/PopoverStyle.kt +++ b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/PopoverStyle.kt @@ -11,7 +11,10 @@ import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.sdds.api.info.compose.ApiInfo +import com.sdds.compose.uikit.graphics.brush.asStatefulBrush +import com.sdds.compose.uikit.interactions.InteractiveColor import com.sdds.compose.uikit.interactions.StatefulValue +import com.sdds.compose.uikit.interactions.asStatefulBrush import com.sdds.compose.uikit.interactions.asStatefulValue import com.sdds.compose.uikit.shadow.ShadowAppearance import com.sdds.compose.uikit.style.Style @@ -31,8 +34,14 @@ interface PopoverStyle : Style { /** * Форма компонента */ + @Deprecated("use shapes", replaceWith = ReplaceWith("shapes")) val shape: CornerBasedShape + /** + * Формы компонента + */ + val shapes: StatefulValue + /** * Тень компонента */ @@ -65,7 +74,13 @@ interface PopoverStyleBuilder : StyleBuilder { /** * Устанавливает форму [shape] компонента */ - fun shape(shape: CornerBasedShape): PopoverStyleBuilder + fun shape(shape: CornerBasedShape): PopoverStyleBuilder = + shape(shape.asStatefulValue()) + + /** + * Устанавливает форму [shape] компонента + */ + fun shape(shape: StatefulValue): PopoverStyleBuilder /** * Устанавливает тень [shadow] компонента @@ -86,20 +101,22 @@ interface PopoverStyleBuilder : StyleBuilder { } private class DefaultPopoverStyle( - override val shape: CornerBasedShape, + override val shapes: StatefulValue, override val shadow: ShadowAppearance, override val dimensions: PopoverDimensions, override val colors: PopoverColors, ) : PopoverStyle { + @Deprecated("use shapes", replaceWith = ReplaceWith("shapes")) + override val shape: CornerBasedShape = shapes.getDefaultValue() class Builder : PopoverStyleBuilder { - private var shape: CornerBasedShape? = null + private var shapes: StatefulValue? = null private var shadow: ShadowAppearance? = null private val colorsBuilder = PopoverColors.builder() private val dimensionsBuilder = PopoverDimensions.builder() - override fun shape(shape: CornerBasedShape) = apply { - this.shape = shape + override fun shape(shape: StatefulValue) = apply { + this.shapes = shape } override fun shadow(shadow: ShadowAppearance) = apply { @@ -119,7 +136,7 @@ private class DefaultPopoverStyle( override fun style(): PopoverStyle { return DefaultPopoverStyle( - shape = shape ?: RoundedCornerShape(15), + shapes = shapes ?: RoundedCornerShape(15).asStatefulValue(), shadow = shadow ?: ShadowAppearance(), colors = colorsBuilder.build(), dimensions = dimensionsBuilder.build(), @@ -152,6 +169,19 @@ interface PopoverColors { * Builder для [PopoverColors] */ interface PopoverColorsBuilder { + + /** + * Устанавливает фон [backgroundColor] компонента. + */ + fun backgroundColor(backgroundColor: Color): PopoverColorsBuilder = + backgroundColor(backgroundColor.asStatefulBrush()) + + /** + * Устанавливает фон [backgroundColor] компонента. + */ + fun backgroundColor(backgroundColor: InteractiveColor): PopoverColorsBuilder = + backgroundColor(backgroundColor.asStatefulBrush()) + /** * Устанавливает фон [backgroundColor] компонента. */ @@ -198,28 +228,58 @@ interface PopoverDimensions { /** * Минимальная ширина компонента */ + @Deprecated("use widthValues", replaceWith = ReplaceWith("widthValues")) val width: Dp + /** + * Минимальная ширина компонента + */ + val widthValues: StatefulValue + /** * Отступ до компонента */ + @Deprecated("use offsetValues", replaceWith = ReplaceWith("offsetValues")) val offset: Dp + /** + * Отступ до компонента + */ + val offsetValues: StatefulValue + /** * Ширина указателя */ + @Deprecated("use tailWidthValues", replaceWith = ReplaceWith("tailWidthValues")) val tailWidth: Dp + /** + * Ширина указателя + */ + val tailWidthValues: StatefulValue + /** * Высота указателя */ + @Deprecated("use tailHeightValues", replaceWith = ReplaceWith("tailHeightValues")) val tailHeight: Dp + /** + * Высота указателя + */ + val tailHeightValues: StatefulValue + /** * Отступ указателя */ + @Deprecated("use tailPaddingValues", replaceWith = ReplaceWith("tailPaddingValues")) val tailPadding: Dp + /** + * Отступ указателя + */ + val tailPaddingValues: StatefulValue + companion object { /** * Создает экземпляр [PopoverDimensionsBuilder] @@ -235,27 +295,52 @@ interface PopoverDimensionsBuilder { /** * Устанавливает минимальную ширину [width] компонента. */ - fun width(width: Dp): PopoverDimensionsBuilder + fun width(width: Dp): PopoverDimensionsBuilder = width(width.asStatefulValue()) + + /** + * Устанавливает минимальную ширину [width] компонента. + */ + fun width(width: StatefulValue): PopoverDimensionsBuilder /** * Устанавливает смещение [offset] компонента относительно триггера. */ - fun offset(offset: Dp): PopoverDimensionsBuilder + fun offset(offset: Dp): PopoverDimensionsBuilder = offset(offset.asStatefulValue()) + + /** + * Устанавливает смещение [offset] компонента относительно триггера. + */ + fun offset(offset: StatefulValue): PopoverDimensionsBuilder + + /** + * Устанавливает ширину [tailWidth] указателя. + */ + fun tailWidth(tailWidth: Dp): PopoverDimensionsBuilder = tailWidth(tailWidth.asStatefulValue()) /** * Устанавливает ширину [tailWidth] указателя. */ - fun tailWidth(tailWidth: Dp): PopoverDimensionsBuilder + fun tailWidth(tailWidth: StatefulValue): PopoverDimensionsBuilder + + /** + * Устанавливает высоту [tailHeight] указателя. + */ + fun tailHeight(tailHeight: Dp): PopoverDimensionsBuilder = tailHeight(tailHeight.asStatefulValue()) /** * Устанавливает высоту [tailHeight] указателя. */ - fun tailHeight(tailHeight: Dp): PopoverDimensionsBuilder + fun tailHeight(tailHeight: StatefulValue): PopoverDimensionsBuilder /** * Устанавливает отступ [tailPadding] указателя относительно края компонента. */ - fun tailPadding(tailPadding: Dp): PopoverDimensionsBuilder + fun tailPadding(tailPadding: Dp): PopoverDimensionsBuilder = tailPadding(tailPadding.asStatefulValue()) + + /** + * Устанавливает отступ [tailPadding] указателя относительно края компонента. + */ + fun tailPadding(tailPadding: StatefulValue): PopoverDimensionsBuilder /** * Создает экземпляр [PopoverDimensions] @@ -264,48 +349,63 @@ interface PopoverDimensionsBuilder { } private class DefaultPopoverDimensions( - override val width: Dp, - override val offset: Dp, - override val tailWidth: Dp, - override val tailHeight: Dp, - override val tailPadding: Dp, + override val widthValues: StatefulValue, + override val offsetValues: StatefulValue, + override val tailWidthValues: StatefulValue, + override val tailHeightValues: StatefulValue, + override val tailPaddingValues: StatefulValue, + ) : PopoverDimensions { + @Deprecated("use widthValues", replaceWith = ReplaceWith("widthValues")) + override val width: Dp = widthValues.getDefaultValue() + + @Deprecated("use offsetValues", replaceWith = ReplaceWith("offsetValues")) + override val offset: Dp = offsetValues.getDefaultValue() + + @Deprecated("use tailWidthValues", replaceWith = ReplaceWith("tailWidthValues")) + override val tailWidth: Dp = tailWidthValues.getDefaultValue() + + @Deprecated("use tailHeightValues", replaceWith = ReplaceWith("tailHeightValues")) + override val tailHeight: Dp = tailHeightValues.getDefaultValue() + + @Deprecated("use tailPaddingValues", replaceWith = ReplaceWith("tailPaddingValues")) + override val tailPadding: Dp = tailPaddingValues.getDefaultValue() class Builder : PopoverDimensionsBuilder { - private var width: Dp? = null - private var offset: Dp? = null - private var tailWidth: Dp? = null - private var tailHeight: Dp? = null - private var tailPadding: Dp? = null + private var width: StatefulValue? = null + private var offset: StatefulValue? = null + private var tailWidth: StatefulValue? = null + private var tailHeight: StatefulValue? = null + private var tailPadding: StatefulValue? = null - override fun width(width: Dp) = apply { + override fun width(width: StatefulValue) = apply { this.width = width } - override fun offset(offset: Dp) = apply { + override fun offset(offset: StatefulValue) = apply { this.offset = offset } - override fun tailWidth(tailWidth: Dp) = apply { + override fun tailWidth(tailWidth: StatefulValue) = apply { this.tailWidth = tailWidth } - override fun tailHeight(tailHeight: Dp) = apply { + override fun tailHeight(tailHeight: StatefulValue) = apply { this.tailHeight = tailHeight } - override fun tailPadding(tailPadding: Dp) = apply { + override fun tailPadding(tailPadding: StatefulValue) = apply { this.tailPadding = tailPadding } override fun build(): PopoverDimensions { return DefaultPopoverDimensions( - width = width ?: 40.dp, - offset = offset ?: 0.dp, - tailWidth = tailWidth ?: 20.dp, - tailHeight = tailHeight ?: 8.dp, - tailPadding = tailPadding ?: 10.dp, + widthValues = width ?: 40.dp.asStatefulValue(), + offsetValues = offset ?: 0.dp.asStatefulValue(), + tailWidthValues = tailWidth ?: 20.dp.asStatefulValue(), + tailHeightValues = tailHeight ?: 8.dp.asStatefulValue(), + tailPaddingValues = tailPadding ?: 10.dp.asStatefulValue(), ) } } diff --git a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/Tooltip.kt b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/Tooltip.kt index d6ccb129a9..c4c84636f3 100644 --- a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/Tooltip.kt +++ b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/Tooltip.kt @@ -18,6 +18,7 @@ import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.PopupProperties +import com.sdds.compose.uikit.interactions.asStatefulValue import com.sdds.compose.uikit.interactions.getValue import com.sdds.compose.uikit.internal.common.StyledText import com.sdds.compose.uikit.internal.popover.BasePopover @@ -75,7 +76,7 @@ fun Tooltip( triggerInfo = triggerInfo, dimensions = style.dimensions.toPopoverDimensions(), colors = style.colors.toPopoverColors(), - shape = style.shape, + shape = style.shape.asStatefulValue(), shadow = style.shadow, placement = placement, placementMode = placementMode, @@ -121,11 +122,25 @@ fun Tooltip( private fun TooltipDimensions.toPopoverDimensions(offset: Dp = this.offset): PopoverDimensions { return object : PopoverDimensions { - override val width = 0.dp - override val offset = offset - override val tailWidth = this@toPopoverDimensions.tailWidth - override val tailHeight = this@toPopoverDimensions.tailHeight - override val tailPadding = this@toPopoverDimensions.tailPadding + @Deprecated("use widthValues", replaceWith = ReplaceWith("widthValues")) + override val width: Dp = 0.dp + override val widthValues = width.asStatefulValue() + + @Deprecated("use offsetValues", replaceWith = ReplaceWith("offsetValues")) + override val offset: Dp = offset + override val offsetValues = this.offset.asStatefulValue() + + @Deprecated("use tailWidthValues", replaceWith = ReplaceWith("tailWidthValues")) + override val tailWidth: Dp = this@toPopoverDimensions.tailWidth + override val tailWidthValues = this.tailWidth.asStatefulValue() + + @Deprecated("use tailHeightValues", replaceWith = ReplaceWith("tailHeightValues")) + override val tailHeight: Dp = this@toPopoverDimensions.tailHeight + override val tailHeightValues = this.tailHeight.asStatefulValue() + + @Deprecated("use tailPaddingValues", replaceWith = ReplaceWith("tailPaddingValues")) + override val tailPadding: Dp = this@toPopoverDimensions.tailPadding + override val tailPaddingValues = this.tailPadding.asStatefulValue() } } diff --git a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/internal/dropdownmenu/BaseDropdownMenu.kt b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/internal/dropdownmenu/BaseDropdownMenu.kt index 03b4e62845..8cf01d88a1 100644 --- a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/internal/dropdownmenu/BaseDropdownMenu.kt +++ b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/internal/dropdownmenu/BaseDropdownMenu.kt @@ -56,6 +56,8 @@ import com.sdds.compose.uikit.graphics.cutout.ProvideCutoutState import com.sdds.compose.uikit.graphics.cutout.cutout import com.sdds.compose.uikit.graphics.cutout.cutoutTarget import com.sdds.compose.uikit.graphics.cutout.rememberCutoutState +import com.sdds.compose.uikit.interactions.StatefulValue +import com.sdds.compose.uikit.interactions.asStatefulValue import com.sdds.compose.uikit.interactions.getValueAsState import com.sdds.compose.uikit.internal.heightOrZero import com.sdds.compose.uikit.internal.modal.EdgeToEdgeDialog @@ -140,7 +142,7 @@ internal fun BaseDropdownMenu( triggerInfo = triggerInfo, colors = style.colors.toPopoverColors(), dimensions = style.dimensions.toPopoverDimensions(offset), - shape = style.shape, + shape = style.shape.asStatefulValue(), shadow = style.shadow, placement = placement, placementMode = placementMode, @@ -418,11 +420,25 @@ private fun ScrollableContentWithHeaderFooter( private fun DropdownMenuDimensions.toPopoverDimensions(offset: Dp = this.offset): PopoverDimensions { return object : PopoverDimensions { + @Deprecated("use widthValues", replaceWith = ReplaceWith("widthValues")) override val width = this@toPopoverDimensions.width + override val widthValues: StatefulValue = this.width.asStatefulValue() + + @Deprecated("use offsetValues", replaceWith = ReplaceWith("offsetValues")) override val offset = offset + override val offsetValues: StatefulValue = this.offset.asStatefulValue() + + @Deprecated("use tailWidthValues", replaceWith = ReplaceWith("tailWidthValues")) override val tailWidth = 0.dp + override val tailWidthValues: StatefulValue = this.tailWidth.asStatefulValue() + + @Deprecated("use tailHeightValues", replaceWith = ReplaceWith("tailHeightValues")) override val tailHeight = 0.dp + override val tailHeightValues: StatefulValue = this.tailHeight.asStatefulValue() + + @Deprecated("use tailPaddingValues", replaceWith = ReplaceWith("tailPaddingValues")) override val tailPadding = 0.dp + override val tailPaddingValues: StatefulValue = this.tailPadding.asStatefulValue() } } diff --git a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/internal/popover/BasePopover.kt b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/internal/popover/BasePopover.kt index 53e5c9c900..7cb83ce86f 100644 --- a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/internal/popover/BasePopover.kt +++ b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/internal/popover/BasePopover.kt @@ -34,7 +34,6 @@ import androidx.compose.ui.draw.CacheDrawScope import androidx.compose.ui.draw.drawWithCache import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Rect -import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Matrix import androidx.compose.ui.graphics.Path import androidx.compose.ui.graphics.PathOperation @@ -63,10 +62,13 @@ import com.sdds.compose.uikit.PopoverPlacement.Companion.TopFallbacks import com.sdds.compose.uikit.PopoverPlacementMode import com.sdds.compose.uikit.PopoverPositionStrategy import com.sdds.compose.uikit.TriggerInfo +import com.sdds.compose.uikit.graphics.brush.BrushProducer +import com.sdds.compose.uikit.interactions.StatefulValue import com.sdds.compose.uikit.interactions.getValue import com.sdds.compose.uikit.internal.plus import com.sdds.compose.uikit.motion.Motion -import com.sdds.compose.uikit.motion.MotionStyle +import com.sdds.compose.uikit.motion.components.popover.PopoverMotionStyle +import com.sdds.compose.uikit.motion.getBrushAsState import com.sdds.compose.uikit.px import com.sdds.compose.uikit.shadow.ShadowAppearance import com.sdds.compose.uikit.shadow.getShadowSafePaddings @@ -83,7 +85,7 @@ internal fun BasePopover( clipHeight: Boolean = false, clipWidth: Boolean = false, triggerInfo: () -> TriggerInfo, - shape: CornerBasedShape, + shape: StatefulValue, shadow: ShadowAppearance, dimensions: PopoverDimensions, colors: PopoverColors, @@ -97,23 +99,32 @@ internal fun BasePopover( popupProperties: PopupProperties, enterTransition: EnterTransition, exitTransition: ExitTransition, - motion: Motion, + motion: Motion, safeAreaPadding: PaddingValues, content: @Composable () -> Unit, ) { val popoverAnchor = rememberPopoverAnchor() val rootSize = rememberPopoverRootSize(popoverAnchor) - val tailHeight = dimensions.tailHeight - val tailWidth = dimensions.tailWidth - val tailPadding = dimensions.tailPadding - val offset = dimensions.offset + val tailHeight = dimensions.tailHeightValues.getValue( + motion.context.interactionSource, + motion.context.semanticStateSource, + ) + val tailWidth = dimensions.tailWidthValues.getValue( + motion.context.interactionSource, + motion.context.semanticStateSource, + ) + val tailPadding = dimensions.tailPaddingValues.getValue( + motion.context.interactionSource, + motion.context.semanticStateSource, + ) + val offset = dimensions.offsetValues.getValue(motion.context.interactionSource, motion.context.semanticStateSource) + val minWidth = dimensions.widthValues.getValue(motion.context.interactionSource, motion.context.semanticStateSource) val visibleState = remember { MutableTransitionState(false) } val currentTrigger = triggerInfo() val triggerReady = currentTrigger.visibleBoundsInScreen != null visibleState.targetState = show && triggerReady val popoverVisible = visibleState.currentState || visibleState.targetState || !visibleState.isIdle - - val backgroundColor = colors.backgroundColor.getValue(motion.context.interactionSource) + val backgroundColor = colors.backgroundColor.getBrushAsState(motion.context, motion.style.backgroundColor) var recalculatedConstraints by remember { mutableStateOf(null) } var popoverContentSize by remember { mutableStateOf(IntSize.Zero) } val constraintsUpdater = rememberDeferredConstraintsUpdater { constraints -> @@ -230,6 +241,7 @@ internal fun BasePopover( } else { Modifier } + val shape = shape.getValue(motion.context.interactionSource, motion.context.semanticStateSource) Popup( popupPositionProvider = positionProvider, properties = effectivePopupProperties, @@ -249,11 +261,11 @@ internal fun BasePopover( .padding(shadowPaddingValues + tailPaddings) .then(ignoreContentTapModifier) .then(resizeModifier) - .defaultMinSize(minWidth = dimensions.width) + .defaultMinSize(minWidth = minWidth) .shadow(shadow, shape) .drawPopover( shape = shape, - backgroundColor = backgroundColor, + backgroundColor = { backgroundColor.value }, popoverAlignment = positionProvider.innerTailAlignment, placement = positionProvider.innerPlacement, tailEnabled = tailEnabled, @@ -450,7 +462,7 @@ private fun canApplyAlignToTail( private fun Modifier.drawPopover( shape: CornerBasedShape, - backgroundColor: Brush, + backgroundColor: BrushProducer, tailEnabled: Boolean, popoverAlignment: PopoverAlignment, placement: PopoverPlacement, @@ -480,7 +492,7 @@ private fun Modifier.drawPopover( } onDrawWithContent { - drawPath(popoverPath, backgroundColor) + drawPath(popoverPath, backgroundColor()) drawContent() } } diff --git a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/motion/components/dropdownmenu/DropdownMenuMotionStyle.kt b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/motion/components/dropdownmenu/DropdownMenuMotionStyle.kt index 452aa6210c..0a7a55c607 100644 --- a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/motion/components/dropdownmenu/DropdownMenuMotionStyle.kt +++ b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/motion/components/dropdownmenu/DropdownMenuMotionStyle.kt @@ -3,9 +3,12 @@ package com.sdds.compose.uikit.motion.components.dropdownmenu import androidx.compose.runtime.Immutable import androidx.compose.runtime.Stable import androidx.compose.runtime.compositionLocalOf +import androidx.compose.ui.graphics.Brush import com.sdds.compose.uikit.DropdownMenu -import com.sdds.compose.uikit.motion.MotionStyle -import com.sdds.compose.uikit.motion.MotionStyleBuilder +import com.sdds.compose.uikit.motion.MotionProperty +import com.sdds.compose.uikit.motion.components.popover.PopoverMotionStyle +import com.sdds.compose.uikit.motion.components.popover.PopoverMotionStyleBuilder +import com.sdds.compose.uikit.motion.noMotion /** * CompositionLocal, предоставляющий текущий [DropdownMenuMotionStyle]. @@ -16,7 +19,7 @@ val LocalDropdownMenuMotionStyle = compositionLocalOf { DropdownMenuMotionStyle. * Описывает анимационные свойства [DropdownMenu]. */ @Stable -interface DropdownMenuMotionStyle : MotionStyle { +interface DropdownMenuMotionStyle : PopoverMotionStyle { companion object { /** @@ -30,12 +33,27 @@ interface DropdownMenuMotionStyle : MotionStyle { * Билдер для поэтапной конфигурации [DropdownMenuMotionStyle]. */ @Stable -interface DropdownMenuMotionStyleBuilder : MotionStyleBuilder +interface DropdownMenuMotionStyleBuilder : PopoverMotionStyleBuilder { + /** + * Устанавливает анимационное свойство цвета фона DropdownMenu. + */ + override fun backgroundColor(background: MotionProperty): DropdownMenuMotionStyleBuilder + override fun style(): DropdownMenuMotionStyle +} @Immutable -private class DropdownMenuMotionStyleImpl : DropdownMenuMotionStyle { +private class DropdownMenuMotionStyleImpl( + override val backgroundColor: MotionProperty, +) : DropdownMenuMotionStyle { class Builder : DropdownMenuMotionStyleBuilder { - override fun style(): DropdownMenuMotionStyle = DropdownMenuMotionStyleImpl() + private var backgroundColor: MotionProperty? = null + + override fun backgroundColor(background: MotionProperty) = apply { + this.backgroundColor = background + } + override fun style(): DropdownMenuMotionStyle = DropdownMenuMotionStyleImpl( + backgroundColor = backgroundColor ?: noMotion(), + ) } } diff --git a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/motion/components/popover/PopoverMotionStyle.kt b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/motion/components/popover/PopoverMotionStyle.kt index 4a4e0fd0a5..d1c3939e31 100644 --- a/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/motion/components/popover/PopoverMotionStyle.kt +++ b/sdds-core/uikit-compose/src/commonMain/kotlin/com/sdds/compose/uikit/motion/components/popover/PopoverMotionStyle.kt @@ -3,9 +3,12 @@ package com.sdds.compose.uikit.motion.components.popover import androidx.compose.runtime.Immutable import androidx.compose.runtime.Stable import androidx.compose.runtime.compositionLocalOf +import androidx.compose.ui.graphics.Brush import com.sdds.compose.uikit.Popover +import com.sdds.compose.uikit.motion.MotionProperty import com.sdds.compose.uikit.motion.MotionStyle import com.sdds.compose.uikit.motion.MotionStyleBuilder +import com.sdds.compose.uikit.motion.noMotion /** * CompositionLocal, предоставляющий текущий [PopoverMotionStyle]. @@ -18,6 +21,11 @@ val LocalPopoverMotionStyle = compositionLocalOf { PopoverMotionStyle.builder(). @Stable interface PopoverMotionStyle : MotionStyle { + /** + * Анимация изменения кисти фона + */ + val backgroundColor: MotionProperty + companion object { /** * Создает билдер для построения [PopoverMotionStyle]. @@ -30,12 +38,30 @@ interface PopoverMotionStyle : MotionStyle { * Билдер для поэтапной конфигурации [PopoverMotionStyle]. */ @Stable -interface PopoverMotionStyleBuilder : MotionStyleBuilder +interface PopoverMotionStyleBuilder : MotionStyleBuilder { + /** + * Устанавливает анимацию изменения цвета фона + */ + fun backgroundColor(background: MotionProperty): PopoverMotionStyleBuilder +} @Immutable -private class PopoverMotionStyleImpl : PopoverMotionStyle { +private class PopoverMotionStyleImpl( + override val backgroundColor: MotionProperty, +) : PopoverMotionStyle { class Builder : PopoverMotionStyleBuilder { - override fun style(): PopoverMotionStyle = PopoverMotionStyleImpl() + + private var backgroundColor: MotionProperty? = null + + override fun backgroundColor(background: MotionProperty) = apply { + this.backgroundColor = background + } + + override fun style(): PopoverMotionStyle { + return PopoverMotionStyleImpl( + backgroundColor = backgroundColor ?: noMotion(), + ) + } } }