1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 14:50:32 +05:30
yattee/Shared/Settings/MultiselectRow.swift
Toni Förster 54915dcea1
rework quality settings
- The order of the formats can now be changed in the Quality Settings.
- sortingOrder is now part of QualitiyProfile.
- bestPlayable is now part of PlayerBackend.
- hls and stream aren't treated as unknown anymore.
2024-04-29 20:03:51 +02:00

45 lines
1.2 KiB
Swift

import SwiftUI
struct MultiselectRow: View {
let title: String
var selected: Bool
var disabled = false
var action: (Bool) -> Void
@State private var toggleChecked = false
var body: some View {
#if os(tvOS)
Button(action: { action(!selected) }) {
HStack {
Text(self.title)
Spacer()
if selected {
Image(systemName: "checkmark")
}
}
.contentShape(Rectangle())
}
.disabled(disabled)
#else
Toggle(title, isOn: $toggleChecked)
#if os(macOS)
.toggleStyle(.checkbox)
#endif
.onAppear {
guard !disabled else { return }
toggleChecked = selected
}
.onChange(of: toggleChecked) { new in
action(new)
}
#endif
}
}
struct MultiselectRow_Previews: PreviewProvider {
static var previews: some View {
MultiselectRow(title: "Title", selected: false) { _ in }
}
}