Skip to content

Commit 0329f33

Browse files
committed
library: SearchBar: Fix font weight & icons padding
1 parent 94a72b8 commit 0329f33

File tree

3 files changed

+59
-6
lines changed

3 files changed

+59
-6
lines changed

example/src/commonMain/kotlin/MainPage.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import androidx.compose.runtime.remember
2222
import androidx.compose.runtime.setValue
2323
import androidx.compose.ui.Modifier
2424
import androidx.compose.ui.input.nestedscroll.nestedScroll
25+
import androidx.compose.ui.text.TextStyle
26+
import androidx.compose.ui.text.font.FontWeight
2527
import androidx.compose.ui.unit.dp
28+
import androidx.compose.ui.unit.sp
2629
import component.OtherComponent
2730
import component.TextComponent
2831
import top.yukonga.miuix.kmp.basic.BasicComponent
@@ -111,6 +114,7 @@ fun MainPage(
111114
miuixSearchValue = ""
112115
},
113116
text = "Cancel",
117+
style = TextStyle(fontSize = 17.sp, fontWeight = FontWeight.Bold),
114118
color = MiuixTheme.colorScheme.primary
115119
)
116120
},

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ import androidx.compose.ui.graphics.SolidColor
3232
import androidx.compose.ui.platform.LocalFocusManager
3333
import androidx.compose.ui.semantics.onClick
3434
import androidx.compose.ui.semantics.semantics
35+
import androidx.compose.ui.text.TextStyle
36+
import androidx.compose.ui.text.font.FontWeight
3537
import androidx.compose.ui.text.input.ImeAction
3638
import androidx.compose.ui.unit.DpSize
3739
import androidx.compose.ui.unit.dp
40+
import androidx.compose.ui.unit.sp
3841
import androidx.compose.ui.zIndex
3942
import kotlinx.coroutines.delay
4043
import top.yukonga.miuix.kmp.icon.MiuixIcons
44+
import top.yukonga.miuix.kmp.icon.icons.basic.Search
4145
import top.yukonga.miuix.kmp.icon.icons.basic.SearchCleanup
42-
import top.yukonga.miuix.kmp.icon.icons.useful.Search
4346
import top.yukonga.miuix.kmp.theme.MiuixTheme
4447
import top.yukonga.miuix.kmp.utils.BackHandler
4548
import top.yukonga.miuix.kmp.utils.SmoothRoundedCornerShape
@@ -124,7 +127,7 @@ fun SearchBar(
124127
fun InputField(
125128
query: String,
126129
onQueryChange: (String) -> Unit,
127-
label: String = "",
130+
label: String = "Search",
128131
onSearch: (String) -> Unit,
129132
expanded: Boolean,
130133
onExpandedChange: (Boolean) -> Unit,
@@ -142,8 +145,8 @@ fun InputField(
142145
val leadingIcon = leadingIcon ?: {
143146
Icon(
144147
modifier = Modifier.padding(start = 16.dp, end = 8.dp),
145-
imageVector = MiuixIcons.Useful.Search,
146-
tint = MiuixTheme.colorScheme.onSurfaceContainer,
148+
imageVector = MiuixIcons.Basic.Search,
149+
tint = MiuixTheme.colorScheme.onSurfaceContainerHigh,
147150
contentDescription = "Search"
148151
)
149152
}
@@ -161,7 +164,7 @@ fun InputField(
161164
Icon(
162165
modifier = Modifier.clip(CircleShape).clickable { onQueryChange("") },
163166
imageVector = MiuixIcons.Basic.SearchCleanup,
164-
tint = MiuixTheme.colorScheme.onSurfaceContainer,
167+
tint = MiuixTheme.colorScheme.onSurfaceContainerHighest,
165168
contentDescription = "Search Cleanup"
166169
)
167170
}
@@ -186,7 +189,7 @@ fun InputField(
186189
},
187190
enabled = enabled,
188191
singleLine = true,
189-
textStyle = MiuixTheme.textStyles.main,
192+
textStyle = MiuixTheme.textStyles.main.copy(fontWeight = FontWeight.Bold),
190193
cursorBrush = SolidColor(MiuixTheme.colorScheme.primary),
191194
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
192195
keyboardActions = KeyboardActions(onSearch = { onSearch(query) }),
@@ -214,6 +217,7 @@ fun InputField(
214217
) {
215218
Text(
216219
text = if (!(query.isNotEmpty() || expanded)) label else "",
220+
style = TextStyle(fontSize = 17.sp, fontWeight = FontWeight.Bold),
217221
color = MiuixTheme.colorScheme.onSurfaceContainerHigh
218222
)
219223
innerTextField()
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package top.yukonga.miuix.kmp.icon.icons.basic
2+
3+
import androidx.compose.ui.graphics.Color
4+
import androidx.compose.ui.graphics.PathFillType
5+
import androidx.compose.ui.graphics.SolidColor
6+
import androidx.compose.ui.graphics.vector.ImageVector
7+
import androidx.compose.ui.graphics.vector.path
8+
import androidx.compose.ui.unit.dp
9+
import top.yukonga.miuix.kmp.icon.MiuixIcons
10+
11+
val MiuixIcons.Basic.Search: ImageVector
12+
get() {
13+
if (_search != null) return _search!!
14+
_search = ImageVector.Builder("Search", 20.0f.dp, 20.0f.dp, 20.0f, 20.0f).apply {
15+
path(
16+
fill = SolidColor(Color.White),
17+
pathFillType = PathFillType.EvenOdd
18+
) {
19+
moveTo(12.572f, 13.379f)
20+
curveTo(11.541f, 14.183f, 10.244f, 14.662f, 8.835f, 14.662f)
21+
curveTo(5.477f, 14.662f, 2.754f, 11.94f, 2.754f, 8.581f)
22+
curveTo(2.754f, 5.223f, 5.477f, 2.5f, 8.835f, 2.5f)
23+
curveTo(12.194f, 2.5f, 14.916f, 5.223f, 14.916f, 8.581f)
24+
curveTo(14.916f, 9.99f, 14.437f, 11.287f, 13.633f, 12.318f)
25+
lineTo(17.464f, 16.149f)
26+
curveTo(17.563f, 16.248f, 17.612f, 16.297f, 17.645f, 16.346f)
27+
curveTo(17.78f, 16.548f, 17.78f, 16.811f, 17.645f, 17.013f)
28+
curveTo(17.612f, 17.062f, 17.563f, 17.111f, 17.464f, 17.21f)
29+
curveTo(17.366f, 17.308f, 17.316f, 17.358f, 17.267f, 17.39f)
30+
curveTo(17.065f, 17.525f, 16.802f, 17.525f, 16.601f, 17.39f)
31+
curveTo(16.551f, 17.358f, 16.502f, 17.308f, 16.403f, 17.21f)
32+
lineTo(12.572f, 13.379f)
33+
close()
34+
moveTo(13.416f, 8.581f)
35+
curveTo(13.416f, 11.111f, 11.365f, 13.162f, 8.835f, 13.162f)
36+
curveTo(6.305f, 13.162f, 4.254f, 11.111f, 4.254f, 8.581f)
37+
curveTo(4.254f, 6.051f, 6.305f, 4f, 8.835f, 4f)
38+
curveTo(11.365f, 4f, 13.416f, 6.051f, 13.416f, 8.581f)
39+
close()
40+
}
41+
}.build()
42+
return _search!!
43+
}
44+
45+
private var _search: ImageVector? = null

0 commit comments

Comments
 (0)