diff --git a/src/ShowyEdge/swift/IndicatorsController.swift b/src/ShowyEdge/swift/IndicatorsController.swift index 92ba594..4cbe626 100644 --- a/src/ShowyEdge/swift/IndicatorsController.swift +++ b/src/ShowyEdge/swift/IndicatorsController.swift @@ -3,7 +3,7 @@ import SettingsAccess import SwiftUI class IndicatorsController { - var userSettings: UserSettings + private var userSettings: UserSettings private var windows: [NSWindow] = [] private var cancellables = Set() @@ -93,7 +93,7 @@ class IndicatorsController { w.collectionBehavior.insert(.ignoresCycle) w.collectionBehavior.insert(.stationary) w.contentView = NSHostingView( - rootView: IndicatorView() + rootView: IndicatorView(userSettings: userSettings) .openSettingsAccess() ) @@ -253,7 +253,7 @@ class IndicatorsController { // check customized language color let inputsourceid = WorkspaceData.shared.currentInputSourceID - if let colors = UserSettings.shared.customizedLanguageColor(inputSourceID: inputsourceid) { + if let colors = userSettings.customizedLanguageColor(inputSourceID: inputsourceid) { setColors(colors) return } @@ -337,7 +337,7 @@ class IndicatorsController { // Calculate opacity // - var opacity = Double(UserSettings.shared.indicatorOpacity) / 100 + var opacity = Double(userSettings.indicatorOpacity) / 100 windows.forEach { w in // If indicator size is too large, set transparency in order to avoid the indicator hides all windows. diff --git a/src/ShowyEdge/swift/UserSettings.swift b/src/ShowyEdge/swift/UserSettings.swift index b029192..9a1b118 100644 --- a/src/ShowyEdge/swift/UserSettings.swift +++ b/src/ShowyEdge/swift/UserSettings.swift @@ -21,7 +21,6 @@ enum CustomFrameUnit: Int { } final class UserSettings: ObservableObject { - static let shared = UserSettings() static let showMenuSettingChanged = Notification.Name("ShowMenuSettingChanged") static let indicatorConfigurationChanged = Notification.Name("IndicatorConfigurationChanged") diff --git a/src/ShowyEdge/swift/Views/IndicatorView.swift b/src/ShowyEdge/swift/Views/IndicatorView.swift index 406c479..b79aea9 100644 --- a/src/ShowyEdge/swift/Views/IndicatorView.swift +++ b/src/ShowyEdge/swift/Views/IndicatorView.swift @@ -1,7 +1,7 @@ import SwiftUI struct IndicatorView: View { - @ObservedObject private var userSettings = UserSettings.shared + @ObservedObject var userSettings: UserSettings @ObservedObject private var indicatorColors = IndicatorColors.shared var body: some View { diff --git a/src/ShowyEdge/swift/Views/Settings/SettingsCustomFrameView.swift b/src/ShowyEdge/swift/Views/Settings/SettingsCustomFrameView.swift index 3694519..bebe389 100644 --- a/src/ShowyEdge/swift/Views/Settings/SettingsCustomFrameView.swift +++ b/src/ShowyEdge/swift/Views/Settings/SettingsCustomFrameView.swift @@ -1,7 +1,7 @@ import SwiftUI struct SettingsCustomFrameView: View { - @ObservedObject private var userSettings = UserSettings.shared + @EnvironmentObject private var userSettings: UserSettings var body: some View { VStack(alignment: .leading, spacing: 25.0) { diff --git a/src/ShowyEdge/swift/Views/Settings/SettingsIndicatorView.swift b/src/ShowyEdge/swift/Views/Settings/SettingsIndicatorView.swift index 9125d8f..fa2eb67 100644 --- a/src/ShowyEdge/swift/Views/Settings/SettingsIndicatorView.swift +++ b/src/ShowyEdge/swift/Views/Settings/SettingsIndicatorView.swift @@ -1,7 +1,7 @@ import SwiftUI struct SettingsIndicatorView: View { - @ObservedObject private var userSettings = UserSettings.shared + @EnvironmentObject private var userSettings: UserSettings var body: some View { VStack(alignment: .leading, spacing: 25.0) { diff --git a/src/ShowyEdge/swift/Views/Settings/SettingsMainView.swift b/src/ShowyEdge/swift/Views/Settings/SettingsMainView.swift index 86620b4..c7918c9 100644 --- a/src/ShowyEdge/swift/Views/Settings/SettingsMainView.swift +++ b/src/ShowyEdge/swift/Views/Settings/SettingsMainView.swift @@ -3,7 +3,7 @@ import SwiftUI struct SettingsMainView: View { @Binding var showMenuBarExtra: Bool - @ObservedObject private var userSettings = UserSettings.shared + @EnvironmentObject private var userSettings: UserSettings @ObservedObject private var openAtLogin = OpenAtLogin.shared @ObservedObject private var workspaceData = WorkspaceData.shared