diff --git a/DevLog/Domain/Entity/PushNotificationQuery.swift b/DevLog/Domain/Entity/PushNotificationQuery.swift index 0c2d62ce..6cf88403 100644 --- a/DevLog/Domain/Entity/PushNotificationQuery.swift +++ b/DevLog/Domain/Entity/PushNotificationQuery.swift @@ -13,7 +13,7 @@ struct PushNotificationQuery: Equatable { case oldest } - enum TimeFilter: Equatable { + enum TimeFilter: Equatable, Hashable { case none case hours(Int) case days(Int) diff --git a/DevLog/UI/Home/TodoListView.swift b/DevLog/UI/Home/TodoListView.swift index e501478b..3bf6049b 100644 --- a/DevLog/UI/Home/TodoListView.swift +++ b/DevLog/UI/Home/TodoListView.swift @@ -311,33 +311,24 @@ struct TodoListView: View { private var sortMenu: some View { Menu { - Section { + Picker(selection: Binding( + get: { viewModel.state.query.sortTarget }, + set: { viewModel.send(.setSortTarget($0)) } + )) { ForEach([TodoQuery.SortTarget.createdAt, .updatedAt], id: \.self) { option in - Button { - viewModel.send(.setSortTarget(option)) - } label: { - selectionLabel( - title: option.title, - isSelected: viewModel.state.query.sortTarget == option - ) - } + Text(option.title).tag(option) } - } header: { + } label: { Text("정렬 기준") } - - Section { + Picker(selection: Binding( + get: { viewModel.state.query.sortOrder }, + set: { viewModel.send(.setSortOrder($0)) } + )) { ForEach([TodoQuery.SortOrder.latest, .oldest], id: \.self) { option in - Button { - viewModel.send(.setSortOrder(option)) - } label: { - selectionLabel( - title: option.title, - isSelected: viewModel.state.query.sortOrder == option - ) - } + Text(option.title).tag(option) } - } header: { + } label: { Text("정렬 순서") } } label: { @@ -353,27 +344,21 @@ struct TodoListView: View { private var filterMenu: some View { Menu { - Button { - viewModel.send(.togglePinnedOnly) - } label: { - selectionLabel( - title: "중요 표시", - isSelected: viewModel.state.query.isPinned == true - ) + Toggle(isOn: Binding( + get: { viewModel.state.query.isPinned == true }, + set: { _ in viewModel.send(.togglePinnedOnly) } + )) { + Text("중요 표시") } - Section { + Picker(selection: Binding( + get: { viewModel.state.query.completionFilter }, + set: { viewModel.send(.setCompletionFilter($0)) } + )) { ForEach([TodoQuery.CompletionFilter.all, .incomplete, .completed], id: \.self) { option in - Button { - viewModel.send(.setCompletionFilter(option)) - } label: { - selectionLabel( - title: option.title, - isSelected: viewModel.state.query.completionFilter == option - ) - } + Text(option.title).tag(option) } - } header: { + } label: { Text("완료 상태") } } label: { @@ -402,19 +387,7 @@ struct TodoListView: View { .background(Circle().fill(backgroundColor)) } - private func selectionLabel(title: String, isSelected: Bool) -> some View { - HStack { - Text(title) - Spacer() - if isSelected { - Image(systemName: "checkmark") - .tint(.blue) - } - } - .frame(maxWidth: .infinity, alignment: .leading) - } - - private enum Path: Hashable { +private enum Path: Hashable { case detail(String) } } diff --git a/DevLog/UI/PushNotification/PushNotificationListView.swift b/DevLog/UI/PushNotification/PushNotificationListView.swift index 07ae6d03..44f33554 100644 --- a/DevLog/UI/PushNotification/PushNotificationListView.swift +++ b/DevLog/UI/PushNotification/PushNotificationListView.swift @@ -168,20 +168,15 @@ struct PushNotificationListView: View { } Menu { - ForEach(PushNotificationQuery.TimeFilter.availableOptions, id: \.id) { option in - Button { - viewModel.send(.setTimeFilter(option)) - } label: { - HStack { - Text(option.title) - Spacer() - if viewModel.state.query.timeFilter == option { - Image(systemName: "checkmark") - .tint(.blue) - } - } - .frame(maxWidth: .infinity, alignment: .leading) + Picker(selection: Binding( + get: { viewModel.state.query.timeFilter }, + set: { viewModel.send(.setTimeFilter($0)) } + )) { + ForEach(PushNotificationQuery.TimeFilter.availableOptions, id: \.self) { option in + Text(option.title).tag(option) } + } label: { + Text("기간") } } label: { let condition = viewModel.state.query.timeFilter == .none