-
-
Save sturdysturge/fc076044bdee3922f9082eb7c778df09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| @available(iOS 16.0, *) | |
| struct ContentView: View { | |
| @State var totalCapsules = 10 | |
| var body: some View { | |
| VStack { | |
| _CircleLayout(radius: 100) { | |
| Group { | |
| ForEach(1...totalCapsules, id: \.self) { index in | |
| Capsule() | |
| .frame(width: 25, height: 10) | |
| .foregroundColor( | |
| Color( | |
| red: Double(index) / Double(totalCapsules), | |
| green: 0, | |
| blue: 0, | |
| opacity: 1 | |
| ) | |
| ) | |
| .id(index) | |
| } | |
| } | |
| } | |
| Stepper("Capsules: \(totalCapsules)", | |
| value: $totalCapsules, in: 1...100) | |
| Button("Set To 50") { | |
| withAnimation(.linear(duration: 1)) { | |
| totalCapsules = 50 | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment