113 lines
3.7 KiB
Swift
113 lines
3.7 KiB
Swift
import Combine
|
|
import Foundation
|
|
import Martin
|
|
import SwiftUI
|
|
|
|
struct ChatScreen: View {
|
|
// @EnvironmentObject var state: AppState
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
// Header
|
|
ChatScreenHeader()
|
|
|
|
// Msg list
|
|
// if !state.messages.isEmpty {
|
|
// List {
|
|
// ForEach(state.messages) { message in
|
|
// ChatMessageView(message: message)
|
|
// }
|
|
// }
|
|
// } else {
|
|
// Text("No messages")
|
|
// Spacer()
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
|
|
private struct ChatScreenHeader: View {
|
|
// @EnvironmentObject var state: AppState
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
// bg
|
|
Color.Main.backgroundDark
|
|
.ignoresSafeArea()
|
|
|
|
// title
|
|
// let name = (
|
|
// state.activeConversation?.participant?.name ??
|
|
// state.activeConversation.participant?.contactBareJid
|
|
// ) ?? L10n.Chat.title
|
|
Text(L10n.Chat.title)
|
|
.font(.head2)
|
|
.foregroundColor(Color.Main.black)
|
|
|
|
HStack {
|
|
Image(systemName: "chevron.left")
|
|
.foregroundColor(Color.Tango.orangeMedium)
|
|
.tappablePadding(.symmetric(12)) {
|
|
// state.flow = .chatsList
|
|
}
|
|
Spacer()
|
|
// Image(systemName: "plus.viewfinder")
|
|
// .foregroundColor(Color.Tango.orangeMedium)
|
|
// .tappablePadding(.symmetric(12)) {
|
|
// print("Scan QR-code")
|
|
// }
|
|
}
|
|
.padding(.horizontal, 16)
|
|
}
|
|
.frame(height: 44)
|
|
}
|
|
}
|
|
|
|
private struct ChatMessageView: View {
|
|
// @EnvironmentObject var state: AppState
|
|
|
|
let message: Message
|
|
|
|
var body: some View {
|
|
HStack {
|
|
Text(message.body ?? "--NO BODY?--")
|
|
// .padding(.all, 8)
|
|
// .background(.black)
|
|
// .clipShape(RoundedRectangle(cornerRadius: 8))
|
|
.foregroundColor(Color.Main.black)
|
|
Spacer()
|
|
// if isIncoming() {
|
|
// Image(systemName: "person.fill")
|
|
// .foregroundColor(Color.Main.black)
|
|
// .frame(width: 32, height: 32)
|
|
// .background(Color.Main.backgroundLight)
|
|
// .clipShape(Circle())
|
|
// Text(message.body ?? "--NO BODY?--")
|
|
// .padding(.all, 8)
|
|
// .background(Color.Main.backgroundLight)
|
|
// .clipShape(RoundedRectangle(cornerRadius: 8))
|
|
// .foregroundColor(Color.Main.black)
|
|
// } else {
|
|
// Text(message.body ?? "--NO BODY?--")
|
|
// .padding(.all, 8)
|
|
// .background(Color.Main.backgroundLight)
|
|
// .clipShape(RoundedRectangle(cornerRadius: 8))
|
|
// .foregroundColor(Color.Main.black)
|
|
// Image(systemName: "person.fill")
|
|
// .foregroundColor(Color.Main.black)
|
|
// .frame(width: 32, height: 32)
|
|
// .background(Color.Main.backgroundLight)
|
|
// .clipShape(Circle())
|
|
// }
|
|
}
|
|
.padding(.horizontal, 16)
|
|
.background(Color.red)
|
|
}
|
|
|
|
// private func isIncoming() -> Bool {
|
|
// message.fromJid != state.currentChat?.account
|
|
// }
|
|
}
|
|
|
|
// for test
|