Created
September 2, 2020 13:35
-
-
Save apatronl/50a572e0e775b4d04eae2a368ba91bfb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State private var newTodo = "" | |
@State private var allTodos: [TodoItem] = [] | |
var body: some View { | |
NavigationView { | |
VStack { | |
HStack { | |
TextField("Add todo...", text: $newTodo) | |
.textFieldStyle(RoundedBorderTextFieldStyle()) | |
Button(action: { | |
guard !self.newTodo.isEmpty else { return } | |
self.allTodos.append(TodoItem(todo: self.newTodo)) | |
self.newTodo = "" | |
}) { | |
Image(systemName: "plus") | |
} | |
.padding(.leading, 5) | |
}.padding() | |
} | |
.navigationBarTitle("Todos") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment