1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 14:50:32 +05:30
yattee/Shared/Views/ListingStyleButtons.swift

42 lines
1.1 KiB
Swift
Raw Normal View History

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)
.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))
}
}
}