Skip to content

Commit b967f19

Browse files
committed
提交记录 - 长按评论菜单
1 parent 98257b0 commit b967f19

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

Coding_iOS/Controllers/CommitFilesViewController.m

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#import "AddMDCommentViewController.h"
2424
#import "WebViewController.h"
2525

26-
26+
#import "UIView+PressMenu.h"
2727

2828
@interface CommitFilesViewController ()<UITableViewDataSource, UITableViewDelegate, TTTAttributedLabelDelegate>
2929
@property (strong, nonatomic) CommitInfo *curCommitInfo;
@@ -202,6 +202,24 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
202202
CommitCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:curCommentItem.htmlMedia.imageItems.count> 0? kCellIdentifier_CommitCommentCell_Media: kCellIdentifier_CommitCommentCell forIndexPath:indexPath];
203203
cell.curItem = curCommentItem;
204204
cell.contentLabel.delegate = self;
205+
206+
__weak typeof(self) weakSelf = self;
207+
NSArray *menuTitles;
208+
if ([curCommentItem.author.global_key isEqualToString:[Login curLoginUser].global_key]) {
209+
menuTitles = @[@"拷贝文字", @"回复", @"删除"];
210+
}else{
211+
menuTitles = @[@"拷贝文字", @"回复"];
212+
}
213+
[cell.contentView addPressMenuTitles:menuTitles menuClickedBlock:^(NSInteger index, NSString *title) {
214+
if ([title hasPrefix:@"拷贝"]) {
215+
[[UIPasteboard generalPasteboard] setString:curCommentItem.content];
216+
}else if ([title isEqualToString:@"删除"]){
217+
[weakSelf deleteComment:curCommentItem];
218+
}else if ([title isEqualToString:@"回复"]){
219+
[weakSelf goToAddCommentVCToUser:curCommentItem.author.name];
220+
}
221+
}];
222+
205223
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:50];
206224
return cell;
207225
}else{
@@ -246,8 +264,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
246264
vc.filePath = curFileChange.path;
247265
[self.navigationController pushViewController:vc animated:YES];
248266
}else if (indexPath.section == _listGroupKeys.count+ 1 && _curCommitInfo.commitComments.count > 0){
249-
ProjectLineNote*curCommentItem = [_curCommitInfo.commitComments objectAtIndex:indexPath.row];
250-
[self goToAddCommentVCToUser:curCommentItem.author.name];
267+
// ProjectLineNote*curCommentItem = [_curCommitInfo.commitComments objectAtIndex:indexPath.row];
268+
// [self goToAddCommentVCToUser:curCommentItem.author.name];
251269
}else{
252270
[self goToAddCommentVCToUser:nil];
253271
}
@@ -277,6 +295,16 @@ - (void)goToAddCommentVCToUser:(NSString *)userName{
277295
[self.navigationController pushViewController:vc animated:YES];
278296
}
279297

298+
- (void)deleteComment:(ProjectLineNote *)lineNote{
299+
__weak typeof(self) weakSelf = self;
300+
[[Coding_NetAPIManager sharedManager] request_DeleteLineNote:lineNote.id inProject:_projectName ofUser:_ownerGK andBlock:^(id data, NSError *error) {
301+
if (data) {
302+
[weakSelf.curCommitInfo.commitComments removeObject:lineNote];
303+
[weakSelf.myTableView reloadData];
304+
}
305+
}];
306+
}
307+
280308
#pragma mark TTTAttributedLabelDelegate
281309
- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithTransitInformation:(NSDictionary *)components{
282310
HtmlMediaItem *clickedItem = [components objectForKey:@"value"];

0 commit comments

Comments
 (0)