|
23 | 23 | #import "AddMDCommentViewController.h" |
24 | 24 | #import "WebViewController.h" |
25 | 25 |
|
26 | | - |
| 26 | +#import "UIView+PressMenu.h" |
27 | 27 |
|
28 | 28 | @interface CommitFilesViewController ()<UITableViewDataSource, UITableViewDelegate, TTTAttributedLabelDelegate> |
29 | 29 | @property (strong, nonatomic) CommitInfo *curCommitInfo; |
@@ -202,6 +202,24 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N |
202 | 202 | CommitCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:curCommentItem.htmlMedia.imageItems.count> 0? kCellIdentifier_CommitCommentCell_Media: kCellIdentifier_CommitCommentCell forIndexPath:indexPath]; |
203 | 203 | cell.curItem = curCommentItem; |
204 | 204 | 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 | + |
205 | 223 | [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:50]; |
206 | 224 | return cell; |
207 | 225 | }else{ |
@@ -246,8 +264,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath |
246 | 264 | vc.filePath = curFileChange.path; |
247 | 265 | [self.navigationController pushViewController:vc animated:YES]; |
248 | 266 | }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]; |
251 | 269 | }else{ |
252 | 270 | [self goToAddCommentVCToUser:nil]; |
253 | 271 | } |
@@ -277,6 +295,16 @@ - (void)goToAddCommentVCToUser:(NSString *)userName{ |
277 | 295 | [self.navigationController pushViewController:vc animated:YES]; |
278 | 296 | } |
279 | 297 |
|
| 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 | + |
280 | 308 | #pragma mark TTTAttributedLabelDelegate |
281 | 309 | - (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithTransitInformation:(NSDictionary *)components{ |
282 | 310 | HtmlMediaItem *clickedItem = [components objectForKey:@"value"]; |
|
0 commit comments