File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ final class TodoEditorViewModel: Store {
4242 var title : String = " "
4343 var content : String = " "
4444 var dueDate : Date ?
45+ var showInfo : Bool = false
4546 var tags : OrderedSet < String > = [ ]
4647 var tagText : String = " "
4748 var focusOnEditor : Bool = false
@@ -62,6 +63,7 @@ final class TodoEditorViewModel: Store {
6263 case setContent( String )
6364 case setDueDate( Date ? )
6465 case setKind( TodoKind )
66+ case setShowInfo( Bool )
6567 case setTabViewTag( Tag )
6668 case setTagText( String )
6769 case setTitle( String )
@@ -145,6 +147,8 @@ final class TodoEditorViewModel: Store {
145147 }
146148 case . setKind( let todoKind) :
147149 state. kind = todoKind
150+ case . setShowInfo( let isPresented) :
151+ state. showInfo = isPresented
148152 case . setTabViewTag( let tag) :
149153 state. tabViewTag = tag
150154 case . togglePinned:
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ struct TodoEditorView: View {
1313 @State var viewModel : TodoEditorViewModel
1414 @Environment ( \. dismiss) private var dismiss
1515 @FocusState private var field : Field ?
16- @State private var showInfo : Bool = false
1716 private let calendar = Calendar . current
1817 var onSubmit : ( ( Todo ) -> Void ) ?
1918
@@ -41,14 +40,15 @@ struct TodoEditorView: View {
4140 . navigationTitle ( viewModel. navigationTitle)
4241 . navigationBarTitleDisplayMode ( . inline)
4342 . toolbarBackground ( . background, for: . navigationBar)
44- . sheet ( isPresented: $showInfo) {
45- editorInfoSheet
43+ . sheet( isPresented: Binding (
44+ get: { viewModel. state. showInfo } ,
45+ set: { viewModel. send ( . setShowInfo( $0) ) }
4646 }
4747 . toolbar {
4848 ToolbarLeadingButton { dismiss ( ) }
4949 ToolbarItem ( placement: . topBarTrailing) {
5050 Button {
51- showInfo = true
51+ viewModel . send ( . setShowInfo ( true ) )
5252 } label: {
5353 Image ( systemName: " info.circle " )
5454 }
@@ -209,7 +209,6 @@ struct TodoEditorView: View {
209209 . navigationBarTitleDisplayMode ( . inline)
210210 . toolbar {
211211 ToolbarLeadingButton {
212- showInfo = false
213212 }
214213 }
215214 }
You can’t perform that action at this time.
0 commit comments