Skip to content

Instantly share code, notes, and snippets.

@Jpunt
Created June 6, 2019 06:56
Show Gist options
  • Save Jpunt/b688647f157b2c7bffbee8c4a2171c3e to your computer and use it in GitHub Desktop.
Save Jpunt/b688647f157b2c7bffbee8c4a2171c3e to your computer and use it in GitHub Desktop.
import SwiftUI
struct Tweet: Identifiable {
var id: UUID
let message: String
let imageName: String?
init(message: String, imageName: String? = nil) {
self.id = UUID()
self.message = message
self.imageName = imageName
}
}
struct TwitterStream: View {
let tweets: [Tweet] = [
Tweet(message: "Wow, this SwiftUI thing seems to be super awesome!"),
Tweet(message: "Check out these people dancing around because they’re so happy about SwiftUI", imageName: "picture.jpg"),
]
var body: some View {
List(tweets) { tweet in
HStack {
Text(tweet.message)
if let imageName = tweet.imageName {
Image(imageName)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment