Created
February 15, 2021 09:06
-
-
Save petrosDemetrakopoulos/4eafe07c0d1680db2b596b460577971c to your computer and use it in GitHub Desktop.
Roulett UI
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
| var body: some View { | |
| VStack { | |
| Text(self.isAnimating ? "Spining\n..." : sectorFromAngle(angle : newAngle)) | |
| .multilineTextAlignment(.center) | |
| Image("Arrow") | |
| .resizable() | |
| .scaledToFit() | |
| .frame(width: 25, height: 25, alignment: .center) | |
| Image("roulette") | |
| .resizable() | |
| .scaledToFit() | |
| .rotationEffect(Angle(degrees: spinDegrees)) | |
| .frame(width: 245, height: 245, alignment: .center) | |
| .animation(spinAnimation) | |
| Button("SPIN") { | |
| isAnimating = true | |
| rand = Double.random(in: 1...360) | |
| spinDegrees += 720.0 + rand | |
| newAngle = getAngle(angle: spinDegrees) | |
| DispatchQueue.main.asyncAfter(deadline: .now() + 2.9) { | |
| isAnimating = false | |
| } | |
| } | |
| .padding(40) | |
| .disabled(isAnimating == true) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment