@@ -311,35 +311,29 @@ struct TodoListView: View {
311311
312312 private var sortMenu : some View {
313313 Menu {
314- Section {
314+ Picker ( selection: Binding (
315+ get: { viewModel. state. query. sortTarget } ,
316+ set: { viewModel. send ( . setSortTarget( $0) ) }
317+ ) ) {
315318 ForEach ( [ TodoQuery . SortTarget. createdAt, . updatedAt] , id: \. self) { option in
316- Button {
317- viewModel. send ( . setSortTarget( option) )
318- } label: {
319- selectionLabel (
320- title: option. title,
321- isSelected: viewModel. state. query. sortTarget == option
322- )
323- }
319+ Text ( option. title) . tag ( option)
324320 }
325- } header : {
321+ } label : {
326322 Text ( " 정렬 기준 " )
327323 }
324+ . tint ( . blue)
328325
329- Section {
326+ Picker ( selection: Binding (
327+ get: { viewModel. state. query. sortOrder } ,
328+ set: { viewModel. send ( . setSortOrder( $0) ) }
329+ ) ) {
330330 ForEach ( [ TodoQuery . SortOrder. latest, . oldest] , id: \. self) { option in
331- Button {
332- viewModel. send ( . setSortOrder( option) )
333- } label: {
334- selectionLabel (
335- title: option. title,
336- isSelected: viewModel. state. query. sortOrder == option
337- )
338- }
331+ Text ( option. title) . tag ( option)
339332 }
340- } header : {
333+ } label : {
341334 Text ( " 정렬 순서 " )
342335 }
336+ . tint ( . blue)
343337 } label: {
344338 let condition = viewModel. state. query. sortTarget == . createdAt && viewModel. state. query. sortOrder == . latest
345339 HStack {
@@ -353,27 +347,21 @@ struct TodoListView: View {
353347
354348 private var filterMenu : some View {
355349 Menu {
356- Button {
357- viewModel. send ( . togglePinnedOnly)
358- } label: {
359- selectionLabel (
360- title: " 중요 표시 " ,
361- isSelected: viewModel. state. query. isPinned == true
362- )
350+ Toggle ( isOn: Binding (
351+ get: { viewModel. state. query. isPinned == true } ,
352+ set: { _ in viewModel. send ( . togglePinnedOnly) }
353+ ) ) {
354+ Text ( " 중요 표시 " )
363355 }
364356
365- Section {
357+ Picker ( selection: Binding (
358+ get: { viewModel. state. query. completionFilter } ,
359+ set: { viewModel. send ( . setCompletionFilter( $0) ) }
360+ ) ) {
366361 ForEach ( [ TodoQuery . CompletionFilter. all, . incomplete, . completed] , id: \. self) { option in
367- Button {
368- viewModel. send ( . setCompletionFilter( option) )
369- } label: {
370- selectionLabel (
371- title: option. title,
372- isSelected: viewModel. state. query. completionFilter == option
373- )
374- }
362+ Text ( option. title) . tag ( option)
375363 }
376- } header : {
364+ } label : {
377365 Text ( " 완료 상태 " )
378366 }
379367 } label: {
@@ -402,19 +390,7 @@ struct TodoListView: View {
402390 . background ( Circle ( ) . fill ( backgroundColor) )
403391 }
404392
405- private func selectionLabel( title: String , isSelected: Bool ) -> some View {
406- HStack {
407- Text ( title)
408- Spacer ( )
409- if isSelected {
410- Image ( systemName: " checkmark " )
411- . tint ( . blue)
412- }
413- }
414- . frame ( maxWidth: . infinity, alignment: . leading)
415- }
416-
417- private enum Path : Hashable {
393+ private enum Path : Hashable {
418394 case detail( String )
419395 }
420396}
0 commit comments