@@ -311,33 +311,24 @@ 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 }
328-
329- Section {
324+ Picker ( selection: Binding (
325+ get: { viewModel. state. query. sortOrder } ,
326+ set: { viewModel. send ( . setSortOrder( $0) ) }
327+ ) ) {
330328 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- }
329+ Text ( option. title) . tag ( option)
339330 }
340- } header : {
331+ } label : {
341332 Text ( " 정렬 순서 " )
342333 }
343334 } label: {
@@ -353,27 +344,21 @@ struct TodoListView: View {
353344
354345 private var filterMenu : some View {
355346 Menu {
356- Button {
357- viewModel. send ( . togglePinnedOnly)
358- } label: {
359- selectionLabel (
360- title: " 중요 표시 " ,
361- isSelected: viewModel. state. query. isPinned == true
362- )
347+ Toggle ( isOn: Binding (
348+ get: { viewModel. state. query. isPinned == true } ,
349+ set: { _ in viewModel. send ( . togglePinnedOnly) }
350+ ) ) {
351+ Text ( " 중요 표시 " )
363352 }
364353
365- Section {
354+ Picker ( selection: Binding (
355+ get: { viewModel. state. query. completionFilter } ,
356+ set: { viewModel. send ( . setCompletionFilter( $0) ) }
357+ ) ) {
366358 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- }
359+ Text ( option. title) . tag ( option)
375360 }
376- } header : {
361+ } label : {
377362 Text ( " 완료 상태 " )
378363 }
379364 } label: {
@@ -402,19 +387,7 @@ struct TodoListView: View {
402387 . background ( Circle ( ) . fill ( backgroundColor) )
403388 }
404389
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 {
390+ private enum Path : Hashable {
418391 case detail( String )
419392 }
420393}
0 commit comments