Skip to content

Commit 10eeedb

Browse files
committed
fix: 修復主页房间人数显示溢出问题
- 将 Text 组件替换为 BasicText,以更好地处理长文本 - 添加自动调整文本大小功能,确保文本能在有限空间内显示 - 设置最大行数为1,保证文本标签的简洁性
1 parent b351efd commit 10eeedb

File tree

1 file changed

+7
-4
lines changed
  • composeApp/src/commonMain/kotlin/presentation/compoments

1 file changed

+7
-4
lines changed

composeApp/src/commonMain/kotlin/presentation/compoments/TextLabel.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ package io.github.vrcmteam.vrcm.presentation.compoments
33
import androidx.compose.foundation.background
44
import androidx.compose.foundation.layout.Box
55
import androidx.compose.foundation.layout.padding
6+
import androidx.compose.foundation.text.BasicText
7+
import androidx.compose.foundation.text.TextAutoSize
68
import androidx.compose.material3.MaterialTheme
7-
import androidx.compose.material3.Text
89
import androidx.compose.runtime.Composable
910
import androidx.compose.ui.Alignment
1011
import androidx.compose.ui.Modifier
1112
import androidx.compose.ui.draw.clip
1213
import androidx.compose.ui.graphics.Color
1314
import androidx.compose.ui.unit.dp
15+
import androidx.compose.ui.unit.sp
1416

1517
@Composable
1618
fun TextLabel(
@@ -29,10 +31,11 @@ fun TextLabel(
2931
.padding(horizontal = 8.dp),
3032
contentAlignment = Alignment.Center
3133
) {
32-
Text(
34+
BasicText(
3335
text = text,
34-
style = MaterialTheme.typography.labelSmall,
35-
color = color
36+
style = MaterialTheme.typography.labelSmall.merge(color = color),
37+
autoSize = TextAutoSize.StepBased(8.sp,MaterialTheme.typography.labelSmall.fontSize),
38+
maxLines = 1
3639
)
3740
}
3841
}

0 commit comments

Comments
 (0)