summaryrefslogtreecommitdiff
path: root/Sora/Views/Settings/Section
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-04-01 13:59:52 +0000
committerFuwn <[email protected]>2026-04-01 13:59:52 +0000
commitddaa9cbfe0cc8d254d4901ad192918d91dd627d4 (patch)
treeb0d1cf6642ae97ce41ff570f2bcd4a06b359685e /Sora/Views/Settings/Section
parentFix iOS install recipe app path resolution (diff)
downloadsora-testing-ddaa9cbfe0cc8d254d4901ad192918d91dd627d4.tar.xz
sora-testing-ddaa9cbfe0cc8d254d4901ad192918d91dd627d4.zip
Migrate settings manager to Swift Observation
Diffstat (limited to 'Sora/Views/Settings/Section')
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionContentRatingsView.swift5
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionDebugView.swift3
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionDetailsView.swift7
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionImportExportView.swift3
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionProviderView.swift11
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionSearchView.swift5
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionSettingsView.swift11
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift7
8 files changed, 37 insertions, 15 deletions
diff --git a/Sora/Views/Settings/Section/SettingsSectionContentRatingsView.swift b/Sora/Views/Settings/Section/SettingsSectionContentRatingsView.swift
index 40a8a7e..353824a 100644
--- a/Sora/Views/Settings/Section/SettingsSectionContentRatingsView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionContentRatingsView.swift
@@ -1,7 +1,8 @@
import SwiftUI
struct SettingsSectionContentRatingsView: View {
- @EnvironmentObject var settings: SettingsManager
+ @Environment(SettingsManager.self)
+ private var settings
var body: some View {
List {
@@ -70,5 +71,5 @@ struct SettingsSectionContentRatingsView: View {
#Preview {
SettingsSectionContentRatingsView()
- .environmentObject(SettingsManager())
+ .environment(SettingsManager())
}
diff --git a/Sora/Views/Settings/Section/SettingsSectionDebugView.swift b/Sora/Views/Settings/Section/SettingsSectionDebugView.swift
index 83acb81..c97b545 100644
--- a/Sora/Views/Settings/Section/SettingsSectionDebugView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionDebugView.swift
@@ -1,7 +1,8 @@
import SwiftUI
struct SettingsSectionDebugView: View {
- @EnvironmentObject private var settingsManager: SettingsManager
+ @Environment(SettingsManager.self)
+ private var settingsManager
var body: some View {
Button(action: {
diff --git a/Sora/Views/Settings/Section/SettingsSectionDetailsView.swift b/Sora/Views/Settings/Section/SettingsSectionDetailsView.swift
index 8db6002..c386634 100644
--- a/Sora/Views/Settings/Section/SettingsSectionDetailsView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionDetailsView.swift
@@ -1,9 +1,12 @@
import SwiftUI
struct SettingsSectionDetailsView: View {
- @EnvironmentObject var settings: SettingsManager
+ @Environment(SettingsManager.self)
+ private var settings
var body: some View {
+ @Bindable var settings = settings
+
Form {
Section("Image Quality") {
Picker("Image Quality", selection: $settings.detailViewQuality) {
@@ -58,6 +61,6 @@ struct SettingsSectionDetailsView: View {
#Preview {
NavigationStack {
SettingsSectionDetailsView()
- .environmentObject(SettingsManager())
+ .environment(SettingsManager())
}
}
diff --git a/Sora/Views/Settings/Section/SettingsSectionImportExportView.swift b/Sora/Views/Settings/Section/SettingsSectionImportExportView.swift
index 381b6a4..846e9e5 100644
--- a/Sora/Views/Settings/Section/SettingsSectionImportExportView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionImportExportView.swift
@@ -2,7 +2,8 @@ import SwiftUI
import UniformTypeIdentifiers
struct SettingsSectionImportExportView: View {
- @EnvironmentObject private var settings: SettingsManager
+ @Environment(SettingsManager.self)
+ private var settings
@State private var isFileExporterPresented = false
@State private var isFileImporterPresented = false
@State private var bookmarksExportDocument: JSONFileDocument?
diff --git a/Sora/Views/Settings/Section/SettingsSectionProviderView.swift b/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
index b9a7900..02a8be6 100644
--- a/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
@@ -1,13 +1,16 @@
import SwiftUI
struct SettingsSectionProviderView: View {
- @EnvironmentObject var settings: SettingsManager
+ @Environment(SettingsManager.self)
+ private var settings
@State private var showingCustomBooruSheet = false
@State private var newDomain: String = ""
@State private var newFlavor: BooruProviderFlavor = .danbooru
@State private var domainError: String?
var body: some View {
+ @Bindable var settings = settings
+
Form {
Section("Source") {
Picker("Website", selection: $settings.preferredBooru) {
@@ -173,7 +176,9 @@ struct SettingsSectionProviderView: View {
) {
Button("OK", role: .cancel) { () }
} message: {
- Text(domainError ?? "An unknown error occurred while validating the domain.")
+ if let domainError {
+ Text(domainError)
+ }
}
}
@@ -271,6 +276,6 @@ struct SettingsSectionProviderView: View {
#Preview {
NavigationStack {
SettingsSectionProviderView()
- .environmentObject(SettingsManager())
+ .environment(SettingsManager())
}
}
diff --git a/Sora/Views/Settings/Section/SettingsSectionSearchView.swift b/Sora/Views/Settings/Section/SettingsSectionSearchView.swift
index b702cd4..e82f872 100644
--- a/Sora/Views/Settings/Section/SettingsSectionSearchView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionSearchView.swift
@@ -1,9 +1,12 @@
import SwiftUI
struct SettingsSectionSearchView: View {
- @EnvironmentObject var settings: SettingsManager
+ @Environment(SettingsManager.self)
+ private var settings
var body: some View {
+ @Bindable var settings = settings
+
Picker("Suggestions", selection: $settings.searchSuggestionsMode) {
ForEach(SettingsSearchSuggestionsMode.allCases, id: \.self) { type in
Text(type.rawValue.capitalized).tag(type)
diff --git a/Sora/Views/Settings/Section/SettingsSectionSettingsView.swift b/Sora/Views/Settings/Section/SettingsSectionSettingsView.swift
index 784ee2a..ad7fe83 100644
--- a/Sora/Views/Settings/Section/SettingsSectionSettingsView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionSettingsView.swift
@@ -1,17 +1,22 @@
import SwiftUI
struct SettingsSectionSettingsView: View {
- @EnvironmentObject var settings: SettingsManager
+ @Environment(SettingsManager.self)
+ private var settings
var body: some View {
+ @Bindable var settings = settings
+
Toggle(isOn: $settings.enableSync) {
Text("Sync with iCloud")
Text("Keep bookmarks, collections, search history, and sources in sync across your devices.")
.font(.caption)
}
- .onChange(of: settings.enableSync) { _, _ in
- settings.triggerSyncIfNeededForAll()
+ .onChange(of: settings.enableSync) { _, isEnabled in
+ if isEnabled {
+ settings.triggerSyncIfNeededForAll()
+ }
}
Button("Reset Settings") {
diff --git a/Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift b/Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift
index f8dffc8..dc9d87e 100644
--- a/Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionThumbnailsView.swift
@@ -1,10 +1,13 @@
import SwiftUI
struct SettingsSectionThumbnailsView: View {
- @EnvironmentObject var settings: SettingsManager
+ @Environment(SettingsManager.self)
+ private var settings
@State private var isShowingContentFiltering = false
var body: some View {
+ @Bindable var settings = settings
+
Form {
Section("Image Quality") {
Picker("Thumbnail Quality", selection: $settings.thumbnailQuality) {
@@ -62,6 +65,6 @@ struct SettingsSectionThumbnailsView: View {
#Preview {
NavigationStack {
SettingsSectionThumbnailsView()
- .environmentObject(SettingsManager())
+ .environment(SettingsManager())
}
}