Files
simplex-chat/apps/ios/Shared/Views/UserView.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

84 lines
2.3 KiB
Swift

//
// UserView.swift
// SimpleX
//
// Created by Evgeny Poberezkin on 27/01/2022.
// Copyright © 2022 SimpleX Chat. All rights reserved.
//
import SwiftUI
struct UserView: View {
@EnvironmentObject var chatModel: ChatModel
var user: User
// private let controller: chat_ctrl
//
// var chatStore: chat_store
// @State private var logbuffer = [String]()
// @State private var chatcmd: String = ""
// @State private var chatlog: String = ""
// @FocusState private var focused: Bool
// func addLine(line: String) {
// print(line)
// logbuffer.append(line)
// if(logbuffer.count > 50) { _ = logbuffer.dropFirst() }
// chatlog = logbuffer.joined(separator: "\n")
// }
var body: some View {
if chatModel.userChats.isEmpty {
VStack {
Text("Hello chat")
Text("Active user: \(user.localDisplayName) (\(user.profile.fullName))")
}
} else {
ChatList()
}
// DispatchQueue.global().async {
// while(true) {
// let msg = String.init(cString: chat_recv_msg(controller))
//
// DispatchQueue.main.async {
// addLine(line: msg)
// }
// }
// }
// return VStack {
// ScrollView {
// VStack(alignment: .leading) {
// HStack { Spacer() }
// Text(chatlog)
// .lineLimit(nil)
// .font(.system(.body, design: .monospaced))
// }
// .frame(maxWidth: .infinity)
// }
//
// TextField("Chat command", text: $chatcmd)
// .focused($focused)
// .onSubmit {
// print(chatcmd)
// var cCmd = chatcmd.cString(using: .utf8)!
//// print(String.init(cString: chat_send_cmd(controller, &cCmd)))
// }
// .textInputAutocapitalization(.never)
// .disableAutocorrection(true)
// .padding()
// }
}
}
//struct UserView_Previews: PreviewProvider {
// static var previews: some View {
// UserView()
// }
//}