yattee/Shared/Views/ListingStyleButtons.swift

43 lines
1.2 KiB
Swift
Raw Permalink Normal View History

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)
.font(.caption)
2022-12-12 00:18:29 +00:00
.imageScale(.small)
#endif
}
2024-02-26 13:12:11 +00:00
.help(listingStyle == .cells ? "List" : "Cells")
2022-12-12 00:18:29 +00:00
#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))
}
}
}