-
Notifications
You must be signed in to change notification settings - Fork 43
/
SilentModeOff.swift
53 lines (43 loc) · 1.93 KB
/
SilentModeOff.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
//
// SilentModeOff.swift
// SwiftUI Spring Animations
// Silent mode off: Animate a slashed bell to fall and rotate after falling
// Created by Amos from getstream.io
//
import SwiftUI
struct SilentModeOff: View {
@State private var showing = true
@State private var rotating = false
var body: some View {
HStack {
Image(systemName: "bell.slash.fill")
.font(.largeTitle)
.mask(Rectangle().offset(y: rotating ? 0 : 40 ))
.rotationEffect(.degrees(rotating ? 0 : -45), anchor: .top)
.animation(.interpolatingSpring(mass: 1, stiffness: 170, damping: 15, initialVelocity: 4).repeatCount(1, autoreverses: true).delay(2.25), value: rotating)
//.animation(.interactiveSpring(response: 0.25, dampingFraction: 0.86/2, blendDuration: 0.25).repeatCount(1, autoreverses: true).delay(2.25), value: rotating)
//.animation(.interpolatingSpring(stiffness: 120, damping: 15).repeatCount(1, autoreverses: true).delay(2.25), value: rotating)
//.animation(.spring(response: 0.55, dampingFraction: 0.825, blendDuration: 0).repeatCount(1, autoreverses: true).delay(2.25), value: rotating)
VStack {
Text("Silent mode")
Text("Off")
}
}
.padding(EdgeInsets(top: 4, leading: 16, bottom: 4, trailing: 16))
.background(Color(.systemGray4))
.cornerRadius(32)
.offset(y: showing ? -UIScreen.main.bounds.height/1.8 : -UIScreen.main.bounds.height/2.5)
.onAppear {
rotating.toggle()
withAnimation(.spring().repeatCount(1, autoreverses: true).delay(2)) {
showing.toggle()
}
}
}
}
struct SilentModeOff_Previews: PreviewProvider {
static var previews: some View {
SilentModeOff()
.preferredColorScheme(.dark)
}
}