@@ -9,16 +9,26 @@ import Foundation
99
1010@Observable
1111final class TodayViewModel : Store {
12- enum SummaryScope : Hashable , CaseIterable {
12+ // TodayView 상단에서 사용자가 선택하는 요약 탭 범위.
13+ enum SectionScope : Hashable , CaseIterable {
1314 case all
1415 case focused
1516 case overdue
1617 case dueSoon
1718 }
1819
20+ // 요약 탭 아래 실제 리스트에 렌더링되는 섹션 분류.
21+ enum SectionCategory : Hashable {
22+ case later
23+ case unscheduled
24+ case focused
25+ case overdue
26+ case dueSoon
27+ }
28+
1929 struct SectionContent : Identifiable , Equatable {
20- var id : SummaryScope { scope }
21- let scope : SummaryScope
30+ var id : SectionCategory { category }
31+ let category : SectionCategory
2232 let title : String
2333 let items : [ TodayTodoItem ]
2434 }
@@ -37,14 +47,14 @@ final class TodayViewModel: Store {
3747 var showAlert : Bool = false
3848 var alertTitle : String = " "
3949 var alertMessage : String = " "
40- var selectedSummaryScope : SummaryScope = . all
50+ var selectedSectionScope : SectionScope = . all
4151 var displayOptions : TodayDisplayOptions = . default
4252 }
4353
4454 enum Action {
4555 case refresh
4656 case setAlert( Bool )
47- case setSummaryScope ( SummaryScope )
57+ case setSectionScope ( SectionScope )
4858 case setDueDateVisibility( TodayDisplayOptions . DueDateVisibility )
4959 case setFocusVisibility( TodayDisplayOptions . FocusVisibility )
5060 case resetDisplayOptions
@@ -90,52 +100,52 @@ final class TodayViewModel: Store {
90100 var sections : [ SectionContent ] {
91101 let items = groupedSectionItems ( from: displayedTodos)
92102
93- switch state. selectedSummaryScope {
103+ switch state. selectedSectionScope {
94104 case . all:
95105 return
96106 makeSection (
97- scope : . focused,
107+ category : . focused,
98108 title: String ( localized: " today_section_focused " ) ,
99109 items: items. focused
100110 )
101111 + makeSection(
102- scope : . overdue,
112+ category : . overdue,
103113 title: String ( localized: " today_section_overdue " ) ,
104114 items: items. overdue
105115 )
106116 + makeSection(
107- scope : . dueSoon,
117+ category : . dueSoon,
108118 title: String . localizedStringWithFormat (
109119 String ( localized: " today_section_due_soon_format " ) ,
110120 Int64 ( upcomingWindowDays)
111121 ) ,
112122 items: items. dueSoon
113123 )
114124 + makeSection(
115- scope : . all ,
125+ category : . later ,
116126 title: String ( localized: " today_section_later " ) ,
117127 items: items. later
118128 )
119129 + makeSection(
120- scope : . all ,
130+ category : . unscheduled ,
121131 title: String ( localized: " today_section_unscheduled " ) ,
122132 items: items. unscheduled
123133 )
124134 case . focused:
125135 return makeSection (
126- scope : . focused,
136+ category : . focused,
127137 title: String ( localized: " today_section_focused " ) ,
128138 items: items. focused
129139 )
130140 case . overdue:
131141 return makeSection (
132- scope : . overdue,
142+ category : . overdue,
133143 title: String ( localized: " today_section_overdue " ) ,
134144 items: items. overdue
135145 )
136146 case . dueSoon:
137147 return makeSection (
138- scope : . dueSoon,
148+ category : . dueSoon,
139149 title: String . localizedStringWithFormat (
140150 String ( localized: " today_section_due_soon_format " ) ,
141151 Int64 ( upcomingWindowDays)
@@ -145,7 +155,7 @@ final class TodayViewModel: Store {
145155 }
146156 }
147157
148- func summaryValue( for scope: SummaryScope ) -> Int {
158+ func summaryValue( for scope: SectionScope ) -> Int {
149159 switch scope {
150160 case . all:
151161 return displayedTodos. count
@@ -163,7 +173,7 @@ final class TodayViewModel: Store {
163173 var effects : [ SideEffect ] = [ ]
164174
165175 switch action {
166- case . refresh, . setAlert, . setSummaryScope , . setDueDateVisibility, . setFocusVisibility,
176+ case . refresh, . setAlert, . setSectionScope , . setDueDateVisibility, . setFocusVisibility,
167177 . resetDisplayOptions, . completeTodo, . togglePinned:
168178 effects = reduceByUser ( action, state: & state)
169179 case . onAppear:
@@ -248,12 +258,12 @@ final class TodayViewModel: Store {
248258
249259private extension TodayViewModel {
250260 func makeSection(
251- scope : SummaryScope ,
261+ category : SectionCategory ,
252262 title: String ,
253263 items: [ TodayTodoItem ]
254264 ) -> [ SectionContent ] {
255265 guard !items. isEmpty else { return [ ] }
256- return [ SectionContent ( scope : scope , title: title, items: items) ]
266+ return [ SectionContent ( category : category , title: title, items: items) ]
257267 }
258268
259269 func reduceByUser( _ action: Action , state: inout State ) -> [ SideEffect ] {
@@ -262,11 +272,11 @@ private extension TodayViewModel {
262272 return [ . fetchTodos]
263273 case . setAlert( let isPresented) :
264274 setAlert ( & state, isPresented: isPresented)
265- case . setSummaryScope ( let scope) :
266- if state. selectedSummaryScope == scope, scope != . all {
267- state. selectedSummaryScope = . all
275+ case . setSectionScope ( let scope) :
276+ if state. selectedSectionScope == scope, scope != . all {
277+ state. selectedSectionScope = . all
268278 } else {
269- state. selectedSummaryScope = scope
279+ state. selectedSectionScope = scope
270280 }
271281 case . setDueDateVisibility( let visibility) :
272282 state. displayOptions. dueDateVisibility = visibility
0 commit comments