initial commit
This commit is contained in:
49
kordophone2/ConversationListView.swift
Normal file
49
kordophone2/ConversationListView.swift
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// 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<Display.Conversation.ID>
|
||||
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user