Skip to content

Commit 04adb66

Browse files
authored
Optimize OtherComponent and ProgressIndicator (#79)
* example: Optimize OtherComponent performance * library: Optimize ProgressIndicator Components This commit refactors the animation of the indeterminate `CircularProgressIndicator` components. - For linear indeterminate progress indicators, the calculation of `progressWidth` is simplified. - For circular indeterminate progress indicators, `rememberInfiniteTransition` and `animateFloat` are now used for smoother and more efficient animations of `rotationAnim` and `sweepAnim`. The `keyframes` animation spec is used for `sweepAnim` to create a more distinct visual effect. - The drawing of end caps for both types of circular progress indicators is simplified by using `StrokeCap.Round`.
1 parent 4a1560f commit 04adb66

File tree

3 files changed

+371
-394
lines changed

3 files changed

+371
-394
lines changed

example/src/commonMain/kotlin/MainPage.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ import androidx.compose.runtime.remember
2525
import androidx.compose.runtime.setValue
2626
import androidx.compose.ui.Modifier
2727
import androidx.compose.ui.input.nestedscroll.nestedScroll
28+
import androidx.compose.ui.platform.LocalFocusManager
2829
import androidx.compose.ui.text.TextStyle
2930
import androidx.compose.ui.text.font.FontWeight
3031
import androidx.compose.ui.unit.dp
3132
import androidx.compose.ui.unit.sp
32-
import component.OtherComponent
3333
import component.TextComponent
34+
import component.otherComponent
3435
import top.yukonga.miuix.kmp.basic.BasicComponent
3536
import top.yukonga.miuix.kmp.basic.InputField
3637
import top.yukonga.miuix.kmp.basic.ScrollBehavior
@@ -97,11 +98,11 @@ fun MainPage(
9798
superSwitchAnimState
9899
)
99100
}
100-
val otherComponent = @Composable { OtherComponent(padding) }
101101

102102
BoxWithConstraints(
103103
modifier = Modifier.fillMaxSize()
104104
) {
105+
val focusManager = LocalFocusManager.current
105106
if (maxWidth < 840.dp) {
106107
LazyColumn(
107108
modifier = Modifier
@@ -166,8 +167,8 @@ fun MainPage(
166167
if (!expanded) {
167168
item {
168169
textComponent()
169-
otherComponent()
170170
}
171+
otherComponent(focusManager, padding)
171172
}
172173
}
173174
} else {
@@ -232,8 +233,8 @@ fun MainPage(
232233
}
233234
}
234235
if (!expanded) {
236+
otherComponent(focusManager, padding)
235237
item {
236-
otherComponent()
237238
Spacer(modifier = Modifier.height(6.dp))
238239
}
239240
}

0 commit comments

Comments
 (0)