Skip to content

Commit

Permalink
Circular reference
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuzukihashi committed Apr 18, 2020
1 parent e919344 commit b4d4ed9
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions Sources/NeumorphismManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,33 @@ public class NeumorphismManager: NeumorphismManagable, ObservableObject {
}

public func setLightColor(color: Color) {
self.lightColor = color

if !isDark {
self.color = color
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.lightColor = color

if !self.isDark {
self.color = color
}
}
}

public func setDarkColor(color: Color) {
self.darkColor = color

if isDark {
self.color = color
}
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.darkColor = color

if self.isDark {
self.color = color
}
}
}

public func changeMode() {
isDark.toggle()
color = isDark ? darkColor : lightColor
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.isDark.toggle()
self.color = self.isDark ? self.darkColor : self.lightColor
}
UserDefaults.standard.set(isDark, forKey: "isDark")
}

Expand Down

0 comments on commit b4d4ed9

Please sign in to comment.