Created
June 6, 2019 06:56
-
-
Save Jpunt/b688647f157b2c7bffbee8c4a2171c3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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