mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Listing styles
This commit is contained in:
41
Shared/Views/ListingStyleButtons.swift
Normal file
41
Shared/Views/ListingStyleButtons.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ListingStyleButtons: View {
|
||||
@Binding var listingStyle: ListingStyle
|
||||
|
||||
var body: some View {
|
||||
#if os(iOS)
|
||||
picker
|
||||
#else
|
||||
Button {
|
||||
listingStyle = listingStyle.next()
|
||||
} label: {
|
||||
Label(listingStyle.rawValue.capitalized, systemImage: listingStyle.systemImage)
|
||||
#if os(tvOS)
|
||||
.font(.caption2)
|
||||
.imageScale(.small)
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
var picker: some View {
|
||||
Picker("Listing Style", selection: $listingStyle) {
|
||||
ForEach(ListingStyle.allCases, id: \.self) { style in
|
||||
Button {
|
||||
listingStyle = style
|
||||
} label: {
|
||||
Label(style.rawValue.capitalized, systemImage: style.systemImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ListingStyleButtons_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack {
|
||||
ListingStyleButtons(listingStyle: .constant(.cells))
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user