-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainView.swift
138 lines (124 loc) · 5.11 KB
/
MainView.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//
// MainView.swift
// HowYa
//
// Created by Joel Wong on 15/10/22.
//
import SwiftUI
struct MainView: View {
@StateObject var viewRouter: ViewRouter
@State var showPopUp = false
var body: some View {
GeometryReader { geometry in
VStack {
Spacer()
switch viewRouter.currentPage {
case .home:
HomeView()
case .friends:
FriendEmotionView()
case .create:
NavigationView{
ReflectionView()
}
case .map:
WholeMapView()
case .me:
Text("Me")
}
Spacer()
ZStack {
if showPopUp {
PlusMenu(widthAndHeight: geometry.size.width/7)
.offset(y: -geometry.size.height/6)
}
HStack {
TabBarIcon(viewRouter: viewRouter, assignedPage: .home, width: geometry.size.width/5, height: geometry.size.height/32, systemIconName: "house.fill", tabName: "Home")
TabBarIcon(viewRouter: viewRouter, assignedPage: .friends, width: geometry.size.width/5, height: geometry.size.height/32, systemIconName: "person.2.fill", tabName: "Friends")
VStack{
ZStack {
Circle()
.frame(width: geometry.size.width/7, height: geometry.size.width/7)
.shadow(radius: 4)
.foregroundColor(.white)
Image(systemName: "plus.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: geometry.size.width/7-6 , height: geometry.size.width/7-6)
.foregroundColor(Color("DarkPurple"))
.rotationEffect(Angle(degrees: showPopUp ? 90 : 0))
}
.offset(y: -geometry.size.height/8/2)
}.onTapGesture {
viewRouter.currentPage = .create
}
TabBarIcon(viewRouter: viewRouter, assignedPage: .map, width: geometry.size.width/5, height: geometry.size.height/32, systemIconName: "map.fill", tabName: "Map")
TabBarIcon(viewRouter: viewRouter, assignedPage: .me, width: geometry.size.width/5, height: geometry.size.height/32, systemIconName: "person.crop.circle", tabName: "Me")
}
.frame(width: geometry.size.width, height: geometry.size.height/8)
.background(Color("TabBarBackground").shadow(radius: 2))
}
}
.edgesIgnoringSafeArea(.bottom)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
MainView(viewRouter: ViewRouter())
.preferredColorScheme(.light)
}
}
struct PlusMenu: View {
let widthAndHeight: CGFloat
var body: some View {
HStack(spacing: 50) {
ZStack {
Circle()
.foregroundColor(Color("DarkPurple"))
.frame(width: widthAndHeight, height: widthAndHeight)
Image(systemName: "record.circle")
.resizable()
.aspectRatio(contentMode: .fit)
.padding(15)
.frame(width: widthAndHeight, height: widthAndHeight)
.foregroundColor(.white)
}
ZStack {
Circle()
.foregroundColor(Color("DarkPurple"))
.frame(width: widthAndHeight, height: widthAndHeight)
Image(systemName: "folder")
.resizable()
.aspectRatio(contentMode: .fit)
.padding(15)
.frame(width: widthAndHeight, height: widthAndHeight)
.foregroundColor(.white)
}
}
.transition(.scale)
}
}
struct TabBarIcon: View {
@StateObject var viewRouter: ViewRouter
let assignedPage: Page
let width, height: CGFloat
let systemIconName, tabName: String
var body: some View {
VStack {
Image(systemName: systemIconName)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: width, height: height)
.padding(.top, 16)
Text(tabName)
.font(.custom("Lexend-Regular", size: 12))
Spacer()
}
.padding(.horizontal, -4)
.onTapGesture {
viewRouter.currentPage = assignedPage
}
.foregroundColor(viewRouter.currentPage == assignedPage ? Color("TabBarHighlight") : .gray)
}
}