Refactor project, add loading/editing/saving notes, add client/server basic logic
This commit is contained in:
@@ -10,12 +10,13 @@ import SwiftUI
|
||||
struct ContentView: View {
|
||||
@AppStorage("peered_username") private var username: String = ""
|
||||
@State private var notes = [Note]()
|
||||
@State private var notesClient: NoteEditingSessionClient?
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List(notes) { note in
|
||||
NavigationLink(note.name) {
|
||||
NoteEditorScreen(note: note)
|
||||
NoteEditorScreen(note: note, username: username)
|
||||
}
|
||||
}
|
||||
.navigationTitle("Peered")
|
||||
@@ -28,6 +29,10 @@ struct ContentView: View {
|
||||
}
|
||||
.onAppear {
|
||||
notes = NotesStorage().loadNotes()
|
||||
if notesClient == nil {
|
||||
notesClient = .init(id: username)
|
||||
}
|
||||
notesClient?.startBrowsingForNotes()
|
||||
}
|
||||
.sheet(isPresented: .constant(username.isEmpty)) {
|
||||
SetUserNameBottomSheetView(username: $username)
|
||||
|
||||
Reference in New Issue
Block a user