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.
56 lines
1.3 KiB
56 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) |
|
} |
|
} |
|
} |
|
} |
|
|
|
@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() |
|
} |
|
}
|
|
|