This commit is contained in:
Iamlooker 2022-04-22 17:50:46 +05:30
parent b4a1ba3080
commit 83011ead2c
2 changed files with 12 additions and 12 deletions

View File

@ -2,9 +2,7 @@ package com.looker.droidify.ui.compose.utils
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColor
import androidx.compose.animation.core.animateDp
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.updateTransition
import androidx.compose.animation.core.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
@ -54,7 +52,10 @@ private fun categoryChipTransition(selected: Boolean): CategoryChipTransition {
SelectionState.Selected -> MaterialTheme.colorScheme.inversePrimary.copy(alpha = 0.8f)
}
}
val checkScale = transition.animateFloat(label = "chip_check_scale") { state ->
val checkScale = transition.animateFloat(
label = "chip_check_scale",
transitionSpec = { spring(dampingRatio = Spring.DampingRatioHighBouncy, stiffness = Spring.StiffnessLow) }
) { state ->
when (state) {
SelectionState.Unselected -> 0.6f
SelectionState.Selected -> 1f

View File

@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material.icons.rounded.Sync
@ -65,15 +64,14 @@ class ExploreFragment : MainNavFragmentX() {
// Avoid the compiler using the same class as observer
Log.d(this::class.java.canonicalName, this.toString())
}
viewModel.primaryProducts.observe(viewLifecycleOwner) {
redrawPage(it, viewModel.categories.value ?: emptyList())
}
viewModel.categories.observe(viewLifecycleOwner) {
redrawPage(viewModel.primaryProducts.value, it)
viewModel.primaryProducts.observe(viewLifecycleOwner) { products ->
viewModel.categories.observe(viewLifecycleOwner) { categories ->
redrawPage(products, categories)
}
}
}
@OptIn(ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class)
private fun redrawPage(products: List<Product>?, categories: List<String> = emptyList()) {
binding.composeView.setContent {
AppTheme(
@ -125,7 +123,8 @@ class ExploreFragment : MainNavFragmentX() {
}
)
}
ProductsVerticalRecycler(products,
ProductsVerticalRecycler(
products,
repositories,
Modifier
.fillMaxWidth()