-
Notifications
You must be signed in to change notification settings - Fork 0
/
iKASveaDarkModeModule.mm
71 lines (50 loc) · 2.06 KB
/
iKASveaDarkModeModule.mm
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#import "iKASveaDarkModeModule.h"
@implementation iKASveaDarkModeModule
+(long long)buttonStyle {
return 1;
}
-(id)contentViewController {
self.buttonController = (TVSMButtonViewController*)[super contentViewController];
[self.buttonController setStyle:1];
[self defaultImage];
return self.buttonController;
}
-(void)handleAction {
systemService = [NSClassFromString(@"PBSSystemService") sharedInstance];
if (self.contentViewController.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
[systemService setSystemAppearance:0];
[self changeImageBasedOnSystemAppearance];
}
else {
[systemService setSystemAppearance:1];
[self changeImageBasedOnSystemAppearance];
}
}
-(void)defaultImage {
packageFile = [[self bundle] pathForResource:@"DarkModeOn" ofType:@"png"];
theImage = [[UIImage imageWithContentsOfFile:packageFile] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.buttonController setImage:theImage];
}
-(void)changeImageBasedOnSystemAppearance {
if (self.contentViewController.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
packageFile = [[self bundle] pathForResource:@"DarkModeOff" ofType:@"png"];
theImage = [[UIImage imageWithContentsOfFile:packageFile] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.buttonController setImage:theImage];
if (@available(tvOS 14.0, *)) {
[self.buttonController setToggledOn:FALSE];
}
}
else {
packageFile = [[self bundle] pathForResource:@"DarkModeOn" ofType:@"png"];
theImage = [[UIImage imageWithContentsOfFile:packageFile] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.buttonController setImage:theImage];
if (@available(tvOS 14.0, *)) {
[self.buttonController setToggledOn:TRUE];
[self.buttonController setSymbolTintColor:[UIColor blackColor]];
}
}
}
-(BOOL)dismissAfterAction {
return FALSE;
}
@end