fix: fixed different percentage rounding in the Disk popup and widget (#2560)

This commit is contained in:
Serhiy Mytrovtsiy
2025-08-26 18:26:08 +02:00
parent f9bcf5a6e9
commit 37701ac9da
2 changed files with 2 additions and 2 deletions

View File

@@ -685,7 +685,7 @@ internal class LegendView: NSView {
if self.showUsedSpace {
percentage = Int((Double(self.size - free) / Double(self.size)) * 100)
} else {
percentage = Int((Double(free) / Double(self.size)) * 100)
percentage = Int((Double(free) / Double(self.size)).rounded(toPlaces: 2) * 100)
}
return "\(percentage < 0 ? 0 : percentage)%"

View File

@@ -70,7 +70,7 @@ public struct DiskWidget: Widget {
GeometryReader { geometry in
if let anchor = chartProxy.plotFrame {
let frame = geometry[anchor]
Text("\(Int((100*(value.size-value.free))/value.size))%")
Text("\(Int(value.percentage.rounded(toPlaces: 2) * 100))%")
.font(.system(size: 16, weight: .regular))
.position(x: frame.midX, y: frame.midY-5)
Text("Disk")