39 lines
1.3 KiB
Swift
39 lines
1.3 KiB
Swift
//
|
|
// SplitView.swift
|
|
// kordophone2
|
|
//
|
|
// Created by James Magahern on 8/29/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct SplitView: View
|
|
{
|
|
@State var conversationListModel = ConversationListView.ViewModel()
|
|
@State var transcriptViewModel = TranscriptView.ViewModel()
|
|
@State var entryViewModel = MessageEntryView.ViewModel()
|
|
|
|
private let xpcClient = XPCClient()
|
|
private var selectedConversation: Display.Conversation? {
|
|
guard let id = conversationListModel.selectedConversations.first else { return nil }
|
|
return conversationListModel.conversations.first { $0.id == id }
|
|
}
|
|
|
|
var body: some View {
|
|
NavigationSplitView {
|
|
ConversationListView(model: $conversationListModel)
|
|
.frame(minWidth: 330.0)
|
|
.xpcClient(xpcClient)
|
|
} detail: {
|
|
ConversationView(transcriptModel: $transcriptViewModel, entryModel: $entryViewModel)
|
|
.xpcClient(xpcClient)
|
|
.selectedConversation(selectedConversation)
|
|
.navigationTitle("Kordophone")
|
|
.navigationSubtitle(selectedConversation?.displayName ?? "")
|
|
.onChange(of: conversationListModel.selectedConversations) { oldValue, newValue in
|
|
transcriptViewModel.displayedConversation = newValue.first
|
|
}
|
|
}
|
|
}
|
|
}
|