Merge pull request #5079 from vector-im/feature/bma/konfetti2

WIP and low priority: upgrade konfetti to 2.0.2
This commit is contained in:
Benoit Marty 2022-04-06 10:00:09 +02:00 committed by GitHub
commit c849cc5c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 17 deletions

1
changelog.d/5079.misc Normal file
View File

@ -0,0 +1 @@
Upgrade konfetti lib from 1.3.2 to 2.0.2

View File

@ -446,7 +446,8 @@ dependencies {
implementation 'me.leolin:ShortcutBadger:1.1.22@aar' implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
// Chat effects // Chat effects
implementation 'nl.dionsegijn:konfetti:1.3.2' implementation 'nl.dionsegijn:konfetti-xml:2.0.2'
implementation 'com.github.jetradarmobile:android-snowfall:1.2.1' implementation 'com.github.jetradarmobile:android-snowfall:1.2.1'
// DI // DI
implementation libs.dagger.hilt implementation libs.dagger.hilt

View File

@ -20,9 +20,14 @@ import android.content.Context
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import im.vector.app.R import im.vector.app.R
import nl.dionsegijn.konfetti.KonfettiView import nl.dionsegijn.konfetti.core.Angle
import nl.dionsegijn.konfetti.models.Shape import nl.dionsegijn.konfetti.core.Party
import nl.dionsegijn.konfetti.models.Size import nl.dionsegijn.konfetti.core.Position
import nl.dionsegijn.konfetti.core.Spread
import nl.dionsegijn.konfetti.core.emitter.Emitter
import nl.dionsegijn.konfetti.core.models.Shape
import nl.dionsegijn.konfetti.core.models.Size
import nl.dionsegijn.konfetti.xml.KonfettiView
fun KonfettiView.play() { fun KonfettiView.play() {
val confettiColors = listOf( val confettiColors = listOf(
@ -35,16 +40,22 @@ fun KonfettiView.play() {
R.color.palette_prune, R.color.palette_prune,
R.color.palette_kiwi R.color.palette_kiwi
) )
build() val emitterConfig = Emitter(2000).perSecond(100)
.addColors(confettiColors.toColorInt(context)) val party = Party(
.setDirection(0.0, 359.0) emitter = emitterConfig,
.setSpeed(2f, 5f) colors = confettiColors.toColorInt(context),
.setFadeOutEnabled(true) angle = Angle.Companion.BOTTOM,
.setTimeToLive(2000L) spread = Spread.ROUND,
.addShapes(Shape.Square, Shape.Circle) shapes = listOf(Shape.Square, Shape.Circle),
.addSizes(Size(12)) size = listOf(Size(12)),
.setPosition(-50f, width + 50f, -50f, -50f) speed = 2f,
.streamFor(150, 3000L) maxSpeed = 5f,
fadeOutEnabled = true,
timeToLive = 2000L,
position = Position.Relative(0.0, 0.0).between(Position.Relative(1.0, 0.0)),
)
reset()
start(party)
} }
@ColorInt @ColorInt

View File

@ -6,7 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?colorSecondary"> android:background="?colorSecondary">
<nl.dionsegijn.konfetti.KonfettiView <nl.dionsegijn.konfetti.xml.KonfettiView
android:id="@+id/viewKonfetti" android:id="@+id/viewKonfetti"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View File

@ -4,7 +4,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<nl.dionsegijn.konfetti.KonfettiView <nl.dionsegijn.konfetti.xml.KonfettiView
android:id="@+id/viewKonfetti" android:id="@+id/viewKonfetti"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View File

@ -188,7 +188,7 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:tint="@android:color/black" /> app:tint="@android:color/black" />
<nl.dionsegijn.konfetti.KonfettiView <nl.dionsegijn.konfetti.xml.KonfettiView
android:id="@+id/viewKonfetti" android:id="@+id/viewKonfetti"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"