1
1
# ConfettiSwiftUI
2
2
3
- <img src =" https://img.shields.io/badge/PLATFORM-IOS%20|%20MACOS-lightgray?style=for-the-badge " />  ;  ;  ; <img src =" https://img.shields.io/badge/LICENSE-MIT-lightgray?style=for-the-badge " />  ;  ;  ; <img src =" https://img.shields.io/badge/MADE WITH-SWIFTUI-orange?style=for-the-badge " />
3
+ ![ GitHub License] ( https://img.shields.io/github/license/simibac/ConfettiSwiftUI?logo=github )
4
+ ![ Cocoapods platforms] ( https://img.shields.io/cocoapods/p/AFNetworking?logo=apple )
4
5
5
- ### Customizable Confetti Animations in SwiftUI
6
6
7
7
<p align =" center " >
8
8
<img src =" ./Gifs/native_default_iphone.png " width =" 200 " width =" 480 " />
9
9
</p >
10
10
11
- ## 🌄 Example
11
+ Customize confetti animations.
12
+
13
+ - All elements are built with pure SwiftUI.
14
+ - Select from default confetti shapes, emojis, SF Symbols or text.
15
+ - Trigger the animation with one state change multiple times with a haptic feed back on each explosion.
16
+
17
+
18
+ ## 🌄 Examples
12
19
13
20
<p align =" center " >
14
21
<img src =" ./Gifs/default.gif " width =" 150 " />
17
24
<img src =" ./Gifs/color.gif " width =" 150 " />
18
25
</p >
19
26
20
- ## 🔭 Overview
21
-
22
- This is an open-source library to use with SwiftUI. It allows you to create and customize confetti animations.
23
-
24
- - Built with pure SwiftUI.
25
- - Select from default confetti shapes or inject emojis as text.
26
- - Configure the radius and angles of the explosion.
27
- - Trigger animation with one state change multiple times.
28
-
29
- ## 🧭 Navigation
30
-
31
- - [ 💻 Installation] ( #-installation )
32
- - [ Swift Package Manager] ( #swift-package-manager )
33
- - [ Manually] ( #manually )
34
- - [ 🧳 Requirements] ( #-requirements )
35
- - [ 🛠 Usage] ( #-usage )
36
- - [ Parameters] ( #parameters )
37
- - [ Configurator Application With Live Preview] ( #configurator-application-with-live-preview )
38
- - [ Examples] ( #examples )
39
- - [ 👨💻 Contributors] ( #-contributors )
40
- - [ ✍️ Author] ( #-author )
41
- - [ 📃 License] ( #-license )
42
- - [ 📦 Projects] ( #-projects )
43
-
44
27
## 💻 Installation
45
28
46
29
### Swift Package Manager
@@ -74,13 +57,13 @@ import SwiftUI
74
57
75
58
struct ContentView : View {
76
59
77
- @State private var counter : Int = 0
60
+ @State private var trigger : Int = 0
78
61
79
62
var body: some View {
80
63
Button (" 🎉" ) {
81
- counter += 1
64
+ trigger += 1
82
65
}
83
- .confettiCannon (counter : $counter )
66
+ .confettiCannon (trigger : $trigger )
84
67
}
85
68
}
86
69
@@ -90,7 +73,7 @@ struct ContentView: View {
90
73
91
74
| parameter | type | description | default |
92
75
| ------------------ | -------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
93
- | counter | Binding<Int > | on any change of this variable triggers the animation | 0 |
76
+ | trigger | Binding<Int > | on any change of this variable triggers the animation | 0 |
94
77
| num | Int | amount of confettis | 20 |
95
78
| confettis | [ ConfettiType] | list of shapes and text | [ .shape(.circle), .shape(.triangle), .shape(.square), .shape(.slimRectangle), .shape(.roundedCross)] |
96
79
| colors | [ Color] | list of colors applied to the default shapes | [ .blue, .red, .green, .yellow, .pink, .purple, .orange] |
@@ -103,76 +86,77 @@ struct ContentView: View {
103
86
| radius | CGFloat | explosion radius | 300.0 |
104
87
| repetitions | Int | number of repetitions for the explosion | 1 |
105
88
| repetitionInterval | Double | duration between the repetitions | 1.0 |
89
+ | hapticFeedback | Bool | haptic feedback on each confetti explosion | true |
106
90
107
91
### Configurator Application With Live Preview
108
92
109
- You can use the configurator app in [ demo project here] ( https://github.com/simibac/ConfettiSwiftUIDemo ) to make your desired animation or get inspired by one of the many examples.
93
+ You can use the configurator app in [ demo project here] ( https://github.com/simibac/ConfettiSwiftUIDemo ) to configure your desired animation or get inspired by one of the many examples.
110
94
111
95
<p align =" center " >
112
96
<img src =" ./Gifs/configurator.png " width =" 150 " />
113
97
<img src =" ./Gifs/examples.png " width =" 150 " />
114
98
</p >
115
99
116
- ### Examples
100
+ ### Configuration Examples
117
101
118
- #### Color and Size Configuration
102
+ #### Color and Size
119
103
120
104
<p align =" center " >
121
105
<img src =" ./Gifs/color.gif " width =" 150 " />
122
106
</p >
123
107
124
108
``` swift
125
- .confettiCannon (counter : $counter , colors : [.red , .black ], confettiSize : 20 )
109
+ .confettiCannon (trigger : $trigger , colors : [.red , .black ], confettiSize : 20 )
126
110
```
127
111
128
- #### Repeat Configuration
112
+ #### Repeat
129
113
130
114
<p align =" center " >
131
115
<img src =" ./Gifs/repeat.gif " width =" 150 " />
132
116
</p >
133
117
134
118
``` swift
135
- .confettiCannon (counter : $counter , repetitions : 3 , repetitionInterval : 0.7 )
119
+ .confettiCannon (trigger : $trigger , repetitions : 3 , repetitionInterval : 0.7 )
136
120
```
137
121
138
- #### Firework Configuration
122
+ #### Firework
139
123
140
124
<p align =" center " >
141
125
<img src =" ./Gifs/explosion.gif " width =" 150 " />
142
126
</p >
143
127
144
128
``` swift
145
- .confettiCannon (counter : $counter , num : 50 , openingAngle : Angle (degrees : 0 ), closingAngle : Angle (degrees : 360 ), radius : 200 )
129
+ .confettiCannon (trigger : $trigger , num : 50 , openingAngle : Angle (degrees : 0 ), closingAngle : Angle (degrees : 360 ), radius : 200 )
146
130
```
147
131
148
- #### Emoji Configuration
132
+ #### Emoji
149
133
150
134
<p align =" center " >
151
135
<img src =" ./Gifs/heart.gif " width =" 150 " />
152
136
</p >
153
137
154
138
``` swift
155
- .confettiCannon (counter : $counter , confettis : [.text (" ❤️" ), .text (" 💙" ), .text (" 💚" ), .text (" 🧡" )])
139
+ .confettiCannon (trigger : $trigger , confettis : [.text (" ❤️" ), .text (" 💙" ), .text (" 💚" ), .text (" 🧡" )])
156
140
```
157
141
158
- #### Endless Configuration
142
+ #### Endless
159
143
160
144
<p align =" center " >
161
145
<img src =" ./Gifs/constant.gif " width =" 150 " />
162
146
</p >
163
147
164
148
``` swift
165
- .confettiCannon (counter : $counter , num :1 , confettis : [.text (" 💩" )], confettiSize : 20 , repetitions : 100 , repetitionInterval : 0.1 )
149
+ .confettiCannon (trigger : $trigger , num :1 , confettis : [.text (" 💩" )], confettiSize : 20 , repetitions : 100 , repetitionInterval : 0.1 )
166
150
```
167
151
168
- #### Make-it-Rain Configuration
152
+ #### Make-it-Rain
169
153
170
154
<p align =" center " >
171
155
<img src =" ./Gifs/make-it-rain.gif " width =" 150 " />
172
156
</p >
173
157
174
158
``` swift
175
- .confettiCannon (counter : $counter , num :1 , confettis : [.text (" 💵" ), .text (" 💶" ), .text (" 💷" ), .text (" 💴" )], confettiSize : 30 , repetitions : 50 , repetitionInterval : 0.1 )
159
+ .confettiCannon (trigger : $trigger , num :1 , confettis : [.text (" 💵" ), .text (" 💶" ), .text (" 💷" ), .text (" 💴" )], confettiSize : 30 , repetitions : 50 , repetitionInterval : 0.1 )
176
160
```
177
161
178
162
@@ -182,17 +166,13 @@ You can use the configurator app in [demo project here](https://github.com/simib
182
166
</p >
183
167
184
168
``` swift
185
- .confettiCannon (counter : $counter8 , confettis : [.image (" arb" ), .image (" eth" ), .image (" btc" ), .image (" op" ), .image (" link" ), .image (" doge" )], confettiSize : 20 )
169
+ .confettiCannon (trigger : $trigger8 , confettis : [.image (" arb" ), .image (" eth" ), .image (" btc" ), .image (" op" ), .image (" link" ), .image (" doge" )], confettiSize : 20 )
186
170
```
187
171
188
172
## 👨💻 Contributors
189
173
190
174
All issue reports, feature requests, pull requests and GitHub stars are welcomed and much appreciated.
191
175
192
- ## ✍️ Author
193
-
194
- Simon Bachmann
195
-
196
176
## 🔨Support
197
177
198
178
If you like the project, don't forget to ` put star 🌟 ` .
0 commit comments