forked from insanj/EditAlarms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.xm
55 lines (42 loc) · 1.57 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
50
51
52
53
54
55
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "CydiaSubstrate.h"
@interface TableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@end
@interface AlarmViewController : TableViewController
-(void)showEditViewForRow:(long long)arg1;
@end
%hook AlarmViewController
BOOL shouldIgnore;
%new -(void)tappedCell:(UIButton *)sender{
UITableView *tableView = MSHookIvar<UITableView *>(self, "_tableView");
if(shouldIgnore)
shouldIgnore = NO;
else
[self showEditViewForRow:[tableView indexPathForCell:(UITableViewCell*)sender.superview.superview].row];
}
%new -(void)cancelCellTap{
shouldIgnore = YES;
}
-(id)tableView:(id)arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2{
UITableViewCell *original = %orig;
UIButton *tap = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect croppedFrame = original.frame;
croppedFrame.size.width /= 1.2f;
[tap setFrame:croppedFrame];
[tap setBackgroundColor:[UIColor clearColor]];
[tap addTarget:self action:@selector(tappedCell:) forControlEvents:UIControlEventTouchUpInside];
[tap addTarget:self action:@selector(cancelCellTap) forControlEvents:UIControlEventTouchDragInside];
[original addSubview:tap];
return original;
}
-(UIBarButtonItem *)editButtonItem{
return nil;
}
-(BOOL)tableView:(UITableView *)arg1 canEditRowAtIndexPath:(NSIndexPath *)arg2{
return YES;
}
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
%end