-
Notifications
You must be signed in to change notification settings - Fork 12
/
AppearanceLifeCycle.xm
102 lines (86 loc) · 3.44 KB
/
AppearanceLifeCycle.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#import "HSWidgetPageController.h"
#import "HSWidgetViewController.h"
#import "SBIconController.h"
#import "SBIconListModel.h"
#import "SBIconListView.h"
#import "SBRootFolderController.h"
#import "SpringBoard.h"
%group SimulateAppearanceMethods
%hook SBIconContentView
-(void)setHidden:(BOOL)arg1 {
BOOL didHiddenChange = arg1 != [self isHidden];
%orig(arg1);
if (didHiddenChange) {
SBIconController *iconController = [%c(SBIconController) sharedInstance];
BOOL isShowingHomescreen = [[%c(SpringBoard) sharedApplication] isShowingHomescreen];
[iconController bs_beginAppearanceTransition:(!arg1 || isShowingHomescreen) animated:YES];
[iconController bs_endAppearanceTransition];
}
}
%end
%hook SpringBoard
-(void)_updateHomeScreenPresenceNotification:(id)arg1 {
%orig();
SBIconController *iconController = [%c(SBIconController) sharedInstance];
[iconController bs_beginAppearanceTransition:[self isShowingHomescreen] animated:YES];
[iconController bs_endAppearanceTransition];
}
%end
%end
%hook SBIconController
-(void)viewWillAppear:(BOOL)arg1 {
%orig(arg1);
SBRootFolderController *rootFolderController = [self _rootFolderController];
for (SBIconListView *iconListView in rootFolderController.iconListViews) {
SBIconListModel *model = [iconListView valueForKey:@"_model"];
for (HSWidgetViewController *widgetViewController in model.widgetViewControllers) {
[widgetViewController beginAppearanceTransition:YES animated:arg1];
}
}
}
-(void)viewDidAppear:(BOOL)arg1 {
%orig(arg1);
SBRootFolderController *rootFolderController = [self _rootFolderController];
for (SBIconListView *iconListView in rootFolderController.iconListViews) {
SBIconListModel *model = [iconListView valueForKey:@"_model"];
for (HSWidgetViewController *widgetViewController in model.widgetViewControllers) {
[widgetViewController endAppearanceTransition];
}
}
}
-(void)viewWillDisappear:(BOOL)arg1 {
%orig(arg1);
SBRootFolderController *rootFolderController = [self _rootFolderController];
for (SBIconListView *iconListView in rootFolderController.iconListViews) {
SBIconListModel *model = [iconListView valueForKey:@"_model"];
for (HSWidgetViewController *widgetViewController in model.widgetViewControllers) {
[widgetViewController beginAppearanceTransition:NO animated:arg1];
}
}
}
-(void)viewDidDisappear:(BOOL)arg1 {
%orig(arg1);
SBRootFolderController *rootFolderController = [self _rootFolderController];
for (SBIconListView *iconListView in rootFolderController.iconListViews) {
SBIconListModel *model = [iconListView valueForKey:@"_model"];
for (HSWidgetViewController *widgetViewController in model.widgetViewControllers) {
[widgetViewController endAppearanceTransition];
}
}
}
-(void)viewWillTransitionToSize:(CGSize)arg1 withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)arg2 {
%orig(arg1, arg2);
SBRootFolderController *rootFolderController = [self _rootFolderController];
for (SBIconListView *iconListView in rootFolderController.iconListViews) {
// mananges its children view controllers manually so we need to forward the events ourself
[iconListView.widgetPageController viewWillTransitionToSize:arg1 withTransitionCoordinator:arg2];
}
}
%end
%ctor {
%init();
// iOS 13+ simulates appearance methods from setIconControllerHidden, for pre iOS 13 we want to do that through hook
if (![%c(SBHomeScreenViewController) instancesRespondToSelector:@selector(setIconControllerHidden:)]) {
%init(SimulateAppearanceMethods);
}
}