Feature: Notes creation

This commit is contained in:
2025-09-25 19:36:21 +02:00
parent 7b84754bd6
commit 209e08754b
5 changed files with 123 additions and 14 deletions
+19 -14
View File
@@ -9,24 +9,29 @@ import SwiftUI
struct ContentView: View {
@AppStorage("peered_username") private var username: String = ""
@State var browser: CommunicationProvider? = nil
@State private var notes = [Note]()
var body: some View {
VStack {
if let browser {
ForEach(browser.availablePeers, id: \.displayName) { peer in
Text(peer.displayName)
}
}
}
.padding()
NavigationView {
List(notes) { note in
NavigationLink(note.name) {
NoteEditorScreen(note: note)
}
}
.navigationTitle("Peered")
.toolbar {
Button("Create note") {
NotesStorage().createNote(name: "New Note")
notes = NotesStorage().loadNotes()
}
}
}
.onAppear {
notes = NotesStorage().loadNotes()
}
.sheet(isPresented: .constant(username.isEmpty)) {
SetUserNameBottomSheetView(username: $username)
}
.onChange(of: username) { _, newValue in
guard !newValue.isEmpty else { return }
browser = .init(id: newValue)
}
}
}