mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: fixed different percentage rounding in the Disk popup and widget (#2560)
This commit is contained in:
@@ -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)%"
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user