2022-12-12 00:18:29 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ListingStyleButtons: View {
|
|
|
|
@Binding var listingStyle: ListingStyle
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
#if os(iOS)
|
|
|
|
picker
|
|
|
|
#else
|
|
|
|
Button {
|
|
|
|
listingStyle = listingStyle.next()
|
|
|
|
} label: {
|
2023-04-24 10:57:20 +00:00
|
|
|
Label(listingStyle.rawValue.capitalized.localized(), systemImage: listingStyle.systemImage)
|
2022-12-12 00:18:29 +00:00
|
|
|
#if os(tvOS)
|
2023-04-22 19:07:30 +00:00
|
|
|
.font(.caption)
|
2022-12-12 00:18:29 +00:00
|
|
|
.imageScale(.small)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
var picker: some View {
|
|
|
|
Picker("Listing Style", selection: $listingStyle) {
|
|
|
|
ForEach(ListingStyle.allCases, id: \.self) { style in
|
|
|
|
Button {
|
|
|
|
listingStyle = style
|
|
|
|
} label: {
|
2023-04-24 10:57:20 +00:00
|
|
|
Label(style.rawValue.capitalized.localized(), systemImage: style.systemImage)
|
2022-12-12 00:18:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ListingStyleButtons_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
VStack {
|
|
|
|
ListingStyleButtons(listingStyle: .constant(.cells))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|