mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: now few widgets can be enabled for one module
This commit is contained in:
@@ -95,9 +95,6 @@ public class Network: Module {
|
||||
}
|
||||
}
|
||||
|
||||
self.usageReader?.readyCallback = { [unowned self] in
|
||||
self.readyHandler()
|
||||
}
|
||||
self.usageReader?.callbackHandler = { [unowned self] value in
|
||||
self.usageCallback(value)
|
||||
}
|
||||
@@ -131,16 +128,19 @@ public class Network: Module {
|
||||
return list.count > 0
|
||||
}
|
||||
|
||||
private func usageCallback(_ value: Network_Usage?) {
|
||||
guard let value = value else {
|
||||
private func usageCallback(_ raw: Network_Usage?) {
|
||||
guard let value = raw else {
|
||||
return
|
||||
}
|
||||
|
||||
self.popupView.usageCallback(value)
|
||||
if let widget = self.widget as? SpeedWidget {
|
||||
widget.setValue(upload: value.bandwidth.upload, download: value.bandwidth.download)
|
||||
} else if let widget = self.widget as? NetworkChart {
|
||||
widget.setValue(upload: Double(value.bandwidth.upload), download: Double(value.bandwidth.download))
|
||||
|
||||
self.widgets.filter{ $0.isActive }.forEach { (w: Widget) in
|
||||
switch w.item {
|
||||
case let widget as SpeedWidget: widget.setValue(upload: value.bandwidth.upload, download: value.bandwidth.download)
|
||||
case let widget as NetworkChart: widget.setValue(upload: Double(value.bandwidth.upload), download: Double(value.bandwidth.download))
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user