-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTweak.xm
71 lines (45 loc) · 2.33 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
68
69
70
71
// Developer By Azozz ALFiras
// github : https://github.com/AzozzALFiras
// Twitter : https://twitter.com/AzozzALFiras
#import <UIKit/UIKit.h>
@interface IGStyledString : NSObject
@property (strong) NSMutableAttributedString* attributedString;
@end
@interface IGCoreTextView : UIView
@property (strong) IGStyledString* styledString;
@end
@interface IGCommetContentView : UITableViewCell
@property (strong) IGCoreTextView* commentCoreTextView;
@end
@interface IGCommentCell : UITableViewCell
@property (strong) IGCommetContentView* commentView;
@end
%hook IGCommentCell // Copy Comment Text
- (void)_didLongPressCommentCell:(UILongPressGestureRecognizer*)sender{
if(sender.state == UIGestureRecognizerStateBegan) {
NSString *CommentTextWithOutUsername = [NSString stringWithFormat:@"%@", MSHookIvar<NSMutableString *>(self.commentView.commentCoreTextView.styledString.attributedString, "mutableString")];
NSUInteger indexUsername = [CommentTextWithOutUsername rangeOfString:@" "].location;
NSString *CommentText = [CommentTextWithOutUsername substringFromIndex:indexUsername+1];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@Name_Tweak message:CommentText preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* copyAction = [UIAlertAction actionWithTitle:@"Copy Text" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[UIPasteboard generalPasteboard].string = CommentText;
}];
UIAlertAction* shareAction = [UIAlertAction actionWithTitle:@"Share Text" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
NSArray * shareItems;
shareItems = @[CommentText];
UIActivityViewController * avc = [[ UIActivityViewController alloc] initWithActivityItems:shareItems applicationActivities:nil];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:avc animated:YES completion:NULL];
[avc setCompletionWithItemsHandler:^(NSString *activityType,BOOL completed, NSArray *returnedItems, NSError *activityError){
}];
}];
[alert addAction:copyAction];
[alert addAction:shareAction];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"الغاء" style:UIAlertActionStyleCancel handler:nil];
[alert addAction:cancel];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alert animated:YES completion:nil];
}
} else {
return %orig;
}
}
%end