Note Sharing, distributing updates

This commit is contained in:
2025-10-09 23:12:34 +02:00
parent 87753865e2
commit d7497e2614
7 changed files with 216 additions and 23 deletions
+22 -8
View File
@@ -12,20 +12,34 @@ extension EnvironmentValues {
}
struct ContentView: View {
@AppStorage("peered_username") private var username: String = ""
@AppStorage("peered_username") private var username: String = "fallback_user"
@State private var notes = [Note]()
@State private var notesClient: NoteEditingSessionClient?
@State private var ownPeer: OwnPeer?
var body: some View {
NavigationStack {
List(notes) { note in
NavigationLink(note.name) {
let peer = ownPeer ?? .init(peer: .init(displayName: username))
if ownPeer == nil {
ownPeer = peer
List {
Section("Your notes") {
ForEach(notes) { note in
NavigationLink(note.name) {
let peer = ownPeer ?? .init(peer: .init(displayName: username))
if ownPeer == nil {
ownPeer = peer
}
return NoteEditorScreen(note: note, peer: peer)
}
}
}
if let notesClient {
Section("External notes") {
ForEach(notesClient.invitations) { invitation in
NavigationLink(invitation.noteName) {
SharedNoteEditor(invitation: invitation, noteClient: notesClient)
}
}
}
return NoteEditorScreen(note: note, peer: peer)
}
}
.environment(\.ownPeer, ownPeer ?? .fallback)
@@ -44,7 +58,7 @@ struct ContentView: View {
}
notesClient?.startBrowsingForNotes()
}
.sheet(isPresented: .constant(username.isEmpty)) {
.sheet(isPresented: .constant(username == "fallback_user" || username.isEmpty)) {
SetUserNameBottomSheetView(username: $username)
}
}