Skip to content

Commit 4d7995b

Browse files
author
Mithun
committed
Animation Between Screens
1 parent 16f9257 commit 4d7995b

File tree

1 file changed

+73
-3
lines changed

1 file changed

+73
-3
lines changed

DesignCode/Home.swift

+73-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,24 @@ import SwiftUI
1111
struct Home: View {
1212

1313
@State var show = false
14+
@State var showProfile = false
1415

1516
var body: some View {
1617
ZStack {
17-
Button(action: { self.show.toggle() }) {
18-
Text("Open Menu")
19-
}
18+
ContentView()
19+
.background(Color.white)
20+
.cornerRadius(30)
21+
.shadow(radius: 20)
22+
.animation(.fluidSpring())
23+
.offset(y: showProfile ? 40 : UIScreen.main.bounds.height)
24+
25+
MenuButton(show: $show)
26+
.offset(x: -30, y: showProfile ? 0 : 80)
27+
.animation(.fluidSpring())
28+
29+
MenuRight(show: $showProfile)
30+
.offset(x: -16, y: showProfile ? 0 : 88)
31+
2032
MenuView(show: $show)
2133
}
2234
}
@@ -90,3 +102,61 @@ struct MenuView: View {
90102
}
91103
}
92104
}
105+
106+
struct CircleButton: View {
107+
108+
var icon = "person.crop.circle"
109+
110+
var body: some View {
111+
return HStack {
112+
Image(systemName: icon)
113+
.foregroundColor(.black)
114+
}
115+
.frame(width: 44, height: 44)
116+
.background(Color.white)
117+
.cornerRadius(30)
118+
.shadow(color: Color("buttonShadow"), radius: 20, x: 0, y: 20)
119+
}
120+
}
121+
122+
struct MenuButton: View {
123+
@Binding var show: Bool
124+
125+
var body: some View {
126+
return ZStack(alignment: .topLeading) {
127+
Button(action: { self.show.toggle() }) {
128+
HStack {
129+
Spacer()
130+
131+
Image(systemName: "list.dash")
132+
.foregroundColor(.black)
133+
}
134+
.padding(.trailing, 20)
135+
.frame(width: 90, height: 60)
136+
.background(Color.white)
137+
.cornerRadius(30)
138+
.shadow(color: Color("buttonShadow"), radius: 20, x: 0, y: 20)
139+
}
140+
Spacer()
141+
}
142+
}
143+
}
144+
145+
struct MenuRight: View {
146+
147+
@Binding var show: Bool
148+
149+
var body: some View {
150+
return ZStack(alignment: .topTrailing) {
151+
HStack {
152+
Button(action: { self.show.toggle() }) {
153+
CircleButton(icon: "person.crop.circle")
154+
}
155+
Button(action: { self.show.toggle() }) {
156+
CircleButton(icon: "bell")
157+
}
158+
}
159+
Spacer()
160+
}
161+
}
162+
}

0 commit comments

Comments
 (0)