Created
April 23, 2020 14:29
-
-
Save nrivard/3c82083bbf60b3d01271896a668fb3a2 to your computer and use it in GitHub Desktop.
Multiplatform SwiftUI code that fails on macOS
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 { | |
var body: some View { | |
List { | |
ScrollySection(sectionName: "Section 1") | |
ScrollySection(sectionName: "Section 2") | |
ScrollySection(sectionName: "Section 3") | |
} | |
} | |
} | |
struct ScrollySection: View { | |
let sectionName: String | |
var body: some View { | |
VStack(alignment: .leading) { | |
Text(verbatim: sectionName) | |
.font(.headline) | |
ScrollView(.horizontal) { | |
HStack { | |
ForEach(0..<20) { | |
Squircle(text: "Item \($0)") | |
.frame(width: 100, height: 100) | |
} | |
} | |
} | |
} | |
} | |
} | |
struct Squircle: View { | |
let text: String | |
var body: some View { | |
ZStack { | |
RoundedRectangle(cornerRadius: 8) | |
.fill(Color.green) | |
Text(verbatim: text) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment