another.im-ios/ConversationsClassic/View/Screens/ConversationScreen.swift
2024-06-21 12:42:50 +02:00

113 lines
3.7 KiB
Swift

import Combine
import Foundation
import Martin
import SwiftUI
struct ConversationScreen: View {
@EnvironmentObject var store: AppStore
var body: some View {
VStack(spacing: 0) {
// Header
ConversationScreenHeader()
// Msg list
// if !state.messages.isEmpty {
// List {
// ForEach(state.messages) { message in
// ChatMessageView(message: message)
// }
// }
// } else {
// Text("No messages")
// Spacer()
// }
}
}
}
private struct ConversationScreenHeader: 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)) {
store.dispatch(.changeFlow(store.state.previousFlow))
}
Spacer()
// Image(systemName: "plus.viewfinder")
// .foregroundColor(Color.Tango.orangeMedium)
// .tappablePadding(.symmetric(12)) {
// print("Scan QR-code")
// }
}
.padding(.horizontal, 16)
}
.frame(height: 44)
}
}
private struct ConversationMessageView: 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