Files
simplex-chat/apps/ios/Shared/Views/ChatListView.swift
Evgeny Poberezkin 7c36ee7955 swift API for chat, started chat UI (#228)
* started swift API for chat

* skeleton UI

* show all chat responses in Terminal view

* show chat list in UI

* refactor swift API
2022-01-29 11:10:04 +00:00

57 lines
1.6 KiB
Swift

//
// ChatListView.swift
// SimpleX
//
// Created by Evgeny Poberezkin on 27/01/2022.
// Copyright © 2022 SimpleX Chat. All rights reserved.
//
import SwiftUI
struct ChatListView: View {
@EnvironmentObject var chatModel: ChatModel
var user: User
var body: some View {
DispatchQueue.global().async {
while(true) { chatRecvMsg(chatModel) }
}
return VStack {
// if chatModel.chats.isEmpty {
VStack {
Text("Hello chat")
Text("Active user: \(user.localDisplayName) (\(user.profile.fullName))")
}
// }
NavigationView {
List {
NavigationLink {
TerminalView()
} label: {
Text("Terminal")
}
ForEach(chatModel.chatPreviews) { chatPreview in
NavigationLink {
ChatView(chatInfo: chatPreview.chatInfo)
.onAppear {
chatSendCmd(chatModel, .apiGetChatItems(type: "direct", id: chatPreview.chatInfo.apiId))
}
} label: {
ChatPreviewView(chatPreview: chatPreview)
}
}
}
}
.navigationViewStyle(.stack)
}
}
}
//struct ChatListView_Previews: PreviewProvider {
// static var previews: some View {
// ChatListView()
// }
//}