|
@@ -9,7 +9,6 @@
|
|
|
#import "WFCURecallCell.h"
|
|
|
#import <WFChatClient/WFCChatClient.h>
|
|
|
#import "WFCUUtilities.h"
|
|
|
-#import "UILabel+YBAttributeTextTapAction.h"
|
|
|
|
|
|
#define TEXT_TOP_PADDING 6
|
|
|
#define TEXT_BUTTOM_PADDING 6
|
|
@@ -26,9 +25,6 @@
|
|
|
|
|
|
+ (NSString *)recallMsg:(WFCCRecallMessageContent *)content {
|
|
|
NSString *digest = [content digest:nil];
|
|
|
- if (content.originalContentType == MESSAGE_CONTENT_TYPE_TEXT && [content.originalSender isEqualToString:[WFCCNetworkService sharedInstance].userId] && content.originalSearchableContent.length > 0) {
|
|
|
- return [digest stringByAppendingString:@" 重新编辑"];
|
|
|
- }
|
|
|
return digest;
|
|
|
}
|
|
|
+ (CGSize)sizeForCell:(WFCUMessageModel *)msgModel withViewWidth:(CGFloat)width {
|
|
@@ -46,40 +42,41 @@
|
|
|
- (void)setModel:(WFCUMessageModel *)model {
|
|
|
[super setModel:model];
|
|
|
|
|
|
+ WFCCRecallMessageContent *content = (WFCCRecallMessageContent *)model.message.content;
|
|
|
NSString *infoText = [WFCURecallCell recallMsg:(WFCCRecallMessageContent *)model.message.content];
|
|
|
-
|
|
|
CGFloat width = self.contentView.bounds.size.width;
|
|
|
|
|
|
- CGSize size = [WFCUUtilities getTextDrawingSize:infoText font:[UIFont systemFontOfSize:14] constrainedSize:CGSizeMake(width - TEXT_LABEL_LEFT_PADDING - TEXT_LABEL_RIGHT_PADDING - TEXT_LEFT_PADDING - TEXT_RIGHT_PADDING, 8000)];
|
|
|
|
|
|
+ CGFloat reeditBtnWidth = 0;
|
|
|
|
|
|
- WFCCRecallMessageContent *content = (WFCCRecallMessageContent *)model.message.content;
|
|
|
- [self.infoLabel yb_removeAttributeTapActions];
|
|
|
if (content.originalContentType == MESSAGE_CONTENT_TYPE_TEXT && [content.originalSender isEqualToString:[WFCCNetworkService sharedInstance].userId] && content.originalSearchableContent.length > 0) {
|
|
|
- NSString *digest = [content digest:nil];
|
|
|
- NSString *info = [digest stringByAppendingString:@" 重新编辑 "];
|
|
|
- NSMutableAttributedString *astr = [[NSMutableAttributedString alloc] initWithString:info];
|
|
|
- [astr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14],NSForegroundColorAttributeName : [UIColor blueColor]} range:NSMakeRange(digest.length+1, 4)];
|
|
|
- self.infoLabel.attributedText = astr;
|
|
|
+ CGSize btnsize = [WFCUUtilities getTextDrawingSize:self.reeditButton.titleLabel.text font:[UIFont systemFontOfSize:14] constrainedSize:CGSizeMake(width - TEXT_LABEL_LEFT_PADDING - TEXT_LABEL_RIGHT_PADDING - TEXT_LEFT_PADDING - TEXT_RIGHT_PADDING, 8000)];
|
|
|
|
|
|
-
|
|
|
- __weak typeof(self)ws = self;
|
|
|
- [self.infoLabel yb_addAttributeTapActionWithStrings:@[@" 重新编辑 "] tapClicked:^(UILabel *label, NSString *string, NSRange range, NSInteger index) {
|
|
|
- [ws.delegate reeditRecalledMessage:ws withModel:ws.model];
|
|
|
- }];
|
|
|
- } else {
|
|
|
- self.infoLabel.text = infoText;
|
|
|
+ reeditBtnWidth = btnsize.width + 4;
|
|
|
}
|
|
|
|
|
|
|
|
|
+ CGSize size = [WFCUUtilities getTextDrawingSize:infoText font:[UIFont systemFontOfSize:14] constrainedSize:CGSizeMake(width - TEXT_LABEL_LEFT_PADDING - TEXT_LABEL_RIGHT_PADDING - TEXT_LEFT_PADDING - TEXT_RIGHT_PADDING, 8000)];
|
|
|
+
|
|
|
+
|
|
|
+ self.infoLabel.text = infoText;
|
|
|
+
|
|
|
self.infoLabel.layoutMargins = UIEdgeInsetsMake(TEXT_TOP_PADDING, TEXT_LEFT_PADDING, TEXT_BUTTOM_PADDING, TEXT_RIGHT_PADDING);
|
|
|
CGFloat timeLableEnd = 0;
|
|
|
if (!self.timeLabel.hidden) {
|
|
|
timeLableEnd = self.timeLabel.frame.size.height + self.timeLabel.frame.origin.y;
|
|
|
}
|
|
|
- self.infoLabel.frame = CGRectMake((width - size.width)/2 - 8, timeLableEnd + TEXT_LABEL_TOP_PADDING, size.width + 16, size.height + TEXT_TOP_PADDING + TEXT_BUTTOM_PADDING);
|
|
|
-// self.infoLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
+ self.recallContainer.frame = CGRectMake((width - size.width - reeditBtnWidth)/2 - 8, timeLableEnd + TEXT_LABEL_TOP_PADDING, size.width + reeditBtnWidth + 16, size.height + TEXT_TOP_PADDING + TEXT_BUTTOM_PADDING);
|
|
|
+
|
|
|
+ self.infoLabel.frame = CGRectMake(8, TEXT_BUTTOM_PADDING, size.width, size.height);
|
|
|
+ if (reeditBtnWidth) {
|
|
|
+ self.reeditButton.frame = CGRectMake(size.width + 8, TEXT_BUTTOM_PADDING, reeditBtnWidth, size.height);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
+- (void)onReeditBtn:(id)sender {
|
|
|
+ [self.delegate reeditRecalledMessage:self withModel:self.model];
|
|
|
}
|
|
|
|
|
|
- (UILabel *)infoLabel {
|
|
@@ -93,13 +90,36 @@
|
|
|
_infoLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
|
_infoLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
_infoLabel.font = [UIFont systemFontOfSize:14.f];
|
|
|
- _infoLabel.layer.masksToBounds = YES;
|
|
|
- _infoLabel.layer.cornerRadius = 5.f;
|
|
|
_infoLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
- _infoLabel.backgroundColor = [UIColor colorWithRed:201/255.f green:201/255.f blue:201/255.f alpha:1.f];
|
|
|
+ _infoLabel.backgroundColor = [UIColor clearColor];
|
|
|
|
|
|
- [self.contentView addSubview:_infoLabel];
|
|
|
+ [self.recallContainer addSubview:_infoLabel];
|
|
|
+ }
|
|
|
+ return _infoLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIButton *)reeditButton {
|
|
|
+ if (!_reeditButton) {
|
|
|
+ _reeditButton = [[UIButton alloc] init];
|
|
|
+ [_reeditButton setTitle:@"重新编辑" forState:UIControlStateNormal];
|
|
|
+ [_reeditButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
|
|
|
+ [_reeditButton setTitleColor:[UIColor grayColor] forState:UIControlStateSelected];
|
|
|
+ [_reeditButton addTarget:self action:@selector(onReeditBtn:) forControlEvents:UIControlEventTouchDown];
|
|
|
+ [_reeditButton setBackgroundColor:[UIColor clearColor]];
|
|
|
+ _reeditButton.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
|
+ [self.recallContainer addSubview:_reeditButton];
|
|
|
+ }
|
|
|
+ return _reeditButton;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIView *)recallContainer {
|
|
|
+ if (!_recallContainer) {
|
|
|
+ _recallContainer = [[UIView alloc] init];
|
|
|
+ _recallContainer.backgroundColor = [UIColor colorWithRed:201/255.f green:201/255.f blue:201/255.f alpha:1.f];
|
|
|
+ _recallContainer.layer.masksToBounds = YES;
|
|
|
+ _recallContainer.layer.cornerRadius = 5.f;
|
|
|
+ [self.contentView addSubview:_recallContainer];
|
|
|
}
|
|
|
- return _infoLabel;
|
|
|
+ return _recallContainer;
|
|
|
}
|
|
|
@end
|