Skip to content

Commit d0a88b3

Browse files
committed
library: TopAppBar: fix small title anim
1 parent 0d3e296 commit d0a88b3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,14 @@ class TopAppBarState(
277277
initialHeightOffset: Float,
278278
initialContentOffset: Float
279279
) {
280+
280281
/**
281282
* The top app bar's height offset limit in pixels, which represents the limit that a top app
282283
* bar is allowed to collapse to.
283284
*
284285
* Use this limit to coerce the [heightOffset] value when it's updated.
285286
*/
286-
var heightOffsetLimit by mutableFloatStateOf(initialHeightOffsetLimit)
287+
var heightOffsetLimit = initialHeightOffsetLimit
287288

288289
/**
289290
* The top app bar's current height offset in pixels. This height offset is applied to the fixed
@@ -583,16 +584,18 @@ private fun TopAppBarLayout(
583584
}
584585

585586
// Small Title Animation
586-
val extOffset by remember(scrolledOffset) {
587+
val extOffset by remember(heightOffset) {
587588
derivedStateOf {
588-
abs(scrolledOffset.offset()) / expandedHeightPx * 2
589+
abs(heightOffset) / expandedHeightPx * 2
589590
}
590591
}
591592

593+
println("extOffset: ${extOffset.coerceIn(0f, 1f)}")
594+
592595
// Large Title Alpha Animation
593-
val largeTitleAlpha by remember(scrolledOffset, expandedHeightPx) {
596+
val largeTitleAlpha by remember(heightOffset, expandedHeightPx) {
594597
derivedStateOf {
595-
1f - (abs(scrolledOffset.offset()) / expandedHeightPx * 2).coerceIn(0f, 1f)
598+
1f - (abs(heightOffset) / expandedHeightPx * 2).coerceIn(0f, 1f)
596599
}
597600
}
598601

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ android {
4040
compileSdk = 36
4141
targetSdk = 36
4242
minSdk = 26
43+
buildToolsVersion = "36.1.0"
4344
}
4445

4546
rootProject.name = "miuix"

0 commit comments

Comments
 (0)