import Combine import Foundation import Martin import SwiftUI struct ConversationScreen: View { @EnvironmentObject var store: AppStore var body: some View { ZStack { // Background color Color.Main.backgroundLight .ignoresSafeArea() // Content VStack(spacing: 0) { // Header ConversationScreenHeader() // Msg list let messages = store.state.conversationsState.currentMessages if !messages.isEmpty { List { ForEach(messages) { message in ConversationMessageRow(message: message) } } .listStyle(.plain) .background(Color.Main.backgroundLight) } else { 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 ConversationMessageRow: View { @EnvironmentObject var store: AppStore let message: Message var body: some View { VStack { if isIncoming() { HStack { MessageContainer(message: message, isOutgoing: false) .padding(.all, 8) Spacer() .frame(minWidth: 48, maxWidth: .infinity, alignment: .leading) } } else { HStack { Spacer() .frame(minWidth: 48, maxWidth: .infinity, alignment: .leading) MessageContainer(message: message, isOutgoing: true) .padding(.all, 8) } } // HStack { // if isIncoming() { // HStack // } // // if isIncoming() { // // Image(systemName: "person.fill") // // .foregroundColor(Color.Main.black) // // .frame(width: 32, height: 32) // // .background(Color.Main.backgroundLight) // // .clipShape(Circle()) // // Text(message.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) } .sharedListRow() } private func isIncoming() -> Bool { message.from != store.state.conversationsState.currentChat?.account } }