From e65c57dbaaf07ba4ac9d88fc8cd26ed26e21005c Mon Sep 17 00:00:00 2001 From: Toxblh Date: Tue, 24 Apr 2018 22:53:56 +0100 Subject: [PATCH] If level a battery less 10% it will be red. --- MTMR/Widgets/BatteryBarItem.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/MTMR/Widgets/BatteryBarItem.swift b/MTMR/Widgets/BatteryBarItem.swift index 296cdc1..1517266 100644 --- a/MTMR/Widgets/BatteryBarItem.swift +++ b/MTMR/Widgets/BatteryBarItem.swift @@ -130,6 +130,19 @@ class BatteryInfo: NSObject { title += String(current) + "%" + timeRemaining button?.title = title + + if current < 10 && ACPower != "AC Power" { + let pstyle = NSMutableParagraphStyle() + pstyle.alignment = .center + + button?.attributedTitle = NSMutableAttributedString( + string: title, + attributes: [ + NSAttributedStringKey.foregroundColor: NSColor.red, + NSAttributedStringKey.paragraphStyle: pstyle, + NSAttributedStringKey.font: NSFont.systemFont(ofSize: 16) + ]) + } } }