Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file removed mmd-core/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fun BadgedBoxMMD(
@Composable
fun BadgeMMD(
modifier: Modifier = Modifier,
containerColor: Color = BadgeDefaults.containerColor,
containerColor: Color = BadgeDefaultsMMD.containerColor,
contentColor: Color = contentColorFor(containerColor),
content: @Composable (RowScope.() -> Unit)? = null,
) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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

/**
Expand All @@ -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. */
Expand Down Expand Up @@ -207,7 +207,7 @@ class SheetStateMMD(
* call.
*/
private suspend fun moveTo(
targetValue: SheetValue,
targetValue: SheetValueMMD,
velocity: Float = anchoredDraggableState.lastVelocity,
) {
anchoredDraggableState.moveTo(targetValue, velocity)
Expand All @@ -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)
}

Expand All @@ -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<SheetStateMMD, SheetValue>(
Saver<SheetStateMMD, SheetValueMMD>(
save = { it.currentValue },
restore = { savedValue ->
SheetStateMMD(
Expand All @@ -265,7 +265,7 @@ class SheetStateMMD(

/** Possible values of [SheetStateMMD]. */
@ExperimentalMaterial3Api
enum class SheetValue {
enum class SheetValueMMD {
/** The sheet is not visible. */
Hidden,

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand All @@ -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,
) {
Expand Down Expand Up @@ -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].
Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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.
Expand All @@ -276,17 +276,17 @@ object CardDefaultsMMD {
contentColor: Color = contentColorFor(containerColor),
disabledContainerColor: Color = Color.Unspecified,
disabledContentColor: Color = contentColor.copy(.38f),
): CardColors =
): CardColorsMMD =
defaultCardColors.copy(
containerColor = containerColor,
contentColor = contentColor,
disabledContainerColor = disabledContainerColor,
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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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 },
Expand All @@ -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
Expand Down
Loading
Loading