Forráskód Böngészése

朋友圈评论复制

桂欢 1 éve
szülő
commit
d4be455cb8

+ 1 - 1
SLAiELTS/SLAiELTS/ViewControllers/MessageVC/Views/IMMessageView/YMIMMessageCollectionView.m

@@ -275,7 +275,7 @@
             case SLMsgCopy:
             {
                 [[UIPasteboard generalPasteboard] setString:model.sendText];
-                [ZFToast ShowWithMessage:@"复制成功"];
+//                [ZFToast ShowWithMessage:@"复制成功"];
             }
                 break;
             default:

+ 1 - 0
SLAiELTS/SLAiELTS/ViewControllers/Moments/Views/Cell/SDTimeLineCell.m

@@ -260,6 +260,7 @@ NSString *const kSDTimeLineCellOperationButtonClickedNotification = @"SDTimeLine
 - (void)setModel:(SDTimeLineCellModel *)model
 {
     _model = model;
+    _commentView.userId = _model.userId;
     [_commentView setupWithLikeItemsArray:model.likeItemsArray commentItemsArray:model.list];
     NSString *userImg = [NSString stringWithFormat:@"%@%@",[SLHttpCenter SharedInstance].serverUrl, model.userImg];
     [_iconView sd_setImageWithURL:[NSURL URLWithString:userImg] placeholderImage:ImageName(@"icon_ellipse")];

+ 2 - 0
SLAiELTS/SLAiELTS/ViewControllers/Moments/Views/CommentView/SDTimeLineCellCommentView.h

@@ -34,6 +34,8 @@
 
 @property (nonatomic, strong) NSIndexPath *indexPath;
 
+@property (nonatomic, strong) NSString *userId;
+
 - (void)setupWithLikeItemsArray:(NSArray *)likeItemsArray commentItemsArray:(NSArray *)commentItemsArray;
 
 @property (nonatomic, copy) void (^didClickCommentLabelBlock)(NSString *commentId, CGRect rectInWindow, NSIndexPath *indexPath);

+ 67 - 4
SLAiELTS/SLAiELTS/ViewControllers/Moments/Views/CommentView/SDTimeLineCellCommentView.m

@@ -33,6 +33,8 @@
 
 #import "LEETheme.h"
 #import "SLFriensInfoVc.h"
+#import "SLMikeSegment.h"
+#import "SLMomentsVc.h"
 
 @interface SDTimeLineCellCommentView () <MLLinkLabelDelegate>
 
@@ -111,18 +113,17 @@
     long originalLabelsCount = self.commentLabelsArray.count;
     long needsToAddCount = commentItemsArray.count > originalLabelsCount ? (commentItemsArray.count - originalLabelsCount) : 0;
     for (int i = 0; i < needsToAddCount; i++) {
-        MLLinkLabel *label = [MLLinkLabel new];
+         MLLinkLabel *label = [MLLinkLabel new];
         UIColor *highLightColor = SLColor(@"#48484A");
         label.linkTextAttributes = @{NSForegroundColorAttributeName : highLightColor, NSFontAttributeName: [UIFont boldSystemFontOfSize:14]};
         label.font = [UIFont systemFontOfSize:14];
         label.textColor = SLColor(@"#48484A");
         label.delegate = self;
         WS(weakSelf);
+        __block UILabel *blockLabel = label;
         label.labelLongTouchBlock = ^{
+            [weakSelf showMsgSegmentWith:blockLabel model:self->_commentItemsArray[i]];
             NSLog(@"didLongTouchCommentLabelBlock--%d---------commentItemsArray",i);
-            if (weakSelf.didLongTouchCommentLabelBlock) {
-                weakSelf.didLongTouchCommentLabelBlock(@"123", CGRectZero, [NSIndexPath indexPathForRow:self.indexPath.row inSection:i]);
-            }
         };
         label.labelClickedBlock = ^{
             NSLog(@"%d---------commentItemsArray",i);
@@ -144,6 +145,68 @@
     }
 }
 
+- (void)showMsgSegmentWith:(UILabel *)bgView model:(SDTimeLineCellCommentItemModel *)commentItemModel {
+    UIViewController *vc = self.viewController;
+    if ([vc isKindOfClass:SLMomentsVc.class]) {
+        CGRect rect = [self convertRect:bgView.frame toView:self.viewController.view];
+        //加一个蒙层
+        __block UIView *bView = [[UIView alloc] initWithFrame:vc.view.frame];
+        bView.backgroundColor = [UIColor clearColor];
+        __block UIView *blockBgView = bView;
+        [bView addTapWithBlock:^{
+            [blockBgView removeFromSuperview];
+        }];
+        [vc.view addSubview:bView];
+        NSMutableArray *arr = [NSMutableArray new];
+        
+        [arr addObject:[SLMikeSegmentModel initWithSegTitle: @"复制" segImage:@"" mikeType:SLMsgCopy]];
+        if ([self.userId isEqualToString:[SLGlobalInfo SharedInstance].loginInfo.user.userId]) {
+            [arr addObject:[SLMikeSegmentModel initWithSegTitle:@"删除" segImage:@"" mikeType:SLMikeInputDelete]];
+        }
+        
+        CGFloat width = arr.count * 45 + 20;
+        SLMikeSegment *mikeSegment = [[SLMikeSegment alloc] initWithFrame:CGRectMake(bgView.frame.origin.x + rect.size.width / 2.0, rect.origin.y - 39, width, 30) titleArray:arr];
+        WS(weakSelf);
+        mikeSegment.mikeSegmentBlock = ^(SLMikeSegmentModel *model) {
+            [bView removeFromSuperview];
+            switch (model.mikeType) {
+                case SLMsgCopy:
+                {
+                    [[UIPasteboard generalPasteboard] setString:commentItemModel.content];
+                }
+                    break;
+                case SLMikeInputTrans:
+                {
+                    
+                }
+                    break;
+                case SLMikeInputDelete:
+                {
+                    if (weakSelf.didLongTouchCommentLabelBlock) {
+                        NSInteger i = [self->_commentItemsArray indexOfObject:commentItemModel];
+                        weakSelf.didLongTouchCommentLabelBlock(@"123", CGRectZero, [NSIndexPath indexPathForRow:self.indexPath.row inSection:i]);
+                    }
+                }
+                    break;
+                    
+                default:
+                    break;
+            }
+        };
+        [bView addSubview:mikeSegment];
+        SLMomentsVc *msgVc = (SLMomentsVc *)vc;
+        UIImageView *imgView = [[UIImageView alloc] initWithImage:ImageName(@"icon_dsjx")];
+        [bView addSubview:imgView];
+        [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.centerX.equalTo(mikeSegment);
+            make.top.equalTo(mikeSegment.mas_bottom).offset(0);
+            make.width.mas_equalTo(16);
+            make.height.mas_equalTo(8);
+        }];
+    }
+}
+
+
 - (void)setLikeItemsArray:(NSArray *)likeItemsArray
 {