Skip to content

Instantly share code, notes, and snippets.

@cardoso

cardoso/MessageView.swift Secret

Created May 18, 2020
Embed
What would you like to do?
import SwiftUI
import StreamChatClient
struct MessageView: View {
@State
var message: Message
var background: some View {
if (message.user.isCurrent) {
return Color.blue.opacity(0.25)
} else {
return Color.gray.opacity(0.25)
}
}
var title: some View {
if message.user.isCurrent {
return Text("")
} else {
return Text(message.user.id).font(.footnote)
}
}
var body: some View {
HStack {
if message.user.isCurrent { Spacer() }
VStack(alignment: .leading) {
title
Text(message.text)
.padding(8)
.background(background)
.cornerRadius(24)
}
if !message.user.isCurrent { Spacer() }
}.frame(maxWidth: .infinity)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.