Browse Source

Show login view in a sheet

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

19
Kordophone/Shared/ContentView.swift

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

3
Kordophone/Shared/ConversationList.swift

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

1
Kordophone/Shared/LoginView.swift

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

Loading…
Cancel
Save