-
Notifications
You must be signed in to change notification settings - Fork 43
/
ConversationsPhotoZoom.swift
66 lines (54 loc) · 1.88 KB
/
ConversationsPhotoZoom.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
62
63
64
65
66
//
// ConversationsPhotoZoom.swift
//
// Learning SwiftUI Spring Animations: The Basics and Beyond
//
// Created by Amos from getstream.io
import SwiftUI
struct ConversationsPhotoZoom: View {
@State private var zoomed = false
@Namespace private var smooth
@State private var tapped = false
var body: some View {
VStack {
ConversationsHeader()
Spacer()
ZStack{
if !tapped {
HStack {
PhotoMessageView()
.matchedGeometryEffect(id: "morph", in: smooth)
Spacer()
}
} else {
Image("iceland4")
.resizable()
.matchedGeometryEffect(id: "morph", in: smooth)
.aspectRatio(contentMode: .fill)
}
}
.onTapGesture {
withAnimation(
.spring()
//.interactiveSpring()
//.spring(response: 0.3, dampingFraction: 0.825, blendDuration: 0)
//.interpolatingSpring(mass: 0.5, stiffness: 170, damping: 15, initialVelocity: 0)
//.interpolatingSpring(stiffness: 170, damping: 15)
//.interactiveSpring(response: 0.15, dampingFraction: 0.86, blendDuration: 0)
){
zoomed.toggle()
tapped.toggle()
}
}
Spacer()
ComposeArea()
}
.padding(.horizontal)
}
struct ConversationsPhotoZoom_Previews: PreviewProvider {
static var previews: some View {
ConversationsPhotoZoom()
.preferredColorScheme(.dark)
}
}
}