From 8d0435db7770d2bdb1c2626304425d1a03587702 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 4 Mar 2022 17:22:18 +0000 Subject: [PATCH] updating all confetti usages to use design palette colours --- .../im/vector/app/core/animations/Konfetti.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/animations/Konfetti.kt b/vector/src/main/java/im/vector/app/core/animations/Konfetti.kt index 18f135d527..22764ac5bd 100644 --- a/vector/src/main/java/im/vector/app/core/animations/Konfetti.kt +++ b/vector/src/main/java/im/vector/app/core/animations/Konfetti.kt @@ -16,14 +16,27 @@ package im.vector.app.core.animations -import android.graphics.Color +import android.content.Context +import androidx.annotation.ColorInt +import androidx.core.content.ContextCompat +import im.vector.app.R import nl.dionsegijn.konfetti.KonfettiView import nl.dionsegijn.konfetti.models.Shape import nl.dionsegijn.konfetti.models.Size fun KonfettiView.play() { + val confettiColors = listOf( + R.color.palette_azure, + R.color.palette_grape, + R.color.palette_verde, + R.color.palette_polly, + R.color.palette_melon, + R.color.palette_aqua, + R.color.palette_prune, + R.color.palette_kiwi + ) build() - .addColors(Color.YELLOW, Color.GREEN, Color.MAGENTA) + .addColors(confettiColors.toColorInt(context)) .setDirection(0.0, 359.0) .setSpeed(2f, 5f) .setFadeOutEnabled(true) @@ -33,3 +46,6 @@ fun KonfettiView.play() { .setPosition(-50f, width + 50f, -50f, -50f) .streamFor(150, 3000L) } + +@ColorInt +private fun List.toColorInt(context: Context) = map { ContextCompat.getColor(context, it) }