-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dragging.xm
102 lines (81 loc) · 3.62 KB
/
Dragging.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 "SBIconController.h"
#import "SBIconListView.h"
#import "SBRootFolderController.h"
%hook SBIconController
%property (nonatomic, assign) BOOL isDraggingWidget;
-(void)viewDidLoad {
%orig();
self.isDraggingWidget = NO;
}
-(BOOL)_iconCanBeGrabbed:(id)arg1 { // iOS 4 - 12
if (self.isDraggingWidget)
return NO; // disable icon grabbing when widget is being dragged
return %orig(arg1);
}
-(BOOL)_shouldRespondToIconCloseBoxes { // iOS 11 - 12
if (self.isDraggingWidget)
return NO; // disable icon deletion when widget is being dragged
return %orig();
}
-(void)uninstallIcon:(id)arg1 { // iOS 10
SBIconListView *iconListView = [[self _rootFolderController] currentIconListView];
HSWidgetPageController *widgetPageController = iconListView.widgetPageController;
[widgetPageController animateUpdateOfIconChangesExcludingCurrentIcon:YES completion:nil];
%orig(arg1);
}
-(void)uninstallIcon:(id)arg1 animate:(BOOL)arg2 completion:(id)arg3 { // iOS 11 - 12
SBIconListView *iconListView = [[self _rootFolderController] currentIconListView];
HSWidgetPageController *widgetPageController = iconListView.widgetPageController;
[widgetPageController animateUpdateOfIconChangesExcludingCurrentIcon:YES completion:nil];
%orig(arg1, arg2, arg3);
}
-(void)iconDragManagerIconDraggingDidChange:(id)arg1 { // iOS 11 - 12
%orig(arg1); // post a SBIconControllerIconDraggingChangedNotification
for (SBIconListView *iconListView in [self _rootFolderController].iconListViews) {
HSWidgetPageController *widgetPageController = iconListView.widgetPageController;
[widgetPageController animateUpdateOfIconChangesExcludingCurrentIcon:NO completion:nil];
}
}
-(void)iconDragManagerMultiItemIconDraggingDidChange:(id)arg1 { // iOS 11 - 12
%orig(arg1);
for (SBIconListView *iconListView in [self _rootFolderController].iconListViews) {
HSWidgetPageController *widgetPageController = iconListView.widgetPageController;
[widgetPageController animateUpdateOfIconChangesExcludingCurrentIcon:NO completion:nil];
}
}
%end
%hook SBHIconManager
-(BOOL)iconViewCanBeginDrags:(id)arg1 { // iOS 13
SBIconController *iconController = [%c(SBIconController) sharedInstance];
if (iconController.isDraggingWidget)
return NO; // disable icon grabbing when widget is being draggged
return %orig(arg1);
}
-(BOOL)_shouldRespondToIconCloseBoxes { // iOS 13
SBIconController *iconController = [%c(SBIconController) sharedInstance];
if (iconController.isDraggingWidget)
return NO; // disable icon deletion when widget is being dragged
return %orig();
}
-(void)uninstallIcon:(id)arg1 animate:(BOOL)arg2 completion:(id)arg3 { // iOS 13
SBIconListView *iconListView = [[self rootFolderController] currentIconListView];
HSWidgetPageController *widgetPageController = iconListView.widgetPageController;
[widgetPageController animateUpdateOfIconChangesExcludingCurrentIcon:YES completion:nil];
%orig(arg1, arg2, arg3);
}
-(void)iconDragManagerIconDraggingDidChange:(id)arg1 { // iOS 13
%orig(arg1); // post a SBHIconManagerIconDraggingChanged
for (SBIconListView *iconListView in [self rootFolderController].iconListViews) {
HSWidgetPageController *widgetPageController = iconListView.widgetPageController;
[widgetPageController animateUpdateOfIconChangesExcludingCurrentIcon:NO completion:nil];
}
}
-(void)iconDragManagerMultiItemIconDraggingDidChange:(id)arg1 { // iOS 13
%orig(arg1);
for (SBIconListView *iconListView in [self rootFolderController].iconListViews) {
HSWidgetPageController *widgetPageController = iconListView.widgetPageController;
[widgetPageController animateUpdateOfIconChangesExcludingCurrentIcon:NO completion:nil];
}
}
%end