Skip to content

Commit e122dbc

Browse files
committed
library: Optimize some recomposition issues
* also removed haze, we should exclude its performance impact in the sample application
1 parent b8d1f17 commit e122dbc

File tree

16 files changed

+179
-205
lines changed

16 files changed

+179
-205
lines changed

docs/components/basiccomponent.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ BasicComponent(
8787

8888
### BasicComponent Properties
8989

90-
| Property Name | Type | Description | Default Value | Required |
91-
| ----------------- | ------------------------------- | ----------------------------------------------------- | ---------------------------------------- | -------- |
92-
| title | String? | Title of the component | null | No |
93-
| titleColor | BasicComponentColors | Title color configuration | BasicComponentDefaults.titleColor() | No |
94-
| summary | String? | Summary of the component | null | No |
95-
| summaryColor | BasicComponentColors | Summary color configuration | BasicComponentDefaults.summaryColor() | No |
96-
| leftAction | @Composable (() -> Unit?)? | Composable content on the left side of the component | null | No |
97-
| rightActions | @Composable RowScope.() -> Unit | Composable content on the right side of the component | {} | No |
98-
| modifier | Modifier | Modifier for the component | Modifier | No |
99-
| insideMargin | PaddingValues | Internal padding of the component | BasicComponentDefaults.InsideMargin | No |
100-
| onClick | (() -> Unit)? | Callback triggered when the component is clicked | null | No |
101-
| holdDownState | Boolean | Whether the component is in the pressed state | false | No |
102-
| enabled | Boolean | Whether the component is enabled | true | No |
103-
| interactionSource | MutableInteractionSource | Interaction source of the component | remember \{ MutableInteractionSource() } | No |
90+
| Property Name | Type | Description | Default Value | Required |
91+
| ----------------- |---------------------------------| ----------------------------------------------------- |---------------------------------------| -------- |
92+
| title | String? | Title of the component | null | No |
93+
| titleColor | BasicComponentColors | Title color configuration | BasicComponentDefaults.titleColor() | No |
94+
| summary | String? | Summary of the component | null | No |
95+
| summaryColor | BasicComponentColors | Summary color configuration | BasicComponentDefaults.summaryColor() | No |
96+
| leftAction | @Composable (() -> Unit?)? | Composable content on the left side of the component | null | No |
97+
| rightActions | @Composable RowScope.() -> Unit | Composable content on the right side of the component | {} | No |
98+
| modifier | Modifier | Modifier for the component | Modifier | No |
99+
| insideMargin | PaddingValues | Internal padding of the component | BasicComponentDefaults.InsideMargin | No |
100+
| onClick | (() -> Unit)? | Callback triggered when the component is clicked | null | No |
101+
| holdDownState | Boolean | Whether the component is in the pressed state | false | No |
102+
| enabled | Boolean | Whether the component is enabled | true | No |
103+
| interactionSource | MutableInteractionSource? | Interaction source of the component | null | No |
104104

105105
### BasicComponentDefaults Object
106106

docs/components/supercheckbox.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,22 @@ SuperCheckbox(
9090

9191
### SuperCheckbox Properties
9292

93-
| Property Name | Type | Description | Default Value | Required |
94-
| ---------------- | ------------------------------- | ------------------------------------ | ------------------------------------- | -------- |
95-
| title | String | Title of the checkbox item | - | Yes |
96-
| checked | Boolean | Checkbox checked state | - | Yes |
97-
| onCheckedChange | ((Boolean) -> Unit)? | Callback when checkbox state changes | - | Yes |
98-
| modifier | Modifier | Modifier applied to component | Modifier | No |
99-
| titleColor | BasicComponentColors | Title text color configuration | BasicComponentDefaults.titleColor() | No |
100-
| summary | String? | Summary description | null | No |
101-
| summaryColor | BasicComponentColors | Summary text color configuration | BasicComponentDefaults.summaryColor() | No |
102-
| checkboxColors | CheckboxColors | Checkbox control color configuration | CheckboxDefaults.checkboxColors() | No |
103-
| rightActions | @Composable RowScope.() -> Unit | Custom content before checkbox | {} | No |
104-
| checkboxLocation | CheckboxLocation | Checkbox position | CheckboxLocation.Left | No |
105-
| onClick | (() -> Unit)? | Additional callback on item click | null | No |
106-
| insideMargin | PaddingValues | Internal content padding | BasicComponentDefaults.InsideMargin | No |
107-
| enabled | Boolean | Whether component is interactive | true | No |
93+
| Property Name | Type | Description | Default Value | Required |
94+
|-------------------| ------------------------------- | ------------------------------------ | ------------------------------------- | -------- |
95+
| title | String | Title of the checkbox item | - | Yes |
96+
| checked | Boolean | Checkbox checked state | - | Yes |
97+
| onCheckedChange | ((Boolean) -> Unit)? | Callback when checkbox state changes | - | Yes |
98+
| modifier | Modifier | Modifier applied to component | Modifier | No |
99+
| titleColor | BasicComponentColors | Title text color configuration | BasicComponentDefaults.titleColor() | No |
100+
| summary | String? | Summary description | null | No |
101+
| summaryColor | BasicComponentColors | Summary text color configuration | BasicComponentDefaults.summaryColor() | No |
102+
| checkboxColors | CheckboxColors | Checkbox control color configuration | CheckboxDefaults.checkboxColors() | No |
103+
| rightActions | @Composable RowScope.() -> Unit | Custom content before checkbox | {} | No |
104+
| checkboxLocation | CheckboxLocation | Checkbox position | CheckboxLocation.Left | No |
105+
| onClick | (() -> Unit)? | Additional callback on item click | null | No |
106+
| holdDownState | Boolean | Whether the component is held down | false | No |
107+
| insideMargin | PaddingValues | Internal content padding | BasicComponentDefaults.InsideMargin | No |
108+
| enabled | Boolean | Whether component is interactive | true | No |
108109

109110
## Advanced Usage
110111

docs/zh_CN/components/basiccomponent.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ BasicComponent(
8787

8888
### BasicComponent 属性
8989

90-
| 属性名 | 类型 | 说明 | 默认值 | 是否必须 |
91-
| ----------------- | ------------------------------- | -------------------- | ---------------------------------------- | -------- |
92-
| title | String? | 组件标题 | null ||
93-
| titleColor | BasicComponentColors | 标题颜色配置 | BasicComponentDefaults.titleColor() ||
94-
| summary | String? | 组件摘要 | null ||
95-
| summaryColor | BasicComponentColors | 摘要颜色配置 | BasicComponentDefaults.summaryColor() ||
96-
| leftAction | @Composable (() -> Unit?)? | 组件左侧的可组合内容 | null ||
97-
| rightActions | @Composable RowScope.() -> Unit | 组件右侧的可组合内容 | {} ||
98-
| modifier | Modifier | 应用于组件的修饰符 | Modifier ||
99-
| insideMargin | PaddingValues | 组件内部边距 | BasicComponentDefaults.InsideMargin ||
100-
| onClick | (() -> Unit)? | 点击组件时触发的回调 | null ||
101-
| holdDownState | Boolean | 组件是否处于按下状态 | false ||
102-
| enabled | Boolean | 组件是否可用 | true ||
103-
| interactionSource | MutableInteractionSource | 组件的交互源 | remember \{ MutableInteractionSource() } ||
90+
| 属性名 | 类型 | 说明 | 默认值 | 是否必须 |
91+
| ----------------- |---------------------------------| -------------------- |---------------------------------------| -------- |
92+
| title | String? | 组件标题 | null ||
93+
| titleColor | BasicComponentColors | 标题颜色配置 | BasicComponentDefaults.titleColor() ||
94+
| summary | String? | 组件摘要 | null ||
95+
| summaryColor | BasicComponentColors | 摘要颜色配置 | BasicComponentDefaults.summaryColor() ||
96+
| leftAction | @Composable (() -> Unit?)? | 组件左侧的可组合内容 | null ||
97+
| rightActions | @Composable RowScope.() -> Unit | 组件右侧的可组合内容 | {} ||
98+
| modifier | Modifier | 应用于组件的修饰符 | Modifier ||
99+
| insideMargin | PaddingValues | 组件内部边距 | BasicComponentDefaults.InsideMargin ||
100+
| onClick | (() -> Unit)? | 点击组件时触发的回调 | null ||
101+
| holdDownState | Boolean | 组件是否处于按下状态 | false ||
102+
| enabled | Boolean | 组件是否可用 | true ||
103+
| interactionSource | MutableInteractionSource? | 组件的交互源 | null ||
104104

105105
### BasicComponentDefaults 对象
106106

docs/zh_CN/components/supercheckbox.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ SuperCheckbox(
9090

9191
### SuperCheckbox 属性
9292

93-
| 属性名 | 类型 | 说明 | 默认值 | 是否必须 |
94-
| ---------------- | ------------------------------- | -------------------------- | ------------------------------------- | -------- |
93+
| 属性名 | 类型 | 说明 | 默认值 | 是否必须 |
94+
|------------------| ------------------------------- | -------------------------- | ------------------------------------- | -------- |
9595
| title | String | 复选框项的标题 | - ||
9696
| checked | Boolean | 复选框的选中状态 | - ||
9797
| onCheckedChange | ((Boolean) -> Unit)? | 复选框状态变化时的回调 | - ||
@@ -103,6 +103,7 @@ SuperCheckbox(
103103
| rightActions | @Composable RowScope.() -> Unit | 右侧自定义内容(复选框前) | {} ||
104104
| checkboxLocation | CheckboxLocation | 复选框的位置 | CheckboxLocation.Left ||
105105
| onClick | (() -> Unit)? | 点击选项时触发的额外回调 | null ||
106+
| holdDownState | Boolean | 组件是否处于按下状态 | false ||
106107
| insideMargin | PaddingValues | 组件内部内容的边距 | BasicComponentDefaults.InsideMargin ||
107108
| enabled | Boolean | 组件是否可交互 | true ||
108109

example/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ kotlin {
9696
implementation(compose.ui)
9797
implementation(compose.components.resources)
9898

99-
implementation(libs.haze)
100-
10199
implementation(project(":miuix"))
102100
}
103101
desktopMain.dependencies {

example/src/commonMain/kotlin/UITest.kt

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType
4545
import androidx.compose.ui.platform.LocalHapticFeedback
4646
import androidx.compose.ui.platform.LocalUriHandler
4747
import androidx.compose.ui.unit.dp
48-
import dev.chrisbanes.haze.HazeState
49-
import dev.chrisbanes.haze.HazeStyle
50-
import dev.chrisbanes.haze.HazeTint
51-
import dev.chrisbanes.haze.hazeEffect
52-
import dev.chrisbanes.haze.hazeSource
5348
import kotlinx.coroutines.launch
5449
import top.yukonga.miuix.kmp.basic.FabPosition
5550
import top.yukonga.miuix.kmp.basic.FloatingActionButton
@@ -123,12 +118,6 @@ fun UITest(
123118
var uiState by remember { mutableStateOf(UIState()) }
124119
val showTopPopup = remember { mutableStateOf(false) }
125120

126-
val hazeState = remember { HazeState() }
127-
val hazeStyle = HazeStyle(
128-
backgroundColor = MiuixTheme.colorScheme.background,
129-
tint = HazeTint(MiuixTheme.colorScheme.background.copy(0.67f))
130-
)
131-
132121
val uriHandler = LocalUriHandler.current
133122

134123
Scaffold(
@@ -165,13 +154,6 @@ fun UITest(
165154
exit = fadeOut() + shrinkVertically(shrinkTowards = Alignment.Top)
166155
) {
167156
NavigationBar(
168-
modifier = Modifier
169-
.hazeEffect(hazeState) {
170-
style = hazeStyle
171-
blurRadius = 25.dp
172-
noiseFactor = 0f
173-
},
174-
color = Color.Transparent,
175157
items = navigationItem,
176158
selected = selectedPage,
177159
onClick = { index ->
@@ -188,13 +170,6 @@ fun UITest(
188170
exit = fadeOut() + shrinkVertically(shrinkTowards = Alignment.Top)
189171
) {
190172
FloatingNavigationBar(
191-
modifier = Modifier
192-
.hazeEffect(hazeState) {
193-
style = hazeStyle
194-
blurRadius = 25.dp
195-
noiseFactor = 0f
196-
},
197-
color = Color.Transparent,
198173
items = navigationItem,
199174
selected = selectedPage,
200175
mode = when (uiState.floatingNavigationBarMode) {
@@ -244,17 +219,7 @@ fun UITest(
244219
enter = fadeIn(),
245220
exit = fadeOut()
246221
) {
247-
val floatingToolbarBgColor = MiuixTheme.colorScheme.primary
248222
FloatingToolbar(
249-
modifier = Modifier
250-
.hazeEffect(hazeState) {
251-
style = HazeStyle(
252-
backgroundColor = floatingToolbarBgColor,
253-
tint = HazeTint(floatingToolbarBgColor.copy(0.67f))
254-
)
255-
blurRadius = 25.dp
256-
noiseFactor = 0f
257-
},
258223
color = Color.Transparent,
259224
cornerRadius = 20.dp
260225
) {
@@ -314,7 +279,6 @@ fun UITest(
314279
AppHorizontalPager(
315280
modifier = Modifier
316281
.imePadding()
317-
.hazeSource(state = hazeState)
318282
.windowInsetsPadding(WindowInsets.displayCutout.only(WindowInsetsSides.Horizontal))
319283
.windowInsetsPadding(WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal)),
320284
pagerState = pagerState,

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ androidx-window = "1.4.0"
55
androidx-graphics-shapes = "1.0.0-alpha09"
66
compose-plugin = "1.8.2"
77
dokka = "2.0.0"
8-
haze = "1.6.9"
98
kotlin = "2.2.0"
109
spotless = "7.2.1"
1110

@@ -14,7 +13,6 @@ androidx-activity-compose = { module = "androidx.activity:activity-compose", ver
1413
androidx-graphics-shapes = { module = "org.jetbrains.androidx.graphics:graphics-shapes", version.ref = "androidx-graphics-shapes" }
1514
androidx-window = { group = "androidx.window", name = "window", version.ref = "androidx-window" }
1615
compose-window-size = { module = "org.jetbrains.compose.material3:material3-window-size-class", version.ref = "compose-plugin" }
17-
haze = { module = "dev.chrisbanes.haze:haze", version.ref = "haze" }
1816

1917
[plugins]
2018
android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }

iosApp/iosApp/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundleShortVersionString</key>
1818
<string>1.0.4</string>
1919
<key>CFBundleVersion</key>
20-
<string>486</string>
20+
<string>487</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>CADisableMinimumFrameDurationOnPhone</key>

0 commit comments

Comments
 (0)