From 78619a0f6b83af7f05a52aa668b2d35fecefb9de Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Fri, 1 Dec 2023 14:42:01 +0800 Subject: [PATCH] refactor: use Spacer replace Box when a small size was used --- .../kotlin/com/highcapable/flexiui/component/CheckBox.kt | 5 +++-- .../kotlin/com/highcapable/flexiui/component/RadioButton.kt | 5 +++-- .../kotlin/com/highcapable/flexiui/component/Switch.kt | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/CheckBox.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/CheckBox.kt index e19d40f..349cf5d 100644 --- a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/CheckBox.kt +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/CheckBox.kt @@ -33,8 +33,9 @@ import androidx.compose.foundation.interaction.collectIsPressedAsState import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable @@ -123,7 +124,7 @@ fun CheckBox( } content?.also { content -> Row(modifier = Modifier.clickable(enabled = enabled) { onCheckedChange(!checked) }) { - Box(modifier = Modifier.width(style.contentSpacing)) + Spacer(modifier = Modifier.padding(end = style.contentSpacing)) content() } } diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/RadioButton.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/RadioButton.kt index 90adf97..9f9a594 100644 --- a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/RadioButton.kt +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/RadioButton.kt @@ -34,8 +34,9 @@ import androidx.compose.foundation.interaction.collectIsPressedAsState import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.ReadOnlyComposable @@ -118,7 +119,7 @@ fun RadioButton( } content?.also { content -> Row(modifier = Modifier.clickable(enabled = enabled, onClick = onClick)) { - Box(modifier = Modifier.width(style.contentSpacing)) + Spacer(modifier = Modifier.padding(end = style.contentSpacing)) content() } } diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Switch.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Switch.kt index f129283..5a4650b 100644 --- a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Switch.kt +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/Switch.kt @@ -36,10 +36,10 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.ReadOnlyComposable @@ -187,7 +187,7 @@ fun Switch( content?.also { content -> Row(modifier = Modifier.clickable(enabled = enabled) { onCheckedChange(!checked) }) { content() - Box(modifier = Modifier.width(style.contentSpacing)) + Spacer(modifier = Modifier.padding(start = style.contentSpacing)) } } Track { Thumb() }