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 1.11 KB | None | 0 0
  1. import SwiftUI
  2.  
  3. struct ContentView : View {
  4. let sample = Story.sample
  5. var body: some View {
  6. ScrollView {
  7. HStack(spacing: 16) {
  8. Spacer()
  9. ForEach(sample) { story in
  10. VStack {
  11. Circle().fill(story.profile)
  12. .frame(width: 50, height: 50)
  13. .overlay(Circle().scale(1.2).stroke(Color.purple))
  14. Text(story.username)
  15. }
  16. }
  17. Spacer()
  18. }
  19. }
  20. }
  21. }
  22.  
  23. struct Story : Identifiable {
  24. let id: Int
  25. let username: String
  26. let profile: Color
  27.  
  28. static var sample: [Story] {
  29. return [Story(id: 0, username: "alice", profile: .blue),
  30. Story(id: 1, username: "bob", profile: .red),
  31. Story(id: 2, username: "carol", profile: .gray),
  32. Story(id: 3, username: "david", profile: .yellow),
  33. Story(id: 4, username: "enoch", profile: .black),
  34. Story(id: 5, username: "francis", profile: .green),
  35. Story(id: 6, username: "garth", profile: .pink)
  36. ]
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement