Skip to content

Commit

Permalink
feat: added a new NetworkChartViewV2 chart. Which merges 2 line chart…
Browse files Browse the repository at this point in the history
…s. Moved the disk and network charts in the popup to the new chart.
  • Loading branch information
exelban committed Apr 8, 2024
1 parent c78319b commit f2d9a49
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 175 deletions.
5 changes: 1 addition & 4 deletions Kit/Widgets/NetworkChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ public class NetworkChart: WidgetWrapper {
private var commonScaleState: Bool = true
private var reverseOrderState: Bool = false

private var chart: NetworkChartView = NetworkChartView(
frame: NSRect(x: 0, y: 0, width: 30, height: Constants.Widget.height - (2*Constants.Widget.margin.y)),
num: 60, minMax: false, toolTip: false
)
private var chart: NetworkChartView = NetworkChartView(frame: NSRect(x: 0, y: 0, width: 30, height: Constants.Widget.height-(2*Constants.Widget.margin.y)), num: 60)
private var width: CGFloat {
get {
switch self.historyCount {
Expand Down
299 changes: 139 additions & 160 deletions Kit/plugins/Charts.swift

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Modules/Disk/popup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ internal class NameView: NSStackView {
}

internal class ChartView: NSStackView {
private var chart: NetworkChartView? = nil
private var chart: NetworkChartViewV2? = nil
private var ready: Bool = false

private var readColor: NSColor {
Expand All @@ -436,7 +436,7 @@ internal class ChartView: NSStackView {
self.wantsLayer = true
self.layer?.cornerRadius = 3

let chart = NetworkChartView(frame: NSRect(
let chart = NetworkChartViewV2(frame: NSRect(
x: 0,
y: 1,
width: self.frame.width,
Expand Down
4 changes: 2 additions & 2 deletions Modules/Disk/portal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Kit

public class Portal: PortalWrapper {
private var circle: PieChartView? = nil
private var chart: NetworkChartView? = nil
private var chart: NetworkChartViewV2? = nil

private var nameField: NSTextField? = nil
private var usedField: NSTextField? = nil
Expand Down Expand Up @@ -91,7 +91,7 @@ public class Portal: PortalWrapper {
self.usedField = portalRow(view, title: "\(localizedString("Used")):")
self.freeField = portalRow(view, title: "\(localizedString("Free")):")

let chart = NetworkChartView(frame: NSRect.zero, num: 120, minMax: false, outColor: self.writeColor, inColor: self.readColor)
let chart = NetworkChartViewV2(frame: NSRect.zero, num: 120, minMax: false, outColor: self.writeColor, inColor: self.readColor)
chart.heightAnchor.constraint(equalToConstant: 26).isActive = true
self.chart = chart
view.addArrangedSubview(chart)
Expand Down
7 changes: 3 additions & 4 deletions Modules/Net/popup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal class Popup: PopupWrapper {
private var processesInitialized: Bool = false
private var connectionInitialized: Bool = false

private var chart: NetworkChartView? = nil
private var chart: NetworkChartViewV2? = nil
private var chartScale: Scale = .none
private var connectivityChart: GridChartView? = nil
private var processes: ProcessesView? = nil
Expand Down Expand Up @@ -175,11 +175,10 @@ internal class Popup: PopupWrapper {
container.layer?.backgroundColor = NSColor.lightGray.withAlphaComponent(0.1).cgColor
container.layer?.cornerRadius = 3

let chart = NetworkChartView(
let chart = NetworkChartViewV2(
frame: NSRect(x: 0, y: 1, width: container.frame.width, height: container.frame.height - 2),
num: 120, outColor: self.uploadColor, inColor: self.downloadColor, toolTip: true, scale: self.chartScale
num: 120, reversedOrder: self.reverseOrderState, outColor: self.uploadColor, inColor: self.downloadColor, scale: self.chartScale
)
chart.setReverseOrder(self.reverseOrderState)
chart.base = self.base
container.addSubview(chart)
self.chart = chart
Expand Down
4 changes: 2 additions & 2 deletions Modules/Net/portal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Cocoa
import Kit

public class Portal: PortalWrapper {
private var chart: NetworkChartView? = nil
private var chart: NetworkChartViewV2? = nil

private var publicIPField: NSTextField? = nil

Expand Down Expand Up @@ -73,7 +73,7 @@ public class Portal: PortalWrapper {
view.orientation = .vertical
view.distribution = .fill
view.spacing = Constants.Popup.spacing*2
let chart = NetworkChartView(frame: NSRect.zero, num: 120, minMax: true, outColor: self.uploadColor, inColor: self.downloadColor)
let chart = NetworkChartViewV2(frame: NSRect.zero, num: 120, outColor: self.uploadColor, inColor: self.downloadColor)
self.chart = chart

view.addArrangedSubview(chart)
Expand Down
1 change: 0 additions & 1 deletion Stats/Views/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ class ApplicationSettings: NSStackView {

@objc private func toggleDock(_ sender: NSButton) {
let state = sender.state

Store.shared.set(key: "dockIcon", value: state == NSControl.StateValue.on)
let dockIconStatus = state == NSControl.StateValue.on ? NSApplication.ActivationPolicy.regular : NSApplication.ActivationPolicy.accessory
NSApp.setActivationPolicy(dockIconStatus)
Expand Down

0 comments on commit f2d9a49

Please sign in to comment.