forked from NSExceptional/FLEXing
-
Notifications
You must be signed in to change notification settings - Fork 8
/
SpringBoard.xm
52 lines (45 loc) · 1.29 KB
/
SpringBoard.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
//
// SpringBoard.xm
// FLEXing
//
// Created by Tanner Bennett on 2019-11-25
// Copyright © 2019 Tanner Bennett. All rights reserved.
//
//-------------------------------//
// This file is for iOS 13+ only //
// Credit: DGh0st/FLEXall //
//-------------------------------//
#import "Interfaces.h"
%group iOS13StatusBar
// Runs in SpringBoard; forwards status bar events to app
%hook SBMainDisplaySceneLayoutStatusBarView
- (void)_addStatusBarIfNeeded {
%orig;
UIView *statusBar = [self valueForKey:@"_statusBar"];
[statusBar addGestureRecognizer:[[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(flexGestureHandler:)
]];
}
%new
- (void)flexGestureHandler:(UILongPressGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateBegan) {
[self _statusBarTapped:recognizer type:kFLEXLongPressGesture];
}
}
%end // SBMainDisplaySceneLayoutStatusBarView
// Runs in apps; receives status bar events
%hook UIStatusBarManager
- (void)handleTapAction:(UIStatusBarTapAction *)action {
if (action.type == kFLEXLongPressGesture) {
[manager performSelector:show];
} else {
%orig(action);
}
}
%end // UIStatusBarManager
%end // iOS13StatusBar
%ctor {
if (@available(iOS 13, *)) {
%init(iOS13StatusBar);
}
}