From 6f1984b8f8c0b6aeeb24b725aa980652bcfd5fdc Mon Sep 17 00:00:00 2001 From: Mateusz Mroz Date: Mon, 16 Feb 2026 16:36:54 +0100 Subject: [PATCH] Refactor MMD components to use updated naming conventions and improve compatibility --- gradle.properties | 2 +- mmd-core/.DS_Store | Bin 6804 -> 0 bytes .../mudita/mmd/components/badge/BadgeMMD.kt | 4 +- .../bottom_sheet/BottomSheetDefaultsMMD.kt | 28 ++-- .../components/bottom_sheet/BottomSheetMMD.kt | 8 +- .../mmd/components/buttons/ButtonMMD.kt | 14 +- .../mudita/mmd/components/cards/CardMMD.kt | 42 +++--- .../mmd/components/checkbox/CheckboxMMD.kt | 26 ++-- .../mudita/mmd/components/chips/ChipMMD.kt | 126 +++++++++--------- .../com/mudita/mmd/components/lazy/LazyMMD.kt | 15 +-- .../mudita/mmd/components/menus/MenuMMD.kt | 22 +-- .../nav_bar/NavigationBottomBarMMD.kt | 24 ++-- .../CircularProgressIndicatorMMD.kt | 2 +- .../components/radio_button/RadioButtonMMD.kt | 22 +-- .../mmd/components/search_bar/SearchBarMMD.kt | 18 +-- .../mudita/mmd/components/slider/SliderMMD.kt | 4 +- .../com/mudita/mmd/components/tabs/TabsMMD.kt | 18 +-- .../text_field/TextFieldDefaultsMMD.kt | 28 ++-- .../components/text_field/TextFieldImpl.kt | 4 +- .../mmd/components/text_field/TextFieldMMD.kt | 8 +- .../mmd/components/time/TimeInputMMD.kt | 26 ++-- .../mmd/components/tooltip/TooltipBoxMMD.kt | 2 +- .../mmd/components/tooltip/TooltipMMD.kt | 16 +-- .../components/top_app_bar/TopAppBarMMD.kt | 17 ++- 24 files changed, 244 insertions(+), 232 deletions(-) delete mode 100644 mmd-core/.DS_Store diff --git a/gradle.properties b/gradle.properties index 66f5755..5c87ec9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,6 @@ library.group=com.mudita library.artifactId=MMD library.namespace=com.mudita.mmd library.compileSdk=34 -library.minSdk=28 +library.minSdk=23 library.targetSdk=34 library.version=1.0.1 diff --git a/mmd-core/.DS_Store b/mmd-core/.DS_Store deleted file mode 100644 index 7b25f40f8db4684d6a3f0055a85a0b0553f1cb55..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6804 zcmeHKL2uJA6i#4Bs9bjB_|#oMD(x8J0++UH5fNL9mX2vR+{8_dvN$--x^n7?-^EYk zvtzMU)o$Ye@{{b(etz%yz0XlyAG8kWSe9!gvZbb@!=tw}TXGr{sgfe4X~_$UWvvoU zpOyT^6Wuz1%aBz(C0WoZ(_9Ib)0-}x%2X@_^z${H)~V2p;<8IWNOon{x}AuG7sj(L zQm#mwol2Gf+)9VOa8(HeKI$IQ3uDlBOYN8MvGH2gbj8+GNKJLc5kge75IHA)lkifL zC@7IvWiD8OoL53G?KUn5(x6KhLe4dVHG_S*Cb_t4N35xnj4ZV--}QQ{)vC*Ewq2>R zUf$GF^-iMW@gyFpR>u*tiFwdwhg$=g_@SLc2TSlQj>*euKXE40r~%8F<`G z_s#u3M!V Unit)? = null, ) { @@ -223,7 +223,7 @@ fun BadgeMMD( } /** Default values used for [BadgeMMD] implementations. */ -object BadgeDefaults { +object BadgeDefaultsMMD { /** Default container color for a badge. */ val containerColor: Color @Composable get() = MaterialTheme.colorScheme.primaryContainer diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/bottom_sheet/BottomSheetDefaultsMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/bottom_sheet/BottomSheetDefaultsMMD.kt index 7801efe..59022ad 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/bottom_sheet/BottomSheetDefaultsMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/bottom_sheet/BottomSheetDefaultsMMD.kt @@ -48,9 +48,9 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.Velocity import androidx.compose.ui.unit.dp -import com.mudita.mmd.components.bottom_sheet.SheetValue.Expanded -import com.mudita.mmd.components.bottom_sheet.SheetValue.Hidden -import com.mudita.mmd.components.bottom_sheet.SheetValue.PartiallyExpanded +import com.mudita.mmd.components.bottom_sheet.SheetValueMMD.Expanded +import com.mudita.mmd.components.bottom_sheet.SheetValueMMD.Hidden +import com.mudita.mmd.components.bottom_sheet.SheetValueMMD.PartiallyExpanded import com.mudita.mmd.internal.bottom_sheet.AnchoredDraggableState import com.mudita.mmd.internal.bottom_sheet.moveTo import com.mudita.mmd.internal.bottom_sheet.snapTo @@ -77,8 +77,8 @@ import kotlinx.coroutines.CancellationException class SheetStateMMD( internal val skipPartiallyExpanded: Boolean, density: Density, - initialValue: SheetValue = Hidden, - confirmValueChange: (SheetValue) -> Boolean = { true }, + initialValue: SheetValueMMD = Hidden, + confirmValueChange: (SheetValueMMD) -> Boolean = { true }, private val skipHiddenState: Boolean = false, ) { init { @@ -101,7 +101,7 @@ class SheetStateMMD( * currently in. If a swipe or an animation is in progress, this corresponds the state the sheet * was in before the swipe or animation started. */ - val currentValue: SheetValue + val currentValue: SheetValueMMD get() = anchoredDraggableState.currentValue /** @@ -111,7 +111,7 @@ class SheetStateMMD( * finishes. If an animation is running, this is the target value of that animation. Finally, if * no swipe or animation is in progress, this is the same as the [currentValue]. */ - val targetValue: SheetValue + val targetValue: SheetValueMMD get() = anchoredDraggableState.targetValue /** Whether the modal bottom sheet is visible. */ @@ -207,7 +207,7 @@ class SheetStateMMD( * call. */ private suspend fun moveTo( - targetValue: SheetValue, + targetValue: SheetValueMMD, velocity: Float = anchoredDraggableState.lastVelocity, ) { anchoredDraggableState.moveTo(targetValue, velocity) @@ -221,7 +221,7 @@ class SheetStateMMD( * gesture interaction or another programmatic interaction like a [moveTo] or [snapTo] * call. */ - private suspend fun snapTo(targetValue: SheetValue) { + private suspend fun snapTo(targetValue: SheetValueMMD) { anchoredDraggableState.snapTo(targetValue) } @@ -244,11 +244,11 @@ class SheetStateMMD( /** The default [Saver] implementation for [SheetStateMMD]. */ fun Saver( skipPartiallyExpanded: Boolean, - confirmValueChange: (SheetValue) -> Boolean, + confirmValueChange: (SheetValueMMD) -> Boolean, density: Density, skipHiddenState: Boolean, ) = - Saver( + Saver( save = { it.currentValue }, restore = { savedValue -> SheetStateMMD( @@ -265,7 +265,7 @@ class SheetStateMMD( /** Possible values of [SheetStateMMD]. */ @ExperimentalMaterial3Api -enum class SheetValue { +enum class SheetValueMMD { /** The sheet is not visible. */ Hidden, @@ -386,8 +386,8 @@ internal fun consumeSwipeWithinBottomSheetBoundsNestedScrollConnection( @ExperimentalMaterial3Api internal fun rememberSheetState( skipPartiallyExpanded: Boolean = false, - confirmValueChange: (SheetValue) -> Boolean = { true }, - initialValue: SheetValue = Hidden, + confirmValueChange: (SheetValueMMD) -> Boolean = { true }, + initialValue: SheetValueMMD = Hidden, skipHiddenState: Boolean = false, ): SheetStateMMD { val density = LocalDensity.current diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/bottom_sheet/BottomSheetMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/bottom_sheet/BottomSheetMMD.kt index b4c0321..cd4d1f1 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/bottom_sheet/BottomSheetMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/bottom_sheet/BottomSheetMMD.kt @@ -61,9 +61,9 @@ import androidx.compose.ui.semantics.traversalIndex import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.mudita.mmd.R -import com.mudita.mmd.components.bottom_sheet.SheetValue.Expanded -import com.mudita.mmd.components.bottom_sheet.SheetValue.Hidden -import com.mudita.mmd.components.bottom_sheet.SheetValue.PartiallyExpanded +import com.mudita.mmd.components.bottom_sheet.SheetValueMMD.Expanded +import com.mudita.mmd.components.bottom_sheet.SheetValueMMD.Hidden +import com.mudita.mmd.components.bottom_sheet.SheetValueMMD.PartiallyExpanded import com.mudita.mmd.internal.bottom_sheet.DraggableAnchors import com.mudita.mmd.internal.bottom_sheet.draggableAnchors import kotlinx.coroutines.CoroutineScope @@ -389,7 +389,7 @@ internal fun BoxScope.ModalBottomSheetContent( @ExperimentalMaterial3Api fun rememberModalBottomSheetMMDState( skipPartiallyExpanded: Boolean = false, - confirmValueChange: (SheetValue) -> Boolean = { true }, + confirmValueChange: (SheetValueMMD) -> Boolean = { true }, ) = rememberSheetState( skipPartiallyExpanded = skipPartiallyExpanded, diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/buttons/ButtonMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/buttons/ButtonMMD.kt index 12c6b91..66a102e 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/buttons/ButtonMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/buttons/ButtonMMD.kt @@ -139,13 +139,13 @@ fun OutlinedButtonMMD( content = content, ) -private object ButtonDefaultsMMD { - private val buttonHorizontalPadding = 16.dp - private val buttonVerticalPadding = 8.dp - private val buttonCornerRadius = 8.dp - private val borderWidth = 2.dp - private val borderColor1 = Color.Black - private val borderColor2 = Color.Black.copy(alpha = 0.75f) +object ButtonDefaultsMMD { + val buttonHorizontalPadding = 16.dp + val buttonVerticalPadding = 8.dp + val buttonCornerRadius = 8.dp + val borderWidth = 2.dp + val borderColor1 = Color.Black + val borderColor2 = Color.Black.copy(alpha = 0.75f) /** * The default content padding used by [ButtonMMD] and [OutlinedButton] buttons. diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/cards/CardMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/cards/CardMMD.kt index 1e80ede..18a3f55 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/cards/CardMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/cards/CardMMD.kt @@ -95,9 +95,9 @@ import androidx.compose.ui.unit.dp * @param modifier the [Modifier] to be applied to this card * @param shape defines the shape of this card's container, border (when [border] is not null), and * shadow (when using [elevation]) - * @param colors [CardColors] that will be used to resolve the colors used for this card in + * @param colors [CardColorsMMD] that will be used to resolve the colors used for this card in * different states. See [CardDefaultsMMD.cardColors]. - * @param elevation [CardElevation] used to resolve the elevation for this card in different states. + * @param elevation [CardElevationMMD] used to resolve the elevation for this card in different states. * This controls the size of the shadow below the card. Additionally, when the container color is * [ColorScheme.surface], this controls the amount of primary color applied as an overlay. See * also: [Surface]. @@ -107,8 +107,8 @@ import androidx.compose.ui.unit.dp fun CardMMD( modifier: Modifier = Modifier, shape: Shape = CardDefaultsMMD.shape, - colors: CardColors = CardDefaultsMMD.cardColors(), - elevation: CardElevation = CardDefaultsMMD.cardElevation(), + colors: CardColorsMMD = CardDefaultsMMD.cardColors(), + elevation: CardElevationMMD = CardDefaultsMMD.cardElevation(), border: BorderStroke? = CardDefaultsMMD.border, content: @Composable ColumnScope.() -> Unit, ) { @@ -173,9 +173,9 @@ fun CardMMD( * services. * @param shape defines the shape of this card's container, border (when [border] is not null), and * shadow (when using [elevation]) - * @param colors [CardColors] that will be used to resolve the color(s) used for this card in + * @param colors [CardColorsMMD] that will be used to resolve the color(s) used for this card in * different states. See [CardDefaultsMMD.cardColors]. - * @param elevation [CardElevation] used to resolve the elevation for this card in different states. + * @param elevation [CardElevationMMD] used to resolve the elevation for this card in different states. * This controls the size of the shadow below the card. Additionally, when the container color is * [ColorScheme.surface], this controls the amount of primary color applied as an overlay. See * also: [Surface]. @@ -191,8 +191,8 @@ fun CardMMD( modifier: Modifier = Modifier, enabled: Boolean = true, shape: Shape = CardDefaultsMMD.shape, - colors: CardColors = CardDefaultsMMD.cardColors(), - elevation: CardElevation = CardDefaultsMMD.cardElevation(), + colors: CardColorsMMD = CardDefaultsMMD.cardColors(), + elevation: CardElevationMMD = CardDefaultsMMD.cardElevation(), border: BorderStroke? = CardDefaultsMMD.border(enabled), interactionSource: MutableInteractionSource? = null, content: @Composable ColumnScope.() -> Unit, @@ -227,7 +227,7 @@ object CardDefaultsMMD { @Composable get() = BorderStroke(3.dp, MaterialTheme.colorScheme.outline) /** - * Creates a [CardElevation] that will switch between the provided values according to the + * Creates a [CardElevationMMD] that will switch between the provided values according to the * Material specification for a [CardMMD]. * * @param defaultElevation the elevation used when the [CardMMD] is has no other [Interaction]s. @@ -244,8 +244,8 @@ object CardDefaultsMMD { hoveredElevation: Dp = 0.dp, draggedElevation: Dp = 0.dp, disabledElevation: Dp = 0.dp, - ): CardElevation = - CardElevation( + ): CardElevationMMD = + CardElevationMMD( defaultElevation = defaultElevation, pressedElevation = pressedElevation, focusedElevation = focusedElevation, @@ -255,14 +255,14 @@ object CardDefaultsMMD { ) /** - * Creates a [CardColors] that represents the default container and content colors used in a + * Creates a [CardColorsMMD] that represents the default container and content colors used in a * [CardMMD]. */ @Composable fun cardColors() = defaultCardColors /** - * Creates a [CardColors] that represents the default container and content colors used in a + * Creates a [CardColorsMMD] that represents the default container and content colors used in a * [CardMMD]. * * @param containerColor the container color of this [CardMMD] when enabled. @@ -276,7 +276,7 @@ object CardDefaultsMMD { contentColor: Color = contentColorFor(containerColor), disabledContainerColor: Color = Color.Unspecified, disabledContentColor: Color = contentColor.copy(.38f), - ): CardColors = + ): CardColorsMMD = defaultCardColors.copy( containerColor = containerColor, contentColor = contentColor, @@ -284,9 +284,9 @@ object CardDefaultsMMD { disabledContentColor = disabledContentColor, ) - private val defaultCardColors: CardColors + private val defaultCardColors: CardColorsMMD @Composable - get() = CardColors( + get() = CardColorsMMD( containerColor = MaterialTheme.colorScheme.surfaceContainerHighest, contentColor = contentColorFor(MaterialTheme.colorScheme.surfaceContainerHighest), disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant @@ -315,7 +315,7 @@ object CardDefaultsMMD { * - See [CardDefaultsMMD.cardElevation] for the default elevation used in a [CardMMD]. */ @Immutable -class CardElevation +class CardElevationMMD internal constructor( private val defaultElevation: Dp, private val pressedElevation: Dp, @@ -376,7 +376,7 @@ internal constructor( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || other !is CardElevation) return false + if (other == null || other !is CardElevationMMD) return false if (defaultElevation != other.defaultElevation) return false if (pressedElevation != other.pressedElevation) return false @@ -410,7 +410,7 @@ internal constructor( * - See [CardDefaultsMMD.outlinedCardColors] for the default colors used in a [OutlinedCardMMD]. */ @Immutable -class CardColors( +class CardColorsMMD( val containerColor: Color, val contentColor: Color, val disabledContainerColor: Color, @@ -426,7 +426,7 @@ class CardColors( disabledContainerColor: Color = this.disabledContainerColor, disabledContentColor: Color = this.disabledContentColor, ) = - CardColors( + CardColorsMMD( containerColor.takeOrElse { this.containerColor }, contentColor.takeOrElse { this.contentColor }, disabledContainerColor.takeOrElse { this.disabledContainerColor }, @@ -453,7 +453,7 @@ class CardColors( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || other !is CardColors) return false + if (other == null || other !is CardColorsMMD) return false if (containerColor != other.containerColor) return false if (contentColor != other.contentColor) return false diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/checkbox/CheckboxMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/checkbox/CheckboxMMD.kt index 97708e7..fd04e8e 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/checkbox/CheckboxMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/checkbox/CheckboxMMD.kt @@ -105,7 +105,7 @@ import kotlin.math.max * @param enabled controls the enabled state of this checkbox. When `false`, this component will not * respond to user input, and it will appear visually disabled and disabled to accessibility * services. - * @param colors [CheckboxColors] that will be used to resolve the colors used for this checkbox in + * @param colors [CheckboxColorsMMD] that will be used to resolve the colors used for this checkbox in * different states. See [CheckboxDefaultsMMD.colors]. * @param interactionSource an optional hoisted [MutableInteractionSource] for observing and * emitting [Interaction]s for this checkbox. You can use this to change the checkbox's appearance @@ -119,7 +119,7 @@ fun CheckboxMMD( onCheckedChange: ((Boolean) -> Unit)?, modifier: Modifier = Modifier, enabled: Boolean = true, - colors: CheckboxColors = CheckboxDefaultsMMD.colors(), + colors: CheckboxColorsMMD = CheckboxDefaultsMMD.colors(), interactionSource: MutableInteractionSource? = null ) { TriStateCheckboxMMD( @@ -216,7 +216,7 @@ fun CheckboxMMD( * @param enabled controls the enabled state of this checkbox. When `false`, this component will not * respond to user input, and it will appear visually disabled and disabled to accessibility * services. - * @param colors [CheckboxColors] that will be used to resolve the colors used for this checkbox in + * @param colors [CheckboxColorsMMD] that will be used to resolve the colors used for this checkbox in * different states. See [CheckboxDefaultsMMD.colors]. * @param interactionSource an optional hoisted [MutableInteractionSource] for observing and * emitting [Interaction]s for this checkbox. You can use this to change the checkbox's appearance @@ -230,7 +230,7 @@ fun TriStateCheckboxMMD( onClick: (() -> Unit)?, modifier: Modifier = Modifier, enabled: Boolean = true, - colors: CheckboxColors = CheckboxDefaultsMMD.colors(), + colors: CheckboxColorsMMD = CheckboxDefaultsMMD.colors(), interactionSource: MutableInteractionSource? = null ) { val toggleableModifier = @@ -267,14 +267,14 @@ fun TriStateCheckboxMMD( /** Defaults used in [CheckboxMMD] and [TriStateCheckboxMMD]. */ object CheckboxDefaultsMMD { /** - * Creates a [CheckboxColors] that will animate between the provided colors according to the + * Creates a [CheckboxColorsMMD] that will animate between the provided colors according to the * Material specification. */ @Composable fun colors() = defaultCheckboxColors /** - * Creates a [CheckboxColors] that will animate between the provided colors according to the + * Creates a [CheckboxColorsMMD] that will animate between the provided colors according to the * Material specification. * * @param checkedColor the color that will be used for the border and box when checked @@ -296,7 +296,7 @@ object CheckboxDefaultsMMD { disabledCheckedColor: Color = Color.Unspecified, disabledUncheckedColor: Color = Color.Unspecified, disabledIndeterminateColor: Color = Color.Unspecified - ): CheckboxColors = defaultCheckboxColors.copy( + ): CheckboxColorsMMD = defaultCheckboxColors.copy( checkedCheckmarkColor = checkmarkColor, uncheckedCheckmarkColor = Color.Transparent, checkedBoxColor = checkedColor, @@ -311,8 +311,8 @@ object CheckboxDefaultsMMD { disabledIndeterminateBorderColor = disabledIndeterminateColor ) - private val defaultCheckboxColors: CheckboxColors - @Composable get() = CheckboxColors( + private val defaultCheckboxColors: CheckboxColorsMMD + @Composable get() = CheckboxColorsMMD( checkedCheckmarkColor = SelectedIconColor, uncheckedCheckmarkColor = Color.Transparent, checkedBoxColor = SelectedContainerColor, @@ -338,7 +338,7 @@ private fun CheckboxImpl( enabled: Boolean, value: ToggleableState, modifier: Modifier, - colors: CheckboxColors + colors: CheckboxColorsMMD ) { val checkDrawFraction = when (value) { ToggleableState.On -> 1f @@ -477,7 +477,7 @@ private class CheckDrawingCache( * default implementation that follows Material specifications. */ @Immutable -class CheckboxColors( +class CheckboxColorsMMD( val checkedCheckmarkColor: Color, val uncheckedCheckmarkColor: Color, val checkedBoxColor: Color, @@ -509,7 +509,7 @@ class CheckboxColors( disabledUncheckedBorderColor: Color = this.disabledUncheckedBorderColor, disabledIndeterminateBorderColor: Color = this.disabledIndeterminateBorderColor ) = - CheckboxColors( + CheckboxColorsMMD( checkedCheckmarkColor.takeOrElse { this.checkedCheckmarkColor }, uncheckedCheckmarkColor.takeOrElse { this.uncheckedCheckmarkColor }, checkedBoxColor.takeOrElse { this.checkedBoxColor }, @@ -597,7 +597,7 @@ class CheckboxColors( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || other !is CheckboxColors) return false + if (other == null || other !is CheckboxColorsMMD) return false if (checkedCheckmarkColor != other.checkedCheckmarkColor) return false if (uncheckedCheckmarkColor != other.uncheckedCheckmarkColor) return false diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/chips/ChipMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/chips/ChipMMD.kt index 7ba8014..ad70490 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/chips/ChipMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/chips/ChipMMD.kt @@ -110,9 +110,9 @@ import com.mudita.mmd.components.text_field.widthOrZero * @param trailingIcon optional icon at the end of the chip * @param shape defines the shape of this chip's container, border (when [border] is not null), and * shadow (when using [elevation]) - * @param colors [ChipColors] that will be used to resolve the colors used for this chip in + * @param colors [ChipColorsMMD] that will be used to resolve the colors used for this chip in * different states. See [AssistChipDefaultsMMD.assistChipColors]. - * @param elevation [ChipElevation] used to resolve the elevation for this chip in different states. + * @param elevation [ChipElevationMMD] used to resolve the elevation for this chip in different states. * This controls the size of the shadow below the chip. Additionally, when the container color is * [ColorScheme.surface], this controls the amount of primary color applied as an overlay. See * [AssistChipDefaultsMMD.assistChipElevation]. @@ -132,8 +132,8 @@ fun AssistChipMMD( leadingIcon: @Composable (() -> Unit)? = null, trailingIcon: @Composable (() -> Unit)? = null, shape: Shape = AssistChipDefaultsMMD.shape, - colors: ChipColors = AssistChipDefaultsMMD.assistChipColors(), - elevation: ChipElevation? = AssistChipDefaultsMMD.assistChipElevation(), + colors: ChipColorsMMD = AssistChipDefaultsMMD.assistChipColors(), + elevation: ChipElevationMMD? = AssistChipDefaultsMMD.assistChipElevation(), border: BorderStroke? = AssistChipDefaultsMMD.assistChipBorder(enabled), interactionSource: MutableInteractionSource? = null, ) = @@ -212,9 +212,9 @@ fun AssistChipMMD( * @param trailingIcon optional icon at the end of the chip * @param shape defines the shape of this chip's container, border (when [border] is not null), and * shadow (when using [elevation]) - * @param colors [SelectableChipColors] that will be used to resolve the colors used for this chip + * @param colors [SelectableChipColorsMMD] that will be used to resolve the colors used for this chip * in different states. See [FilterChipDefaultsMMD.filterChipColors]. - * @param elevation [SelectableChipElevation] used to resolve the elevation for this chip in + * @param elevation [SelectableChipElevationMMD] used to resolve the elevation for this chip in * different states. This controls the size of the shadow below the chip. Additionally, when the * container color is [ColorScheme.surface], this controls the amount of primary color applied as * an overlay. See [FilterChipDefaultsMMD.filterChipElevation]. @@ -235,8 +235,8 @@ fun FilterChipMMD( leadingIcon: @Composable (() -> Unit)? = null, trailingIcon: @Composable (() -> Unit)? = null, shape: Shape = FilterChipDefaultsMMD.shape, - colors: SelectableChipColors = FilterChipDefaultsMMD.filterChipColors(), - elevation: SelectableChipElevation? = FilterChipDefaultsMMD.filterChipElevation(), + colors: SelectableChipColorsMMD = FilterChipDefaultsMMD.filterChipColors(), + elevation: SelectableChipElevationMMD? = FilterChipDefaultsMMD.filterChipElevation(), border: BorderStroke? = FilterChipDefaultsMMD.filterChipBorder(enabled, selected), interactionSource: MutableInteractionSource? = null, ) = @@ -320,9 +320,9 @@ fun FilterChipMMD( * @param trailingIcon optional icon at the end of the chip * @param shape defines the shape of this chip's container, border (when [border] is not null), and * shadow (when using [elevation]) - * @param colors [ChipColors] that will be used to resolve the colors used for this chip in + * @param colors [ChipColorsMMD] that will be used to resolve the colors used for this chip in * different states. See [InputChipDefaultsMMD.inputChipColors]. - * @param elevation [ChipElevation] used to resolve the elevation for this chip in different states. + * @param elevation [ChipElevationMMD] used to resolve the elevation for this chip in different states. * This controls the size of the shadow below the chip. Additionally, when the container color is * [ColorScheme.surface], this controls the amount of primary color applied as an overlay. See * [InputChipDefaultsMMD.inputChipElevation]. @@ -344,8 +344,8 @@ fun InputChipMMD( avatar: @Composable (() -> Unit)? = null, trailingIcon: @Composable (() -> Unit)? = null, shape: Shape = InputChipDefaultsMMD.shape, - colors: SelectableChipColors = InputChipDefaultsMMD.inputChipColors(), - elevation: SelectableChipElevation? = InputChipDefaultsMMD.inputChipElevation(), + colors: SelectableChipColorsMMD = InputChipDefaultsMMD.inputChipColors(), + elevation: SelectableChipElevationMMD? = InputChipDefaultsMMD.inputChipElevation(), border: BorderStroke? = InputChipDefaultsMMD.inputChipBorder(enabled, selected), interactionSource: MutableInteractionSource? = null, ) { @@ -423,9 +423,9 @@ fun InputChipMMD( * @param icon optional icon at the start of the chip, preceding the [label] text * @param shape defines the shape of this chip's container, border (when [border] is not null), and * shadow (when using [elevation]) - * @param colors [ChipColors] that will be used to resolve the colors used for this chip in + * @param colors [ChipColorsMMD] that will be used to resolve the colors used for this chip in * different states. See [SuggestionChipDefaultsMMD.suggestionChipColors]. - * @param elevation [ChipElevation] used to resolve the elevation for this chip in different states. + * @param elevation [ChipElevationMMD] used to resolve the elevation for this chip in different states. * This controls the size of the shadow below the chip. Additionally, when the container color is * [ColorScheme.surface], this controls the amount of primary color applied as an overlay. See * [SuggestionChipDefaultsMMD.suggestionChipElevation]. @@ -444,8 +444,8 @@ fun SuggestionChipMMD( enabled: Boolean = true, icon: @Composable (() -> Unit)? = null, shape: Shape = SuggestionChipDefaultsMMD.shape, - colors: ChipColors = SuggestionChipDefaultsMMD.suggestionChipColors(), - elevation: ChipElevation? = SuggestionChipDefaultsMMD.suggestionChipElevation(), + colors: ChipColorsMMD = SuggestionChipDefaultsMMD.suggestionChipColors(), + elevation: ChipElevationMMD? = SuggestionChipDefaultsMMD.suggestionChipElevation(), border: BorderStroke? = SuggestionChipDefaultsMMD.suggestionChipBorder(enabled), interactionSource: MutableInteractionSource? = null, ) = @@ -479,14 +479,14 @@ object AssistChipDefaultsMMD { val IconSize = 22.dp /** - * Creates a [ChipColors] that represents the default container , label, and icon colors used in + * Creates a [ChipColorsMMD] that represents the default container , label, and icon colors used in * a flat [AssistChipMMD]. */ @Composable fun assistChipColors() = defaultAssistChipColors /** - * Creates a [ChipColors] that represents the default container , label, and icon colors used in + * Creates a [ChipColorsMMD] that represents the default container , label, and icon colors used in * a flat [AssistChipMMD]. * * @param containerColor the container color of this chip when enabled @@ -508,7 +508,7 @@ object AssistChipDefaultsMMD { disabledLabelColor: Color = Color.Unspecified, disabledLeadingIconContentColor: Color = Color.Unspecified, disabledTrailingIconContentColor: Color = Color.Unspecified, - ): ChipColors = + ): ChipColorsMMD = defaultAssistChipColors.copy( containerColor = containerColor, labelColor = labelColor, @@ -520,9 +520,9 @@ object AssistChipDefaultsMMD { disabledTrailingIconContentColor = disabledTrailingIconContentColor, ) - private val defaultAssistChipColors: ChipColors + private val defaultAssistChipColors: ChipColorsMMD @Composable - get() = ChipColors( + get() = ChipColorsMMD( containerColor = Color.Transparent, labelColor = MaterialTheme.colorScheme.onSurface, leadingIconContentColor = MaterialTheme.colorScheme.primary, @@ -537,7 +537,7 @@ object AssistChipDefaultsMMD { ) /** - * Creates a [ChipElevation] that will switch between the provided values according to the + * Creates a [ChipElevationMMD] that will switch between the provided values according to the * Material specification for a flat [AssistChipMMD]. * * @param elevation the elevation used when the [AssistChipMMD] is has no other [Interaction]s @@ -555,8 +555,8 @@ object AssistChipDefaultsMMD { hoveredElevation: Dp = elevation, draggedElevation: Dp = 0.dp, disabledElevation: Dp = elevation, - ): ChipElevation = - ChipElevation( + ): ChipElevationMMD = + ChipElevationMMD( elevation = elevation, pressedElevation = pressedElevation, focusedElevation = focusedElevation, @@ -601,14 +601,14 @@ object FilterChipDefaultsMMD { val IconSize = 22.dp /** - * Creates a [SelectableChipColors] that represents the default container and content colors + * Creates a [SelectableChipColorsMMD] that represents the default container and content colors * used in a flat [FilterChipMMD]. */ @Composable fun filterChipColors() = defaultFilterChipColors /** - * Creates a [SelectableChipColors] that represents the default container and content colors + * Creates a [SelectableChipColorsMMD] that represents the default container and content colors * used in a flat [FilterChipMMD]. * * @param containerColor the container color of this chip when enabled @@ -639,7 +639,7 @@ object FilterChipDefaultsMMD { selectedLabelColor: Color = Color.Unspecified, selectedLeadingIconColor: Color = Color.Unspecified, selectedTrailingIconColor: Color = Color.Unspecified, - ): SelectableChipColors = + ): SelectableChipColorsMMD = defaultFilterChipColors.copy( containerColor = containerColor, labelColor = labelColor, @@ -656,9 +656,9 @@ object FilterChipDefaultsMMD { selectedTrailingIconColor = selectedTrailingIconColor, ) - private val defaultFilterChipColors: SelectableChipColors + private val defaultFilterChipColors: SelectableChipColorsMMD @Composable - get() = SelectableChipColors( + get() = SelectableChipColorsMMD( containerColor = Color.Transparent, labelColor = MaterialTheme.colorScheme.onSurfaceVariant, leadingIconColor = MaterialTheme.colorScheme.primary, @@ -679,7 +679,7 @@ object FilterChipDefaultsMMD { ) /** - * Creates a [SelectableChipElevation] that will switch between the provided values according + * Creates a [SelectableChipElevationMMD] that will switch between the provided values according * to the Material specification for a flat [FilterChipMMD]. * * @param elevation the elevation used when the [FilterChipMMD] is has no other [Interaction]s @@ -697,8 +697,8 @@ object FilterChipDefaultsMMD { hoveredElevation: Dp = 0.dp, draggedElevation: Dp = 0.dp, disabledElevation: Dp = elevation, - ): SelectableChipElevation = - SelectableChipElevation( + ): SelectableChipElevationMMD = + SelectableChipElevationMMD( elevation = elevation, pressedElevation = pressedElevation, focusedElevation = focusedElevation, @@ -765,14 +765,14 @@ object InputChipDefaultsMMD { val AvatarSize = 22.dp /** - * Creates a [SelectableChipColors] that represents the default container, label, and icon + * Creates a [SelectableChipColorsMMD] that represents the default container, label, and icon * colors used in an [InputChipMMD]. */ @Composable fun inputChipColors() = defaultInputChipColors /** - * Creates a [SelectableChipColors] that represents the default container, label, and icon + * Creates a [SelectableChipColorsMMD] that represents the default container, label, and icon * colors used in an [InputChipMMD]. * * @param containerColor the container color of this chip when enabled @@ -805,7 +805,7 @@ object InputChipDefaultsMMD { selectedLabelColor: Color = Color.Unspecified, selectedLeadingIconColor: Color = Color.Unspecified, selectedTrailingIconColor: Color = Color.Unspecified, - ): SelectableChipColors = + ): SelectableChipColorsMMD = defaultInputChipColors.copy( containerColor = containerColor, labelColor = labelColor, @@ -822,9 +822,9 @@ object InputChipDefaultsMMD { selectedTrailingIconColor = selectedTrailingIconColor, ) - private val defaultInputChipColors: SelectableChipColors + private val defaultInputChipColors: SelectableChipColorsMMD @Composable - get() = SelectableChipColors( + get() = SelectableChipColorsMMD( containerColor = Color.Transparent, labelColor = MaterialTheme.colorScheme.onSurfaceVariant, leadingIconColor = MaterialTheme.colorScheme.onSurfaceVariant, @@ -845,7 +845,7 @@ object InputChipDefaultsMMD { ) /** - * Creates a [SelectableChipElevation] that will switch between the provided values according + * Creates a [SelectableChipElevationMMD] that will switch between the provided values according * to the Material specification for an [InputChipMMD]. * * @param elevation the elevation used when the [FilterChipMMD] is has no other [Interaction]s @@ -863,8 +863,8 @@ object InputChipDefaultsMMD { hoveredElevation: Dp = elevation, draggedElevation: Dp = 0.dp, disabledElevation: Dp = elevation, - ): SelectableChipElevation = - SelectableChipElevation( + ): SelectableChipElevationMMD = + SelectableChipElevationMMD( elevation = elevation, pressedElevation = pressedElevation, focusedElevation = focusedElevation, @@ -928,14 +928,14 @@ object SuggestionChipDefaultsMMD { val IconSize = 22.dp /** - * Creates a [ChipColors] that represents the default container, label, and icon colors used in + * Creates a [ChipColorsMMD] that represents the default container, label, and icon colors used in * a flat [SuggestionChipMMD]. */ @Composable fun suggestionChipColors() = defaultSuggestionChipColors /** - * Creates a [ChipColors] that represents the default container, label, and icon colors used in + * Creates a [ChipColorsMMD] that represents the default container, label, and icon colors used in * a flat [SuggestionChipMMD]. * * @param containerColor the container color of this chip when enabled @@ -953,7 +953,7 @@ object SuggestionChipDefaultsMMD { disabledContainerColor: Color = Color.Unspecified, disabledLabelColor: Color = Color.Unspecified, disabledIconContentColor: Color = Color.Unspecified, - ): ChipColors = + ): ChipColorsMMD = defaultSuggestionChipColors.copy( containerColor = containerColor, labelColor = labelColor, @@ -966,7 +966,7 @@ object SuggestionChipDefaultsMMD { ) /** - * Creates a [ChipElevation] that will switch between the provided values according to the + * Creates a [ChipElevationMMD] that will switch between the provided values according to the * Material specification for a flat [SuggestionChipMMD]. * * @param elevation the elevation used when the chip is has no other [Interaction]s @@ -984,8 +984,8 @@ object SuggestionChipDefaultsMMD { hoveredElevation: Dp = elevation, draggedElevation: Dp = 0.dp, disabledElevation: Dp = elevation, - ): ChipElevation = - ChipElevation( + ): ChipElevationMMD = + ChipElevationMMD( elevation = elevation, pressedElevation = pressedElevation, focusedElevation = focusedElevation, @@ -1029,8 +1029,8 @@ private fun Chip( leadingIcon: @Composable (() -> Unit)?, trailingIcon: @Composable (() -> Unit)?, shape: Shape, - colors: ChipColors, - elevation: ChipElevation?, + colors: ChipColorsMMD, + elevation: ChipElevationMMD?, border: BorderStroke?, minHeight: Dp, paddingValues: PaddingValues, @@ -1075,8 +1075,8 @@ private fun SelectableChip( avatar: @Composable (() -> Unit)?, trailingIcon: @Composable (() -> Unit)?, shape: Shape, - colors: SelectableChipColors, - elevation: SelectableChipElevation?, + colors: SelectableChipColorsMMD, + elevation: SelectableChipElevationMMD?, border: BorderStroke?, minHeight: Dp, paddingValues: PaddingValues, @@ -1214,7 +1214,7 @@ private fun ChipContent( * * Note that this default implementation does not take into consideration the `selectable` state * passed into its [shadowElevation]. If you wish to apply that state, use a different - * [SelectableChipElevation]. + * [SelectableChipElevationMMD]. * * @param elevation the elevation used when the chip is enabled. * @param pressedElevation the elevation used when the chip is pressed. @@ -1224,7 +1224,7 @@ private fun ChipContent( * @param disabledElevation the elevation used when the chip is not enabled */ @Immutable -class ChipElevation( +class ChipElevationMMD( val elevation: Dp, val pressedElevation: Dp, val focusedElevation: Dp, @@ -1276,7 +1276,7 @@ class ChipElevation( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is ChipElevation) return false + if (other !is ChipElevationMMD) return false return elevation == other.elevation && pressedElevation == other.pressedElevation && @@ -1308,7 +1308,7 @@ class ChipElevation( * @param disabledElevation the elevation used when the chip is not enabled */ @Immutable -class SelectableChipElevation( +class SelectableChipElevationMMD( val elevation: Dp, val pressedElevation: Dp, val focusedElevation: Dp, @@ -1360,7 +1360,7 @@ class SelectableChipElevation( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is SelectableChipElevation) return false + if (other !is SelectableChipElevationMMD) return false return elevation == other.elevation && pressedElevation == other.pressedElevation && @@ -1397,7 +1397,7 @@ class SelectableChipElevation( * Chip configurations. */ @Immutable -class ChipColors( +class ChipColorsMMD( val containerColor: Color, val labelColor: Color, val leadingIconContentColor: Color, @@ -1421,7 +1421,7 @@ class ChipColors( disabledLeadingIconContentColor: Color = this.disabledLeadingIconContentColor, disabledTrailingIconContentColor: Color = this.disabledTrailingIconContentColor, ) = - ChipColors( + ChipColorsMMD( containerColor.takeOrElse { this.containerColor }, labelColor.takeOrElse { this.labelColor }, leadingIconContentColor.takeOrElse { this.leadingIconContentColor }, @@ -1470,7 +1470,7 @@ class ChipColors( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || other !is ChipColors) return false + if (other == null || other !is ChipColorsMMD) return false if (containerColor != other.containerColor) return false if (labelColor != other.labelColor) return false @@ -1498,9 +1498,9 @@ class ChipColors( } } -internal val defaultSuggestionChipColors: ChipColors +internal val defaultSuggestionChipColors: ChipColorsMMD @Composable - get() = ChipColors( + get() = ChipColorsMMD( containerColor = Color.Transparent, labelColor = MaterialTheme.colorScheme.onSurfaceVariant, leadingIconContentColor = MaterialTheme.colorScheme.primary, @@ -1519,7 +1519,7 @@ internal val defaultSuggestionChipColors: ChipColors * See [FilterChipDefaultsMMD.filterChipColors] for the default colors used in [FilterChipMMD]. */ @Immutable -class SelectableChipColors( +class SelectableChipColorsMMD( private val containerColor: Color, private val labelColor: Color, private val leadingIconColor: Color, @@ -1553,7 +1553,7 @@ class SelectableChipColors( selectedLeadingIconColor: Color = this.selectedLeadingIconColor, selectedTrailingIconColor: Color = this.selectedTrailingIconColor, ) = - SelectableChipColors( + SelectableChipColorsMMD( containerColor.takeOrElse { this.containerColor }, labelColor.takeOrElse { this.labelColor }, leadingIconColor.takeOrElse { this.leadingIconColor }, @@ -1631,7 +1631,7 @@ class SelectableChipColors( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || other !is SelectableChipColors) return false + if (other == null || other !is SelectableChipColorsMMD) return false if (containerColor != other.containerColor) return false if (labelColor != other.labelColor) return false diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/lazy/LazyMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/lazy/LazyMMD.kt index 2481db9..0edb384 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/lazy/LazyMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/lazy/LazyMMD.kt @@ -425,13 +425,11 @@ private fun VerticalScrollbar( layoutInfo.totalItemsCount - visibleCount, ) - val maxOffset = size.height - adjustedSliderHeight + val maxOffset = (size.height - adjustedSliderHeight).coerceAtLeast(0f) + val denominator = (layoutInfo.totalItemsCount - visibleCount).coerceAtLeast(1) val sliderOffset = - ((firstVisible.toFloat() / (layoutInfo.totalItemsCount - visibleCount)) * maxOffset) - .coerceIn( - 0f, - maxOffset, - ) + ((firstVisible.toFloat() / denominator) * maxOffset) + .coerceIn(0f, maxOffset) // Draw the container for the slider drawRoundRect( @@ -539,9 +537,10 @@ private fun HorizontalScrollbar( layoutInfo.totalItemsCount - visibleCount, ) - val maxOffset = size.width - adjustedSliderWidth + val maxOffset = (size.width - adjustedSliderWidth).coerceAtLeast(0f) + val denominator = (layoutInfo.totalItemsCount - visibleCount).coerceAtLeast(1) val sliderOffset = - ((firstVisible.toFloat() / (layoutInfo.totalItemsCount - visibleCount)) * maxOffset) + ((firstVisible.toFloat() / denominator) * maxOffset) .coerceIn(0f, maxOffset) drawRoundRect( diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/menus/MenuMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/menus/MenuMMD.kt index 04ede54..5763e94 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/menus/MenuMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/menus/MenuMMD.kt @@ -272,7 +272,7 @@ fun DropdownMenuMMD( * @param enabled controls the enabled state of this menu item. When `false`, this component will * not respond to user input, and it will appear visually disabled and disabled to accessibility * services. - * @param colors [MenuItemColors] that will be used to resolve the colors used for this menu item in + * @param colors [MenuItemColorsMMD] that will be used to resolve the colors used for this menu item in * different states. See [MenuDefaultsMMD.itemColors]. * @param contentPadding the padding applied to the content of this menu item * @param interactionSource an optional hoisted [MutableInteractionSource] for observing and @@ -288,7 +288,7 @@ fun DropdownMenuItemMMD( leadingIcon: @Composable (() -> Unit)? = null, trailingIcon: @Composable (() -> Unit)? = null, enabled: Boolean = true, - colors: MenuItemColors = MenuDefaultsMMD.itemColors(), + colors: MenuItemColorsMMD = MenuDefaultsMMD.itemColors(), contentPadding: PaddingValues = MenuDefaultsMMD.DropdownMenuItemContentPadding, interactionSource: MutableInteractionSource? = null, ) { @@ -326,14 +326,14 @@ object MenuDefaultsMMD { @Composable get() = BorderStroke(2.dp, MaterialTheme.colorScheme.outline) /** - * Creates a [MenuItemColors] that represents the default text and icon colors used in a + * Creates a [MenuItemColorsMMD] that represents the default text and icon colors used in a * [DropdownMenuItemContent]. */ @Composable fun itemColors() = defaultMenuItemColors /** - * Creates a [MenuItemColors] that represents the default text and icon colors used in a + * Creates a [MenuItemColorsMMD] that represents the default text and icon colors used in a * [DropdownMenuItemContent]. * * @param textColor the text color of this [DropdownMenuItemContent] when enabled @@ -354,7 +354,7 @@ object MenuDefaultsMMD { disabledTextColor: Color = Color.Unspecified, disabledLeadingIconColor: Color = Color.Unspecified, disabledTrailingIconColor: Color = Color.Unspecified, - ): MenuItemColors = + ): MenuItemColorsMMD = defaultMenuItemColors.copy( textColor = textColor, leadingIconColor = leadingIconColor, @@ -364,8 +364,8 @@ object MenuDefaultsMMD { disabledTrailingIconColor = disabledTrailingIconColor, ) - private val defaultMenuItemColors: MenuItemColors - @Composable get() = MenuItemColors( + private val defaultMenuItemColors: MenuItemColorsMMD + @Composable get() = MenuItemColorsMMD( textColor = MaterialTheme.colorScheme.onSurface, leadingIconColor = MaterialTheme.colorScheme.onSurfaceVariant, trailingIconColor = MaterialTheme.colorScheme.onSurfaceVariant, @@ -399,7 +399,7 @@ internal val DefaultMenuProperties: PopupProperties = PopupProperties(focusable * default colors used in a [DropdownMenuItemContent]. */ @Immutable -class MenuItemColors( +class MenuItemColorsMMD( val textColor: Color, val leadingIconColor: Color, val trailingIconColor: Color, @@ -420,7 +420,7 @@ class MenuItemColors( disabledLeadingIconColor: Color = this.disabledLeadingIconColor, disabledTrailingIconColor: Color = this.disabledTrailingIconColor, ) = - MenuItemColors( + MenuItemColorsMMD( textColor.takeOrElse { this.textColor }, leadingIconColor.takeOrElse { this.leadingIconColor }, trailingIconColor.takeOrElse { this.trailingIconColor }, @@ -457,7 +457,7 @@ class MenuItemColors( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || other !is MenuItemColors) return false + if (other == null || other !is MenuItemColorsMMD) return false if (textColor != other.textColor) return false if (leadingIconColor != other.leadingIconColor) return false @@ -516,7 +516,7 @@ internal fun DropdownMenuItemContent( leadingIcon: @Composable (() -> Unit)?, trailingIcon: @Composable (() -> Unit)?, enabled: Boolean, - colors: MenuItemColors, + colors: MenuItemColorsMMD, contentPadding: PaddingValues, interactionSource: MutableInteractionSource? ) { diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/nav_bar/NavigationBottomBarMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/nav_bar/NavigationBottomBarMMD.kt index 0432018..c2682ba 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/nav_bar/NavigationBottomBarMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/nav_bar/NavigationBottomBarMMD.kt @@ -539,14 +539,22 @@ object NavigationBarItemDefaultsMMD { * specification. */ @Composable - fun colors() = NavigationBarItemColors( - selectedIconColor = MaterialTheme.colorScheme.onSurface, - selectedTextColor = MaterialTheme.colorScheme.onSurface, - selectedIndicatorColor = MaterialTheme.colorScheme.onSurface, - unselectedIconColor = MaterialTheme.colorScheme.onSurface, - unselectedTextColor = MaterialTheme.colorScheme.onSurface, - disabledIconColor = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.75f), - disabledTextColor = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.75f), + fun colors( + selectedIconColor: Color = MaterialTheme.colorScheme.onSurface, + selectedTextColor: Color = MaterialTheme.colorScheme.onSurface, + selectedIndicatorColor: Color = MaterialTheme.colorScheme.onSurface, + unselectedIconColor: Color = MaterialTheme.colorScheme.onSurface, + unselectedTextColor: Color = MaterialTheme.colorScheme.onSurface, + disabledIconColor: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.75f), + disabledTextColor: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.75f) + ) = NavigationBarItemColors( + selectedIconColor = selectedIconColor, + selectedTextColor = selectedTextColor, + selectedIndicatorColor = selectedIndicatorColor, + unselectedIconColor = unselectedIconColor, + unselectedTextColor = unselectedTextColor, + disabledIconColor = disabledIconColor, + disabledTextColor = disabledTextColor ) /** diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/progress_indicator/CircularProgressIndicatorMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/progress_indicator/CircularProgressIndicatorMMD.kt index 71a54e2..0158640 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/progress_indicator/CircularProgressIndicatorMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/progress_indicator/CircularProgressIndicatorMMD.kt @@ -103,7 +103,7 @@ fun CircularProgressIndicatorMMD( } } -private object ProgressIndicatorDefaultsMMD { +object ProgressIndicatorDefaultsMMD { const val ANIMATION_STEP_DEGREES = 45f const val STROKE_DEGREES = 360 diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/radio_button/RadioButtonMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/radio_button/RadioButtonMMD.kt index c5ababe..96e6846 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/radio_button/RadioButtonMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/radio_button/RadioButtonMMD.kt @@ -121,7 +121,7 @@ import androidx.compose.ui.unit.dp * @param enabled controls the enabled state of this radio button. When `false`, this component will * not respond to user input, and it will appear visually disabled and disabled to accessibility * services. - * @param colors [RadioButtonColors] that will be used to resolve the color used for this radio + * @param colors [RadioButtonColorsMMD] that will be used to resolve the color used for this radio * button in different states. See [RadioButtonDefaultsMMD.colors]. * @param interactionSource an optional hoisted [MutableInteractionSource] for observing and * emitting [Interaction]s for this radio button. You can use this to change the radio button's @@ -134,7 +134,7 @@ fun RadioButtonMMD( onClick: (() -> Unit)?, modifier: Modifier = Modifier, enabled: Boolean = true, - colors: RadioButtonColors = RadioButtonDefaultsMMD.colors(), + colors: RadioButtonColorsMMD = RadioButtonDefaultsMMD.colors(), interactionSource: MutableInteractionSource? = null, ) { val radioColor = colors.radioColor(enabled, selected) @@ -186,14 +186,14 @@ fun RadioButtonMMD( object RadioButtonDefaultsMMD { /** - * Creates a [RadioButtonColors] that will animate between the provided colors according to the + * Creates a [RadioButtonColorsMMD] that will animate between the provided colors according to the * Material specification. */ @Composable fun colors() = defaultRadioButtonColors /** - * Creates a [RadioButtonColors] that will animate between the provided colors according to the + * Creates a [RadioButtonColorsMMD] that will animate between the provided colors according to the * Material specification. * * @param selectedColor the color to use for the RadioButton when selected and enabled. @@ -201,7 +201,7 @@ object RadioButtonDefaultsMMD { * @param disabledSelectedColor the color to use for the RadioButton when disabled and selected. * @param disabledUnselectedColor the color to use for the RadioButton when disabled and not * selected. - * @return the resulting [RadioButtonColors] used for the RadioButton + * @return the resulting [RadioButtonColorsMMD] used for the RadioButton */ @Composable fun colors( @@ -209,7 +209,7 @@ object RadioButtonDefaultsMMD { unselectedColor: Color = Color.Unspecified, disabledSelectedColor: Color = Color.Unspecified, disabledUnselectedColor: Color = Color.Unspecified, - ): RadioButtonColors = + ): RadioButtonColorsMMD = defaultRadioButtonColors.copy( selectedColor, unselectedColor, @@ -217,8 +217,8 @@ object RadioButtonDefaultsMMD { disabledUnselectedColor, ) - private val defaultRadioButtonColors: RadioButtonColors - @Composable get() = RadioButtonColors( + private val defaultRadioButtonColors: RadioButtonColorsMMD + @Composable get() = RadioButtonColorsMMD( selectedColor = SelectedIconColor, unselectedColor = UnselectedIconColor, disabledSelectedColor = DisabledSelectedIconColor.copy(alpha = DisabledSelectedIconOpacity), @@ -238,7 +238,7 @@ object RadioButtonDefaultsMMD { * default implementation that follows Material specifications. */ @Immutable -class RadioButtonColors( +class RadioButtonColorsMMD( val selectedColor: Color, val unselectedColor: Color, val disabledSelectedColor: Color, @@ -254,7 +254,7 @@ class RadioButtonColors( disabledSelectedColor: Color = this.disabledSelectedColor, disabledUnselectedColor: Color = this.disabledUnselectedColor, ) = - RadioButtonColors( + RadioButtonColorsMMD( selectedColor.takeOrElse { this.selectedColor }, unselectedColor.takeOrElse { this.unselectedColor }, disabledSelectedColor.takeOrElse { this.disabledSelectedColor }, @@ -283,7 +283,7 @@ class RadioButtonColors( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || other !is RadioButtonColors) return false + if (other == null || other !is RadioButtonColorsMMD) return false if (selectedColor != other.selectedColor) return false if (unselectedColor != other.unselectedColor) return false diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/search_bar/SearchBarMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/search_bar/SearchBarMMD.kt index af3089c..0f0aa94 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/search_bar/SearchBarMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/search_bar/SearchBarMMD.kt @@ -88,7 +88,7 @@ import com.mudita.mmd.components.divider.HorizontalDividerMMD import com.mudita.mmd.components.search_bar.SearchBarDefaultsMMD.SearchBarColorsMMD import com.mudita.mmd.components.search_bar.SearchBarDefaultsMMD.SearchBarImpl import com.mudita.mmd.components.search_bar.SearchBarDefaultsMMD.inputFieldShape -import com.mudita.mmd.components.text_field.TextFieldColors +import com.mudita.mmd.components.text_field.TextFieldColorsMMD import com.mudita.mmd.components.text_field.TextFieldDefaultsMMD import kotlin.coroutines.cancellation.CancellationException import kotlin.math.abs @@ -303,10 +303,10 @@ object SearchBarDefaultsMMD { ) /** - * Creates a [TextFieldColors] that represents the different colors used in the search bar input + * Creates a [TextFieldColorsMMD] that represents the different colors used in the search bar input * field in different states. * - * Only a subset of the full list of [TextFieldColors] parameters are used in the input field. + * Only a subset of the full list of [TextFieldColorsMMD] parameters are used in the input field. * All other parameters have no effect. * * @param focusedTextColor the color used for the input text of this input field when focused @@ -354,7 +354,7 @@ object SearchBarDefaultsMMD { MaterialTheme.colorScheme.onSurface.copy( alpha = 0.38f, ), - ): TextFieldColors = + ): TextFieldColorsMMD = TextFieldDefaultsMMD.colors( focusedTextColor = focusedTextColor, unfocusedTextColor = unfocusedTextColor, @@ -390,7 +390,7 @@ object SearchBarDefaultsMMD { * @param placeholder the placeholder to be displayed when the [query] is empty. * @param leadingIcon the leading icon to be displayed at the start of the input field. * @param trailingIcon the trailing icon to be displayed at the end of the input field. - * @param colors [TextFieldColors] that will be used to resolve the colors used for this input + * @param colors [TextFieldColorsMMD] that will be used to resolve the colors used for this input * field in different states. See [SearchBarDefaultsMMD.inputFieldColors]. * @param interactionSource an optional hoisted [MutableInteractionSource] for observing and * emitting [Interaction]s for this input field. You can use this to change the search bar's @@ -410,7 +410,7 @@ object SearchBarDefaultsMMD { placeholder: @Composable (() -> Unit)? = null, leadingIcon: @Composable (() -> Unit)? = null, trailingIcon: @Composable (() -> Unit)? = null, - colors: TextFieldColors = inputFieldColors(), + colors: TextFieldColorsMMD = inputFieldColors(), interactionSource: MutableInteractionSource? = null, ) { @Suppress("NAME_SHADOWING") @@ -503,7 +503,7 @@ object SearchBarDefaultsMMD { "TextFieldColors should be passed explicitly to the input field. " + "The `inputFieldColors` property will be removed in a future version of the library.", ) - val inputFieldColors: TextFieldColors, + val inputFieldColors: TextFieldColorsMMD, ) { constructor( containerColor: Color, @@ -767,8 +767,8 @@ object SearchBarDefaultsMMD { return (interpolatedOffsetY * predictiveBackMultiplier * directionMultiplier).roundToInt() } - private val UnspecifiedTextFieldColors: TextFieldColors = - TextFieldColors( + private val UnspecifiedTextFieldColors: TextFieldColorsMMD = + TextFieldColorsMMD( focusedTextColor = Color.Unspecified, unfocusedTextColor = Color.Unspecified, disabledTextColor = Color.Unspecified, diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/slider/SliderMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/slider/SliderMMD.kt index 69a25ac..307a061 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/slider/SliderMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/slider/SliderMMD.kt @@ -1286,7 +1286,7 @@ private enum class SliderComponents { @Suppress("DEPRECATION") @Deprecated("Not necessary with the introduction of Slider state") @Stable -class SliderPositions( +class SliderPositionsMMD( initialActiveRange: ClosedFloatingPointRange = 0f..1f, initialTickFractions: FloatArray = floatArrayOf(), ) { @@ -1307,7 +1307,7 @@ class SliderPositions( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is SliderPositions) return false + if (other !is SliderPositionsMMD) return false if (activeRange != other.activeRange) return false if (!tickFractions.contentEquals(other.tickFractions)) return false diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tabs/TabsMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tabs/TabsMMD.kt index 3914350..da5ebb0 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tabs/TabsMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tabs/TabsMMD.kt @@ -192,7 +192,7 @@ fun PrimaryTabRowMMD( modifier: Modifier = Modifier, containerColor: Color = TabRowDefaultsMMD.primaryContainerColor, contentColor: Color = TabRowDefaultsMMD.primaryContentColor, - indicator: @Composable TabIndicatorScope.() -> Unit = { + indicator: @Composable TabIndicatorScopeMMD.() -> Unit = { TabRowDefaultsMMD.PrimaryIndicator( modifier = Modifier.tabIndicatorOffset(selectedTabIndex, matchContentSize = true), width = Dp.Unspecified, @@ -268,7 +268,7 @@ fun SecondaryTabRowMMD( modifier: Modifier = Modifier, containerColor: Color = TabRowDefaultsMMD.secondaryContainerColor, contentColor: Color = TabRowDefaultsMMD.secondaryContentColor, - indicator: @Composable TabIndicatorScope.() -> Unit = + indicator: @Composable TabIndicatorScopeMMD.() -> Unit = @Composable { TabRowDefaultsMMD.SecondaryIndicator( Modifier.tabIndicatorOffset(selectedTabIndex, matchContentSize = false), @@ -454,7 +454,7 @@ fun PrimaryScrollableTabRowMMD( containerColor: Color = TabRowDefaultsMMD.primaryContainerColor, contentColor: Color = TabRowDefaultsMMD.primaryContentColor, edgePadding: Dp = TabRowDefaultsMMD.ScrollableTabRowEdgeStartPadding, - indicator: @Composable TabIndicatorScope.() -> Unit = + indicator: @Composable TabIndicatorScopeMMD.() -> Unit = @Composable { TabRowDefaultsMMD.PrimaryIndicator( Modifier.tabIndicatorOffset(selectedTabIndex, matchContentSize = true), @@ -521,7 +521,7 @@ fun SecondaryScrollableTabRowMMD( containerColor: Color = TabRowDefaultsMMD.secondaryContainerColor, contentColor: Color = TabRowDefaultsMMD.secondaryContentColor, edgePadding: Dp = TabRowDefaultsMMD.ScrollableTabRowEdgeStartPadding, - indicator: @Composable TabIndicatorScope.() -> Unit = + indicator: @Composable TabIndicatorScopeMMD.() -> Unit = @Composable { TabRowDefaultsMMD.SecondaryIndicator( Modifier.tabIndicatorOffset(selectedTabIndex, matchContentSize = false), @@ -613,7 +613,7 @@ fun ScrollableTabRowMMD( * [TabRowDefaultsMMD.SecondaryIndicator] */ @ExperimentalMaterial3Api -interface TabIndicatorScope { +interface TabIndicatorScopeMMD { /** * A layout modifier that provides tab positions, this can be used to animate and layout a @@ -646,7 +646,7 @@ private fun TabRowImpl( modifier: Modifier, containerColor: Color, contentColor: Color, - indicator: @Composable TabIndicatorScope.() -> Unit, + indicator: @Composable TabIndicatorScopeMMD.() -> Unit, divider: @Composable () -> Unit, tabs: @Composable () -> Unit, ) { @@ -656,7 +656,7 @@ private fun TabRowImpl( contentColor = contentColor, ) { val scope = remember { - object : TabIndicatorScope, TabPositionsHolder { + object : TabIndicatorScopeMMD, TabPositionsHolder { val tabPositions = mutableStateOf<(List)>(listOf()) @@ -769,7 +769,7 @@ private fun ScrollableTabRowImpl( contentColor: Color, edgePadding: Dp, scrollState: ScrollState, - indicator: @Composable TabIndicatorScope.() -> Unit, + indicator: @Composable TabIndicatorScopeMMD.() -> Unit, divider: @Composable () -> Unit, tabs: @Composable () -> Unit, ) { @@ -791,7 +791,7 @@ private fun ScrollableTabRowImpl( } val scope = remember { - object : TabIndicatorScope, TabPositionsHolder { + object : TabIndicatorScopeMMD, TabPositionsHolder { val tabPositions = mutableStateOf<(List)>(listOf()) diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldDefaultsMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldDefaultsMMD.kt index 5e4ff47..67dc4e4 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldDefaultsMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldDefaultsMMD.kt @@ -87,7 +87,7 @@ object TextFieldDefaultsMMD { * @param interactionSource the [InteractionSource] of the text field. Used to determine if the * text field is in focus or not * @param modifier the [Modifier] of this container - * @param colors [TextFieldColors] used to resolve colors of the text field + * @param colors [TextFieldColorsMMD] used to resolve colors of the text field * @param shape the shape of this container * @param focusedIndicatorLineThickness thickness of the indicator line when the text field is * focused @@ -101,7 +101,7 @@ object TextFieldDefaultsMMD { isError: Boolean, interactionSource: InteractionSource, modifier: Modifier = Modifier, - colors: TextFieldColors = colors(), + colors: TextFieldColorsMMD = colors(), shape: Shape = TextFieldDefaultsMMD.shape, focusedIndicatorLineThickness: Dp = FocusedIndicatorThickness, unfocusedIndicatorLineThickness: Dp = UnfocusedIndicatorThickness, @@ -134,7 +134,7 @@ object TextFieldDefaultsMMD { * @param isError whether the text field's current value is in error * @param interactionSource the [InteractionSource] of the text field. Used to determine if the * text field is in focus or not - * @param colors [TextFieldColors] used to resolve colors of the text field + * @param colors [TextFieldColorsMMD] used to resolve colors of the text field * @param focusedIndicatorLineThickness thickness of the indicator line when the text field is * focused * @param unfocusedIndicatorLineThickness thickness of the indicator line when the text field is @@ -145,7 +145,7 @@ object TextFieldDefaultsMMD { enabled: Boolean, isError: Boolean, interactionSource: InteractionSource, - colors: TextFieldColors, + colors: TextFieldColorsMMD, focusedIndicatorLineThickness: Dp = FocusedIndicatorThickness, unfocusedIndicatorLineThickness: Dp = UnfocusedIndicatorThickness ) = @@ -264,7 +264,7 @@ object TextFieldDefaultsMMD { * @param suffix the optional suffix to be displayed after the input text in the text field * @param supportingText the optional supporting text to be displayed below the text field * @param shape defines the shape of this decoration box's container - * @param colors [TextFieldColors] that will be used to resolve the colors used for this text + * @param colors [TextFieldColorsMMD] that will be used to resolve the colors used for this text * field decoration box in different states. See [TextFieldDefaultsMMD.colors]. * @param contentPadding the padding applied between the internal elements of this decoration * box and the edge of its container. If a [label] is present, the top padding represents the @@ -293,7 +293,7 @@ object TextFieldDefaultsMMD { suffix: @Composable (() -> Unit)? = null, supportingText: @Composable (() -> Unit)? = null, shape: Shape = TextFieldDefaultsMMD.shape, - colors: TextFieldColors = colors(), + colors: TextFieldColorsMMD = colors(), contentPadding: PaddingValues = if (label == null) { contentPaddingWithoutLabel() @@ -367,14 +367,14 @@ object TextFieldDefaultsMMD { ): PaddingValues = PaddingValues(start, top, end, bottom) /** - * Creates a [TextFieldColors] that represents the default input text, container, and content + * Creates a [TextFieldColorsMMD] that represents the default input text, container, and content * colors (including label, placeholder, icons, etc.) used in a [TextFieldMMD]. */ @Composable fun colors() = defaultTextFieldColors /** - * Creates a [TextFieldColors] that represents the default input text, container, and content + * Creates a [TextFieldColorsMMD] that represents the default input text, container, and content * colors (including label, placeholder, icons, etc.) used in a [TextFieldMMD]. * * @param focusedTextColor the color used for the input text of this text field when focused @@ -472,7 +472,7 @@ object TextFieldDefaultsMMD { unfocusedSuffixColor: Color = Color.Unspecified, disabledSuffixColor: Color = Color.Unspecified, errorSuffixColor: Color = Color.Unspecified, - ): TextFieldColors = + ): TextFieldColorsMMD = defaultTextFieldColors.copy( focusedTextColor = focusedTextColor, unfocusedTextColor = unfocusedTextColor, @@ -519,8 +519,8 @@ object TextFieldDefaultsMMD { errorSuffixColor = errorSuffixColor, ) - private val defaultTextFieldColors: TextFieldColors - @Composable get() = TextFieldColors( + private val defaultTextFieldColors: TextFieldColorsMMD + @Composable get() = TextFieldColorsMMD( focusedTextColor = FocusInputColor, unfocusedTextColor = InputColor, disabledTextColor = DisabledInputColor @@ -629,7 +629,7 @@ object TextFieldDefaultsMMD { * colors used in [OutlinedTextField]. */ @Immutable -class TextFieldColors( +class TextFieldColorsMMD( val focusedTextColor: Color, val unfocusedTextColor: Color, val disabledTextColor: Color, @@ -724,7 +724,7 @@ class TextFieldColors( disabledSuffixColor: Color = this.disabledSuffixColor, errorSuffixColor: Color = this.errorSuffixColor, ) = - TextFieldColors( + TextFieldColorsMMD( focusedTextColor.takeOrElse { this.focusedTextColor }, unfocusedTextColor.takeOrElse { this.unfocusedTextColor }, disabledTextColor.takeOrElse { this.disabledTextColor }, @@ -985,7 +985,7 @@ class TextFieldColors( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || other !is TextFieldColors) return false + if (other == null || other !is TextFieldColorsMMD) return false if (focusedTextColor != other.focusedTextColor) return false if (unfocusedTextColor != other.unfocusedTextColor) return false diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldImpl.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldImpl.kt index 00b844f..211166f 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldImpl.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldImpl.kt @@ -77,7 +77,7 @@ internal fun CommonDecorationBox( isError: Boolean = false, interactionSource: InteractionSource, contentPadding: PaddingValues, - colors: TextFieldColors, + colors: TextFieldColorsMMD, container: @Composable () -> Unit, ) { val transformedText = remember(value, visualTransformation) { @@ -325,7 +325,7 @@ internal fun getBorderStroke( enabled: Boolean, isError: Boolean, focused: Boolean, - colors: TextFieldColors, + colors: TextFieldColorsMMD, focusedBorderThickness: Dp, unfocusedBorderThickness: Dp, ): State { diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldMMD.kt index 2e9057d..61315d2 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/text_field/TextFieldMMD.kt @@ -315,7 +315,7 @@ import kotlin.math.roundToInt * appearance or preview the text field in different states. Note that if `null` is provided, * interactions will still happen internally. * @param shape defines the shape of this text field's container - * @param colors [TextFieldColors] that will be used to resolve the colors used for this text field + * @param colors [TextFieldColorsMMD] that will be used to resolve the colors used for this text field * in different states. See [TextFieldDefaultsMMD.colors]. */ @OptIn(ExperimentalMaterial3Api::class) @@ -343,7 +343,7 @@ fun TextFieldMMD( minLines: Int = 1, interactionSource: MutableInteractionSource? = null, shape: Shape = TextFieldDefaultsMMD.shape, - colors: TextFieldColors = TextFieldDefaultsMMD.colors(), + colors: TextFieldColorsMMD = TextFieldDefaultsMMD.colors(), ) { @Suppress("NAME_SHADOWING") val interactionSource = interactionSource ?: remember { MutableInteractionSource() } @@ -474,7 +474,7 @@ fun TextFieldMMD( * appearance or preview the text field in different states. Note that if `null` is provided, * interactions will still happen internally. * @param shape defines the shape of this text field's container - * @param colors [TextFieldColors] that will be used to resolve the colors used for this text field + * @param colors [TextFieldColorsMMD] that will be used to resolve the colors used for this text field * in different states. See [TextFieldDefaultsMMD.colors]. */ @OptIn(ExperimentalMaterial3Api::class) @@ -502,7 +502,7 @@ fun TextFieldMMD( minLines: Int = 1, interactionSource: MutableInteractionSource? = null, shape: Shape = TextFieldDefaultsMMD.shape, - colors: TextFieldColors = TextFieldDefaultsMMD.colors(), + colors: TextFieldColorsMMD = TextFieldDefaultsMMD.colors(), ) { @Suppress("NAME_SHADOWING") val interactionSource = interactionSource ?: remember { MutableInteractionSource() } diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/time/TimeInputMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/time/TimeInputMMD.kt index 1ccc77e..273868f 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/time/TimeInputMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/time/TimeInputMMD.kt @@ -139,7 +139,7 @@ import com.mudita.mmd.internal.top * @param state state for this timepicker, allows to subscribe to changes to [TimeInputStateMMD.hour] * and [TimeInputStateMMD.minute], and set the initial time for this picker. * @param modifier the [Modifier] to be applied to this time input - * @param colors colors [TimeInputColors] that will be used to resolve the colors used for this + * @param colors colors [TimeInputColorsMMD] that will be used to resolve the colors used for this * time input in different states. See [TimeInputDefaultsMMD.colors]. */ @Composable @@ -147,7 +147,7 @@ import com.mudita.mmd.internal.top fun TimeInputMMD( state: TimeInputStateMMD, modifier: Modifier = Modifier, - colors: TimeInputColors = TimeInputDefaultsMMD.colors(), + colors: TimeInputColorsMMD = TimeInputDefaultsMMD.colors(), ) { TimeInputImpl(modifier, colors, state) } @@ -206,8 +206,8 @@ object TimeInputDefaultsMMD { timeSelectorUnselectedContentColor = timeSelectorUnselectedContentColor, ) - private val defaultTimeInputColors: TimeInputColors - @Composable get() = TimeInputColors( + private val defaultTimeInputColors: TimeInputColorsMMD + @Composable get() = TimeInputColorsMMD( periodSelectorBorderColor = PeriodSelectorOutlineColor, periodSelectorSelectedContainerColor = PeriodSelectorSelectedContainerColor, periodSelectorUnselectedContainerColor = Color.Transparent, @@ -244,7 +244,7 @@ object TimeInputDefaultsMMD { */ @Immutable @ExperimentalMaterial3Api -class TimeInputColors( +class TimeInputColorsMMD( val periodSelectorBorderColor: Color, val periodSelectorSelectedContainerColor: Color, val periodSelectorUnselectedContainerColor: Color, @@ -270,7 +270,7 @@ class TimeInputColors( timeSelectorSelectedContentColor: Color = this.timeSelectorSelectedContentColor, timeSelectorUnselectedContentColor: Color = this.timeSelectorUnselectedContentColor, ) = - TimeInputColors( + TimeInputColorsMMD( periodSelectorBorderColor.takeOrElse { this.periodSelectorBorderColor }, periodSelectorSelectedContainerColor.takeOrElse { this.periodSelectorSelectedContainerColor @@ -333,7 +333,7 @@ class TimeInputColors( if (other === null) return false if (this::class != other::class) return false - other as TimeInputColors + other as TimeInputColorsMMD if (periodSelectorBorderColor != other.periodSelectorBorderColor) return false if (periodSelectorSelectedContainerColor != other.periodSelectorSelectedContainerColor) @@ -527,7 +527,7 @@ internal val TimeInputStateMMD.hourForDisplay: Int @Composable private fun TimeInputImpl( modifier: Modifier, - colors: TimeInputColors, + colors: TimeInputColorsMMD, state: TimeInputStateMMD, ) { var hourValue by rememberSaveable(stateSaver = TextFieldValue.Saver) { @@ -644,7 +644,7 @@ private fun TimeInputImpl( private fun VerticalPeriodToggle( modifier: Modifier, state: TimeInputStateMMD, - colors: TimeInputColors, + colors: TimeInputColorsMMD, ) { val measurePolicy = remember { MeasurePolicy { measurables, constraints -> @@ -689,7 +689,7 @@ private fun VerticalPeriodToggle( private fun PeriodToggleImpl( modifier: Modifier, state: TimeInputStateMMD, - colors: TimeInputColors, + colors: TimeInputColorsMMD, measurePolicy: MeasurePolicy, startShape: Shape, endShape: Shape, @@ -741,7 +741,7 @@ private fun ToggleItem( checked: Boolean, shape: Shape, onClick: () -> Unit, - colors: TimeInputColors, + colors: TimeInputColorsMMD, content: @Composable RowScope.() -> Unit, ) { val contentColor = colors.periodSelectorContentColor(checked) @@ -789,7 +789,7 @@ private fun TimeSelector( value: Int, state: TimeInputStateMMD, selection: TimePickerSelectionMode, - colors: TimeInputColors, + colors: TimeInputColorsMMD, ) { val context = LocalContext.current val selected = state.selection == selection @@ -900,7 +900,7 @@ private fun TimePickerTextField( selection: TimePickerSelectionMode, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, - colors: TimeInputColors, + colors: TimeInputColorsMMD, ) { val context = LocalContext.current val interactionSource = remember { MutableInteractionSource() } diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tooltip/TooltipBoxMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tooltip/TooltipBoxMMD.kt index 2c88342..3cc17ad 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tooltip/TooltipBoxMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tooltip/TooltipBoxMMD.kt @@ -30,7 +30,7 @@ import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import com.mudita.mmd.components.tooltip.CaretDirection.Down +import com.mudita.mmd.components.tooltip.CaretDirectionMMD.Down @OptIn(ExperimentalMaterial3Api::class) @Composable diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tooltip/TooltipMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tooltip/TooltipMMD.kt index addd4db..76004d4 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tooltip/TooltipMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/tooltip/TooltipMMD.kt @@ -51,9 +51,9 @@ import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.compose.ui.window.PopupPositionProvider -import com.mudita.mmd.components.tooltip.CaretDirection.Auto -import com.mudita.mmd.components.tooltip.CaretDirection.Down -import com.mudita.mmd.components.tooltip.CaretDirection.Up +import com.mudita.mmd.components.tooltip.CaretDirectionMMD.Auto +import com.mudita.mmd.components.tooltip.CaretDirectionMMD.Down +import com.mudita.mmd.components.tooltip.CaretDirectionMMD.Up /** * A custom tooltip component that displays a message when the user hovers over or focuses on a specific UI element. @@ -114,7 +114,7 @@ import com.mudita.mmd.components.tooltip.CaretDirection.Up fun TooltipMMD( modifier: Modifier = Modifier, caretSize: DpSize = TooltipDefaultsMMD.CaretSize, - caretDirection: CaretDirection = Auto, + caretDirection: CaretDirectionMMD = Auto, containerColor: Color = TooltipDefaultsMMD.ContainerColor, contentColor: Color = TooltipDefaultsMMD.ContentColor, borderColor: Color = TooltipDefaultsMMD.BorderColor, @@ -212,7 +212,7 @@ fun TooltipMMD( } } -enum class CaretDirection { Up, Down, Auto } +enum class CaretDirectionMMD { Up, Down, Auto } /** * TooltipDefaultsMMD provides default values and configurations for tooltips in a Composable UI. @@ -285,7 +285,7 @@ object TooltipDefaultsMMD { @Composable fun rememberPlainTooltipPositionProvider( spacingBetweenTooltipAndAnchor: Dp = SpacingBetweenTooltipAndAnchor, - onCaretDirectionChange: (CaretDirection) -> Unit, + onCaretDirectionChange: (CaretDirectionMMD) -> Unit, ): PopupPositionProvider { val tooltipAnchorSpacing = with(LocalDensity.current) { spacingBetweenTooltipAndAnchor.roundToPx() } @@ -299,14 +299,14 @@ object TooltipDefaultsMMD { /** * A [PopupPositionProvider] implementation for positioning a tooltip relative to its anchor. * This class calculates the optimal position for the tooltip, ensuring it does not overlap with the anchor. - * It also handles caret direction changes when the caret direction is set to [CaretDirection.Auto]. + * It also handles caret direction changes when the caret direction is set to [CaretDirectionMMD.Auto]. * * @param tooltipAnchorSpacing The space in pixels between the tooltip and its anchor. * @param onCaretDirectionChange A callback invoked when the caret direction changes. * */ private class PlainTooltipPositionProvider( private val tooltipAnchorSpacing: Int, - private val onCaretDirectionChange: (CaretDirection) -> Unit, + private val onCaretDirectionChange: (CaretDirectionMMD) -> Unit, ) : PopupPositionProvider { override fun calculatePosition( diff --git a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/top_app_bar/TopAppBarMMD.kt b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/top_app_bar/TopAppBarMMD.kt index 58e2206..8e887a5 100644 --- a/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/top_app_bar/TopAppBarMMD.kt +++ b/mmd-core/src/androidMain/kotlin/com/mudita/mmd/components/top_app_bar/TopAppBarMMD.kt @@ -163,13 +163,18 @@ object TopAppBarDefaultsMMD { * between the provided colors according to the Material Design specification. */ @Composable - fun topAppBarColors() = + fun topAppBarColors( + containerColor: Color = MaterialTheme.colorScheme.surface, + scrolledContainerColor: Color = MaterialTheme.colorScheme.surfaceContainer, + navigationIconContentColor: Color = MaterialTheme.colorScheme.onSurface, + titleContentColor: Color = MaterialTheme.colorScheme.onSurface + ) = TopAppBarColors( - containerColor = MaterialTheme.colorScheme.surface, - scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainer, - navigationIconContentColor = MaterialTheme.colorScheme.onSurface, - titleContentColor = MaterialTheme.colorScheme.onSurface, - actionIconContentColor = MaterialTheme.colorScheme.onSurfaceVariant, + containerColor = containerColor, + scrolledContainerColor = scrolledContainerColor, + navigationIconContentColor = navigationIconContentColor, + titleContentColor = navigationIconContentColor, + actionIconContentColor = titleContentColor, ) /** Default divider colors used by a [TopAppBarMMD] */