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 @ViewBuilder
private var content: some View { private var content: some View {
if !connection.authenticated { NavigationView {
LoginView { info in ConversationListWrapper(selectedConversation: $selectedConversation)
Task { selectedConversation.map {
await connection.connect(info: info) ConversationViewWrapper(conversation: $0)
}
} }
} }
else { .sheet(isPresented: showLoginSheet) {
NavigationView { loginOverlay
ConversationListWrapper(selectedConversation: $selectedConversation)
selectedConversation.map {
ConversationViewWrapper(conversation: $0)
}
}
} }
} }

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