-
-
Save cardoso/3e3b7852a57129119e1d113337baa3f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import StreamChat | |
struct MessageView: View { | |
let message: ChatMessage | |
var background: some View { | |
if (message.isSentByCurrentUser) { | |
return Color.blue.opacity(0.25) | |
} else { | |
return Color.gray.opacity(0.25) | |
} | |
} | |
var title: some View { | |
if message.isSentByCurrentUser { | |
return Text("") | |
} else { | |
return Text(message.author.id).font(.footnote) | |
} | |
} | |
var body: some View { | |
HStack { | |
if message.isSentByCurrentUser { Spacer() } | |
VStack(alignment: .leading) { | |
title | |
Text(message.text) | |
.padding(8) | |
.background(background) | |
.cornerRadius(24) | |
} | |
if !message.isSentByCurrentUser { Spacer() } | |
}.frame(maxWidth: .infinity) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment