osx: wiring for opening a new window, but not connected to gesture yet
when I add `.tapGesture(count: 2)` to list items, this seems to block single clicks because SwiftUI sucks. Need to find a better way to invoke this.
This commit is contained in:
@@ -18,6 +18,10 @@ struct KordophoneApp: App
|
||||
TextEditingCommands()
|
||||
}
|
||||
|
||||
WindowGroup(id: .transcriptWindow, for: Display.Conversation.self) { selectedConversation in
|
||||
TranscriptWindowView(conversation: selectedConversation)
|
||||
}
|
||||
|
||||
Settings {
|
||||
PreferencesView()
|
||||
}
|
||||
@@ -28,3 +32,42 @@ struct KordophoneApp: App
|
||||
print("Error: \(e.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
struct TranscriptWindowView: View
|
||||
{
|
||||
@State private var transcriptViewModel = TranscriptView.ViewModel()
|
||||
@State private var entryViewModel = MessageEntryView.ViewModel()
|
||||
private let displayedConversation: Binding<Display.Conversation?>
|
||||
|
||||
public init(conversation: Binding<Display.Conversation?>) {
|
||||
self.displayedConversation = conversation
|
||||
transcriptViewModel.displayedConversation = conversation.wrappedValue
|
||||
observeDisplayedConversationChanges()
|
||||
}
|
||||
|
||||
private func observeDisplayedConversationChanges() {
|
||||
withObservationTracking {
|
||||
_ = displayedConversation.wrappedValue
|
||||
} onChange: {
|
||||
Task { @MainActor in
|
||||
guard let displayedConversation = self.displayedConversation.wrappedValue else { return }
|
||||
transcriptViewModel.displayedConversation = displayedConversation
|
||||
|
||||
observeDisplayedConversationChanges()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
ConversationView(transcriptModel: $transcriptViewModel, entryModel: $entryViewModel)
|
||||
.navigationTitle(displayedConversation.wrappedValue?.displayName ?? "Kordophone")
|
||||
.selectedConversation(displayedConversation.wrappedValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension String
|
||||
{
|
||||
static let transcriptWindow = "TranscriptWindow"
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ struct ConversationListView: View
|
||||
{
|
||||
@Binding var model: ViewModel
|
||||
@Environment(\.xpcClient) private var xpcClient
|
||||
@Environment(\.openWindow) private var openWindow
|
||||
|
||||
var body: some View {
|
||||
List($model.conversations, selection: $model.selectedConversation) { conv in
|
||||
|
||||
@@ -10,7 +10,7 @@ import XPC
|
||||
|
||||
enum Display
|
||||
{
|
||||
struct Conversation: Identifiable, Hashable
|
||||
struct Conversation: Identifiable, Hashable, Codable
|
||||
{
|
||||
let id: String
|
||||
let name: String?
|
||||
|
||||
Reference in New Issue
Block a user