// // ContentView.swift // Shared // // Created by Peter Hajas on 4/16/22. // import SwiftUI import KordophoneKit struct ContentView: View { @EnvironmentObject private var connection: Connection @State private var selectedConversation: Conversation? @ViewBuilder private var loginOverlay: some View { if !connection.authenticated { LoginView { info in Task { await connection.connect(info: info) } } } } @ViewBuilder private var content: some View { if !connection.authenticated { LoginView { info in Task { await connection.connect(info: info) } } } else { NavigationView { ConversationListWrapper(selectedConversation: $selectedConversation) selectedConversation.map { ConversationViewWrapper(conversation: $0) } } } } var body: some View { content .environmentObject(connection) .frame(maxWidth: .infinity, maxHeight: .infinity) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }