blob: de4712dbba2d4101865eec076f27addcf79b4b9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/*
* This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
* See LICENSE.md
*/
import SwiftUI
struct LaunchAnimationView: View {
@State private var rotationEnabled = true
var body: some View {
ZStack {
Color(.systemGray6).ignoresSafeArea()
RotatingTaler(size: (350 < UIScreen.screenWidth) ? 200 : 250, rotationEnabled: $rotationEnabled)
}
}
}
struct RotatingTaler: View {
let size: CGFloat
@Binding var rotationEnabled: Bool
@State private var rotationDirection = false
private let animationTimer = Timer
.publish(every: 1.6, on: .current, in: .common)
.autoconnect()
var body: some View {
Image("taler-logo-2023-red")
.resizable()
.scaledToFit()
.frame(width: size, height: size)
.rotationEffect(rotationDirection ? Angle(degrees: 0) : Angle(degrees: 900))
.accessibilityHidden(true) // decorative logo
.onReceive(animationTimer) { timerValue in
if rotationEnabled {
withAnimation(.easeInOut(duration: 1.9)) {
rotationDirection.toggle()
}
}
}
}
}
// MARK: -
struct LaunchAnimationView_Previews: PreviewProvider {
static var previews: some View {
LaunchAnimationView()
}
}
|