-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathStreamLaunchscreenAnimation.swift
61 lines (55 loc) · 2.22 KB
/
StreamLaunchscreenAnimation.swift
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// StreamLaunchScreenAnimation.swift
//
// System-provided loading indicators can sometimes feel out of context. So, create custom iOS (SwiftUI) loading animations to match your brand style and provide immersive UX like what Stream did for app launching
//
import SwiftUI
struct StreamLaunchScreenAnimation: View {
@State private var move = false
@State private var splash = false
let StreamBlue = Color(#colorLiteral(red: 0, green: 0.368627451, blue: 1, alpha: 1))
@State private var swinging = false
var body: some View {
ZStack {
StreamBlue
.opacity(0.25)
.ignoresSafeArea()
ZStack {
Image("STREAMMARK")
.scaleEffect(0.6)
.rotationEffect(.degrees(swinging ? -10 : 10), anchor: swinging ? .bottomLeading : .bottomTrailing)
.offset(y: -15)
.animation(.easeInOut(duration: 1).repeatCount(14, autoreverses: true), value: swinging)
VStack(spacing: -46) {
Image("stream_wave")
.offset(y: 20)
.offset(x: move ? -160 : 160)
.animation(.linear(duration: 14), value: move)
Image("stream_wave")
.offset(y: 10)
.offset(x: move ? -150 : 150)
.animation(.linear(duration: 14), value: move)
}
.mask(Image("wave_top"))
Circle()
.frame(width: 5, height: 5)
.scaleEffect(splash ? UIScreen.main.bounds.height : 0)
.foregroundColor(StreamBlue)
//.opacity(splash ? 1 : 0)
}
.onAppear {
move.toggle()
swinging.toggle()
withAnimation(.easeInOut(duration: 1).delay(13).repeatCount(1, autoreverses: false)){
splash.toggle()
}
}
.scaleEffect(2)
}
}
}
struct StreamLaunchScreenAnimation_Previews: PreviewProvider {
static var previews: some View {
StreamLaunchScreenAnimation()
}
}