Skip to content

Commit 492f573

Browse files
wxxsfxyzmYuKongA
andauthored
library: Add spacer between rightActions in BasicComponent (#143)
Co-authored-by: YuKongA <70465933+YuKongA@users.noreply.github.com>
1 parent d0a88b3 commit 492f573

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

docs/components/basiccomponent.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ BasicComponent(
9393
| titleColor | BasicComponentColors | Title color configuration | BasicComponentDefaults.titleColor() | No |
9494
| summary | String? | Summary of the component | null | No |
9595
| summaryColor | BasicComponentColors | Summary color configuration | BasicComponentDefaults.summaryColor() | No |
96-
| leftAction | @Composable (() -> Unit?)? | Composable content on the left side of the component | null | No |
97-
| rightActions | @Composable RowScope.() -> Unit | Composable content on the right side of the component | {} | No |
96+
| leftAction | @Composable (() -> Unit)? | Composable content on the left side of the component | null | No |
97+
| rightActions | @Composable (RowScope.() -> Unit)? | Composable content on the right side of the component | null | No |
9898
| modifier | Modifier | Modifier for the component | Modifier | No |
9999
| insideMargin | PaddingValues | Internal padding of the component | BasicComponentDefaults.InsideMargin | No |
100100
| onClick | (() -> Unit)? | Callback triggered when the component is clicked | null | No |

docs/zh_CN/components/basiccomponent.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ BasicComponent(
9393
| titleColor | BasicComponentColors | 标题颜色配置 | BasicComponentDefaults.titleColor() ||
9494
| summary | String? | 组件摘要 | null ||
9595
| summaryColor | BasicComponentColors | 摘要颜色配置 | BasicComponentDefaults.summaryColor() ||
96-
| leftAction | @Composable (() -> Unit?)? | 组件左侧的可组合内容 | null ||
97-
| rightActions | @Composable RowScope.() -> Unit | 组件右侧的可组合内容 | {} ||
96+
| leftAction | @Composable (() -> Unit)? | 组件左侧的可组合内容 | null ||
97+
| rightActions | @Composable (RowScope.() -> Unit)? | 组件右侧的可组合内容 | null ||
9898
| modifier | Modifier | 应用于组件的修饰符 | Modifier ||
9999
| insideMargin | PaddingValues | 组件内部边距 | BasicComponentDefaults.InsideMargin ||
100100
| onClick | (() -> Unit)? | 点击组件时触发的回调 | null ||

iosApp/iosApp/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundleShortVersionString</key>
1818
<string>1.0.6</string>
1919
<key>CFBundleVersion</key>
20-
<string>603</string>
20+
<string>605</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>CADisableMinimumFrameDurationOnPhone</key>

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/Component.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import androidx.compose.foundation.layout.Column
1111
import androidx.compose.foundation.layout.PaddingValues
1212
import androidx.compose.foundation.layout.Row
1313
import androidx.compose.foundation.layout.RowScope
14+
import androidx.compose.foundation.layout.Spacer
1415
import androidx.compose.foundation.layout.fillMaxWidth
1516
import androidx.compose.foundation.layout.heightIn
1617
import androidx.compose.foundation.layout.padding
18+
import androidx.compose.foundation.layout.width
1719
import androidx.compose.runtime.Composable
1820
import androidx.compose.runtime.Immutable
1921
import androidx.compose.runtime.LaunchedEffect
@@ -51,7 +53,7 @@ fun BasicComponent(
5153
summary: String? = null,
5254
summaryColor: BasicComponentColors = BasicComponentDefaults.summaryColor(),
5355
leftAction: @Composable (() -> Unit)? = null,
54-
rightActions: @Composable RowScope.() -> Unit = {},
56+
rightActions: @Composable (RowScope.() -> Unit)? = null,
5557
modifier: Modifier = Modifier,
5658
insideMargin: PaddingValues = BasicComponentDefaults.InsideMargin,
5759
onClick: (() -> Unit)? = null,
@@ -120,8 +122,13 @@ fun BasicComponent(
120122
}
121123
}
122124

123-
// Right actions (optional)
124-
rightActions()
125+
if (rightActions != null) {
126+
// Add a Spacer for margin when rightActions are present
127+
Spacer(modifier = Modifier.width(8.dp))
128+
129+
// Right actions (optional)
130+
rightActions()
131+
}
125132
}
126133
}
127134

@@ -166,4 +173,4 @@ class BasicComponentColors(
166173
) {
167174
@Stable
168175
internal fun color(enabled: Boolean): Color = if (enabled) color else disabledColor
169-
}
176+
}

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/extra/SuperArrow.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package top.yukonga.miuix.kmp.extra
66
import androidx.compose.foundation.Image
77
import androidx.compose.foundation.layout.PaddingValues
88
import androidx.compose.foundation.layout.RowScope
9-
import androidx.compose.foundation.layout.padding
109
import androidx.compose.foundation.layout.size
1110
import androidx.compose.foundation.layout.widthIn
1211
import androidx.compose.runtime.Composable
@@ -103,7 +102,6 @@ private fun SuperArrowRightActions(
103102
}
104103
Image(
105104
modifier = Modifier
106-
.padding(start = 8.dp)
107105
.size(width = 10.dp, height = 16.dp),
108106
imageVector = MiuixIcons.Basic.ArrowRight,
109107
contentDescription = null,

0 commit comments

Comments
 (0)