mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-01 00:56:05 +00:00
* started swift API for chat * skeleton UI * show all chat responses in Terminal view * show chat list in UI * refactor swift API
84 lines
2.3 KiB
Swift
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()
|
|
// }
|
|
//}
|