From 8036d1dd2d1c0afea56563fcf0791d40b0c8f87c Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Wed, 14 Aug 2024 13:16:46 +0530 Subject: [PATCH] Handle nullable seed colors --- .../sasikanth/rss/reader/home/ui/FeaturedSection.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/ui/FeaturedSection.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/ui/FeaturedSection.kt index c35a38f28..8028cd0d0 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/ui/FeaturedSection.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/ui/FeaturedSection.kt @@ -116,6 +116,8 @@ internal fun FeaturedSection( systemBarsEndPadding } + val defaultSeedColor = AppTheme.colorScheme.tintedForeground + LaunchedEffect(pagerState, featuredPosts) { snapshotFlow { val settledPage = pagerState.settledPage @@ -148,9 +150,14 @@ internal fun FeaturedSection( currentItem } + val fromSeedColor = + fromItem.seedColor.run { if (this != null) Color(this) else defaultSeedColor } + val toSeedColor = + toItem.seedColor.run { if (this != null) Color(this) else defaultSeedColor } + dynamicColorState.animate( - fromSeedColor = Color(fromItem.seedColor!!), - toSeedColor = Color(toItem.seedColor!!), + fromSeedColor = fromSeedColor, + toSeedColor = toSeedColor, progress = offset ) }