@@ -22,6 +22,7 @@ import androidx.compose.material3.HorizontalDivider
2222import androidx.compose.material3.Icon
2323import androidx.compose.material3.Text
2424import androidx.compose.runtime.Composable
25+ import androidx.compose.runtime.remember
2526import androidx.compose.ui.Alignment
2627import androidx.compose.ui.Modifier
2728import androidx.compose.ui.draw.clip
@@ -43,6 +44,14 @@ import kotlinx.collections.immutable.ImmutableList
4344import kotlinx.collections.immutable.persistentListOf
4445import com.ninecraft.booket.core.designsystem.R as designR
4546
47+ private val EMOTION_DISPLAY_ORDER = listOf (
48+ EmotionCode .WARMTH ,
49+ EmotionCode .JOY ,
50+ EmotionCode .SADNESS ,
51+ EmotionCode .INSIGHT ,
52+ EmotionCode .OTHER ,
53+ )
54+
4655@Composable
4756internal fun CollectedSeeds (
4857 seedsStats : ImmutableList <EmotionModel >,
@@ -87,14 +96,10 @@ internal fun CollectedSeeds(
8796
8897 Spacer (modifier = Modifier .height(ReedTheme .spacing.spacing4))
8998
90- val displayEmotions = listOf (
91- EmotionCode .WARMTH ,
92- EmotionCode .JOY ,
93- EmotionCode .SADNESS ,
94- EmotionCode .INSIGHT ,
95- EmotionCode .OTHER ,
96- ).mapNotNull { emotionCode ->
97- seedsStats.find { it.code == emotionCode && it.count > 0 }
99+ val displayEmotions = remember(seedsStats) {
100+ EMOTION_DISPLAY_ORDER .mapNotNull { emotionCode ->
101+ seedsStats.find { it.code == emotionCode && it.count > 0 }
102+ }
98103 }
99104
100105 if (displayEmotions.isNotEmpty()) {
@@ -188,7 +193,9 @@ private fun EmotionRatioBar(
188193 seedsStats : ImmutableList <EmotionModel >,
189194 modifier : Modifier = Modifier ,
190195) {
191- val totalCount = seedsStats.sumOf { it.count }.coerceAtLeast(1 )
196+ val totalCount = remember(seedsStats) {
197+ seedsStats.sumOf { it.count }.coerceAtLeast(1 )
198+ }
192199
193200 Row (
194201 modifier = modifier
0 commit comments