mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: changed the way of how widget could be enabled/disabled. Drag the widget to enable or disable it.
This commit is contained in:
@@ -266,8 +266,17 @@ public class Widget {
|
||||
}
|
||||
|
||||
// toggle the widget
|
||||
public func toggle() {
|
||||
self.isActive = !self.isActive
|
||||
public func toggle(_ state: Bool? = nil) {
|
||||
var newState: Bool = !self.isActive
|
||||
if let state = state {
|
||||
newState = state
|
||||
}
|
||||
|
||||
if self.isActive == newState {
|
||||
return
|
||||
}
|
||||
|
||||
self.isActive = newState
|
||||
|
||||
if !self.isActive {
|
||||
self.disable()
|
||||
|
||||
Reference in New Issue
Block a user