Use motion scheme transition spec for grid popup
This commit is contained in:
parent
85bfd9d79a
commit
8f4766d28a
@ -216,21 +216,17 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
val animationProgress = remember {
|
||||
Animatable(0f)
|
||||
}
|
||||
val animationSpec = MaterialTheme.motionScheme.defaultSpatialSpec<Float>()
|
||||
|
||||
LaunchedEffect(show.targetState) {
|
||||
if (!show.targetState) {
|
||||
animationProgress.animateTo(
|
||||
0f, spring(
|
||||
Spring.DampingRatioNoBouncy,
|
||||
Spring.StiffnessMediumLow,
|
||||
)
|
||||
0f, animationSpec
|
||||
)
|
||||
onDismissRequest()
|
||||
} else {
|
||||
animationProgress.animateTo(
|
||||
1f, spring(
|
||||
Spring.DampingRatioLowBouncy,
|
||||
Spring.StiffnessMediumLow,
|
||||
)
|
||||
100f, animationSpec
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -239,11 +235,12 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
}
|
||||
|
||||
Overlay {
|
||||
val p = animationProgress.value * 0.01f
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.background(
|
||||
MaterialTheme.colorScheme.scrim.copy(
|
||||
alpha = 0.32f * animationProgress.value.coerceIn(
|
||||
alpha = 0.32f * p.coerceIn(
|
||||
0f,
|
||||
1f
|
||||
)
|
||||
@ -266,7 +263,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
)
|
||||
) {
|
||||
LauncherCard(
|
||||
elevation = 8.dp * animationProgress.value,
|
||||
elevation = 8.dp * p,
|
||||
backgroundOpacity = MaterialTheme.transparency.elevatedSurface,
|
||||
modifier = Modifier
|
||||
.placeOverlay(
|
||||
@ -275,7 +272,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
-WindowInsets.systemBars.union(WindowInsets.ime)
|
||||
.getTop(LocalDensity.current)
|
||||
),
|
||||
animationProgress.value
|
||||
p,
|
||||
)
|
||||
) {
|
||||
when (searchable) {
|
||||
@ -283,7 +280,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
AppItemGridPopup(
|
||||
app = searchable,
|
||||
show = show,
|
||||
animationProgress = animationProgress.value,
|
||||
animationProgress = p,
|
||||
origin = origin,
|
||||
onDismiss = {
|
||||
show.targetState = false
|
||||
@ -295,7 +292,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
WebsiteItemGridPopup(
|
||||
website = searchable,
|
||||
show = show,
|
||||
animationProgress = animationProgress.value,
|
||||
animationProgress = p,
|
||||
origin = origin,
|
||||
onDismiss = {
|
||||
show.targetState = false
|
||||
@ -307,7 +304,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
ArticleItemGridPopup(
|
||||
article = searchable,
|
||||
show = show,
|
||||
animationProgress = animationProgress.value,
|
||||
animationProgress = p,
|
||||
origin = origin,
|
||||
onDismiss = {
|
||||
show.targetState = false
|
||||
@ -319,7 +316,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
ContactItemGridPopup(
|
||||
contact = searchable,
|
||||
show = show,
|
||||
animationProgress = animationProgress.value,
|
||||
animationProgress = p,
|
||||
origin = origin,
|
||||
onDismiss = {
|
||||
show.targetState = false
|
||||
@ -331,7 +328,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
FileItemGridPopup(
|
||||
file = searchable,
|
||||
show = show,
|
||||
animationProgress = animationProgress.value,
|
||||
animationProgress = p,
|
||||
origin = origin,
|
||||
onDismiss = {
|
||||
show.targetState = false
|
||||
@ -343,7 +340,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
CalendarItemGridPopup(
|
||||
calendar = searchable,
|
||||
show = show,
|
||||
animationProgress = animationProgress.value,
|
||||
animationProgress = p,
|
||||
origin = origin,
|
||||
onDismiss = {
|
||||
show.targetState = false
|
||||
@ -355,7 +352,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
ShortcutItemGridPopup(
|
||||
shortcut = searchable,
|
||||
show = show,
|
||||
animationProgress = animationProgress.value,
|
||||
animationProgress = p,
|
||||
origin = origin,
|
||||
onDismiss = {
|
||||
show.targetState = false
|
||||
@ -367,7 +364,7 @@ fun ItemPopup(origin: IntRect, searchable: Searchable, onDismissRequest: () -> U
|
||||
LocationItemGridPopup(
|
||||
location = searchable,
|
||||
show = show,
|
||||
animationProgress = animationProgress.value,
|
||||
animationProgress = p,
|
||||
origin = origin,
|
||||
onDismiss = {
|
||||
show.targetState = false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user