Skip to content

Commit 3febeac

Browse files
committed
[HOTFIX/#123] Tabview 디버깅
Tabview 사용 시 생기는 여백을 제거하기 위해 Custom 진행
1 parent 0c2d76b commit 3febeac

6 files changed

Lines changed: 129 additions & 83 deletions

File tree

DMU-iOS/DMU-iOS/Features/Home/Views/HomeView.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ struct HomeUniversityNoticeListView: View {
144144
ScrollView {
145145
LazyVStack(alignment: .leading) {
146146
ForEach(universityNotices) { notice in
147-
NavigationLink(destination: NoticeWebViewDetail(urlString: notice.noticeURL)){
148-
NoticeSingleView(notices: notice)
149-
}
147+
NoticeSingleView(notices: notice)
150148
.onAppear {
151149
if self.universityNotices.isLastItem(notice) {
152150
self.viewModel.loadNextPageOfUniversityNoticesIfNotLoading()
@@ -173,9 +171,7 @@ struct HomeDepartmentNoticeListView: View {
173171
ScrollView {
174172
LazyVStack(alignment: .leading) {
175173
ForEach(departmentNotices) { notice in
176-
NavigationLink(destination: NoticeWebViewDetail(urlString: notice.noticeURL)){
177-
NoticeSingleView(notices: notice)
178-
}
174+
NoticeSingleView(notices: notice)
179175
.onAppear {
180176
if self.departmentNotices.isLastItem(notice) {
181177
self.viewModel.loadNextPageIfNotLoading(department: userSettings.selectedDepartment)
@@ -191,10 +187,10 @@ struct HomeDepartmentNoticeListView: View {
191187
}
192188
}
193189

194-
195190
struct NoticeSingleView: View {
196191
let notices: any NoticeProtocol
197-
192+
@State private var isWebViewPresented = false
193+
198194
var body: some View {
199195
VStack(alignment: .leading) {
200196
HStack {
@@ -224,6 +220,12 @@ struct NoticeSingleView: View {
224220
.padding(.vertical, 10)
225221
.cornerRadius(0)
226222
.shadow(color: Color.gray200, radius: 0, x: 0, y: 0)
223+
.onTapGesture {
224+
isWebViewPresented = true // 웹뷰 표시 상태 변경
225+
}
226+
.fullScreenCover(isPresented: $isWebViewPresented) {
227+
NoticeWebViewDetail(urlString: notices.noticeURL) // 웹뷰로 연결
228+
}
227229
}
228230
}
229231

DMU-iOS/DMU-iOS/Features/Home/Views/NoticeWebView.swift

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77

88
import SwiftUI
9-
109
import WebKit
1110

1211
struct NoticeWebViewDetail: View {
@@ -16,11 +15,44 @@ struct NoticeWebViewDetail: View {
1615
@State private var showShareSheet = false
1716

1817
@Environment(\.presentationMode) var presentationMode
19-
18+
2019
var body: some View {
21-
VStack {
20+
VStack(spacing: 0) {
21+
HStack {
22+
Button(action: {
23+
}) {
24+
Image(systemName: "xmark").hidden()
25+
}
26+
.disabled(true)
27+
28+
Spacer()
29+
30+
VStack {
31+
Text("동양미래대학교")
32+
.font(.Medium16)
33+
.accentColor(Color.Gray500)
34+
.environment(\.sizeCategory, .large)
35+
Text("www.dongyang.ac.kr")
36+
.font(.Medium12)
37+
.accentColor(Color.Gray300)
38+
.environment(\.sizeCategory, .large)
39+
}
40+
41+
Spacer()
42+
43+
Button(action: {
44+
self.presentationMode.wrappedValue.dismiss()
45+
}) {
46+
Image(systemName: "xmark")
47+
.foregroundColor(Color.Gray400)
48+
}
49+
}
50+
.padding(.horizontal, 20)
51+
.padding(.vertical, 10)
52+
.background(Color.white)
53+
2254
WebView(url: URL(string: urlString)!)
23-
.edgesIgnoringSafeArea(.all)
55+
.padding(.top, 0)
2456

2557
HStack(spacing: 60) {
2658
Button(action: {
@@ -56,30 +88,11 @@ struct NoticeWebViewDetail: View {
5688
.frame(width: 44, height: 44)
5789
}
5890
}
59-
.padding()
91+
.padding(.horizontal, 20)
92+
.padding(.vertical, 10)
6093
.background(Color.white)
6194
.frame(height: 44)
6295
}
63-
.navigationBarBackButtonHidden(true)
64-
.navigationBarItems(
65-
trailing: Button(action: {
66-
self.presentationMode.wrappedValue.dismiss()
67-
}) {
68-
Image(systemName: "xmark")
69-
.foregroundColor(Color.Gray400)
70-
})
71-
.toolbar {
72-
ToolbarItem(placement: .principal) {
73-
VStack {
74-
Text("동양미래대학교")
75-
.font(.Medium16)
76-
.accentColor(Color.Gray500)
77-
Text("www.dongyang.ac.kr")
78-
.font(.Medium12)
79-
.accentColor(Color.Gray300)
80-
}
81-
}
82-
}
8396
}
8497
}
8598

@@ -97,7 +110,6 @@ struct ActivityView: UIViewControllerRepresentable {
97110
}
98111
}
99112

100-
101113
struct WebView: UIViewRepresentable {
102114
let url: URL
103115

DMU-iOS/DMU-iOS/Features/Notification/Views/NotificationKeywordEditView.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@ struct NotificationKeywordEditTopBarView: View {
6666

6767
var body: some View {
6868
HStack {
69-
Button(action: {
70-
isNavigatingToKeywordEditView = false
71-
}) {
72-
Image(systemName: "xmark")
73-
.foregroundColor(Color.black)
74-
.padding()
69+
70+
Button(action: {}) {
71+
Image(systemName: "xmark").hidden()
7572
}
73+
.padding()
74+
.disabled(true)
7675

7776
Spacer()
7877

@@ -83,11 +82,13 @@ struct NotificationKeywordEditTopBarView: View {
8382

8483
Spacer()
8584

86-
Button(action: {}) {
87-
Image(systemName: "xmark").hidden()
85+
Button(action: {
86+
isNavigatingToKeywordEditView = false
87+
}) {
88+
Image(systemName: "xmark")
89+
.foregroundColor(Color.black)
90+
.padding()
8891
}
89-
.padding()
90-
.disabled(true)
9192
}
9293
}
9394
}

DMU-iOS/DMU-iOS/Features/Search/Views/SearchView.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,17 @@ struct SearchBarView: View {
173173
struct SearchResultsListView: View {
174174

175175
@ObservedObject var viewModel: SearchViewModel
176-
176+
177177
var body: some View {
178178
VStack {
179179
LazyVStack(alignment: .leading) {
180180
ForEach(viewModel.searchNotices, id: \.id) { notice in
181-
NavigationLink(destination: NoticeWebViewDetail(urlString: notice.noticeURL)){
182-
SearchResultSingleView(notice: notice)
183-
}
184-
.onAppear {
185-
if viewModel.searchNotices.isLastItem(notice) {
186-
viewModel.loadNextPageIfNotLoading()
181+
SearchResultSingleView(notice: notice)
182+
.onAppear {
183+
if viewModel.searchNotices.isLastItem(notice) {
184+
viewModel.loadNextPageIfNotLoading()
185+
}
187186
}
188-
}
189187

190188
Divider().background(Color.Gray200)
191189
}
@@ -197,6 +195,7 @@ struct SearchResultsListView: View {
197195
struct SearchResultSingleView: View {
198196

199197
var notice: SearchNotice
198+
@State private var isWebViewPresented = false
200199

201200
var body: some View {
202201
VStack(alignment: .leading) {
@@ -226,6 +225,12 @@ struct SearchResultSingleView: View {
226225
.background(Color.white)
227226
.cornerRadius(0)
228227
.shadow(color: .gray, radius: 0, x: 0, y: 0)
228+
.onTapGesture {
229+
isWebViewPresented = true
230+
}
231+
.fullScreenCover(isPresented: $isWebViewPresented) {
232+
NoticeWebViewDetail(urlString: notice.noticeURL)
233+
}
229234
}
230235
}
231236

DMU-iOS/DMU-iOS/Features/Setting/Views/SettingView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct SettingView: View {
2424
.frame(maxWidth: .infinity, alignment: .center)
2525
.foregroundColor(Color.Gray600)
2626
.environment(\.sizeCategory, .large)
27-
.padding()
27+
.padding(.top, 10)
2828

2929
Text("대학 공지")
3030
.font(.SemiBold15)

DMU-iOS/DMU-iOS/Features/TabBar/Views/TabBarView.swift

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,74 @@ class TabBarViewModel: ObservableObject {
1515

1616
// MARK: - 탭 목록
1717
enum Tab: String {
18-
1918
case Home, Schedule, Meal, Settings
2019
}
2120

2221
// MARK: - 메인화면 탭바 뷰
2322
struct TabBarView: View {
2423

2524
@ObservedObject var userSettings = UserSettings()
26-
2725
@ObservedObject var viewModel: TabBarViewModel
2826

2927
var body: some View {
30-
TabView(selection: $viewModel.selectedTab) {
31-
HomeView(viewModel: NoticeViewModel(), userSettings: UserSettings())
32-
.tabItem {
33-
Image(systemName: "megaphone.fill")
34-
Text("공지")
35-
}
36-
.tag(Tab.Home)
37-
38-
ScheduleView(viewModel: ScheduleViewModel())
39-
.tabItem {
40-
Image(systemName: "calendar")
41-
Text("일정")
42-
}
43-
.tag(Tab.Schedule)
44-
45-
MealView(viewModel: MealViewModel())
46-
.tabItem {
47-
Image(systemName: "fork.knife")
48-
Text("식단")
49-
}
50-
.tag(Tab.Meal)
51-
52-
SettingView(viewModel: SettingViewModel(userSettings: UserSettings()))
53-
.tabItem {
54-
Image(systemName: "gearshape")
55-
Text("설정")
56-
}
57-
.tag(Tab.Settings)
28+
VStack {
29+
switch viewModel.selectedTab {
30+
case .Home:
31+
HomeView(viewModel: NoticeViewModel(), userSettings: userSettings)
32+
case .Schedule:
33+
ScheduleView(viewModel: ScheduleViewModel())
34+
case .Meal:
35+
MealView(viewModel: MealViewModel())
36+
case .Settings:
37+
SettingView(viewModel: SettingViewModel(userSettings: userSettings))
38+
}
39+
40+
CustomTabView(selectedTab: $viewModel.selectedTab)
41+
.frame(height: 60)
5842
}
5943
.accentColor(Color.Blue300)
6044
}
6145
}
6246

47+
// MARK: - 커스텀 탭바 뷰
48+
struct CustomTabView: View {
49+
50+
@Binding var selectedTab: Tab
51+
52+
var body: some View {
53+
HStack {
54+
TabButton(tab: .Home, selectedTab: $selectedTab, image: "megaphone.fill", title: "공지")
55+
TabButton(tab: .Schedule, selectedTab: $selectedTab, image: "calendar", title: "일정")
56+
TabButton(tab: .Meal, selectedTab: $selectedTab, image: "fork.knife", title: "식단")
57+
TabButton(tab: .Settings, selectedTab: $selectedTab, image: "gearshape", title: "설정")
58+
}
59+
.frame(maxWidth: .infinity)
60+
.background(Color.white)
61+
}
62+
}
63+
64+
// MARK: - 탭 버튼 뷰
65+
struct TabButton: View {
66+
67+
var tab: Tab
68+
@Binding var selectedTab: Tab
69+
var image: String
70+
var title: String
71+
72+
var body: some View {
73+
Button(action: {
74+
selectedTab = tab
75+
}) {
76+
VStack(spacing: 4) {
77+
Image(systemName: image)
78+
.foregroundColor(selectedTab == tab ? .Blue300 : .Gray400)
79+
80+
Text(title)
81+
.font(.Medium12)
82+
.foregroundColor(selectedTab == tab ? .Blue300 : .Gray400)
83+
.environment(\.sizeCategory, .large)
84+
}
85+
}
86+
.frame(maxWidth: .infinity)
87+
}
88+
}

0 commit comments

Comments
 (0)