// // 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) } } } } private var showLoginSheet: Binding { Binding { !connection.authenticated } set: { _ in // swallow } } @ViewBuilder private var content: some View { NavigationView { ConversationListWrapper(selectedConversation: $selectedConversation) selectedConversation.map { ConversationViewWrapper(conversation: $0) } } .sheet(isPresented: showLoginSheet) { loginOverlay } } var body: some View { content .environmentObject(connection) .frame(maxWidth: .infinity, maxHeight: .infinity) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }