Skip to content

Commit

Permalink
Fixing color scheme change for macOS Sonoma
Browse files Browse the repository at this point in the history
  • Loading branch information
DamascenoRafael committed Sep 30, 2023
1 parent f6e41d6 commit 4e2a2ea
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
6 changes: 0 additions & 6 deletions reminders-menubar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {

changeBehaviorToDismissIfNeeded()
configurePopover()
configureAppColorScheme()
configureMenuBarButton()
configureKeyboardShortcut()
configureDidCloseNotification()
Expand All @@ -55,11 +54,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

func configureAppColorScheme() {
let colorScheme = UserPreferences.shared.rmbColorScheme
NSApplication.shared.appearance = colorScheme.nsAppearance
}

func updateMenuBarTodayCount(to todayCount: Int) {
let buttonTitle = todayCount > 0 ? String(todayCount) : ""
statusBarItem.button?.title = buttonTitle
Expand Down
6 changes: 3 additions & 3 deletions reminders-menubar/Resources/RmbColorScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ enum RmbColorScheme: String {
case light
case dark

var nsAppearance: NSAppearance? {
var colorScheme: ColorScheme? {
switch self {
case .system:
return nil
case .light:
return NSAppearance(named: .aqua)
return .light
case .dark:
return NSAppearance(named: .darkAqua)
return .dark
}
}
}
1 change: 1 addition & 0 deletions reminders-menubar/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct ContentView: View {
SettingsBarView()
}
.background(Color.rmbColor(for: .backgroundTheme, and: colorSchemeContrast).padding(-80))
.preferredColorScheme(userPreferences.rmbColorScheme.colorScheme)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,23 @@ struct SettingsBarGearMenu: View {
func appAppearanceMenu() -> some View {
Menu {
Button(action: {
changeColorScheme(to: .system)
userPreferences.rmbColorScheme = .system
}) {
let isSelected = userPreferences.rmbColorScheme == .system
SelectableView(title: rmbLocalized(.appAppearanceColorSystemModeOptionButton),
isSelected: isSelected)
}

Button(action: {
changeColorScheme(to: .light)
userPreferences.rmbColorScheme = .light
}) {
let isSelected = userPreferences.rmbColorScheme == .light
SelectableView(title: rmbLocalized(.appAppearanceColorLightModeOptionButton),
isSelected: isSelected)
}

Button(action: {
changeColorScheme(to: .dark)
userPreferences.rmbColorScheme = .dark
}) {
let isSelected = userPreferences.rmbColorScheme == .dark
SelectableView(title: rmbLocalized(.appAppearanceColorDarkModeOptionButton),
Expand Down Expand Up @@ -217,11 +217,6 @@ struct SettingsBarGearMenu: View {
Text(rmbLocalized(.preferredLanguageMenu))
}
}

func changeColorScheme(to rmbColorScheme: RmbColorScheme) {
userPreferences.rmbColorScheme = rmbColorScheme
AppDelegate.shared.configureAppColorScheme()
}
}

struct SettingsBarGearMenu_Previews: PreviewProvider {
Expand Down

0 comments on commit 4e2a2ea

Please sign in to comment.