From f99dc2a0a9562f2b77cf978b33a13c962d0c5f65 Mon Sep 17 00:00:00 2001 From: Ben Myers Date: Tue, 20 Jul 2021 23:50:51 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8A=20Single-color=20confetti=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/ConfettiView/ConfettiView.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/ConfettiView/ConfettiView.swift b/Sources/ConfettiView/ConfettiView.swift index 88553f5..05034ff 100644 --- a/Sources/ConfettiView/ConfettiView.swift +++ b/Sources/ConfettiView/ConfettiView.swift @@ -69,14 +69,25 @@ fileprivate struct SingleConfettiView: View { public struct ConfettiView: View { + /// The color of the confetti. Leave blank to imply random colors. + fileprivate var color: Color? = nil + public init() {} + public init(_ color: Color) { + self.color = color + } + public var body: some View { ZStack { ForEach(0...20, id: \.self) { _ in - SingleConfettiView() + if let color = self.color { + SingleConfettiView(color: color) + } else { + SingleConfettiView() + } } } }