feat: add MindDump button and improve new list button
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@State private var navigationPath: [UUID] = []
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
NavigationStack(path: $navigationPath) {
|
||||
ListsOverviewView()
|
||||
.navigationDestination(for: UUID.self) { listID in
|
||||
ListDetailView(listID: listID)
|
||||
}
|
||||
}
|
||||
MindDumpButton(activeListID: navigationPath.last)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@ import Observation
|
||||
class ListStore {
|
||||
var lists: [TodoList]
|
||||
|
||||
var inboxID: UUID {
|
||||
lists.first { $0.isInbox }!.id
|
||||
}
|
||||
|
||||
init() {
|
||||
self.lists = [TodoList(name: "Inbox", isInbox: true)]
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ struct ListDetailView: View {
|
||||
@Environment(ListStore.self) private var store
|
||||
let listID: UUID
|
||||
@State private var editorItem: TodoItem?
|
||||
@State private var showingEditor = false
|
||||
|
||||
private var todoList: TodoList? {
|
||||
store.lists.first { $0.id == listID }
|
||||
@@ -22,7 +21,6 @@ struct ListDetailView: View {
|
||||
store.toggleItemCompleted(item.id, in: listID)
|
||||
}, onTap: {
|
||||
editorItem = item
|
||||
showingEditor = true
|
||||
})
|
||||
}
|
||||
.onDelete { offsets in
|
||||
@@ -35,18 +33,8 @@ struct ListDetailView: View {
|
||||
}
|
||||
}
|
||||
.navigationTitle(todoList?.name ?? "")
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(action: {
|
||||
editorItem = nil
|
||||
showingEditor = true
|
||||
}) {
|
||||
Image(systemName: "plus")
|
||||
}
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showingEditor) {
|
||||
TodoEditorView(listID: listID, item: editorItem)
|
||||
.sheet(item: $editorItem) { item in
|
||||
TodoEditorView(listID: listID, item: item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,13 @@ struct ListsOverviewView: View {
|
||||
}
|
||||
}
|
||||
.onDelete(perform: deleteLists)
|
||||
|
||||
Button(action: { showingAddList = true }) {
|
||||
Label("Neue Liste", systemImage: "plus")
|
||||
.foregroundStyle(.blue)
|
||||
}
|
||||
}
|
||||
.navigationTitle("MindDump")
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(action: { showingAddList = true }) {
|
||||
Image(systemName: "plus")
|
||||
}
|
||||
}
|
||||
}
|
||||
.alert("Neue Liste", isPresented: $showingAddList) {
|
||||
TextField("Name", text: $newListName)
|
||||
Button("Abbrechen", role: .cancel) {
|
||||
|
||||
27
MindDump/Views/MindDumpButton.swift
Normal file
27
MindDump/Views/MindDumpButton.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MindDumpButton: View {
|
||||
@Environment(ListStore.self) private var store
|
||||
var activeListID: UUID?
|
||||
@State private var showingEditor = false
|
||||
|
||||
private var targetListID: UUID {
|
||||
activeListID ?? store.inboxID
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
showingEditor = true
|
||||
} label: {
|
||||
Text("🧠")
|
||||
.font(.system(size: 28))
|
||||
.frame(width: 56, height: 56)
|
||||
.background(Circle().fill(.blue))
|
||||
.shadow(color: .black.opacity(0.3), radius: 4, x: 0, y: 2)
|
||||
}
|
||||
.padding(24)
|
||||
.sheet(isPresented: $showingEditor) {
|
||||
TodoEditorView(listID: targetListID, item: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user