mirror of
https://github.com/yattee/yattee.git
synced 2025-04-26 00:26:33 +00:00
Fix #338
This commit is contained in:
parent
5d033cbdfc
commit
611bcde238
@ -89,7 +89,7 @@ struct BrowsingSettings: View {
|
|||||||
Section(header: SettingsHeader(text: "Sections".localized())) {
|
Section(header: SettingsHeader(text: "Sections".localized())) {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
let list = ForEach(VisibleSection.allCases, id: \.self) { section in
|
let list = ForEach(VisibleSection.allCases, id: \.self) { section in
|
||||||
VisibleSectionSelectionRow(
|
MultiselectRow(
|
||||||
title: section.title,
|
title: section.title,
|
||||||
selected: visibleSections.contains(section)
|
selected: visibleSections.contains(section)
|
||||||
) { value in
|
) { value in
|
||||||
@ -110,7 +110,7 @@ struct BrowsingSettings: View {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ForEach(VisibleSection.allCases, id: \.self) { section in
|
ForEach(VisibleSection.allCases, id: \.self) { section in
|
||||||
VisibleSectionSelectionRow(
|
MultiselectRow(
|
||||||
title: section.title,
|
title: section.title,
|
||||||
selected: visibleSections.contains(section)
|
selected: visibleSections.contains(section)
|
||||||
) { value in
|
) { value in
|
||||||
@ -128,51 +128,13 @@ struct BrowsingSettings: View {
|
|||||||
visibleSections.remove(section)
|
visibleSections.remove(section)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VisibleSectionSelectionRow: View {
|
|
||||||
let title: String
|
|
||||||
let selected: Bool
|
|
||||||
var action: (Bool) -> Void
|
|
||||||
|
|
||||||
@State private var toggleChecked = false
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
Button(action: { action(!selected) }) {
|
|
||||||
HStack {
|
|
||||||
#if os(macOS)
|
|
||||||
Toggle(isOn: $toggleChecked) {
|
|
||||||
Text(self.title)
|
|
||||||
Spacer()
|
|
||||||
}
|
|
||||||
.onAppear {
|
|
||||||
toggleChecked = selected
|
|
||||||
}
|
|
||||||
.onChange(of: toggleChecked) { new in
|
|
||||||
action(new)
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
Text(self.title)
|
|
||||||
Spacer()
|
|
||||||
if selected {
|
|
||||||
Image(systemName: "checkmark")
|
|
||||||
#if os(iOS)
|
|
||||||
.foregroundColor(.accentColor)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
.contentShape(Rectangle())
|
|
||||||
}
|
|
||||||
#if !os(tvOS)
|
|
||||||
.buttonStyle(.plain)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BrowsingSettings_Previews: PreviewProvider {
|
struct BrowsingSettings_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
BrowsingSettings()
|
VStack {
|
||||||
.injectFixtureEnvironmentObjects()
|
BrowsingSettings()
|
||||||
|
}
|
||||||
|
.injectFixtureEnvironmentObjects()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,21 +9,19 @@ struct MultiselectRow: View {
|
|||||||
@State private var toggleChecked = false
|
@State private var toggleChecked = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Button(action: { action(!selected) }) {
|
#if os(macOS)
|
||||||
HStack {
|
Toggle(title, isOn: $toggleChecked)
|
||||||
#if os(macOS)
|
.toggleStyle(.checkbox)
|
||||||
Toggle(isOn: $toggleChecked) {
|
.onAppear {
|
||||||
Text(self.title)
|
guard !disabled else { return }
|
||||||
Spacer()
|
toggleChecked = selected
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onChange(of: toggleChecked) { new in
|
||||||
guard !disabled else { return }
|
action(new)
|
||||||
toggleChecked = selected
|
}
|
||||||
}
|
#else
|
||||||
.onChange(of: toggleChecked) { new in
|
Button(action: { action(!selected) }) {
|
||||||
action(new)
|
HStack {
|
||||||
}
|
|
||||||
#else
|
|
||||||
Text(self.title)
|
Text(self.title)
|
||||||
Spacer()
|
Spacer()
|
||||||
if selected {
|
if selected {
|
||||||
@ -32,13 +30,13 @@ struct MultiselectRow: View {
|
|||||||
.foregroundColor(.accentColor)
|
.foregroundColor(.accentColor)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
.contentShape(Rectangle())
|
||||||
}
|
}
|
||||||
.contentShape(Rectangle())
|
.disabled(disabled)
|
||||||
}
|
#if !os(tvOS)
|
||||||
.disabled(disabled)
|
.buttonStyle(.plain)
|
||||||
#if !os(tvOS)
|
#endif
|
||||||
.buttonStyle(.plain)
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ struct SponsorBlockSettings: View {
|
|||||||
}
|
}
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
.frame(maxWidth: 1000)
|
.frame(maxWidth: 1000)
|
||||||
#elseif os(iOS)
|
#else
|
||||||
.listStyle(.insetGrouped)
|
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||||
#endif
|
#endif
|
||||||
.navigationTitle("SponsorBlock")
|
.navigationTitle("SponsorBlock")
|
||||||
}
|
}
|
||||||
@ -106,5 +106,6 @@ struct SponsorBlockSettings_Previews: PreviewProvider {
|
|||||||
VStack {
|
VStack {
|
||||||
SponsorBlockSettings()
|
SponsorBlockSettings()
|
||||||
}
|
}
|
||||||
|
.frame(maxHeight: 600)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user