mirror of
https://github.com/yattee/yattee.git
synced 2025-04-25 16:16:29 +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())) {
|
||||
#if os(macOS)
|
||||
let list = ForEach(VisibleSection.allCases, id: \.self) { section in
|
||||
VisibleSectionSelectionRow(
|
||||
MultiselectRow(
|
||||
title: section.title,
|
||||
selected: visibleSections.contains(section)
|
||||
) { value in
|
||||
@ -110,7 +110,7 @@ struct BrowsingSettings: View {
|
||||
}
|
||||
#else
|
||||
ForEach(VisibleSection.allCases, id: \.self) { section in
|
||||
VisibleSectionSelectionRow(
|
||||
MultiselectRow(
|
||||
title: section.title,
|
||||
selected: visibleSections.contains(section)
|
||||
) { value in
|
||||
@ -128,51 +128,13 @@ struct BrowsingSettings: View {
|
||||
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 {
|
||||
static var previews: some View {
|
||||
BrowsingSettings()
|
||||
.injectFixtureEnvironmentObjects()
|
||||
VStack {
|
||||
BrowsingSettings()
|
||||
}
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
@ -9,21 +9,19 @@ struct MultiselectRow: View {
|
||||
@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 {
|
||||
guard !disabled else { return }
|
||||
toggleChecked = selected
|
||||
}
|
||||
.onChange(of: toggleChecked) { new in
|
||||
action(new)
|
||||
}
|
||||
#else
|
||||
#if os(macOS)
|
||||
Toggle(title, isOn: $toggleChecked)
|
||||
.toggleStyle(.checkbox)
|
||||
.onAppear {
|
||||
guard !disabled else { return }
|
||||
toggleChecked = selected
|
||||
}
|
||||
.onChange(of: toggleChecked) { new in
|
||||
action(new)
|
||||
}
|
||||
#else
|
||||
Button(action: { action(!selected) }) {
|
||||
HStack {
|
||||
Text(self.title)
|
||||
Spacer()
|
||||
if selected {
|
||||
@ -32,13 +30,13 @@ struct MultiselectRow: View {
|
||||
.foregroundColor(.accentColor)
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.disabled(disabled)
|
||||
#if !os(tvOS)
|
||||
.buttonStyle(.plain)
|
||||
.disabled(disabled)
|
||||
#if !os(tvOS)
|
||||
.buttonStyle(.plain)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ struct SponsorBlockSettings: View {
|
||||
}
|
||||
#if os(tvOS)
|
||||
.frame(maxWidth: 1000)
|
||||
#elseif os(iOS)
|
||||
.listStyle(.insetGrouped)
|
||||
#else
|
||||
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||
#endif
|
||||
.navigationTitle("SponsorBlock")
|
||||
}
|
||||
@ -106,5 +106,6 @@ struct SponsorBlockSettings_Previews: PreviewProvider {
|
||||
VStack {
|
||||
SponsorBlockSettings()
|
||||
}
|
||||
.frame(maxHeight: 600)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user