-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tweak.xm
32 lines (25 loc) · 1.12 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
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <objc/runtime.h>
@interface SBAppSliderScrollView : UIScrollView
@end
%hook SBAppSliderScrollingViewController
- (void)scrollViewWillEndDragging:(id)arg1 withVelocity:(struct CGPoint)arg2 targetContentOffset:(struct CGPoint *)arg3 {
if ([(SBAppSliderScrollView *)arg1 contentOffset].y < -20.0 && arg2.y < -2.0) {
long long orientation;
object_getInstanceVariable(self, "_layoutOrientation", (void **)&orientation);
int cardWidth = (int)((orientation == UIInterfaceOrientationPortrait) ? [UIScreen mainScreen].bounds.size.width : [UIScreen mainScreen].bounds.size.height)/2;
int noteIndex = 0;
noteIndex = (int)([(SBAppSliderScrollView *)arg1 frame].origin.x/cardWidth);
if (noteIndex > 7) {
noteIndex = 7;
}
CFURLRef soundFileURLRef;
soundFileURLRef = (CFURLRef)[NSURL URLWithString:[NSString stringWithFormat:@"/Library/MusicalSwitcher/note%d.m4a", noteIndex]];
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
%orig;
}
%end