-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.m
More file actions
27 lines (22 loc) · 806 Bytes
/
Utils.m
File metadata and controls
27 lines (22 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Copyright (c) 2024 Nightwind
*/
#import <UIKit/UIColor.h>
#import <GcUniversal/GcColorPickerUtils.h>
UIColor *const colorForKey(NSString *const key) {
NSDictionary *const prefs = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.nightwind.musicplayercontrolscolorsettings.plist"];
NSString *const hexString = [prefs objectForKey:key];
if (!hexString) return [UIColor whiteColor];
unsigned rgbValue = 0;
NSScanner *const scanner = [NSScanner scannerWithString:hexString];
if ([hexString hasPrefix:@"#"]) {
scanner.scanLocation = 1;
}
[scanner scanHexInt:&rgbValue];
return [UIColor
colorWithRed:((rgbValue >> 24) & 0xFF) / 255.0
green:((rgbValue >> 16) & 0xFF) / 255.0
blue:((rgbValue >> 8) & 0xFF) / 255.0
alpha:(rgbValue & 0xFF) / 255.0
];
}