Skip to content

Commit

Permalink
Implement theme accent handling in PrimalLoadingSpinner
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarIlic committed Nov 13, 2023
1 parent 6deeeb4 commit 15e6238
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,31 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
import net.primal.android.LocalPrimalTheme
import net.primal.android.R
import net.primal.android.theme.domain.PrimalAccent

@Composable
fun PrimalLoadingSpinner(
size: Dp = 96.dp,
) {
val primalTheme = LocalPrimalTheme.current
val animationRawResId = remember(primalTheme) {
when (primalTheme.accent) {
PrimalAccent.Summer -> R.raw.primal_loading_spinner_summer
PrimalAccent.Winter -> R.raw.primal_loading_spinner_winter
}
}
val composition by rememberLottieComposition(
spec = LottieCompositionSpec.RawRes(R.raw.primal_loading_spinner_sunset)
spec = LottieCompositionSpec.RawRes(animationRawResId)
)
val progress by animateLottieCompositionAsState(
composition = composition,
Expand Down

0 comments on commit 15e6238

Please sign in to comment.