From c4f02ff78fa5973066cf04bdc049344b73916120 Mon Sep 17 00:00:00 2001 From: nimbold <11913706+nimbold@users.noreply.github.com> Date: Wed, 3 Jun 2026 05:17:17 +0330 Subject: [PATCH] fix: remove unused showMenuBarIcon from AppSettings and conditionally apply theme backgrounds --- Sources/Firelink/AppSettings.swift | 8 -------- Sources/Firelink/ContentView.swift | 6 ++---- Sources/Firelink/SettingsView.swift | 2 +- Sources/Firelink/Theme.swift | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Sources/Firelink/AppSettings.swift b/Sources/Firelink/AppSettings.swift index 3ef5588..fc00bfa 100644 --- a/Sources/Firelink/AppSettings.swift +++ b/Sources/Firelink/AppSettings.swift @@ -76,10 +76,6 @@ final class AppSettings: ObservableObject { @Published var listRowDensity: ListRowDensity = .standard { didSet { save() } } - - @Published var showMenuBarIcon: Bool = true { - didSet { save() } - } @Published var perServerConnections: Int { didSet { @@ -148,7 +144,6 @@ final class AppSettings: ObservableObject { appTheme = stored.appTheme ?? .system appFontSize = stored.appFontSize ?? .standard listRowDensity = stored.listRowDensity ?? .standard - showMenuBarIcon = stored.showMenuBarIcon ?? true perServerConnections = min(max(stored.perServerConnections, 1), 16) maxConcurrentDownloads = min(max(stored.maxConcurrentDownloads ?? 3, 1), 12) globalSpeedLimitKiBPerSecond = min(max(stored.globalSpeedLimitKiBPerSecond ?? 0, 0), 10_485_760) @@ -160,7 +155,6 @@ final class AppSettings: ObservableObject { appTheme = .system appFontSize = .standard listRowDensity = .standard - showMenuBarIcon = true perServerConnections = 16 maxConcurrentDownloads = 3 globalSpeedLimitKiBPerSecond = 0 @@ -245,7 +239,6 @@ final class AppSettings: ObservableObject { appTheme: appTheme, appFontSize: appFontSize, listRowDensity: listRowDensity, - showMenuBarIcon: showMenuBarIcon, perServerConnections: perServerConnections, maxConcurrentDownloads: maxConcurrentDownloads, globalSpeedLimitKiBPerSecond: globalSpeedLimitKiBPerSecond, @@ -308,7 +301,6 @@ private struct StoredSettings: Codable { var appTheme: AppTheme? var appFontSize: AppFontSize? var listRowDensity: ListRowDensity? - var showMenuBarIcon: Bool? var perServerConnections: Int var maxConcurrentDownloads: Int? var globalSpeedLimitKiBPerSecond: Int? diff --git a/Sources/Firelink/ContentView.swift b/Sources/Firelink/ContentView.swift index 6c3376f..9a0ed14 100644 --- a/Sources/Firelink/ContentView.swift +++ b/Sources/Firelink/ContentView.swift @@ -13,12 +13,10 @@ struct ContentView: View { NavigationSplitView { SidebarView(selection: $sidebarSelection) .navigationSplitViewColumnWidth(min: 190, ideal: 220, max: 260) - .scrollContentBackground(.hidden) - .background(settings.appTheme.theme.secondaryBackground ?? Color(NSColor.windowBackgroundColor)) + .themeBackground(settings.appTheme.theme.secondaryBackground) } detail: { detailView - .scrollContentBackground(.hidden) - .background(settings.appTheme.theme.background ?? Color(NSColor.windowBackgroundColor)) + .themeBackground(settings.appTheme.theme.background) } } diff --git a/Sources/Firelink/SettingsView.swift b/Sources/Firelink/SettingsView.swift index d9c88b6..8a9357e 100644 --- a/Sources/Firelink/SettingsView.swift +++ b/Sources/Firelink/SettingsView.swift @@ -73,7 +73,7 @@ struct SettingsView: View { } } .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) - .background(settings.appTheme.theme.background ?? Color(NSColor.windowBackgroundColor)) + .themeBackground(settings.appTheme.theme.background) } private var settingsSidebar: some View { diff --git a/Sources/Firelink/Theme.swift b/Sources/Firelink/Theme.swift index 85738bf..a48b15e 100644 --- a/Sources/Firelink/Theme.swift +++ b/Sources/Firelink/Theme.swift @@ -118,3 +118,23 @@ struct AppThemeModifier: ViewModifier { } } } + +struct ThemeBackgroundModifier: ViewModifier { + let color: Color? + + func body(content: Content) -> some View { + if let color { + content + .scrollContentBackground(.hidden) + .background(color) + } else { + content + } + } +} + +extension View { + func themeBackground(_ color: Color?) -> some View { + modifier(ThemeBackgroundModifier(color: color)) + } +}