annotate GeoQuiz/Tests/Animation.swift @ 3:4dbe0cd9dadc

first game prototype
author Dennis C. M. <dennis@denniscm.com>
date Thu, 22 Sep 2022 10:42:39 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
1 //
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
2 // Animation.swift
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
3 // GeoQuiz
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
4 //
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
5 // Created by Dennis Concepción Martín on 21/9/22.
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
6 //
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
7
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
8 import SwiftUI
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
9
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
10 struct Animation: View {
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
11 @State private var amount = 1.0
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
12
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
13 var body: some View {
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
14 Button {
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
15 withAnimation(.easeIn(duration: 0.5)) {
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
16 amount += 1
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
17 }
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
18
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
19 DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
20 withAnimation(.easeIn(duration: 0.5)) {
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
21 amount = 1
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
22 }
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
23 }
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
24 } label: {
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
25 Circle()
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
26 .overlay(
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
27 Text("Button")
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
28 .foregroundColor(.white)
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
29 )
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
30 }
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
31 .frame(height: 100)
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
32 .scaleEffect(amount)
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
33 }
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
34 }
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
35
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
36 struct Animation_Previews: PreviewProvider {
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
37 static var previews: some View {
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
38 Animation()
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
39 }
4dbe0cd9dadc first game prototype
Dennis C. M. <dennis@denniscm.com>
parents:
diff changeset
40 }