Skip to content

Commit 4d3f421

Browse files
committed
chore(notifications): improve banner animations
1 parent 031173a commit 4d3f421

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

feature/notification/api/src/androidMain/kotlin/net/thunderbird/feature/notification/api/ui/animation/BannerSlideInSlideOutAnimationSpec.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import androidx.compose.animation.AnimatedContentTransitionScope
44
import androidx.compose.animation.ContentTransform
55
import androidx.compose.animation.SizeTransform
66
import androidx.compose.animation.core.keyframes
7+
import androidx.compose.animation.expandVertically
78
import androidx.compose.animation.fadeIn
89
import androidx.compose.animation.fadeOut
9-
import androidx.compose.animation.slideInVertically
10-
import androidx.compose.animation.slideOutVertically
10+
import androidx.compose.animation.shrinkVertically
1111
import androidx.compose.animation.togetherWith
1212
import androidx.compose.ui.unit.IntSize
1313

@@ -30,12 +30,20 @@ private const val A_QUARTER = 4
3030
* as well as the size transformation.
3131
*/
3232
fun <T> AnimatedContentTransitionScope<T>.bannerSlideInSlideOutAnimationSpec(): ContentTransform {
33-
val enter = fadeIn() + slideInVertically()
34-
val exit = fadeOut() + slideOutVertically()
35-
return enter togetherWith exit using SizeTransform { initialSize, targetSize ->
36-
keyframes {
37-
IntSize(width = targetSize.width, height = initialSize.height) at durationMillis / A_QUARTER
38-
IntSize(width = targetSize.width, height = targetSize.height)
33+
val enter = fadeIn() + expandVertically()
34+
val exit = fadeOut() + shrinkVertically()
35+
return (enter togetherWith exit) using SizeTransform { initialSize, targetSize ->
36+
this.contentAlignment
37+
if (targetState != null) {
38+
keyframes {
39+
IntSize(width = targetSize.width, height = initialSize.height) at durationMillis / A_QUARTER
40+
IntSize(width = targetSize.width, height = targetSize.height)
41+
}
42+
} else {
43+
keyframes {
44+
IntSize(width = initialSize.width, height = initialSize.height) at durationMillis / A_QUARTER
45+
IntSize(width = initialSize.width, height = 0)
46+
}
3947
}
4048
}
4149
}

legacy/ui/legacy/src/main/java/com/fsck/k9/activity/compose/MessageComposeInAppNotificationFragment.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import android.os.Bundle
44
import android.view.LayoutInflater
55
import android.view.View
66
import android.view.ViewGroup
7-
import androidx.compose.animation.animateContentSize
8-
import androidx.compose.ui.Modifier
97
import androidx.compose.ui.platform.ComposeView
108
import androidx.compose.ui.platform.ViewCompositionStrategy
119
import androidx.core.os.bundleOf
@@ -57,7 +55,6 @@ class MessageComposeInAppNotificationFragment : Fragment() {
5755
val accountUuid = event.notification.accountUuid
5856
accountUuid != null && accountUuid == accountId?.asRaw()
5957
},
60-
modifier = Modifier.animateContentSize(),
6158
)
6259
}
6360
}

0 commit comments

Comments
 (0)