Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import SwiftUI
  2.  
  3. struct Tweet: Identifiable {
  4. var id: UUID
  5. let message: String
  6. let imageName: String?
  7.  
  8. init(message: String, imageName: String? = nil) {
  9. self.id = UUID()
  10. self.message = message
  11. self.imageName = imageName
  12. }
  13. }
  14.  
  15. struct TwitterStream: View {
  16. let tweets: [Tweet] = [
  17. Tweet(message: "Wow, this SwiftUI thing seems to be super awesome!"),
  18. Tweet(message: "Check out these people dancing around because they’re so happy about SwiftUI", imageName: "picture.jpg"),
  19. ]
  20.  
  21. var body: some View {
  22. List(tweets) { tweet in
  23. HStack {
  24. Text(tweet.message)
  25.  
  26. if let imageName = tweet.imageName {
  27. Image(imageName)
  28. }
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement