summaryrefslogtreecommitdiff
path: root/Sora
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-09-22 02:05:34 -0700
committerFuwn <[email protected]>2025-09-22 02:05:34 -0700
commit3e82a4422fadfadd8b6bd4b41b9a41d768e70ac1 (patch)
treef0287230c16ab8a30e15588314f32238b0803cb9 /Sora
parentfeat: Development commit (diff)
downloadsora-testing-3e82a4422fadfadd8b6bd4b41b9a41d768e70ac1.tar.xz
sora-testing-3e82a4422fadfadd8b6bd4b41b9a41d768e70ac1.zip
feat: Development commit
Diffstat (limited to 'Sora')
-rw-r--r--Sora/Views/Settings/Section/SettingsDetailsView.swift39
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionDetailsView.swift63
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionProviderView.swift (renamed from Sora/Views/Settings/Section/SettingsProviderView.swift)151
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift67
-rw-r--r--Sora/Views/Settings/Section/SettingsThumbnailsView.swift45
-rw-r--r--Sora/Views/Settings/SettingsView.swift18
6 files changed, 227 insertions, 156 deletions
diff --git a/Sora/Views/Settings/Section/SettingsDetailsView.swift b/Sora/Views/Settings/Section/SettingsDetailsView.swift
deleted file mode 100644
index 3866994..0000000
--- a/Sora/Views/Settings/Section/SettingsDetailsView.swift
+++ /dev/null
@@ -1,39 +0,0 @@
-import SwiftUI
-
-struct SettingsDetailsView: View {
- @EnvironmentObject var settings: SettingsManager
-
- var body: some View {
- Picker("Image Quality", selection: $settings.detailViewQuality) {
- ForEach(BooruPostFileType.allCases, id: \.self) { type in
- Text(type.rawValue.capitalized).tag(type)
- }
- }
-
- Toggle("Enable \"Share Image\" Shortcut", isOn: $settings.enableShareShortcut)
-
- Toggle("Display Information Bar", isOn: $settings.displayDetailsInformationBar)
-
- #if os(macOS)
- Toggle(isOn: $settings.saveTagsToFile) {
- Text("Save Tags to File")
-
- Text("Saves post tags in a file alongside the downloaded image.")
- }
- #endif
-
- let preloadRange = 0...10
-
- #if os(macOS)
- Picker("Preloaded Images", selection: $settings.preloadedCarouselImages) {
- ForEach(preloadRange, id: \.self) { columns in Text("\(columns)") }
- }
- #else
- Stepper(
- "Preloaded Images: \(settings.preloadedCarouselImages)",
- value: $settings.preloadedCarouselImages,
- in: preloadRange
- )
- #endif
- }
-}
diff --git a/Sora/Views/Settings/Section/SettingsSectionDetailsView.swift b/Sora/Views/Settings/Section/SettingsSectionDetailsView.swift
new file mode 100644
index 0000000..9634297
--- /dev/null
+++ b/Sora/Views/Settings/Section/SettingsSectionDetailsView.swift
@@ -0,0 +1,63 @@
+import SwiftUI
+
+struct SettingsSectionDetailsView: View {
+ @EnvironmentObject var settings: SettingsManager
+
+ var body: some View {
+ Form {
+ Section(header: Text("Image Quality")) {
+ Picker("Image Quality", selection: $settings.detailViewQuality) {
+ ForEach(BooruPostFileType.allCases, id: \.self) { type in
+ Text(type.rawValue.capitalized).tag(type)
+ }
+ }
+ }
+
+ Section(header: Text("Display Options")) {
+ Toggle("Enable \"Share Image\" Shortcut", isOn: $settings.enableShareShortcut)
+
+ Toggle("Display Information Bar", isOn: $settings.displayDetailsInformationBar)
+ }
+
+ #if os(macOS)
+ Section(header: Text("File Management")) {
+ Toggle(isOn: $settings.saveTagsToFile) {
+ Text("Save Tags to File")
+
+ Text("Saves post tags in a file alongside the downloaded image.")
+ }
+ }
+ #endif
+
+ Section(header: Text("Performance")) {
+ let preloadRange = 0...10
+
+ #if os(macOS)
+ Picker("Preloaded Images", selection: $settings.preloadedCarouselImages) {
+ ForEach(preloadRange, id: \.self) { columns in Text("\(columns)") }
+ }
+ #else
+ Stepper(
+ "Preloaded Images: \(settings.preloadedCarouselImages)",
+ value: $settings.preloadedCarouselImages,
+ in: preloadRange
+ )
+ #endif
+ }
+ }
+ #if os(macOS)
+ .formStyle(.grouped)
+ #endif
+ .navigationTitle("Details")
+ #if !os(macOS)
+ .navigationBarTitleDisplayMode(.large)
+ #endif
+ }
+}
+
+#Preview {
+ NavigationStack {
+ SettingsSectionDetailsView()
+ .environmentObject(SettingsManager())
+ }
+}
diff --git a/Sora/Views/Settings/Section/SettingsProviderView.swift b/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
index 82834b9..02c5b02 100644
--- a/Sora/Views/Settings/Section/SettingsProviderView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
@@ -1,6 +1,6 @@
import SwiftUI
-struct SettingsProviderView: View {
+struct SettingsSectionProviderView: View {
@EnvironmentObject var settings: SettingsManager
@State private var showingCustomBooruSheet = false
@State private var newDomain: String = ""
@@ -8,63 +8,103 @@ struct SettingsProviderView: View {
@State private var domainError: String?
var body: some View {
- Group {
- Picker("Provider", selection: $settings.preferredBooru) {
- ForEach(BooruProvider.allCases, id: \.self) { type in
- Text(type.rawValue).tag(type)
- }
+ Form {
+ Section(header: Text("Provider Selection")) {
+ Picker("Provider", selection: $settings.preferredBooru) {
+ ForEach(BooruProvider.allCases, id: \.self) { type in
+ Text(type.rawValue).tag(type)
+ }
- ForEach(settings.customProviders, id: \.id) { provider in
- Text(provider.domain)
- .tag(BooruProvider.custom(provider))
+ ForEach(settings.customProviders, id: \.id) { provider in
+ Text(provider.domain)
+ .tag(BooruProvider.custom(provider))
+ }
}
}
- SecureField(
- "API Key",
- text: Binding(
- get: { settings.providerAPIKeys[settings.preferredBooru] ?? "" },
- set: { updateCredentials(apiKey: $0) }
+ Section(header: Text("API Credentials")) {
+ SecureField(
+ "API Key",
+ text: Binding(
+ get: { settings.providerAPIKeys[settings.preferredBooru] ?? "" },
+ set: { updateCredentials(apiKey: $0) }
+ )
)
- )
- .autocorrectionDisabled(true)
-
- TextField(
- "User ID",
- text: Binding(
- get: {
- String(settings.providerUserIDs[settings.preferredBooru] ?? 0)
- },
- set: { newValue in
- let userID = Int(newValue) ?? 0
-
- updateCredentials(userID: userID)
- }
+ .autocorrectionDisabled(true)
+
+ TextField(
+ "User ID",
+ text: Binding(
+ get: {
+ String(settings.providerUserIDs[settings.preferredBooru] ?? 0)
+ },
+ set: { newValue in
+ let userID = Int(newValue) ?? 0
+
+ updateCredentials(userID: userID)
+ }
+ )
)
- )
- .autocorrectionDisabled(true)
- #if os(iOS)
- .keyboardType(.numberPad)
- #endif
+ .autocorrectionDisabled(true)
+ #if os(iOS)
+ .keyboardType(.numberPad)
+ #endif
+ }
+
+ Section(header: Text("Custom Providers")) {
+ Button("Add Custom Provider") {
+ showingCustomBooruSheet = true
+ }
+ .trailingFrame()
+
+ if case .custom(let provider) = settings.preferredBooru {
+ Button("Remove Custom Provider") {
+ settings.customProviders.removeAll { $0.id == provider.id }
+ settings.preferredBooru = .safebooru
+ }
+ .disabled(!settings.customProviders.contains { $0.id == provider.id })
+ }
+
+ Button("Remove All Custom Providers") {
+ if case .custom = settings.preferredBooru {
+ settings.preferredBooru = .safebooru
+ }
- Button("Add Custom Provider") {
- showingCustomBooruSheet = true
+ if !settings.customProviders.isEmpty {
+ settings.customProviders.removeAll()
+ }
+ }
+ .trailingFrame()
}
- .trailingFrame()
- .sheet(isPresented: $showingCustomBooruSheet) {
+ }
+ #if os(macOS)
+ .formStyle(.grouped)
+ #endif
+ .navigationTitle("Provider")
+ #if !os(macOS)
+ .navigationBarTitleDisplayMode(.large)
+ #endif
+ .sheet(isPresented: $showingCustomBooruSheet) {
+ NavigationStack {
Form {
- TextField("Domain", text: $newDomain)
- .autocorrectionDisabled(true)
+ Section(header: Text("Provider Details")) {
+ TextField("Domain", text: $newDomain)
+ .autocorrectionDisabled(true)
- Picker("Flavor", selection: $newFlavor) {
- ForEach(BooruProviderFlavor.allCases, id: \.self) { flavor in
- Text(flavor.rawValue).tag(flavor)
+ Picker("Flavor", selection: $newFlavor) {
+ ForEach(BooruProviderFlavor.allCases, id: \.self) { flavor in
+ Text(flavor.rawValue).tag(flavor)
+ }
}
}
}
#if os(macOS)
.formStyle(.grouped)
#endif
+ .navigationTitle("Add Custom Provider")
+ #if !os(macOS)
+ .navigationBarTitleDisplayMode(.inline)
+ #endif
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") {
@@ -84,21 +124,6 @@ struct SettingsProviderView: View {
}
}
}
-
- if case .custom(let provider) = settings.preferredBooru {
- removeCustomProviderButtonContent(provider)
- }
-
- Button("Remove All Custom Providers") {
- if case .custom = settings.preferredBooru {
- settings.preferredBooru = .safebooru
- }
-
- if !settings.customProviders.isEmpty {
- settings.customProviders.removeAll()
- }
- }
- .trailingFrame()
}
.alert(
"Invalid Domain",
@@ -196,13 +221,11 @@ struct SettingsProviderView: View {
settings.providerCredentials = allCredentials
}
+}
- private func removeCustomProviderButtonContent(_ provider: BooruProviderCustom) -> some View {
- Button("Remove Custom Provider") {
- settings.customProviders.removeAll { $0.id == provider.id }
- settings.preferredBooru = .safebooru
- }
- .disabled(!settings.customProviders.contains { $0.id == provider.id })
- .trailingFrame()
+#Preview {
+ NavigationStack {
+ SettingsSectionProviderView()
+ .environmentObject(SettingsManager())
}
}
diff --git a/Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift b/Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift
new file mode 100644
index 0000000..27c4676
--- /dev/null
+++ b/Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift
@@ -0,0 +1,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) {
+ SettingsContentRatingsView()
+ .frame(minHeight: 250)
+ }
+ .trailingFrame()
+ #else
+ NavigationLink(destination: SettingsContentRatingsView()) {
+ Text("Content Filtering")
+ }
+ #endif
+ }
+ }
+ #if os(macOS)
+ .formStyle(.grouped)
+ #endif
+ .navigationTitle("Thumbnails")
+ #if !os(macOS)
+ .navigationBarTitleDisplayMode(.large)
+ #endif
+ }
+}
+
+#Preview {
+ NavigationStack {
+ SettingsSectionThumbnailsView()
+ .environmentObject(SettingsManager())
+ }
+}
diff --git a/Sora/Views/Settings/Section/SettingsThumbnailsView.swift b/Sora/Views/Settings/Section/SettingsThumbnailsView.swift
deleted file mode 100644
index 910debb..0000000
--- a/Sora/Views/Settings/Section/SettingsThumbnailsView.swift
+++ /dev/null
@@ -1,45 +0,0 @@
-import SwiftUI
-
-struct SettingsThumbnailsView: View {
- @EnvironmentObject var settings: SettingsManager
- @State private var isShowingContentFiltering = false
-
- var body: some View {
- Picker("Thumbnail Quality", selection: $settings.thumbnailQuality) {
- ForEach(BooruPostFileType.allCases, id: \.self) { type in
- Text(type.rawValue.capitalized).tag(type)
- }
- }
-
- #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)
-
- #if os(macOS)
- Button("Content Filtering") {
- isShowingContentFiltering.toggle()
- }
- .sheet(isPresented: $isShowingContentFiltering) {
- SettingsContentRatingsView()
- .frame(minHeight: 250)
- }
- .trailingFrame()
- #else
- NavigationLink(destination: SettingsContentRatingsView()) {
- Text("Content Filtering")
- }
- #endif
- }
-}
diff --git a/Sora/Views/Settings/SettingsView.swift b/Sora/Views/Settings/SettingsView.swift
index 3315301..6c034e3 100644
--- a/Sora/Views/Settings/SettingsView.swift
+++ b/Sora/Views/Settings/SettingsView.swift
@@ -4,16 +4,18 @@ struct SettingsView: View {
var body: some View {
NavigationStack {
Form {
- Section(header: Text("Provider")) {
- SettingsProviderView()
- }
+ Section(header: Text("Appearance & Behavior")) {
+ NavigationLink(destination: SettingsSectionProviderView()) {
+ Text("Provider Settings")
+ }
- Section(header: Text("Thumbnails")) {
- SettingsThumbnailsView()
- }
+ NavigationLink(destination: SettingsSectionThumbnailsView()) {
+ Text("Thumbnail Settings")
+ }
- Section(header: Text("Details")) {
- SettingsDetailsView()
+ NavigationLink(destination: SettingsSectionDetailsView()) {
+ Text("Details Settings")
+ }
}
Section(header: Text("Search")) {