Skip to content

Commit 2d1ffd9

Browse files
committed
fix: 프로필 상세 패널 라우팅 조정
1 parent 43c918d commit 2d1ffd9

2 files changed

Lines changed: 62 additions & 22 deletions

File tree

Application/DevLogPresentation/Sources/Main/MainView.swift

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,22 @@ struct MainView: View {
328328

329329
private var profileRegularDetailView: some View {
330330
Group {
331-
if let todoId = profileSelectedTodoId {
332-
TodoDetailView(viewModel: profileViewCoordinator.makeTodoDetailViewModel(todoId: todoId))
333-
.id(todoId)
331+
if let profileRoute = profileViewCoordinator.router.root {
332+
switch profileRoute {
333+
case .activity(let todoId):
334+
TodoDetailView(viewModel: profileViewCoordinator.makeTodoDetailViewModel(todoId: todoId))
335+
.id(todoId)
336+
case .settings, .theme, .pushNotification, .account:
337+
NavigationStack(path: Binding(
338+
get: { profileViewCoordinator.router.detailPath },
339+
set: { profileViewCoordinator.router.detailPath = $0 }
340+
)) {
341+
profileRegularDestinationView(profileRoute)
342+
.navigationDestination(for: ProfileRoute.self) { route in
343+
profileRegularDestinationView(route)
344+
}
345+
}
346+
}
334347
} else {
335348
ContentUnavailableView(
336349
String(localized: "profile_select_detail"),
@@ -340,6 +353,31 @@ struct MainView: View {
340353
}
341354
.background(Color(.secondarySystemBackground).ignoresSafeArea())
342355
}
356+
357+
@ViewBuilder
358+
private func profileRegularDestinationView(_ route: ProfileRoute) -> some View {
359+
switch route {
360+
case .activity(let todoId):
361+
TodoDetailView(viewModel: profileViewCoordinator.makeTodoDetailViewModel(todoId: todoId))
362+
.id(todoId)
363+
case .settings:
364+
SettingView(viewModel: profileViewCoordinator.settingViewModel)
365+
.environment(profileViewCoordinator.router)
366+
case .theme:
367+
ThemeView(
368+
theme: Binding(
369+
get: { profileViewCoordinator.settingViewModel.state.theme },
370+
set: { profileViewCoordinator.settingViewModel.send(.setTheme($0)) }
371+
)
372+
)
373+
case .pushNotification:
374+
PushNotificationSettingsView(
375+
viewModel: profileViewCoordinator.makePushNotificationSettingsViewModel()
376+
)
377+
case .account:
378+
AccountView(viewModel: profileViewCoordinator.makeAccountViewModel())
379+
}
380+
}
343381
}
344382

345383
private extension MainView {
@@ -393,15 +431,6 @@ private extension MainView {
393431
)
394432
}
395433

396-
var profileSelectedTodoId: String? {
397-
for route in profileViewCoordinator.router.path.reversed() {
398-
if case let .activity(todoId) = route {
399-
return todoId
400-
}
401-
}
402-
return nil
403-
}
404-
405434
}
406435
private extension MainTab {
407436
var title: String {

Application/DevLogPresentation/Sources/Profile/ProfileView.swift

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ struct ProfileView: View {
1919
if isCompactLayout {
2020
NavigationStack(path: navigationPath) {
2121
profileContentView
22-
.toolbar {
23-
ToolbarItem(placement: .topBarTrailing) {
24-
Button {
25-
coordinator.router.push(.settings)
26-
} label: {
27-
Image(systemName: "gearshape")
28-
}
29-
}
30-
}
3122
.navigationDestination(for: ProfileRoute.self) { route in
3223
profileDestinationView(route)
3324
}
@@ -36,6 +27,7 @@ struct ProfileView: View {
3627
profileContentView
3728
}
3829
}
30+
.toolbar { profileToolbarContent }
3931
.onChange(of: focused) { _, newValue in
4032
withAnimation {
4133
coordinator.viewModel.send(.updateStatusTextFieldFocus(newValue))
@@ -137,6 +129,21 @@ struct ProfileView: View {
137129
.background(Color(.systemGroupedBackground))
138130
}
139131

132+
@ToolbarContentBuilder
133+
private var profileToolbarContent: some ToolbarContent {
134+
ToolbarItem(placement: .topBarTrailing) {
135+
Button {
136+
if isCompactLayout {
137+
coordinator.router.push(.settings)
138+
} else {
139+
coordinator.router.replace(with: .settings)
140+
}
141+
} label: {
142+
Image(systemName: "gearshape")
143+
}
144+
}
145+
}
146+
140147
@ViewBuilder
141148
private func profileDestinationView(_ route: ProfileRoute) -> some View {
142149
switch route {
@@ -368,7 +375,11 @@ struct ProfileView: View {
368375
ForEach(activities) { activity in
369376
Button {
370377
if !activity.isDeleted {
371-
coordinator.router.push(.activity(activity.todoId))
378+
if isCompactLayout {
379+
coordinator.router.push(.activity(activity.todoId))
380+
} else {
381+
coordinator.router.replace(with: .activity(activity.todoId))
382+
}
372383
}
373384
} label: {
374385
let item = TodoCategoryItem(from: activity.category)

0 commit comments

Comments
 (0)