aboutsummaryrefslogtreecommitdiff
path: root/LibreTasks
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2024-01-03 21:15:48 -0600
committerChristian Cleberg <hello@cleberg.net>2024-01-03 21:15:48 -0600
commitc6ca3187066f3be4b28b6daf3bd3e2b410b3ae62 (patch)
tree71e62c16d5bbd51e03dad6989d28da67a9b97bdb /LibreTasks
parent3f77f5ee38a092f05856b0d5a440500d7f3c586d (diff)
downloadlibre-tasks-c6ca3187066f3be4b28b6daf3bd3e2b410b3ae62.tar.gz
libre-tasks-c6ca3187066f3be4b28b6daf3bd3e2b410b3ae62.tar.bz2
libre-tasks-c6ca3187066f3be4b28b6daf3bd3e2b410b3ae62.zip
feat: move task creation to popover
Diffstat (limited to 'LibreTasks')
-rw-r--r--LibreTasks/ContentView.swift46
1 files changed, 31 insertions, 15 deletions
diff --git a/LibreTasks/ContentView.swift b/LibreTasks/ContentView.swift
index b382020..226db4d 100644
--- a/LibreTasks/ContentView.swift
+++ b/LibreTasks/ContentView.swift
@@ -12,6 +12,7 @@ struct ContentView: View {
@State var newTask : String = ""
@State private var query = ""
@State var newTaskDate: Date = Date()
+ @State private var showingPopover = false
var filteredTasks: [Task] {
if query.isEmpty {
@@ -23,20 +24,6 @@ struct ContentView: View {
}
}
- var addTaskBar: some View {
- HStack {
- VStack {
- TextField("Add Task: ", text: self.$newTask)
- DatePicker("Date: ", selection: $newTaskDate)
- .datePickerStyle(CompactDatePickerStyle())
- }
- Button(action: self.addNewTask, label: {
- Text("Add New")
- })
- }
- .padding()
- }
-
func addNewTask() {
taskStore.tasks.append(Task(
id: String(taskStore.tasks.count + 1),
@@ -44,12 +31,12 @@ struct ContentView: View {
taskDate: newTaskDate
))
self.newTask = ""
+ self.showingPopover = false
}
var body: some View {
NavigationView {
VStack {
- addTaskBar.padding()
List {
ForEach(filteredTasks) { task in
VStack(alignment: .leading) {
@@ -79,6 +66,35 @@ struct ContentView: View {
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
EditButton()
+ Button {
+ showingPopover = true
+ } label: {
+ Image(systemName: "square.and.pencil")
+ }.popover(isPresented: $showingPopover) {
+ HStack {
+ Button {
+ showingPopover = false
+ } label: {
+ Text("Close")
+ }
+ Spacer()
+ Text("Add New Task")
+ Spacer()
+ Button(action: self.addNewTask, label: {
+ Text("Save")
+ })
+ }
+ .padding()
+ HStack {
+ VStack {
+ TextField("Add Task: ", text: self.$newTask)
+ DatePicker("Scheduled: ", selection: $newTaskDate)
+ .datePickerStyle(CompactDatePickerStyle())
+ }
+ }
+ .padding()
+ Spacer()
+ }
}
}
}