Skip to content

Commit 8002e16

Browse files
committed
Update PullToRefresh.kt
1 parent ef1b20e commit 8002e16

File tree

5 files changed

+45
-49
lines changed

5 files changed

+45
-49
lines changed

docs/components/searchbar.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,30 @@ SearchBar(
3939

4040
### SearchBar Properties
4141

42-
| Property Name | Type | Description | Default Value | Required |
43-
| ------------------ | ---------------------------------- | ------------------------------------------------- | ------------- | -------- |
44-
| inputField | @Composable () -> Unit | Search input field component | - | Yes |
45-
| expanded | Boolean | Whether to show search results | false | Yes |
46-
| onExpandedChange | (Boolean) -> Unit | Callback when expanded state changes | - | Yes |
47-
| modifier | Modifier | Modifier applied to the search bar | Modifier | No |
48-
| outsideRightAction | @Composable (() -> Unit)? | Action component shown on the right when expanded | null | No |
49-
| content | @Composable ColumnScope.() -> Unit | Content shown when expanded | - | Yes |
42+
| Property Name | Type | Description | Default Value | Required |
43+
| ------------------ | ---------------------------------- | ------------------------------------------------- | ------------------- | -------- |
44+
| inputField | @Composable () -> Unit | Search input field component | - | Yes |
45+
| onExpandedChange | (Boolean) -> Unit | Callback when expanded state changes | - | Yes |
46+
| insideMargin | DpSize | Internal padding | DpSize(12.dp, 0.dp) | No |
47+
| modifier | Modifier | Modifier applied to the search bar | Modifier | No |
48+
| expanded | Boolean | Whether to show search results | false | No |
49+
| outsideRightAction | @Composable (() -> Unit)? | Action component shown on the right when expanded | null | No |
50+
| content | @Composable ColumnScope.() -> Unit | Content shown when expanded | - | Yes |
5051

5152
### InputField Properties
5253

5354
| Property Name | Type | Description | Default Value | Required |
5455
| ----------------- | ------------------------- | ------------------------------------ | -------------------- | -------- |
5556
| query | String | Text content in search field | - | Yes |
5657
| onQueryChange | (String) -> Unit | Callback when text content changes | - | Yes |
58+
| label | String | Placeholder text when empty | "" | No |
5759
| onSearch | (String) -> Unit | Callback when search is executed | - | Yes |
5860
| expanded | Boolean | Whether in expanded state | - | Yes |
5961
| onExpandedChange | (Boolean) -> Unit | Callback when expanded state changes | - | Yes |
60-
| label | String | Placeholder text when empty | "" | No |
62+
| modifier | Modifier | Modifier applied to the input field | Modifier | No |
6163
| enabled | Boolean | Whether search field is enabled | true | No |
62-
| insideMargin | DpSize | Internal padding | DpSize(12.dp, 12.dp) | No |
63-
| leadingIcon | @Composable (() -> Unit)? | Leading icon | null | No |
64-
| trailingIcon | @Composable (() -> Unit)? | Trailing icon | null | No |
64+
| leadingIcon | @Composable (() -> Unit)? | Leading icon | default search icon | No |
65+
| trailingIcon | @Composable (() -> Unit)? | Trailing icon | default clear button | No |
6566
| interactionSource | MutableInteractionSource? | Interaction source | null | No |
6667

6768
## Advanced Usage

docs/zh_CN/components/searchbar.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,31 @@ SearchBar(
3939

4040
### SearchBar 属性
4141

42-
| 属性名 | 类型 | 说明 | 默认值 | 是否必须 |
43-
| ------------------ | ---------------------------------- | -------------------------- | -------- | -------- |
44-
| inputField | @Composable () -> Unit | 搜索输入框组件 | - ||
45-
| expanded | Boolean | 是否展开显示搜索结果 | false ||
46-
| onExpandedChange | (Boolean) -> Unit | 展开状态变化的回调 | - ||
47-
| modifier | Modifier | 应用于搜索栏的修饰符 | Modifier ||
48-
| outsideRightAction | @Composable (() -> Unit)? | 展开时显示在右侧的操作组件 | null ||
49-
| content | @Composable ColumnScope.() -> Unit | 展开时显示的内容 | - ||
42+
| 属性名 | 类型 | 说明 | 默认值 | 是否必须 |
43+
| ------------------ | ---------------------------------- | -------------------------- | ------------------- | -------- |
44+
| inputField | @Composable () -> Unit | 搜索输入框组件 | - ||
45+
| onExpandedChange | (Boolean) -> Unit | 展开状态变化的回调 | - ||
46+
| insideMargin | DpSize | 内部边距 | DpSize(12.dp, 0.dp) ||
47+
| modifier | Modifier | 应用于搜索栏的修饰符 | Modifier ||
48+
| expanded | Boolean | 是否展开显示搜索结果 | false ||
49+
| outsideRightAction | @Composable (() -> Unit)? | 展开时显示在右侧的操作组件 | null ||
50+
| content | @Composable ColumnScope.() -> Unit | 展开时显示的内容 | - ||
5051

5152
### InputField 属性
5253

53-
| 属性名 | 类型 | 说明 | 默认值 | 是否必须 |
54-
| ----------------- | ------------------------- | -------------------------- | -------------------- | -------- |
55-
| query | String | 搜索框中的文本内容 | - ||
56-
| onQueryChange | (String) -> Unit | 文本内容变化时的回调 | - ||
57-
| onSearch | (String) -> Unit | 执行搜索操作时的回调 | - | |
58-
| expanded | Boolean | 是否处于展开状态 | - ||
59-
| onExpandedChange | (Boolean) -> Unit | 展开状态变化的回调 | - ||
60-
| label | String | 搜索框为空时显示的提示文本 | "" | |
61-
| enabled | Boolean | 是否启用搜索框 | true ||
62-
| insideMargin | DpSize | 内部边距 | DpSize(12.dp, 12.dp) ||
63-
| leadingIcon | @Composable (() -> Unit)? | 前置图标 | null ||
64-
| trailingIcon | @Composable (() -> Unit)? | 后置图标 | null ||
65-
| interactionSource | MutableInteractionSource? | 交互源 | null ||
54+
| 属性名 | 类型 | 说明 | 默认值 | 是否必须 |
55+
| ----------------- | ------------------------- | -------------------------- | ------------ | -------- |
56+
| query | String | 搜索框中的文本内容 | - ||
57+
| onQueryChange | (String) -> Unit | 文本内容变化时的回调 | - ||
58+
| label | String | 搜索框为空时显示的提示文本 | "" | |
59+
| onSearch | (String) -> Unit | 执行搜索操作时的回调 | - ||
60+
| expanded | Boolean | 是否处于展开状态 | - ||
61+
| onExpandedChange | (Boolean) -> Unit | 展开状态变化的回调 | - | |
62+
| modifier | Modifier | 应用于输入框的修饰符 | Modifier ||
63+
| enabled | Boolean | 是否启用搜索框 | true ||
64+
| leadingIcon | @Composable (() -> Unit)? | 前置图标 | 默认放大镜 ||
65+
| trailingIcon | @Composable (() -> Unit)? | 后置图标 | 默认清除按钮 ||
66+
| interactionSource | MutableInteractionSource? | 交互源 | null ||
6667

6768
## 进阶用法
6869

example/src/commonMain/kotlin/MainPage.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,8 @@ fun MainPage(
9090
item {
9191
SmallTitle(text = "SearchBar")
9292
SearchBar(
93-
modifier = Modifier
94-
.padding(start = 12.dp, bottom = 6.dp),
9593
inputField = {
9694
InputField(
97-
modifier = Modifier
98-
.padding(end = 12.dp),
9995
query = miuixSearchValue,
10096
onQueryChange = { miuixSearchValue = it },
10197
onSearch = { expanded = false },
@@ -163,19 +159,14 @@ fun MainPage(
163159
LazyColumn(
164160
modifier = Modifier
165161
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection)
166-
.padding(start = 12.dp)
167162
.weight(1f),
168163
contentPadding = PaddingValues(top = padding.calculateTopPadding())
169164
) {
170165
item {
171166
SmallTitle(text = "SearchBar")
172167
SearchBar(
173-
modifier = Modifier
174-
.padding(start = 12.dp, bottom = 6.dp),
175168
inputField = {
176169
InputField(
177-
modifier = Modifier
178-
.padding(end = 12.dp),
179170
query = miuixSearchValue,
180171
onQueryChange = { miuixSearchValue = it },
181172
onSearch = { expanded = false },
@@ -187,7 +178,6 @@ fun MainPage(
187178
outsideRightAction = {
188179
Text(
189180
modifier = Modifier
190-
.padding(end = 12.dp)
191181
.clickable(
192182
interactionSource = null,
193183
indication = null

example/src/commonMain/kotlin/SecondPage.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ fun SecondPage(
5757
) {
5858
item {
5959
Card(
60-
modifier = Modifier
61-
.padding(12.dp)
60+
modifier = Modifier.padding(12.dp)
6261
) {
6362
for (i in 0 until ii.value) {
6463
SuperDropdown(

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import androidx.compose.foundation.layout.Column
1717
import androidx.compose.foundation.layout.ColumnScope
1818
import androidx.compose.foundation.layout.Row
1919
import androidx.compose.foundation.layout.fillMaxWidth
20+
import androidx.compose.foundation.layout.heightIn
2021
import androidx.compose.foundation.layout.padding
2122
import androidx.compose.foundation.shape.CircleShape
2223
import androidx.compose.foundation.text.BasicTextField
@@ -57,6 +58,7 @@ import top.yukonga.miuix.kmp.utils.SmoothRoundedCornerShape
5758
* @param inputField the input field to input a query in the [SearchBar].
5859
* @param onExpandedChange the callback to be invoked when the [SearchBar]'s expanded state is
5960
* changed.
61+
* @param insideMargin The margin inside the [SearchBar].
6062
* @param modifier the [Modifier] to be applied to the [SearchBar].
6163
* @param expanded whether the [SearchBar] is expanded and showing search results.
6264
* @param outsideRightAction the action to be shown at the right side of the [SearchBar] when it is
@@ -67,6 +69,7 @@ import top.yukonga.miuix.kmp.utils.SmoothRoundedCornerShape
6769
fun SearchBar(
6870
inputField: @Composable () -> Unit,
6971
onExpandedChange: (Boolean) -> Unit,
72+
insideMargin: DpSize = DpSize(12.dp, 0.dp),
7073
modifier: Modifier = Modifier,
7174
expanded: Boolean = false,
7275
outsideRightAction: @Composable (() -> Unit)? = null,
@@ -80,7 +83,11 @@ fun SearchBar(
8083
modifier = Modifier.fillMaxWidth(),
8184
verticalAlignment = Alignment.CenterVertically,
8285
) {
83-
Box(modifier = Modifier.weight(1f)) {
86+
Box(
87+
modifier = Modifier
88+
.weight(1f)
89+
.padding(vertical = insideMargin.height, horizontal = insideMargin.width)
90+
) {
8491
inputField()
8592
}
8693
AnimatedVisibility(
@@ -121,7 +128,6 @@ fun SearchBar(
121128
* @param enabled the enabled state of this input field. When `false`, this component will not
122129
* respond to user input, and it will appear visually disabled and disabled to accessibility
123130
* services.
124-
* @param insideMargin the margin inside the [InputField].
125131
* @param leadingIcon the leading icon to be displayed at the start of the input field.
126132
* @param trailingIcon the trailing icon to be displayed at the end of the input field.
127133
* @param interactionSource an optional hoisted [MutableInteractionSource] for observing and
@@ -139,7 +145,6 @@ fun InputField(
139145
onExpandedChange: (Boolean) -> Unit,
140146
modifier: Modifier = Modifier,
141147
enabled: Boolean = true,
142-
insideMargin: DpSize = DpSize(12.dp, 12.dp),
143148
leadingIcon: @Composable (() -> Unit)? = null,
144149
trailingIcon: @Composable (() -> Unit)? = null,
145150
interactionSource: MutableInteractionSource? = null,
@@ -218,7 +223,7 @@ fun InputField(
218223
Box(
219224
modifier = Modifier
220225
.weight(1f)
221-
.padding(vertical = insideMargin.height),
226+
.heightIn(min = 45.dp),
222227
contentAlignment = Alignment.CenterStart
223228
) {
224229
Text(

0 commit comments

Comments
 (0)