Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement