Private
Public Access
1
0
Files
Kordophone/osx/kordophone2/SplitView.swift

39 lines
1.4 KiB
Swift
Raw Permalink Normal View History

2025-08-29 19:59:11 -06:00
//
// 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? {
2025-09-10 14:41:24 -07:00
guard let id = conversationListModel.selectedConversation else { return nil }
2025-08-29 19:59:11 -06:00
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)
2025-09-10 14:41:24 -07:00
.navigationTitle(selectedConversation?.displayName ?? "Kordophone")
.navigationSubtitle(selectedConversation?.participants.joined(separator: ", ") ?? "")
.onChange(of: conversationListModel.selectedConversation) { oldValue, newValue in
transcriptViewModel.displayedConversation = conversationListModel.conversations.first { $0.id == newValue }
2025-08-29 19:59:11 -06:00
}
}
}
}