summaryrefslogtreecommitdiff
path: root/Sora/Views/Settings/Section/SettingsSearchView.swift
blob: fbe16568cad1982e5ee5d4d5259d26975f0b608d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import SwiftUI

struct SettingsSearchView: View {
  @EnvironmentObject var settings: SettingsManager

  #if os(macOS)
    var manager = BooruManager(.yandere)
  #else
    @EnvironmentObject var manager: BooruManager
  #endif

  var body: some View {
    Picker("Suggestion Mode", selection: $settings.searchSuggestionsMode) {
      ForEach(SettingsSearchSuggestionsMode.allCases, id: \.self) { type in
        Text(type.rawValue.capitalized).tag(type)
      }
    }

    Button(
      "Clear Cached Tags (\(manager.cacheSize ?? "Unknown size"))"
    ) {
      manager.clearCachedTags()
    }
    #if os(macOS)
      .frame(maxWidth: .infinity, alignment: .trailing)
    #endif

    Button("Clear History") {
      settings.searchHistory.removeAll()
    }
    #if os(macOS)
      .frame(maxWidth: .infinity, alignment: .trailing)
    #endif
  }
}