Files
simplex-chat/apps/ios/Shared/Views/ChatView.swift
Evgeny Poberezkin cb602dd377 show received messages in chat, send command on Enter, fix Date parsing (#237)
* refactor UI and API, send command on Enter, fix Date parsing

* UI sheets to create connection and groups

* show received messages

* readme
2022-01-29 23:37:02 +00:00

56 lines
1.3 KiB
Swift

//
// ChatView.swift
// SimpleX
//
// Created by Evgeny Poberezkin on 27/01/2022.
// Copyright © 2022 SimpleX Chat. All rights reserved.
//
import SwiftUI
struct ChatView: View {
@EnvironmentObject var chatModel: ChatModel
@State var inProgress: Bool = false
var chatInfo: ChatInfo
var body: some View {
VStack {
if let chat: Chat = chatModel.chats[chatInfo.id] {
VStack {
ScrollView {
LazyVStack {
ForEach(chat.chatItems) { chatItem in
Text(chatItem.content.text)
}
}
}
}
} else {
Text("unexpected: chat not found...")
}
Spacer()
SendMessageView(sendMessage: sendMessage, inProgress: inProgress)
}
}
func sendMessage(_ msg: String) {
}
}
struct ChatView_Previews: PreviewProvider {
static var previews: some View {
let chatModel = ChatModel()
chatModel.chats = [
"@1": Chat(
chatInfo: sampleDirectChatInfo,
chatItems: []
)
]
return ChatView(chatInfo: sampleDirectChatInfo)
.environmentObject(chatModel)
}
}