Skip to content

Instantly share code, notes, and snippets.

@d-srd
Created September 20, 2019 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d-srd/3cf759102bcb043539aa29ac92350df7 to your computer and use it in GitHub Desktop.
Save d-srd/3cf759102bcb043539aa29ac92350df7 to your computer and use it in GitHub Desktop.
struct MessageView: View {
let message: Message
var body: some View {
HStack {
if message.sender == .me {
Spacer()
}
Text(message.content)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.padding(.horizontal, 12)
.padding(.vertical, 4)
.background(message.sender == .me ? Color.blue : Color.gray)
.foregroundColor(message.sender == .me ? Color.white : Color.black)
.cornerRadius(16)
if message.sender != .me {
Spacer()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment