Note Sharing, distributing updates
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user