You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.3 KiB
59 lines
1.3 KiB
// |
|
// 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<Bool> { |
|
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() |
|
} |
|
}
|
|
|