Repository Public
1import SwiftUI23/// SP Search preferences (language, region, filtering, summary, history). They follow the account between devices.4struct SPSearchPreferencesSection: View {5 let services: BrowserServices6 @State private var confirmClear = false78 private func binding<T>(_ keyPath: WritableKeyPath<SearchPreferences, T>) -> Binding<T> {9 Binding(get: { services.searchPreferences[keyPath: keyPath] },10 set: { var prefs = services.searchPreferences; prefs[keyPath: keyPath] = $0; services.searchPreferences = prefs })11 }1213 var body: some View {14 let _ = services.libraryRevision15 Section("SP Search") {16 Picker(L("Language of results"), selection: binding(\.language)) {17 ForEach(SearchPreferences.languages, id: \.code) { Text($0.code.isEmpty ? L("Any language") : $0.name).tag($0.code) }18 }19 Picker(L("Region"), selection: binding(\.region)) {20 ForEach(SearchPreferences.regions, id: \.self) { Text(SearchPreferences.regionName($0)).tag($0) }21 }22 Toggle(L("Safe search"), isOn: binding(\.safeSearch))23 Toggle(L("Show an AI summary above web results"), isOn: binding(\.showSummary))24 Toggle(L("Keep search history"), isOn: binding(\.keepSearchHistory))25 Button(L("Clear Search History…"), role: .destructive) { confirmClear = true }26 .confirmationDialog(L("Clear your search history?"), isPresented: $confirmClear, titleVisibility: .visible) {27 Button(L("Clear Search History"), role: .destructive) { services.clearSearchData() }28 } message: { Text(L("Past searches are removed from this device and, when sync is on, from your other devices.")) }29 Text(L("Searches are sent to the SP Browser server, which queries the search provider without your account or address attached and keeps no log of what you search. Suggestions come from your own search history only."))30 .font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)31 }32 }33}34