Skip to content

Commit c1aa461

Browse files
authored
library: Optimize icons, colors, corner radii and font sizes (#28)
* update: Optimize icons, colors, corner radii * update: Optimize font sizes (temporary solution) * update: [MiuixIndication] Remove useless code
1 parent 9a98700 commit c1aa461

File tree

18 files changed

+283
-119
lines changed

18 files changed

+283
-119
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ kotlin {
2727
@Composable
2828
fun App() {
2929
MiuixTheme(
30-
colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
30+
colors = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
3131
) {
3232
// Other content...
3333
}

composeApp/src/commonMain/kotlin/ui/Theme.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fun AppTheme(
1313
) {
1414
val darkTheme = isSystemInDarkTheme()
1515
return MiuixTheme(
16-
colorScheme = when (colorMode) {
16+
colors = when (colorMode) {
1717
1 -> lightColorScheme()
1818
2 -> darkColorScheme()
1919
else -> if (darkTheme) darkColorScheme() else lightColorScheme()

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import top.yukonga.miuix.kmp.utils.SmoothRoundedCornerShape
3030
* @param enabled Whether the [Button] is enabled.
3131
* @param submit Whether the [Button] is a submit button.
3232
* @param cornerRadius The corner radius of the [Button].
33+
* @param minHeight The minimum height of the [Button].
3334
*/
3435
@Composable
3536
fun Button(
@@ -38,7 +39,8 @@ fun Button(
3839
onClick: () -> Unit,
3940
enabled: Boolean = true,
4041
submit: Boolean = false,
41-
cornerRadius: Dp = 18.dp
42+
cornerRadius: Dp = 16.dp,
43+
minHeight: Dp = 40.dp
4244
) {
4345
val hapticFeedback = LocalHapticFeedback.current
4446
val color by rememberUpdatedState(getButtonColor(enabled, submit))
@@ -56,14 +58,15 @@ fun Button(
5658
) {
5759
Row(
5860
Modifier
59-
.defaultMinSize(minWidth = 58.dp, minHeight = 40.dp)
61+
.defaultMinSize(minWidth = 58.dp, minHeight = minHeight)
6062
.padding(16.dp, 16.dp),
6163
horizontalArrangement = Arrangement.Center,
6264
verticalAlignment = Alignment.CenterVertically,
6365
) {
6466
Text(
6567
text = text,
6668
color = textColor,
69+
fontSize = MiuixTheme.textStyles.button.fontSize,
6770
fontWeight = FontWeight.Medium
6871
)
6972
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import top.yukonga.miuix.kmp.utils.SmoothRoundedCornerShape
2929
fun Card(
3030
modifier: Modifier = Modifier,
3131
insideMargin: DpSize = DpSize(0.dp, 0.dp),
32-
cornerRadius: Dp = 18.dp,
32+
cornerRadius: Dp = 16.dp,
3333
color: Color = MiuixTheme.colorScheme.surface,
3434
content: @Composable ColumnScope.() -> Unit
3535
) {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Column
88
import androidx.compose.foundation.layout.Row
99
import androidx.compose.foundation.layout.RowScope
1010
import androidx.compose.foundation.layout.fillMaxWidth
11+
import androidx.compose.foundation.layout.heightIn
1112
import androidx.compose.foundation.layout.padding
1213
import androidx.compose.runtime.Composable
1314
import androidx.compose.runtime.getValue
@@ -81,6 +82,7 @@ fun BasicComponent(
8182
}
8283
}
8384
}
85+
.heightIn(min = 56.dp)
8486
.fillMaxWidth()
8587
.then(paddingModifier),
8688
verticalAlignment = Alignment.CenterVertically,
@@ -99,14 +101,15 @@ fun BasicComponent(
99101
title?.let {
100102
Text(
101103
text = it,
104+
fontSize = MiuixTheme.textStyles.headline1.fontSize,
102105
fontWeight = FontWeight.Medium,
103106
color = titleColor
104107
)
105108
}
106109
summary?.let {
107110
Text(
108111
text = it,
109-
fontSize = MiuixTheme.textStyles.title.fontSize,
112+
fontSize = MiuixTheme.textStyles.body2.fontSize,
110113
color = summaryColor
111114
)
112115
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import androidx.compose.ui.graphics.Color
88
import androidx.compose.ui.text.font.FontWeight
99
import androidx.compose.ui.unit.DpSize
1010
import androidx.compose.ui.unit.dp
11-
import androidx.compose.ui.unit.sp
1211
import top.yukonga.miuix.kmp.theme.MiuixTheme
1312

1413
/**
@@ -32,7 +31,7 @@ fun SmallTitle(
3231
Text(
3332
modifier = modifier.then(paddingModifier),
3433
text = text,
35-
fontSize = 14.sp,
34+
fontSize = MiuixTheme.textStyles.subtitle.fontSize,
3635
fontWeight = FontWeight.Medium,
3736
color = textColor
3837
)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ fun TextField(
195195
value: String,
196196
onValueChange: (String) -> Unit,
197197
modifier: Modifier = Modifier,
198-
insideMargin: DpSize = DpSize(16.dp, 16.dp),
198+
insideMargin: DpSize = DpSize(16.dp, 15.dp),
199199
backgroundColor: Color = MiuixTheme.colorScheme.secondaryContainer,
200-
cornerRadius: Dp = 18.dp,
200+
cornerRadius: Dp = 16.dp,
201201
label: String = "",
202202
labelColor: Color = MiuixTheme.colorScheme.onSecondaryContainer,
203203
enabled: Boolean = true,
@@ -223,7 +223,7 @@ fun TextField(
223223
else Modifier.padding(vertical = insideMargin.height)
224224
}
225225
val isFocused by interactionSource.collectIsFocusedAsState()
226-
val borderWidth by animateDpAsState(if (isFocused) 1.6.dp else 0.dp)
226+
val borderWidth by animateDpAsState(if (isFocused) 2.0.dp else 0.dp)
227227
val borderColor by animateColorAsState(if (isFocused) MiuixTheme.colorScheme.primary else backgroundColor)
228228
val labelOffsetY by animateDpAsState(if (value.isNotEmpty()) -(insideMargin.height / 2) else 0.dp)
229229
val innerTextOffsetY by animateDpAsState(if (value.isNotEmpty()) (insideMargin.height / 2) else 0.dp)

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import androidx.compose.ui.unit.Constraints
5353
import androidx.compose.ui.unit.Dp
5454
import androidx.compose.ui.unit.Velocity
5555
import androidx.compose.ui.unit.dp
56-
import androidx.compose.ui.unit.sp
5756
import androidx.compose.ui.util.fastFirst
5857
import top.yukonga.miuix.kmp.theme.MiuixTheme
5958
import kotlin.math.abs
@@ -524,7 +523,7 @@ private fun TopAppBarLayout(
524523
Text(
525524
text = title,
526525
maxLines = 1,
527-
fontSize = 20.sp,
526+
fontSize = MiuixTheme.textStyles.title3.fontSize,
528527
fontWeight = FontWeight.Medium
529528
)
530529
}
@@ -544,7 +543,7 @@ private fun TopAppBarLayout(
544543
Text(
545544
text = largeTitle,
546545
maxLines = 1,
547-
fontSize = 32.sp,
546+
fontSize = MiuixTheme.textStyles.title1.fontSize,
548547
fontWeight = FontWeight.Normal
549548
)
550549
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import androidx.compose.ui.graphics.Color
1313
import androidx.compose.ui.text.style.TextAlign
1414
import androidx.compose.ui.unit.DpSize
1515
import androidx.compose.ui.unit.dp
16-
import androidx.compose.ui.unit.sp
1716
import top.yukonga.miuix.kmp.basic.BasicComponent
1817
import top.yukonga.miuix.kmp.basic.Text
1918
import top.yukonga.miuix.kmp.icon.MiuixIcons
@@ -60,15 +59,15 @@ fun SuperArrow(
6059
if (rightText != null) {
6160
Text(
6261
text = rightText,
63-
fontSize = 15.sp,
62+
fontSize = MiuixTheme.textStyles.body2.fontSize,
6463
color = MiuixTheme.colorScheme.onSurfaceVariantActions,
6564
textAlign = TextAlign.End,
6665
)
6766
}
6867
Image(
6968
modifier = Modifier
70-
.size(15.dp)
71-
.padding(start = 6.dp),
69+
.padding(start = 8.dp)
70+
.size(10.dp, 16.dp),
7271
imageVector = MiuixIcons.ArrowRight,
7372
contentDescription = null,
7473
colorFilter = BlendModeColorFilter(MiuixTheme.colorScheme.onSurfaceVariantActions, BlendMode.SrcIn),

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import androidx.compose.ui.text.style.TextAlign
2828
import androidx.compose.ui.unit.Dp
2929
import androidx.compose.ui.unit.DpSize
3030
import androidx.compose.ui.unit.dp
31-
import androidx.compose.ui.unit.sp
3231
import top.yukonga.miuix.kmp.basic.Box
3332
import top.yukonga.miuix.kmp.basic.Text
3433
import top.yukonga.miuix.kmp.theme.MiuixTheme
@@ -60,7 +59,7 @@ fun SuperDialog(
6059
title: String? = null,
6160
titleColor: Color = MiuixTheme.colorScheme.onSurface,
6261
summary: String? = null,
63-
summaryColor: Color = MiuixTheme.colorScheme.onSurfaceVariantDialog,
62+
summaryColor: Color = MiuixTheme.colorScheme.onSurfaceSecondary,
6463
backgroundColor: Color = MiuixTheme.colorScheme.surfaceVariant,
6564
show: MutableState<Boolean>,
6665
onDismissRequest: (() -> Unit)? = null,
@@ -129,18 +128,21 @@ fun SuperDialog(
129128
) {
130129
title?.let {
131130
Text(
132-
modifier = Modifier.fillMaxWidth().padding(bottom = 20.dp),
131+
modifier = Modifier.fillMaxWidth()
132+
.padding(start = 36.dp, end = 36.dp, bottom = 16.dp),
133133
text = it,
134-
fontSize = 20.sp,
134+
fontSize = MiuixTheme.textStyles.title4.fontSize,
135135
fontWeight = FontWeight.Medium,
136136
textAlign = TextAlign.Center,
137137
color = titleColor
138138
)
139139
}
140140
summary?.let {
141141
Text(
142-
modifier = Modifier.fillMaxWidth().padding(bottom = 20.dp),
142+
modifier = Modifier.fillMaxWidth()
143+
.padding(start = 28.dp, end = 28.dp, bottom = 16.dp),
143144
text = it,
145+
fontSize = MiuixTheme.textStyles.body1.fontSize,
144146
textAlign = TextAlign.Center,
145147
color = summaryColor
146148
)

0 commit comments

Comments
 (0)