-
Notifications
You must be signed in to change notification settings - Fork 4
/
Tweak.xm
67 lines (48 loc) · 1.95 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
56
57
58
59
60
61
62
63
64
65
66
67
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "substrate.h"
@interface TableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@end
@interface AlarmViewController : TableViewController
- (void)showEditViewForRow:(long long)arg1;
@end
%hook AlarmViewController
static BOOL editAlarms_shouldIgnoreTaps;
%new - (void)editAlarmsButtonTapped:(UIButton *)sender {
UITableView *tableView = MSHookIvar<UITableView *>(self, "_tableView");
if (editAlarms_shouldIgnoreTaps) {
editAlarms_shouldIgnoreTaps = NO;
}
else {
UIView *tappedCell = sender.superview;
while (![tappedCell isKindOfClass:[UITableViewCell class]]) {
tappedCell = tappedCell.superview;
}
[self showEditViewForRow:[tableView indexPathForCell:(UITableViewCell *)tappedCell].row];
}
}
%new - (void)editAlarmsButtonCancelled:(UIButton *)sender {
editAlarms_shouldIgnoreTaps = YES;
}
- (id)tableView:(id)arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2 {
UITableViewCell *cell = %orig;
CGRect editAlarmsButtonFrame = cell.frame;
editAlarmsButtonFrame.size.width /= 2.0;
UIButton *editAlarmsButton = [UIButton buttonWithType:UIButtonTypeCustom];
editAlarmsButton.frame = editAlarmsButtonFrame;
editAlarmsButton.backgroundColor = [UIColor clearColor];
[editAlarmsButton addTarget:self action:@selector(editAlarmsButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[editAlarmsButton addTarget:self action:@selector(editAlarmsButtonCancelled:) forControlEvents:UIControlEventTouchDragInside];
[cell addSubview:editAlarmsButton];
return cell;
}
- (UIBarButtonItem *)editButtonItem {
return nil;
}
- (BOOL)tableView:(UITableView *)arg1 canEditRowAtIndexPath:(NSIndexPath *)arg2 {
return YES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
%end