Skip to content

Commit

Permalink
Merge pull request #873 from kiwix/871-search-snippet-setting-is-outd…
Browse files Browse the repository at this point in the history
…ated

Change search snippet in setting to be a toggle
  • Loading branch information
kelson42 authored Jul 20, 2024
2 parents d4afb15 + aa7416c commit 86a037c
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions Views/Settings/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ struct ReadingSettings: View {
@Default(.webViewPageZoom) private var webViewPageZoom

var body: some View {
let isSnippet = Binding {
switch searchResultSnippetMode {
case .matches: return true
case .disabled: return false
}
} set: { isOn in
searchResultSnippetMode = isOn ? .matches : .disabled
}
VStack(spacing: 16) {
SettingSection(name: "reading_settings.zoom.title".localized) {
HStack {
Expand All @@ -45,11 +53,7 @@ struct ReadingSettings: View {
}
if FeatureFlags.showSearchSnippetInSettings {
SettingSection(name: "reading_settings.search_snippet.title".localized) {
Picker(selection: $searchResultSnippetMode) {
ForEach(SearchResultSnippetMode.allCases) { snippetMode in
Text(snippetMode.name).tag(snippetMode)
}
} label: { }
Toggle(" ", isOn: isSnippet)
}
}
}
Expand Down Expand Up @@ -152,7 +156,15 @@ struct Settings: View {
}

var readingSettings: some View {
Section("reading_settings.tab.reading".localized) {
let isSnippet = Binding {
switch searchResultSnippetMode {
case .matches: return true
case .disabled: return false
}
} set: { isOn in
searchResultSnippetMode = isOn ? .matches : .disabled
}
return Section("reading_settings.tab.reading".localized) {
Stepper(value: $webViewPageZoom, in: 0.5...2, step: 0.05) {
Text("reading_settings.zoom.title".localized +
": \(Formatter.percent.string(from: NSNumber(value: webViewPageZoom)) ?? "")")
Expand All @@ -165,11 +177,7 @@ struct Settings: View {
}
}
if FeatureFlags.showSearchSnippetInSettings {
Picker("reading_settings.search_snippet.title".localized, selection: $searchResultSnippetMode) {
ForEach(SearchResultSnippetMode.allCases) { snippetMode in
Text(snippetMode.name).tag(snippetMode)
}
}
Toggle("reading_settings.search_snippet.title".localized, isOn: isSnippet)
}
}
}
Expand Down

0 comments on commit 86a037c

Please sign in to comment.