Created
June 6, 2019 02:16
-
-
Save augustjoki/91ca20937968a96478488f46e8a8425f 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 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