-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tweak.xm
49 lines (38 loc) · 1.83 KB
/
Tweak.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
#import <AudioToolbox/AudioServices.h>
#import "ScrollyPrefManager.h"
extern "C" void AudioServicesPlaySystemSoundWithVibration(SystemSoundID inSystemSoundID, id unknown, NSDictionary *options);
static void hapticFeedback(NSInteger arg1){
NSMutableDictionary* VibrationDictionary = [NSMutableDictionary dictionary];
NSMutableArray* VibrationArray = [NSMutableArray array ];
[VibrationArray addObject:[NSNumber numberWithBool:YES]];
[VibrationArray addObject:[NSNumber numberWithInt:100]];
[VibrationDictionary setObject:VibrationArray forKey:@"VibePattern"];
[VibrationDictionary setObject:[NSNumber numberWithInt:arg1] forKey:@"Intensity"];
AudioServicesPlaySystemSoundWithVibration(4095,nil,VibrationDictionary);
}
@interface UIScrollView (extension)
-(BOOL)_isScrollingToTop;
@end
%hook UIScrollView
-(BOOL)_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1{
BOOL returnValue = %orig;
HBLogDebug(@"%@",[[NSBundle mainBundle] bundleIdentifier])
if ([[ScrollyPrefManager sharedInstance] enabled] && ![[ScrollyPrefManager sharedInstance] isApplicationEnabled:[[NSBundle mainBundle] bundleIdentifier]])
{
CGPoint offset = self.contentOffset;
CGRect bounds = self.bounds;
CGSize size = self.contentSize;
UIEdgeInsets inset = self.contentInset;
float y = offset.y + bounds.size.height - inset.bottom;
float h = size.height;
float reload_distance = 10;
if(y > h + reload_distance && offset.y > 0 && [[ScrollyPrefManager sharedInstance] bot_enabled]) {
hapticFeedback([[ScrollyPrefManager sharedInstance] bot_intensity]);
} else if ( offset.y < 0 && offset.y < (-1*inset.top) && [[ScrollyPrefManager sharedInstance] top_enabled])
{
hapticFeedback([[ScrollyPrefManager sharedInstance] top_intensity]);
}
}
return returnValue;
}
%end