// // ConversationListView.swift // kordophone2 // // Created by James Magahern on 8/24/25. // import SwiftUI struct ConversationListView: View { @Binding var model: ViewModel var body: some View { List($model.conversations, selection: $model.selectedConversations) { conv in VStack(alignment: .leading) { Text(conv.wrappedValue.displayName) .bold() Text(conv.wrappedValue.messagePreview) } .padding(8.0) } .listStyle(.sidebar) } // MARK: - Types @Observable class ViewModel { var conversations: [Display.Conversation] var selectedConversations: Set public init(conversations: [Display.Conversation] = []) { self.conversations = conversations self.selectedConversations = Set() } } } #Preview { @Previewable @State var viewModel = ConversationListView.ViewModel(conversations: [ .init(id: "asdf", name: "Cool", participants: ["me"], messagePreview: "Hello there"), .init(id: "gjkl", name: "Nice", participants: ["me"], messagePreview: "How are you"), ]) ConversationListView(model: $viewModel) }