-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathControlCenterAirPlaySectionView.xm
56 lines (50 loc) · 2.73 KB
/
ControlCenterAirPlaySectionView.xm
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
#import "headers.h"
@implementation ControlCenterAirPlaySectionView
-(id)initWithFrame:(CGRect)frame {
frame = CGRectMake(frame.origin.x + 20, frame.origin.y, frame.size.width - 40, frame.size.height);
self = [super initWithFrame:frame];
if (self != nil) {
_airPlayController = [[objc_getClass("CCUIAirStuffSectionController") alloc] init];
[_airPlayController setDelegate:self];
_airPlayController.view.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
[self addSubview:[_airPlayController view]];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
UIAlertController *_airDropAlertController = (UIAlertController *)[_airPlayController valueForKey:@"_airDropAlertController"];
[_airDropAlertController setPreferredStyle:UIAlertControllerStyleAlert];
}
}
return self;
}
-(void)dealloc {
[_airPlayController release];
[super dealloc];
}
@end
%hook CCUIControlCenterButton
-(void)layoutSubviews {
%orig();
if ([self superview] != nil && ([[[self superview] class] isEqual:[ControlCenterAirPlaySectionView class]] || ([[self superview] superview] != nil && [[[[self superview] superview] class] isEqual:[ControlCenterAirPlaySectionView class]]))) {
if (UIInterfaceOrientationIsPortrait([[%c(SpringBoard) sharedApplication] activeInterfaceOrientation])) {
if ([SCPreferences sharedInstance].isPortraitNightAndAirLabelsHidden) {
UIView *parent = [self superview];
if ([[parent class] isEqual:[ControlCenterAirPlaySectionView class]] || [[[parent superview] class] isEqual:[ControlCenterAirPlaySectionView class]]) {
[(UILabel *)[self valueForKey:@"_label"] setHidden:YES];
[(UILabel *)[self valueForKey:@"_alteredStateLabel"] setHidden:YES];
((UIImageView *)[self valueForKey:@"_glyphImageView"]).center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
((UIImageView *)[self valueForKey:@"_alteredStateGlyphImageView"]).center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
}
}
} else {
if ([SCPreferences sharedInstance].isLandscapeNightAndAirLabelsHidden) {
UIView *parent = [self superview];
if ([[parent class] isEqual:[ControlCenterAirPlaySectionView class]] || [[[parent superview] class] isEqual:[ControlCenterAirPlaySectionView class]]) {
[(UILabel *)[self valueForKey:@"_label"] setHidden:YES];
[(UILabel *)[self valueForKey:@"_alteredStateLabel"] setHidden:YES];
((UIImageView *)[self valueForKey:@"_glyphImageView"]).center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
((UIImageView *)[self valueForKey:@"_alteredStateGlyphImageView"]).center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
}
}
}
}
}
%end