Skip to content

Instantly share code, notes, and snippets.

@halavins
Last active October 12, 2019 03:43
Show Gist options
  • Save halavins/bf79035692038cfd60272e63705a6aa3 to your computer and use it in GitHub Desktop.
Save halavins/bf79035692038cfd60272e63705a6aa3 to your computer and use it in GitHub Desktop.
ChatRow struct from contentView.swift
// ChatRow will be a view similar to a Cell in standard Swift
struct ChatRow : View {
// we will need to access and represent the chatMessages here
var chatMessage: ChatMessage
// body - is the body of the view, just like the body of the first view we created when opened the project
var body: some View {
// HStack - is a horizontal stack. We let the SwiftUI know that we need to place
// all the following contents horizontally one after another
HStack {
Group {
Text(chatMessage.avatar)
Text(chatMessage.message)
.bold()
.padding(10)
.foregroundColor(Color.white)
.background(chatMessage.color)
.cornerRadius(10)
}
}
}
}
@halavins
Copy link
Author

Updated on Oct 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment