Browse Source

Show login view in a sheet

master
Peter Hajas 3 years ago
parent
commit
3a81df4c3f
  1. 27
      Kordophone/Shared/ContentView.swift
  2. 3
      Kordophone/Shared/ConversationList.swift
  3. 1
      Kordophone/Shared/LoginView.swift

27
Kordophone/Shared/ContentView.swift

@ -23,22 +23,25 @@ struct ContentView: View {
}
}
private var showLoginSheet: Binding<Bool> {
Binding {
!connection.authenticated
} set: { _ in
// swallow
}
}
@ViewBuilder
private var content: some View {
if !connection.authenticated {
LoginView { info in
Task {
await connection.connect(info: info)
}
NavigationView {
ConversationListWrapper(selectedConversation: $selectedConversation)
selectedConversation.map {
ConversationViewWrapper(conversation: $0)
}
}
else {
NavigationView {
ConversationListWrapper(selectedConversation: $selectedConversation)
selectedConversation.map {
ConversationViewWrapper(conversation: $0)
}
}
.sheet(isPresented: showLoginSheet) {
loginOverlay
}
}

3
Kordophone/Shared/ConversationList.swift

@ -44,5 +44,8 @@ struct ConversationListWrapper : View {
.onAppear {
refresh()
}
.onChange(of: connection.authenticated) { newValue in
refresh()
}
}
}

1
Kordophone/Shared/LoginView.swift

@ -20,6 +20,7 @@ struct LoginView : View {
password: password)))
}
}
.padding()
}
}

Loading…
Cancel
Save