Skip to content

Commit 126fcdd

Browse files
committed
WIP 19
* Remove `HorizontalPager` Component * Remove LazyColumn's topAppBarScrollBehavior param
1 parent aba0d3a commit 126fcdd

File tree

19 files changed

+1093
-105
lines changed

19 files changed

+1093
-105
lines changed

docs/.vitepress/config.mts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export default defineConfig({
6363
darkModeSwitchTitle: '切换到深色模式',
6464
skipToContentLabel: '跳转到内容',
6565

66+
socialLinks: [
67+
{ icon: 'github', link: 'https://github.com/YuKongA/miuix-kotlin-multiplatform' }
68+
],
69+
6670
editLink: {
6771
pattern: 'https://github.com/miuix-kotlin-multiplatform/miuix/edit/main/docs/:path',
6872
text: '在 GitHub 上编辑此页面'
@@ -123,6 +127,7 @@ export default defineConfig({
123127
{ text: 'Card', link: '/components/card' },
124128
{ text: 'BasicComponent', link: '/components/basiccomponent' },
125129
{ text: 'Button', link: '/components/button' },
130+
{ text: 'IconButton', link: '/components/iconbutton' },
126131
{ text: 'Text', link: '/components/text' },
127132
{ text: 'SmallTitle', link: '/components/smalltitle' },
128133
{ text: 'TextField', link: '/components/textfield' },
@@ -136,6 +141,14 @@ export default defineConfig({
136141
{ text: 'PullToRefresh', link: '/components/pulltorefresh' },
137142
{ text: 'SearchBar', link: '/components/searchbar' },
138143
{ text: 'ColorPicker', link: '/components/colorpicker' },
144+
{ text: 'ListPopup', link: '/components/listpopup' },
145+
]
146+
},
147+
{
148+
text: '特殊组件',
149+
collapsed: false,
150+
items: [
151+
{ text: 'LazyColumn', link: '/components/lazycolumn' },
139152
]
140153
},
141154
{
@@ -149,12 +162,9 @@ export default defineConfig({
149162
{ text: 'SuperSpinner', link: '/components/superspinner' },
150163
{ text: 'SuperDialog', link: '/components/superdialog' },
151164
]
152-
}
165+
},
153166
]
154167
},
155168

156-
socialLinks: [
157-
{ icon: 'github', link: 'https://github.com/YuKongA/miuix-kotlin-multiplatform' }
158-
]
159169
}
160170
})

docs/components/card.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Card(
8888
Spacer(modifier = Modifier.width(8.dp))
8989
TextButton(
9090
text = "确定",
91-
colors = textButtonColorsPrimary(),
91+
colors = ButtonDefaults.textButtonColorsPrimary(), // 使用主题颜色
9292
onClick = { /* 处理取消事件 */ }
9393
)
9494
}

docs/components/colorpicker.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,10 @@ Scaffold {
173173
text = "选择颜色",
174174
onClick = { showColorDialog.value = true }
175175
)
176-
SuperDialog( // 注意使用 SuperDialog 需要 Scaffold 包裹
176+
SuperDialog(
177177
title = "选择颜色",
178178
show = showColorDialog,
179-
onDismissRequest = {
180-
dismissDialog(showColorDialog)
181-
}
179+
onDismissRequest = { dismissDialog(showColorDialog) } // 关闭对话框
182180
) {
183181
Column {
184182
ColorPicker(
@@ -193,15 +191,16 @@ Scaffold {
193191
TextButton(
194192
modifier = Modifier.weight(1f),
195193
text = "取消",
196-
onClick = { showColorDialog.value = false }
194+
onClick = { dismissDialog(showColorDialog) } // 关闭对话框
197195
)
198196
TextButton(
199197
modifier = Modifier.weight(1f),
200198
text = "确认",
201-
colors = textButtonColorsPrimary(),
199+
colors = ButtonDefaults.textButtonColorsPrimary(), // 使用主题颜色
202200
onClick = {
203-
showColorDialog.value = false
204-
// 使用选择的颜色
201+
dismissDialog(showColorDialog) // 关闭对话框
202+
// 处理确认逻辑
203+
// 例如:保存选中的颜色
205204
})
206205
}
207206
}

docs/components/iconbutton.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# IconButton
2+
3+
`IconButton` 是 Miuix 中的图标按钮组件,用于提供辅助操作的交互点。它们通常用于需要紧凑按钮的场景,如工具栏或图片列表中。
4+
5+
## 引入
6+
7+
```kotlin
8+
import top.yukonga.miuix.kmp.basic.IconButton
9+
```
10+
11+
## 基本用法
12+
13+
IconButton 组件可以用于触发操作或事件:
14+
15+
```kotlin
16+
IconButton(
17+
onClick = { /* 处理点击事件 */ }
18+
) {
19+
Icon(
20+
imageVector = MiuixIcons.Useful.Like,
21+
contentDescription = "点赞"
22+
)
23+
}
24+
```
25+
26+
## 组件状态
27+
28+
### 禁用状态
29+
30+
```kotlin
31+
IconButton(
32+
onClick = { /* 处理点击事件 */ },
33+
enabled = false
34+
) {
35+
Icon(
36+
imageVector = MiuixIcons.Useful.Like,
37+
contentDescription = "点赞"
38+
)
39+
}
40+
```
41+
42+
### 按下状态
43+
44+
IconButton 支持通过 `holdDownState` 参数控制按下状态,通常用于显示弹出对话框时的视觉反馈:
45+
46+
```kotlin
47+
Scaffold {
48+
var showDialog = remember { mutableStateOf(false) }
49+
IconButton(
50+
onClick = { showDialog.value = true },
51+
holdDownState = showDialog.value
52+
) {
53+
Icon(
54+
imageVector = MiuixIcons.Useful.Like,
55+
contentDescription = "点赞"
56+
)
57+
}
58+
// 在其他地方定义对话框
59+
SuperDialog(
60+
title = "对话框",
61+
show = showDialog,
62+
onDismissRequest = { dismissDialog(showDialog) } // 关闭对话框
63+
) {
64+
// 对话框内容
65+
}
66+
}
67+
```
68+
69+
## 属性
70+
71+
### IconButton 属性
72+
73+
| 属性名 | 类型 | 说明 | 默认值 | 是否必须 |
74+
| --------------- | ---------------------- | --------------------- | ------------------------------- | -------- |
75+
| onClick | () -> Unit | 点击按钮时触发的回调 | - ||
76+
| modifier | Modifier | 应用于按钮的修饰符 | Modifier ||
77+
| enabled | Boolean | 按钮是否可点击 | true ||
78+
| holdDownState | Boolean | 是否处于按下状态 | false ||
79+
| backgroundColor | Color | 按钮的背景颜色 | Color.Unspecified ||
80+
| cornerRadius | Dp | 按钮圆角半径 | IconButtonDefaults.CornerRadius ||
81+
| minHeight | Dp | 按钮最小高度 | IconButtonDefaults.MinHeight ||
82+
| minWidth | Dp | 按钮最小宽度 | IconButtonDefaults.MinWidth ||
83+
| content | @Composable () -> Unit | 按钮内容,通常是 Icon | - ||
84+
85+
### IconButtonDefaults 对象
86+
87+
IconButtonDefaults 对象提供了图标按钮组件的默认值。
88+
89+
#### 常量
90+
91+
| 常量名 | 类型 | 说明 | 默认值 |
92+
| ------------ | ---- | -------------- | ------ |
93+
| MinWidth | Dp | 按钮的最小宽度 | 40.dp |
94+
| MinHeight | Dp | 按钮的最小高度 | 40.dp |
95+
| CornerRadius | Dp | 按钮的圆角半径 | 40.dp |
96+
97+
## 进阶用法
98+
99+
### 自定义背景颜色
100+
101+
```kotlin
102+
IconButton(
103+
onClick = { /* 处理点击事件 */ },
104+
backgroundColor = Color.LightGray.copy(alpha = 0.3f)
105+
) {
106+
Icon(
107+
imageVector = MiuixIcons.Useful.Like,
108+
contentDescription = "点赞"
109+
)
110+
}
111+
```
112+
113+
### 自定义大小和圆角
114+
115+
```kotlin
116+
IconButton(
117+
onClick = { /* 处理点击事件 */ },
118+
minWidth = 48.dp,
119+
minHeight = 48.dp,
120+
cornerRadius = 12.dp
121+
) {
122+
Icon(
123+
imageVector = MiuixIcons.Useful.Like,
124+
contentDescription = "点赞"
125+
)
126+
}
127+
```
128+
129+
### 结合其他组件使用
130+
131+
```kotlin
132+
Surface {
133+
Row(
134+
verticalAlignment = Alignment.CenterVertically
135+
) {
136+
IconButton(
137+
onClick = { /* 处理点击事件 */ }
138+
) {
139+
Icon(
140+
imageVector = MiuixIcons.Useful.New,
141+
tint = MiuixTheme.colorScheme.onBackground,
142+
contentDescription = "添加"
143+
)
144+
}
145+
Text("添加新项目")
146+
}
147+
}
148+
```
149+
150+
### 动态图标按钮
151+
152+
```kotlin
153+
var isLiked by remember { mutableStateOf(false) }
154+
IconButton(
155+
onClick = { isLiked = !isLiked }
156+
) {
157+
Icon(
158+
imageVector = if (isLiked) MiuixIcons.Useful.Like else MiuixIcons.Useful.Unlike,
159+
contentDescription = if (isLiked) "已点赞" else "点赞",
160+
tint = if (isLiked) Color.Red else MiuixTheme.colorScheme.onBackground
161+
)
162+
}
163+
```
164+

docs/components/index.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ Miuix 提供了丰富的 UI 组件,严格遵循 Xiaomi HyperOS 设计规范。
88
| -------------------------------- | -------------- | ------------------ |
99
| [Scaffold](/components/scaffold) | 应用的基础布局 | 页面结构、内容展示 |
1010

11-
## 导航组件
11+
::: warning 注意
12+
Scaffold 组件为跨平台提供了一个合适的弹出窗口的容器。`SuperDialog``SuperDropdown``SuperSpinner``ListPopup` 等组件都基于此实现弹出窗口,因此都需要被该组件包裹。
13+
:::
14+
15+
## 基础组件
1216

1317
| 组件 | 描述 | 常见用途 |
1418
| -------------------------------------------------------- | ---------------------- | -------------------- |
@@ -32,6 +36,14 @@ Miuix 提供了丰富的 UI 组件,严格遵循 Xiaomi HyperOS 设计规范。
3236
| [PullToRefresh](/components/pulltorefresh) | 下拉触发刷新操作 | 数据更新、页面刷新 |
3337
| [SearchBar](/components/searchbar) | 执行搜索的输入框 | 内容搜索、快速查找 |
3438
| [ColorPicker](/components/colorpicker) | 选择颜色的控件 | 主题设置、颜色选择 |
39+
| [ListPopup](/components/listpopup) | 列表弹出窗口组件 | 选项选择、功能列表 |
40+
41+
42+
## 特殊组件
43+
44+
| 组件 | 描述 | 常见用途 |
45+
| ------------------------------------ | -------------------- | -------------------- |
46+
| [LazyColumn](/components/lazycolumn) | 懒加载的垂直列表组件 | 长列表展示、数据加载 |
3547

3648
## 扩展组件
3749

@@ -42,4 +54,4 @@ Miuix 提供了丰富的 UI 组件,严格遵循 Xiaomi HyperOS 设计规范。
4254
| [SuperCheckBox](/components/supercheckbox) | 基于 BasicComponent 的复选框组件 | 多项选择、条款同意 |
4355
| [SuperDropdown](/components/superdropdown) | 基于 BasicComponent 的下拉菜单组件 | 选项选择、功能列表 |
4456
| [SuperSpinner](/components/superspinner) | 基于 BasicComponent 的高级菜单组件 | 进阶选项选择、功能列表 |
45-
| [SuperDialog](/components/superdialog) | 基于 BasicComponent 的对话弹窗组件 | 提示、确认操作 |
57+
| [SuperDialog](/components/superdialog) | 基于 BasicComponent 的对话弹窗组件 | 提示、确认操作 |

docs/components/lazycolumn.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# LazyColumn
2+
3+
::: tip
4+
`LazyColumn` 组件是直接继承自 foundation 库的基础组件,具体的使用说明请参考 [LazyColumn](https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/package-summary#LazyColumn(androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.LazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,kotlin.Function1))
5+
:::
6+
7+
Miuix 包下的该组件在原本的 `LazyColumn` 基础上添加了一个额外的 `isEnabledOverScroll` 属性,用于控制是否启用 Miuix 的越界回弹效果。 同时将该组件原有的 `overscrollEffect` 属性设为 `null`
8+
9+
默认情况下,`LazyColumn``isEnabledOverScroll` 属性为 `{ platform() == Platform.Android }`,表示仅为安卓平台启用越界回弹效果。

0 commit comments

Comments
 (0)