Skip to content

Commit

Permalink
Remove UserSettings.shared
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jan 21, 2025
1 parent eb9215c commit f9c77e7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/ShowyEdge/swift/IndicatorsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnyCancellable>()
Expand Down Expand Up @@ -93,7 +93,7 @@ class IndicatorsController {
w.collectionBehavior.insert(.ignoresCycle)
w.collectionBehavior.insert(.stationary)
w.contentView = NSHostingView(
rootView: IndicatorView()
rootView: IndicatorView(userSettings: userSettings)
.openSettingsAccess()
)

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/ShowyEdge/swift/UserSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion src/ShowyEdge/swift/Views/IndicatorView.swift
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/ShowyEdge/swift/Views/Settings/SettingsMainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f9c77e7

Please sign in to comment.