Skip to content

Instantly share code, notes, and snippets.

@augustjoki
Created June 6, 2019 02:16
Show Gist options
  • Save augustjoki/91ca20937968a96478488f46e8a8425f to your computer and use it in GitHub Desktop.
Save augustjoki/91ca20937968a96478488f46e8a8425f to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView : View {
let sample = Story.sample
var body: some View {
ScrollView {
HStack(spacing: 16) {
Spacer()
ForEach(sample) { story in
VStack {
Circle().fill(story.profile)
.frame(width: 50, height: 50)
.overlay(Circle().scale(1.2).stroke(Color.purple))
Text(story.username)
}
}
Spacer()
}
}
}
}
struct Story : Identifiable {
let id: Int
let username: String
let profile: Color
static var sample: [Story] {
return [Story(id: 0, username: "alice", profile: .blue),
Story(id: 1, username: "bob", profile: .red),
Story(id: 2, username: "carol", profile: .gray),
Story(id: 3, username: "david", profile: .yellow),
Story(id: 4, username: "enoch", profile: .black),
Story(id: 5, username: "francis", profile: .green),
Story(id: 6, username: "garth", profile: .pink)
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment