Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
colors finally work
Browse files Browse the repository at this point in the history
  • Loading branch information
andylin2004 committed Apr 3, 2023
1 parent 18487dc commit 5704804
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"colors" : [
{
"color" : {
"platform" : "universal",
"reference" : "labelColor"
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"color" : {
"platform" : "universal",
"reference" : "systemYellowColor"
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"color" : {
"platform" : "universal",
"reference" : "labelColor"
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"platform" : "universal",
"reference" : "systemYellowColor"
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
29 changes: 26 additions & 3 deletions Low-Power-Mode-Toggler/Low_Power_Mode_TogglerApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
if let internalBattery = internalFinder.getInternalBattery(){
isLowPowerEnabled = ProcessInfo.processInfo.isLowPowerModeEnabled
menuItem.state = isLowPowerEnabled ? .on : .off
if ProcessInfo.processInfo.isLowPowerModeEnabled{
let attributes = [NSAttributedString.Key.font: NSFont.systemFont(ofSize: 11), NSAttributedString.Key.foregroundColor: NSColor.systemYellow]
if ProcessInfo.processInfo.isLowPowerModeEnabled {
let attributes = [NSAttributedString.Key.font: NSFont.systemFont(ofSize: 11), .backgroundColor: NSColor(named: "menuBarBackgroundColor"), .foregroundColor: NSColor(named: "menuBarForegroundColor")]
let str = NSAttributedString(string: "\(Int(internalBattery.charge ?? 0))%", attributes: attributes)
statusItem.button?.attributedTitle = str
if internalBattery.charge ?? 0 == 80 && batteryPercentage <= 79 {
changePowerMode()
notifCenter.getNotificationSettings(completionHandler: {(settings) in
if settings.authorizationStatus == .authorized{
let request = UNNotificationRequest(identifier: self.chargedEnoughNotifId, content: self.chargedEnoughNotification, trigger: self.notifTrigger)
Expand Down Expand Up @@ -210,7 +211,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
NSApp.windows.last?.orderFrontRegardless()
}

@objc public func powerSourceUpdate(_: AnyObject){
@objc public func powerSourceUpdate(_: AnyObject) {
DispatchQueue.main.async {
self.updateBatteryInBar()
}
Expand Down Expand Up @@ -273,3 +274,25 @@ extension Acknowledgement: Hashable {
return lhs.title == rhs.title
}
}

class RoundedMenuItemView: NSView {
override func draw(_ dirtyRect: NSRect) {
// Draw the rounded background
let cornerRadius: CGFloat = 10
let backgroundRect = NSBezierPath(roundedRect: dirtyRect, xRadius: cornerRadius, yRadius: cornerRadius)
NSColor.red.setFill()
backgroundRect.fill()

// Draw the attributed string
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .center
let attributes: [NSAttributedString.Key: Any] = [
.foregroundColor: NSColor.white,
.font: NSFont.systemFont(ofSize: 12),
.paragraphStyle: paragraphStyle
]
let attributedTitle = NSAttributedString(string: "deez", attributes: attributes)
let titleRect = NSRect(x: dirtyRect.origin.x + 10, y: dirtyRect.origin.y, width: dirtyRect.size.width - 20, height: dirtyRect.size.height)
attributedTitle.draw(in: titleRect)
}
}

0 comments on commit 5704804

Please sign in to comment.