Skip to content

Commit 0403bb6

Browse files
committed
Remove horizontalSizeClass on macOS
Not available. Why not? Would be useful! :-)
1 parent 16c7460 commit 0403bb6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/NorthwindSwiftUI/ProductsList.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ struct ProductsList: View {
1717
/// The current search string.
1818
@State private var searchString = ""
1919

20+
#if !os(macOS)
2021
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
22+
#endif
2123

2224
var body: some View {
2325
List(products, selection: $selectedProduct) { product in
@@ -35,12 +37,14 @@ struct ProductsList: View {
3537
)
3638
}
3739

40+
#if !os(macOS)
3841
if horizontalSizeClass != .compact {
3942
// Pre-select the first match if none is selected
4043
if selectedProduct == nil, let product = products.first {
4144
selectedProduct = product.id
4245
}
4346
}
47+
#endif
4448
}
4549
catch { // really, do proper error handling :-)
4650
print("Fetch failed:", error)

0 commit comments

Comments
 (0)