ivanvorobei/SPConfetti

Resetting Global color in config does not work as expected

WestFlow127 opened this issue · 0 comments

  • iOS Version: 17.2
  • Framework Version: 1.4.1
  • Installed via SPM

Context:
I show different confetti in various places of my app. I like to use the Globals for easy use.

Problem:
When I set the global SPConfettiConfiguration's color for the first time, it works:

SPConfettiConfiguration.particlesConfig.colors = [.red]

But when I reset it to some other color, the next confetti animation remains the color that was set in the first place.
Here's an example:

func rainHearts() {
   SPConfettiConfiguration.particlesConfig.colors = [.red]
   SPConfettiConfiguration.particlesConfig.contentsScale = 0.60
   SPConfetti.startAnimating(.fullWidthToDown, particles: [.custom(UIImage(systemName: "heart.fill")!)], duration: 3)
}
    
func rainConfetti() {
   SPConfettiConfiguration.particlesConfig.colors = [.yellow]
   SPConfettiConfiguration.particlesConfig.contentsScale = 0.5
   SPConfetti.startAnimating(.fullWidthToDown, particles: [.triangle, .arc, .heart, .star, .custom(UIImage(named: "Trophy")!)], duration: 3)
}

self.rainHearts() /// this rains `red` hearts perfectly
self.rainConfetti() /// this rains triangle, arc, heart, etc but in `red` color, when I expect it to be `yellow`

I even tried setting the SPConfettiConfiguration to it's default value:
SPConfettiConfiguration.particlesConfig = .defaultValue

That did not work.
Am I doing something wrong or is this a bug?
Either way, any suggestions?