Add favorites transition
This commit is contained in:
parent
f7f0e54f2e
commit
eae816c3d7
@ -1,8 +1,16 @@
|
|||||||
package de.mm20.launcher2.ui.launcher.search.common.grid
|
package de.mm20.launcher2.ui.launcher.search.common.grid
|
||||||
|
|
||||||
import androidx.compose.animation.animateContentSize
|
import androidx.compose.animation.AnimatedContent
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.animation.SharedTransitionScope
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.togetherWith
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -20,28 +28,40 @@ fun SearchResultGrid(
|
|||||||
reverse: Boolean = false,
|
reverse: Boolean = false,
|
||||||
highlightedItem: SavableSearchable? = null
|
highlightedItem: SavableSearchable? = null
|
||||||
) {
|
) {
|
||||||
Column(
|
SharedTransitionScope {
|
||||||
modifier = modifier
|
AnimatedContent(
|
||||||
.animateContentSize()
|
items,
|
||||||
.fillMaxWidth()
|
modifier = it then modifier
|
||||||
.padding(4.dp),
|
.fillMaxWidth()
|
||||||
verticalArrangement = if (reverse) Arrangement.BottomReversed else Arrangement.Top
|
.padding(4.dp),
|
||||||
) {
|
transitionSpec = {
|
||||||
for (i in 0 until ceil(items.size / columns.toFloat()).toInt()) {
|
fadeIn() togetherWith fadeOut()
|
||||||
Row {
|
}
|
||||||
for (j in 0 until columns) {
|
) { items ->
|
||||||
val item = items.getOrNull(i * columns + j)
|
Column(
|
||||||
if (item != null) {
|
verticalArrangement = if (reverse) Arrangement.BottomReversed else Arrangement.Top
|
||||||
GridItem(
|
) {
|
||||||
modifier = Modifier
|
for (i in 0 until ceil(items.size / columns.toFloat()).toInt()) {
|
||||||
.weight(1f)
|
Row {
|
||||||
.padding(4.dp),
|
for (j in 0 until columns) {
|
||||||
item = item,
|
val item = items.getOrNull(i * columns + j)
|
||||||
showLabels = showLabels,
|
if (item != null) {
|
||||||
highlight = item.key == highlightedItem?.key
|
GridItem(
|
||||||
)
|
modifier = Modifier
|
||||||
} else {
|
.sharedBounds(
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
rememberSharedContentState(item.key),
|
||||||
|
this@AnimatedContent,
|
||||||
|
)
|
||||||
|
.weight(1f)
|
||||||
|
.padding(4.dp),
|
||||||
|
item = item,
|
||||||
|
showLabels = showLabels,
|
||||||
|
highlight = item.key == highlightedItem?.key
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
package de.mm20.launcher2.ui.launcher.search.favorites
|
package de.mm20.launcher2.ui.launcher.search.favorites
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedContent
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.togetherWith
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
package de.mm20.launcher2.ui.launcher.widgets.favorites
|
package de.mm20.launcher2.ui.launcher.widgets.favorites
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedContent
|
||||||
|
import androidx.compose.animation.Crossfade
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.togetherWith
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user