summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sora/Extensions/View.swift12
-rw-r--r--Sora/Views/Settings/Section/SettingsDebugView.swift8
-rw-r--r--Sora/Views/Settings/Section/SettingsImportExportView.swift2
-rw-r--r--Sora/Views/Settings/Section/SettingsProviderView.swift12
-rw-r--r--Sora/Views/Settings/Section/SettingsSearchView.swift8
-rw-r--r--Sora/Views/Settings/Section/SettingsSettingsView.swift4
-rw-r--r--Sora/Views/Settings/Section/SettingsThumbnailsView.swift2
7 files changed, 22 insertions, 26 deletions
diff --git a/Sora/Extensions/View.swift b/Sora/Extensions/View.swift
new file mode 100644
index 0000000..1edfcde
--- /dev/null
+++ b/Sora/Extensions/View.swift
@@ -0,0 +1,12 @@
+import SwiftUI
+
+extension View {
+ @ViewBuilder
+ func trailingFrame() -> some View {
+ #if os(macOS)
+ self.frame(maxWidth: .infinity, alignment: .trailing)
+ #else
+ self
+ #endif
+ }
+}
diff --git a/Sora/Views/Settings/Section/SettingsDebugView.swift b/Sora/Views/Settings/Section/SettingsDebugView.swift
index 368676b..ef817a3 100644
--- a/Sora/Views/Settings/Section/SettingsDebugView.swift
+++ b/Sora/Views/Settings/Section/SettingsDebugView.swift
@@ -11,9 +11,7 @@ struct SettingsDebugView: View {
}) {
Text("Add Dummy Bookmarks")
}
- #if os(macOS)
- .frame(maxWidth: .infinity, alignment: .trailing)
- #endif
+ .trailingFrame()
Button(action: {
#if DEBUG
@@ -22,8 +20,6 @@ struct SettingsDebugView: View {
}) {
Text("Add Dummy Search History")
}
- #if os(macOS)
- .frame(maxWidth: .infinity, alignment: .trailing)
- #endif
+ .trailingFrame()
}
}
diff --git a/Sora/Views/Settings/Section/SettingsImportExportView.swift b/Sora/Views/Settings/Section/SettingsImportExportView.swift
index 1abf457..d9f23b7 100644
--- a/Sora/Views/Settings/Section/SettingsImportExportView.swift
+++ b/Sora/Views/Settings/Section/SettingsImportExportView.swift
@@ -24,7 +24,7 @@ struct SettingsImportExportView: View {
}
}
#if os(macOS)
- .frame(maxWidth: .infinity, alignment: .trailing)
+ .trailingFrame()
.fileExporter(
isPresented: $isFileExporterPresented,
document: try? JSONFileDocument(settings.exportBookmarks()),
diff --git a/Sora/Views/Settings/Section/SettingsProviderView.swift b/Sora/Views/Settings/Section/SettingsProviderView.swift
index 79ea146..606fe64 100644
--- a/Sora/Views/Settings/Section/SettingsProviderView.swift
+++ b/Sora/Views/Settings/Section/SettingsProviderView.swift
@@ -23,9 +23,7 @@ struct SettingsProviderView: View {
Button("Add Custom Provider") {
showingCustomBooruSheet = true
}
- #if os(macOS)
- .frame(maxWidth: .infinity, alignment: .trailing)
- #endif
+ .trailingFrame()
.sheet(isPresented: $showingCustomBooruSheet) {
Form {
TextField("Domain", text: $newDomain)
@@ -73,9 +71,7 @@ struct SettingsProviderView: View {
settings.customProviders.removeAll()
}
}
- #if os(macOS)
- .frame(maxWidth: .infinity, alignment: .trailing)
- #endif
+ .trailingFrame()
}
.alert(
"Invalid Domain",
@@ -155,8 +151,6 @@ struct SettingsProviderView: View {
settings.preferredBooru = .safebooru
}
.disabled(!settings.customProviders.contains { $0.id == provider.id })
- #if os(macOS)
- .frame(maxWidth: .infinity, alignment: .trailing)
- #endif
+ .trailingFrame()
}
}
diff --git a/Sora/Views/Settings/Section/SettingsSearchView.swift b/Sora/Views/Settings/Section/SettingsSearchView.swift
index fbe1656..062efad 100644
--- a/Sora/Views/Settings/Section/SettingsSearchView.swift
+++ b/Sora/Views/Settings/Section/SettingsSearchView.swift
@@ -21,15 +21,11 @@ struct SettingsSearchView: View {
) {
manager.clearCachedTags()
}
- #if os(macOS)
- .frame(maxWidth: .infinity, alignment: .trailing)
- #endif
+ .trailingFrame()
Button("Clear History") {
settings.searchHistory.removeAll()
}
- #if os(macOS)
- .frame(maxWidth: .infinity, alignment: .trailing)
- #endif
+ .trailingFrame()
}
}
diff --git a/Sora/Views/Settings/Section/SettingsSettingsView.swift b/Sora/Views/Settings/Section/SettingsSettingsView.swift
index 92b1c32..404d252 100644
--- a/Sora/Views/Settings/Section/SettingsSettingsView.swift
+++ b/Sora/Views/Settings/Section/SettingsSettingsView.swift
@@ -7,8 +7,6 @@ struct SettingsSettingsView: View {
Button("Reset to Defaults") {
settings.resetToDefaults()
}
- #if os(macOS)
- .frame(maxWidth: .infinity, alignment: .trailing)
- #endif
+ .trailingFrame()
}
}
diff --git a/Sora/Views/Settings/Section/SettingsThumbnailsView.swift b/Sora/Views/Settings/Section/SettingsThumbnailsView.swift
index 5378165..ddd8b29 100644
--- a/Sora/Views/Settings/Section/SettingsThumbnailsView.swift
+++ b/Sora/Views/Settings/Section/SettingsThumbnailsView.swift
@@ -31,7 +31,7 @@ struct SettingsThumbnailsView: View {
SettingsContentRatingsView()
.frame(minHeight: 250)
}
- .frame(maxWidth: .infinity, alignment: .trailing)
+ .trailingFrame()
#else
NavigationLink(destination: SettingsContentRatingsView()) {
Text("Content Filtering")