-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTweak.x
56 lines (49 loc) · 2.22 KB
/
Tweak.x
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 <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#include <RemoteLog.h>
#import "PiPViewController.h"
BOOL enabled;
PiPViewController *newControlsViewController;
%hook PGPictureInPictureControlsViewController
-(void)_manageControlsSize {
%orig;
PGPlaybackProgressIndicator *progressIndicator = [self valueForKey:@"_playbackProgressIndicator"];
progressIndicator.translatesAutoresizingMaskIntoConstraints = YES;
progressIndicator.frame = CGRectMake(8, self.view.frame.size.height-7, self.view.frame.size.width-16, 4);
progressIndicator.subviews[0].layer.cornerRadius = 2;
UIButton *stopButton = [self valueForKey:@"_stopButton"];
UIButton *actionButton = [self valueForKey:@"_actionButton"];
UIButton *cancelButton = [self valueForKey:@"_cancelButton"];
stopButton.hidden = YES;
actionButton.hidden = YES;
cancelButton.hidden = YES;
if(newControlsViewController) {
[newControlsViewController.view removeFromSuperview];
[newControlsViewController removeFromParentViewController];
}
newControlsViewController = [[PiPViewController alloc] initWithControlsViewController:self];
[self addChildViewController:newControlsViewController];
[self.view addSubview:newControlsViewController.view];
UIView *view = newControlsViewController.view;
[view.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor].active = YES;
[view.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor].active = YES;
[view.widthAnchor constraintEqualToAnchor:self.view.widthAnchor].active = YES;
[view.heightAnchor constraintEqualToAnchor:self.view.heightAnchor].active = YES;
}
-(void)_updateControlsVisibility {
%orig;
BOOL hidden = ![[self valueForKey:@"_showsControls"] boolValue];
[UIView animateWithDuration:0.5 animations: ^{
//the hidden property can't be animated, so I have to use alpha
newControlsViewController.view.alpha = !hidden;
}];
}
%end
static void loadPrefs() {
NSDictionary *prefs = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.galacticdev.14pipprefs.plist"];
enabled = prefs[@"enabled"] ? [prefs[@"enabled"] boolValue] : YES;
}
%ctor {
loadPrefs();
if(enabled) %init;
}