-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentView.swift
More file actions
289 lines (231 loc) · 11.8 KB
/
ContentView.swift
File metadata and controls
289 lines (231 loc) · 11.8 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
import SwiftUI
import MapKit
import CoreLocation
class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
private var locationManager = CLLocationManager()
@Published var Region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.56, longitude: 126.97), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)) // 초기 값
override init() {
super.init()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations location: [CLLocation]) {
guard let location = location.last else { return }
// 사용자의 현재 위치를 기반으로 지도의 중심 업데이트
Region = MKCoordinateRegion(center: location.coordinate, span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("Failed to find user's location: \(error.localizedDescription)")
}
}
struct ContentView: View {
@State private var isActive = false // 기본 값 false로 둬서 스플래시 실행 후 나오게
var body: some View {
if isActive {
TabView(selection: .constant(0)) { // 하단 Tab bar
// 프로필 페이지 탭
ProfileView()
.tabItem {Label("Profile", systemImage: "house.fill")}
.tag(0)
// 모임 페이지 탭
RunView()
.tabItem {Label("Run", systemImage: "figure.run")}
.tag(1)
// 채팅 페이지 탭
ChatView()
.tabItem {Label("Chat", systemImage: "message.fill")}
.tag(2)
}
} else {
SplashView(isActive: $isActive)
}
}
}
// 프로필 페이지
struct ProfileView: View {
@StateObject private var locationManager = LocationManager() // 위치 관리 객체 생성
var body: some View {
VStack(alignment: .leading) {
// 프로필 글씨, 알림, 설정
HStack{
Text("프로필")
.font(.largeTitle.bold())
Spacer() // 텍스트와 이미지 사이 공간 최대화
Image(systemName: "bell.fill") // 종 모양 이미지
.resizable() // 이미지 사이즈 변경할 수 있게 허용
.frame(width: 26, height: 30) // 종 사이즈
.padding(.horizontal, 15) // 종과 톱니바퀴 사이 간격 가로 패딩
Image(systemName: "gearshape.fill") // 톱니바퀴 모양 이미지
.resizable()
.frame(width: 30, height: 30)
}
.padding(.horizontal, 35) // 가로 패딩
.padding(.vertical, 20) // 세로 패딩
// 프로필 사진, 이름, 키워드
HStack{
Image("ProfileImage") // 프로필 사진 이미지
.resizable() // 이미지 사이즈 변경 허용
.frame(width: 100, height: 100)
Spacer()
// (이름, 새싹), 위치, 온도, 키워드 세로 쌓기
VStack(alignment: .leading){
HStack{ // (이름, 새싹), 위치, 러닝 온도 가로 쌓기
VStack(alignment: .leading){ // (이름, 새싹)과 위치 세로 쌓기
HStack{ // 이름, 새싹 이미지 가로 쌓기
Text("비니")
.font(.title.bold())
Image(systemName: "leaf.fill") // 새싹 이미지
.resizable() // 이미지 사이즈 변경 허용
.frame(width: 25, height: 22)
}
Text("경상북도, 포항시")
.font(.system(size: 15))
}
// 러닝 온도
VStack{
Image(systemName: "smiley") // 스마일 이미지
.resizable()
.frame(width: 50, height: 50) // 스마일 이미지 크기
Text("36.8")
}
.frame(width: 70, height: 100) // 스마일 외각
.background(Color.teal.opacity(0.3)) // 스마일 외각 색상
.cornerRadius(20) // 스마일 외각 라디언스(둥글게)
.padding(.horizontal, 20) // 이름, 위치와의 가로 패딩
} // HStack (이름, 새싹), 위치, 러닝 온도 가로 쌓기 블록
// 키워드
HStack{
Text("주말선호")
.font(.system(size: 13, weight: .bold)) // 폰트 크기, 볼드체
.frame(width: 70, height: 24) // 폰트 감싸고 있는 프레임 가로 세로
.background(Color.black.opacity(0.7)) // 프레임 색상
.foregroundColor(.white) // 폰트 자체 색상
Text("취미")
.font(.system(size: 13, weight: .bold))
.frame(width: 65, height: 24)
.background(Color.black.opacity(0.7))
.foregroundColor(.white)
Text("건강")
.font(.system(size: 13, weight: .bold))
.frame(width: 65, height: 24)
.background(Color.black.opacity(0.7))
.foregroundColor(.white)
}
} // VStack (이름, 새싹), 위치, 온도, 키워드 세로 쌓기
} // HStack 프로필 사진, 이름, 키워드 다 포함된 블록
.padding(.horizontal, 30) // 가로 패딩
.padding(.vertical, 5) // 세로 패딩
Divider() // 가로선 (구분선)
// 참여 예정 러닝, 뛴 거리 텍스트 박스
VStack{
HStack{
VStack{
Text("2")
.foregroundStyle(.black)
.font(.system(size: 24, weight: .bold))
Text("참여 예정 러닝")
.frame(maxWidth: .infinity)
.foregroundColor(.black.opacity(0.6))
.font(.system(size: 13, weight: .bold))
}
.padding(.horizontal, 20)
Divider()
VStack{
Text("42.1km")
.foregroundColor(.black)
.font(.system(size: 24, weight: .bold))
Text("이번 달 뛴 거리")
.foregroundColor(.black.opacity(0.6))
.font(.system(size: 13, weight: .bold))
}
.padding(.horizontal, 20)
.frame(maxWidth: .infinity)
}
.frame(maxWidth: .infinity)
.frame(height: 70)
.background(Color.gray.opacity(0.15))
} // VStack 참여 예정, 뛴 거리 블록
.cornerRadius(15)
.padding(.horizontal, 18)
// 마지막 러닝 글씨
VStack{
Text("마지막 러닝")
.font(.system(size: 20, weight: .bold))
}
.padding(.leading, 23)
.padding(.top, 10)
.padding(.bottom, -2)
// map 이미지
VStack{
if #available(iOS 17.0, *) {
Map(coordinateRegion: $locationManager.Region) // 사용자의 현재 위치로 맵 표시
.frame(width: 360, height: 250)
.cornerRadius(15)
.onAppear() {
locationManager.locationManager.startUpdatingLocation()
}
} else { // ios 버전 안 맞으면 map 이미지 띄우기
Image("map")
.resizable()
.frame(width: 360, height: 250)
.cornerRadius(15)
// .padding(.horizontal, 18)
}
}
.frame(maxWidth: .infinity) // 가운데 정렬
// 러닝 정보
VStack{
HStack{
VStack{
Text("5.01")
.foregroundStyle(.black)
.font(.system(size: 18, weight: .bold))
Text("KM")
.frame(maxWidth: .infinity)
.foregroundColor(.black.opacity(0.6))
.font(.system(size: 13, weight: .bold))
}
.padding(.leading, 10)
.frame(maxWidth: .infinity)
VStack{
Text("5'02''")
.foregroundStyle(.black)
.font(.system(size: 18, weight: .bold))
Text("평균 페이스")
.frame(maxWidth: .infinity)
.foregroundColor(.black.opacity(0.6))
.font(.system(size: 13, weight: .bold))
}
.frame(maxWidth: .infinity)
VStack{
Text("25:12")
.foregroundStyle(.black)
.font(.system(size: 18, weight: .bold))
Text("시간")
.frame(maxWidth: .infinity)
.foregroundColor(.black.opacity(0.6))
.font(.system(size: 13, weight: .bold))
}
.frame(maxWidth: .infinity)
VStack{
Text("15m")
.foregroundColor(.black)
.font(.system(size: 18, weight: .bold))
Text("최고 고도")
.foregroundColor(.black.opacity(0.6))
.font(.system(size: 13, weight: .bold))
}
.padding(.leading, -10)
.frame(maxWidth: .infinity)
}
.frame(maxWidth: .infinity)
.frame(height: 70)
} // VStack 하단 러닝 정보 블록
.padding(.top, -10)
Divider()
Spacer() // VStack과 HStack 사이 공간 최대화
} // 가장 큰 VStack 블록
} // var body 블록
} // strust 블록