feat: add MindDump button and improve new list button
This commit is contained in:
@@ -1,13 +1,18 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
@State private var navigationPath: [UUID] = []
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
ZStack(alignment: .bottomTrailing) {
|
||||||
|
NavigationStack(path: $navigationPath) {
|
||||||
ListsOverviewView()
|
ListsOverviewView()
|
||||||
.navigationDestination(for: UUID.self) { listID in
|
.navigationDestination(for: UUID.self) { listID in
|
||||||
ListDetailView(listID: listID)
|
ListDetailView(listID: listID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MindDumpButton(activeListID: navigationPath.last)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import Observation
|
|||||||
class ListStore {
|
class ListStore {
|
||||||
var lists: [TodoList]
|
var lists: [TodoList]
|
||||||
|
|
||||||
|
var inboxID: UUID {
|
||||||
|
lists.first { $0.isInbox }!.id
|
||||||
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
self.lists = [TodoList(name: "Inbox", isInbox: true)]
|
self.lists = [TodoList(name: "Inbox", isInbox: true)]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ struct ListDetailView: View {
|
|||||||
@Environment(ListStore.self) private var store
|
@Environment(ListStore.self) private var store
|
||||||
let listID: UUID
|
let listID: UUID
|
||||||
@State private var editorItem: TodoItem?
|
@State private var editorItem: TodoItem?
|
||||||
@State private var showingEditor = false
|
|
||||||
|
|
||||||
private var todoList: TodoList? {
|
private var todoList: TodoList? {
|
||||||
store.lists.first { $0.id == listID }
|
store.lists.first { $0.id == listID }
|
||||||
@@ -22,7 +21,6 @@ struct ListDetailView: View {
|
|||||||
store.toggleItemCompleted(item.id, in: listID)
|
store.toggleItemCompleted(item.id, in: listID)
|
||||||
}, onTap: {
|
}, onTap: {
|
||||||
editorItem = item
|
editorItem = item
|
||||||
showingEditor = true
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
.onDelete { offsets in
|
.onDelete { offsets in
|
||||||
@@ -35,18 +33,8 @@ struct ListDetailView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle(todoList?.name ?? "")
|
.navigationTitle(todoList?.name ?? "")
|
||||||
.toolbar {
|
.sheet(item: $editorItem) { item in
|
||||||
ToolbarItem(placement: .primaryAction) {
|
TodoEditorView(listID: listID, item: item)
|
||||||
Button(action: {
|
|
||||||
editorItem = nil
|
|
||||||
showingEditor = true
|
|
||||||
}) {
|
|
||||||
Image(systemName: "plus")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.sheet(isPresented: $showingEditor) {
|
|
||||||
TodoEditorView(listID: listID, item: editorItem)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,13 @@ struct ListsOverviewView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onDelete(perform: deleteLists)
|
.onDelete(perform: deleteLists)
|
||||||
|
|
||||||
|
Button(action: { showingAddList = true }) {
|
||||||
|
Label("Neue Liste", systemImage: "plus")
|
||||||
|
.foregroundStyle(.blue)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle("MindDump")
|
.navigationTitle("MindDump")
|
||||||
.toolbar {
|
|
||||||
ToolbarItem(placement: .primaryAction) {
|
|
||||||
Button(action: { showingAddList = true }) {
|
|
||||||
Image(systemName: "plus")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.alert("Neue Liste", isPresented: $showingAddList) {
|
.alert("Neue Liste", isPresented: $showingAddList) {
|
||||||
TextField("Name", text: $newListName)
|
TextField("Name", text: $newListName)
|
||||||
Button("Abbrechen", role: .cancel) {
|
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