forked from NeoFreeBird/tweak
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBHDimPalette.m
More file actions
49 lines (40 loc) · 1.32 KB
/
BHDimPalette.m
File metadata and controls
49 lines (40 loc) · 1.32 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// BHDimPalette.m
// NeoFreeBird
//
// Created by nyaathea
//
#import "BHDimPalette.h"
#import <objc/runtime.h>
// Interface declaration for Twitter's internal classes
@interface TAETwitterColorPaletteSettingInfo : NSObject
@property(readonly, nonatomic) BOOL isDark;
@property(readonly, copy, nonatomic) NSString *name;
@end
@interface TAEColorSettings : NSObject
+ (instancetype)sharedSettings;
- (id)currentColorPalette;
@end
@implementation BHDimPalette
+ (BOOL)isDimMode {
TAETwitterColorPaletteSettingInfo *paletteInfo = (TAETwitterColorPaletteSettingInfo *)[[objc_getClass("TAEColorSettings") sharedSettings] currentColorPalette];
// Check if we're in dim mode by checking palette info
if ([paletteInfo respondsToSelector:@selector(isDark)] && [paletteInfo isDark]) {
// Access _name using KVC since name property might not be directly accessible
NSString *name = [paletteInfo valueForKey:@"_name"];
return [name isEqualToString:@"dark"];
}
return NO;
}
+ (UIColor *)currentBackgroundColor {
if ([self isDimMode]) {
return [self dimModeColor];
} else {
return [UIColor systemBackgroundColor];
}
}
+ (UIColor *)dimModeColor {
// Twitter's dim dark mode color (#15202b)
return [UIColor colorWithRed:0.082 green:0.125 blue:0.169 alpha:1.0];
}
@end