mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 19:44:25 +08:00
refactor: merge contentSpacing into style in RadioButton
This commit is contained in:
@@ -65,6 +65,7 @@ data class RadioButtonColors(
|
|||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
data class RadioButtonStyle(
|
data class RadioButtonStyle(
|
||||||
|
val contentSpacing: Dp,
|
||||||
val contentRadius: Dp,
|
val contentRadius: Dp,
|
||||||
val contentShadowSize: Dp,
|
val contentShadowSize: Dp,
|
||||||
val strokeRadius: Dp,
|
val strokeRadius: Dp,
|
||||||
@@ -83,7 +84,6 @@ fun RadioButton(
|
|||||||
style: RadioButtonStyle = RadioButton.style,
|
style: RadioButtonStyle = RadioButton.style,
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||||
contentSpacing: Dp = RadioButton.contentSpacing,
|
|
||||||
content: @Composable () -> Unit = {}
|
content: @Composable () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
val contentDiameter = style.contentRadius * 2
|
val contentDiameter = style.contentRadius * 2
|
||||||
@@ -116,7 +116,7 @@ fun RadioButton(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.padding(start = contentSpacing)
|
modifier = Modifier.padding(start = style.contentSpacing)
|
||||||
.clickable(enabled = enabled, onClick = onClick)
|
.clickable(enabled = enabled, onClick = onClick)
|
||||||
) { content() }
|
) { content() }
|
||||||
}
|
}
|
||||||
@@ -131,10 +131,6 @@ object RadioButton {
|
|||||||
@Composable
|
@Composable
|
||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
get() = defaultRadioButtonStyle()
|
get() = defaultRadioButtonStyle()
|
||||||
val contentSpacing: Dp
|
|
||||||
@Composable
|
|
||||||
@ReadOnlyComposable
|
|
||||||
get() = defaultRadioButtonContentSpacing()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -148,6 +144,7 @@ private fun defaultRadioButtonColors() = RadioButtonColors(
|
|||||||
@Composable
|
@Composable
|
||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
private fun defaultRadioButtonStyle() = RadioButtonStyle(
|
private fun defaultRadioButtonStyle() = RadioButtonStyle(
|
||||||
|
contentSpacing = LocalSizes.current.spacingSecondary,
|
||||||
contentRadius = DefaultContentRadius,
|
contentRadius = DefaultContentRadius,
|
||||||
contentShadowSize = DefaultContentShadowSize,
|
contentShadowSize = DefaultContentShadowSize,
|
||||||
strokeRadius = DefaultStrokeRadius,
|
strokeRadius = DefaultStrokeRadius,
|
||||||
@@ -161,10 +158,6 @@ private fun defaultRadioButtonStyle() = RadioButtonStyle(
|
|||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
private fun defaultRadioButtonBorder() = BorderStroke(LocalSizes.current.borderSizeTertiary, LocalColors.current.textPrimary)
|
private fun defaultRadioButtonBorder() = BorderStroke(LocalSizes.current.borderSizeTertiary, LocalColors.current.textPrimary)
|
||||||
|
|
||||||
@Composable
|
|
||||||
@ReadOnlyComposable
|
|
||||||
private fun defaultRadioButtonContentSpacing() = LocalSizes.current.spacingSecondary
|
|
||||||
|
|
||||||
private val DefaultContentRadius = 5.dp
|
private val DefaultContentRadius = 5.dp
|
||||||
private val DefaultStrokeRadius = 10.dp
|
private val DefaultStrokeRadius = 10.dp
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user