Files
praca_inzynierska/Peered/ContentView.swift
T

46 lines
960 B
Swift

//
// ContentView.swift
// Peered
//
// Created by Oskar Chybowski on 11/05/2025.
//
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, username: username)
}
}
.navigationTitle("Peered")
.toolbar {
Button("Create note") {
NotesStorage().createNote(name: "New Note")
notes = NotesStorage().loadNotes()
}
}
}
.onAppear {
notes = NotesStorage().loadNotes()
if notesClient == nil {
notesClient = .init(id: username)
}
notesClient?.startBrowsingForNotes()
}
.sheet(isPresented: .constant(username.isEmpty)) {
SetUserNameBottomSheetView(username: $username)
}
}
}
#Preview {
ContentView()
}