2022-12-12 05:48:29 +05:30
|
|
|
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 16:27:20 +05:30
|
|
|
Label(listingStyle.rawValue.capitalized.localized(), systemImage: listingStyle.systemImage)
|
2022-12-12 05:48:29 +05:30
|
|
|
#if os(tvOS)
|
2023-04-23 00:37:30 +05:30
|
|
|
.font(.caption)
|
2022-12-12 05:48:29 +05:30
|
|
|
.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 16:27:20 +05:30
|
|
|
Label(style.rawValue.capitalized.localized(), systemImage: style.systemImage)
|
2022-12-12 05:48:29 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ListingStyleButtons_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
VStack {
|
|
|
|
ListingStyleButtons(listingStyle: .constant(.cells))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|