summaryrefslogtreecommitdiff
path: root/Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift
blob: ddfbdcce9a8daa0495d37af81d7389b8d194f91a (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import SwiftUI

struct SettingsSectionThumbnailsView: View {
  @EnvironmentObject var settings: SettingsManager
  @State private var isShowingContentFiltering = false

  var body: some View {
    Form {
      Section(header: Text("Thumbnail Quality")) {
        Picker("Thumbnail Quality", selection: $settings.thumbnailQuality) {
          ForEach(BooruPostFileType.allCases, id: \.self) { type in
            Text(type.rawValue.capitalized).tag(type)
          }
        }
      }

      Section(header: Text("Grid Layout")) {
        #if os(macOS)
          Picker("Thumbnail Grid Columns", selection: $settings.thumbnailGridColumns) {
            ForEach(1...10, id: \.self) { columns in Text("\(columns)") }
          }
        #else
          Stepper(
            "Thumbnail Grid Columns: \(settings.thumbnailGridColumns)",
            value: $settings.thumbnailGridColumns,
            in: 1...10
          )
        #endif

        Toggle("Uniform Thumbnail Size", isOn: $settings.uniformThumbnailGrid)

        Toggle("Lazy Thumbnail Loading", isOn: $settings.alternativeThumbnailGrid)
      }

      Section(header: Text("Content Filtering")) {
        #if os(macOS)
          Button("Content Filtering") {
            isShowingContentFiltering.toggle()
          }
          .sheet(isPresented: $isShowingContentFiltering) {
            SettingsSectionContentRatingsView()
              .frame(minHeight: 250)
          }
          .trailingFrame()
        #else
          NavigationLink(destination: SettingsSectionContentRatingsView()) {
            Text("Content Filtering")
          }
        #endif
      }
    }
    #if os(macOS)
      .formStyle(.grouped)
    #endif
    .navigationTitle("Thumbnails")
    #if !os(macOS)
      .navigationBarTitleDisplayMode(.large)
    #endif
  }
}

#Preview {
  NavigationStack {
    SettingsSectionThumbnailsView()
      .environmentObject(SettingsManager())
  }
}