Skip to content

Commit d700ad9

Browse files
authored
[#504] ProfileView 탭 모드를 content, detail로 수정한다 (#509)
* ui: ProfileView에서 활동을 선택하면 detail 탭에서 볼 수 있도록 수정 * fix: 프로필 상세 패널 라우팅 조정 * ui: .navigationSplitViewColumnWidth(min:ideal:max) 적용 * fix: 프로필 상세 패널 내비게이션 일원화
1 parent 9335ec8 commit d700ad9

3 files changed

Lines changed: 253 additions & 193 deletions

File tree

Application/DevLogApp/Sources/Resource/Localizable.xcstrings

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,23 @@
966966
}
967967
}
968968
},
969+
"profile_select_detail" : {
970+
"extractionState" : "manual",
971+
"localizations" : {
972+
"en" : {
973+
"stringUnit" : {
974+
"state" : "translated",
975+
"value" : "Select an activity."
976+
}
977+
},
978+
"ko" : {
979+
"stringUnit" : {
980+
"state" : "translated",
981+
"value" : "활동을 선택해주세요."
982+
}
983+
}
984+
}
985+
},
969986
"profile_select_quarter" : {
970987
"extractionState" : "manual",
971988
"localizations" : {
@@ -3451,4 +3468,4 @@
34513468
}
34523469
},
34533470
"version" : "1.0"
3454-
}
3471+
}

Application/DevLogPresentation/Sources/Main/MainView.swift

Lines changed: 99 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -106,65 +106,62 @@ struct MainView: View {
106106

107107
@ViewBuilder
108108
private func sidebarView(for selectedTab: MainTab) -> some View {
109-
switch selectedTab.mainTabSplitStyle {
110-
case .detailOnly:
109+
switch selectedTab {
110+
case .home:
111111
NavigationSplitView {
112112
mainSidebar
113+
} content: {
114+
homeView
115+
.navigationSplitViewColumnWidth(min: 350, ideal: 450, max: nil)
113116
} detail: {
114-
selectedTabView(for: selectedTab)
117+
homeRegularDetailView
115118
}
116-
case .contentDetail:
117-
switch selectedTab {
118-
case .home:
119-
NavigationSplitView {
120-
mainSidebar
121-
} content: {
122-
homeView
123-
} detail: {
124-
homeRegularDetailView
125-
}
126-
.environment(homeViewCoordinator.router)
127-
case .today:
128-
NavigationSplitView {
129-
mainSidebar
130-
} content: {
131-
todayView
132-
} detail: {
133-
todayRegularDetailView
134-
}
135-
case .notification:
136-
NavigationSplitView {
137-
mainSidebar
138-
} content: {
139-
PushNotificationListView(
140-
coordinator: pushNotificationListViewCoordinator,
141-
isCompactLayout: isCompactLayout
142-
)
143-
} detail: {
144-
Group {
145-
if let todoId = pushNotificationListViewCoordinator.todoIdToPresent?.id {
146-
TodoDetailView(
147-
viewModel: pushNotificationListViewCoordinator.makeTodoDetailViewModel(
148-
todoId: todoId
149-
)
150-
)
151-
.id(todoId)
152-
} else {
153-
ContentUnavailableView(
154-
String(localized: "push_notifications_select_detail"),
155-
systemImage: "bell.badge"
119+
.environment(homeViewCoordinator.router)
120+
case .today:
121+
NavigationSplitView {
122+
mainSidebar
123+
} content: {
124+
todayView
125+
.navigationSplitViewColumnWidth(min: 350, ideal: 450, max: nil)
126+
} detail: {
127+
todayRegularDetailView
128+
}
129+
case .notification:
130+
NavigationSplitView {
131+
mainSidebar
132+
} content: {
133+
PushNotificationListView(
134+
coordinator: pushNotificationListViewCoordinator,
135+
isCompactLayout: isCompactLayout
136+
)
137+
.navigationSplitViewColumnWidth(min: 350, ideal: 450, max: nil)
138+
} detail: {
139+
Group {
140+
if let todoId = pushNotificationListViewCoordinator.todoIdToPresent?.id {
141+
TodoDetailView(
142+
viewModel: pushNotificationListViewCoordinator.makeTodoDetailViewModel(
143+
todoId: todoId
156144
)
157-
}
145+
)
146+
.id(todoId)
147+
} else {
148+
ContentUnavailableView(
149+
String(localized: "push_notifications_select_detail"),
150+
systemImage: "bell.badge"
151+
)
158152
}
159-
.background(Color(.secondarySystemBackground).ignoresSafeArea())
160-
}
161-
case .profile:
162-
NavigationSplitView {
163-
mainSidebar
164-
} detail: {
165-
selectedTabView(for: selectedTab)
166153
}
167154
}
155+
.background(Color(.secondarySystemBackground).ignoresSafeArea())
156+
case .profile:
157+
NavigationSplitView {
158+
mainSidebar
159+
} content: {
160+
profileView
161+
.navigationSplitViewColumnWidth(min: 350, ideal: 450, max: nil)
162+
} detail: {
163+
profileRegularDetailView
164+
}
168165
}
169166
}
170167

@@ -178,20 +175,6 @@ struct MainView: View {
178175
.listStyle(.sidebar)
179176
}
180177

181-
@ViewBuilder
182-
private func selectedTabView(for selectedTab: MainTab) -> some View {
183-
switch selectedTab {
184-
case .home:
185-
homeView
186-
case .today:
187-
todayView
188-
case .notification:
189-
notificationView
190-
case .profile:
191-
profileView
192-
}
193-
}
194-
195178
@ViewBuilder
196179
private func sidebarRow(_ tab: MainTab) -> some View {
197180
if tab == .notification {
@@ -341,7 +324,57 @@ struct MainView: View {
341324
}
342325

343326
private var profileView: some View {
344-
ProfileView(coordinator: profileViewCoordinator)
327+
ProfileView(
328+
coordinator: profileViewCoordinator,
329+
isCompactLayout: isCompactLayout
330+
)
331+
}
332+
333+
private var profileRegularDetailView: some View {
334+
NavigationStack(path: Binding(
335+
get: { profileViewCoordinator.router.detailPath },
336+
set: { profileViewCoordinator.router.detailPath = $0 }
337+
)) {
338+
Group {
339+
if let profileRoute = profileViewCoordinator.router.root {
340+
profileRegularDestinationView(profileRoute)
341+
} else {
342+
ContentUnavailableView(
343+
String(localized: "profile_select_detail"),
344+
systemImage: "person.crop.circle"
345+
)
346+
}
347+
}
348+
.navigationDestination(for: ProfileRoute.self) { route in
349+
profileRegularDestinationView(route)
350+
}
351+
}
352+
.background(Color(.secondarySystemBackground).ignoresSafeArea())
353+
}
354+
355+
@ViewBuilder
356+
private func profileRegularDestinationView(_ route: ProfileRoute) -> some View {
357+
switch route {
358+
case .activity(let todoId):
359+
TodoDetailView(viewModel: profileViewCoordinator.makeTodoDetailViewModel(todoId: todoId))
360+
.id(todoId)
361+
case .settings:
362+
SettingView(viewModel: profileViewCoordinator.settingViewModel)
363+
.environment(profileViewCoordinator.router)
364+
case .theme:
365+
ThemeView(
366+
theme: Binding(
367+
get: { profileViewCoordinator.settingViewModel.state.theme },
368+
set: { profileViewCoordinator.settingViewModel.send(.setTheme($0)) }
369+
)
370+
)
371+
case .pushNotification:
372+
PushNotificationSettingsView(
373+
viewModel: profileViewCoordinator.makePushNotificationSettingsViewModel()
374+
)
375+
case .account:
376+
AccountView(viewModel: profileViewCoordinator.makeAccountViewModel())
377+
}
345378
}
346379
}
347380

@@ -397,22 +430,7 @@ private extension MainView {
397430
}
398431

399432
}
400-
401-
private enum MainTabSplitStyle {
402-
case detailOnly
403-
case contentDetail
404-
}
405-
406433
private extension MainTab {
407-
var mainTabSplitStyle: MainTabSplitStyle {
408-
switch self {
409-
case .home, .today, .notification:
410-
.contentDetail
411-
case .profile:
412-
.detailOnly
413-
}
414-
}
415-
416434
var title: String {
417435
switch self {
418436
case .home:

0 commit comments

Comments
 (0)