|
|
@@ -101,7 +101,7 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
[super layoutSubviews];
|
|
|
|
|
|
if (_currentContentView && _messageModel.isSender) {
|
|
|
- CGFloat offset = _messageModel.messageType == ChatMessageTypeFile ? 16 : 8;
|
|
|
+ CGFloat offset = (_messageModel.messageType == ChatMessageTypeFile || _messageModel.messageType == ChatMessageTypeVoice) ? 16 : 8;
|
|
|
[_progressContainerView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.width.height.mas_equalTo(30);
|
|
|
make.right.equalTo(_currentContentView.mas_left).offset(-offset);
|
|
|
@@ -109,7 +109,7 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
}];
|
|
|
|
|
|
[_resendButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.right.equalTo(_currentContentView.mas_left).offset(-8);
|
|
|
+ make.right.equalTo(_currentContentView.mas_left).offset(-offset);
|
|
|
make.centerY.equalTo(_currentContentView);
|
|
|
}];
|
|
|
}
|
|
|
@@ -224,14 +224,16 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
- (void)updateProgress:(CGFloat)progress {
|
|
|
if (progress < 0) progress = 0;
|
|
|
if (progress > 1) progress = 1;
|
|
|
-
|
|
|
+ self.messageModel.uploadProgress = progress;
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ if (self.progressContainerView.isHidden) {
|
|
|
+ [self showProgressView];
|
|
|
+ }
|
|
|
self.progressLayer.strokeEnd = progress;
|
|
|
-
|
|
|
-// // 如果进度完成,隐藏圆环
|
|
|
-// if (progress >= 1.0) {
|
|
|
-// self.progressContainerView.hidden = YES;
|
|
|
-// }
|
|
|
+ // 如果进度完成,隐藏圆环
|
|
|
+ if (progress >= 1.0) {
|
|
|
+ self.progressContainerView.hidden = YES;
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -239,7 +241,7 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
- (void)showProgressView {
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
self.progressContainerView.hidden = NO;
|
|
|
- self.progressLayer.strokeEnd = 0.0f;
|
|
|
+ self.progressLayer.strokeEnd = self.messageModel.uploadProgress;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -276,6 +278,8 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
// 重发按钮点击事件
|
|
|
- (void)handleResendButtonTap {
|
|
|
NSLog(@"点击重发按钮: msgId=%@", _messageModel.msgId);
|
|
|
+ [self hideResendButton];
|
|
|
+ self.messageModel.fileError = 0;
|
|
|
|
|
|
// 触发重发回调
|
|
|
if (self.resendMessageBlock) {
|
|
|
@@ -624,6 +628,14 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
[self setupSendingProgress];
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+- (void)fileUploadProgressDidChanged:(NSInteger)persent localtime:(NSInteger)localtime {
|
|
|
+ if (localtime == _messageModel.localtime) {
|
|
|
+ CGFloat progress = persent / 100.0f;
|
|
|
+ [self updateProgress:progress];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - 批量状态
|
|
|
- (void)setBatchState:(BOOL)batchState{
|
|
|
|
|
|
@@ -664,12 +676,6 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
|
|
|
_timeLabel.text = _messageModel.formatterTime;
|
|
|
_readStateLbl.text = _messageModel.readStatus;
|
|
|
- if(_messageModel.readstate==4){
|
|
|
- _readStateLbl.textColor = globalColor(GCTypeOrangeR);
|
|
|
- }
|
|
|
- else{
|
|
|
- _readStateLbl.textColor = [UIColor whiteColor];
|
|
|
- }
|
|
|
|
|
|
|
|
|
if (_messageModel.type==1) {
|
|
|
@@ -744,40 +750,19 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
[self hideResendButton];
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- // 根据消息状态显示进度或失败按钮
|
|
|
- switch (_messageModel.messageSendStatus) {
|
|
|
- case MessageSending: {
|
|
|
- // 发送中,显示进度圆环,隐藏失败按钮
|
|
|
- [self showProgressView];
|
|
|
- [self hideResendButton];
|
|
|
-
|
|
|
- // 如果有上传进度回调,监听进度
|
|
|
- weakSelf(self);
|
|
|
- if (_messageModel.isUploadFile) {
|
|
|
- _messageModel.uploadPersentChange = ^(NSInteger persent, NSInteger localtime) {
|
|
|
- if (localtime == weakself.messageModel.localtime) {
|
|
|
- CGFloat progress = persent / 100.0f;
|
|
|
- [weakself updateProgress:progress];
|
|
|
- if (progress >= 1) {
|
|
|
- weakself.messageModel.messageSendStatus = MessageSent;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- case MessageSendFail: {
|
|
|
- // 发送失败,显示失败按钮,隐藏进度圆环
|
|
|
- [self hideProgressView];
|
|
|
- [self showResendButton];
|
|
|
- break;
|
|
|
- }
|
|
|
- case MessageSent:
|
|
|
- // 其他状态隐藏进度和失败按钮
|
|
|
- [self hideProgressView];
|
|
|
- [self hideResendButton];
|
|
|
- break;
|
|
|
+
|
|
|
+ if (self.messageModel.isSent) {
|
|
|
+ [self hideProgressView];
|
|
|
+ } else {
|
|
|
+ // 发送中,显示进度圆环,隐藏失败按钮
|
|
|
+ [self showProgressView];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (self.messageModel.fileError) {
|
|
|
+ [self showResendButton];
|
|
|
+ [self hideProgressView];
|
|
|
+ } else {
|
|
|
+ [self hideResendButton];
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -1276,11 +1261,15 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
make.top.mas_equalTo(self.avatarImageView);
|
|
|
}];
|
|
|
|
|
|
- if (_currentContentView) {
|
|
|
+ if (_currentContentView && _bubbleImageView) {
|
|
|
+ BOOL isBubble = self.messageModel.messageType == ChatMessageTypeText ||
|
|
|
+ self.messageModel.messageType == ChatMessageTypeFile ||
|
|
|
+ self.messageModel.messageType == ChatMessageTypeVoice;
|
|
|
+ UIView *content = isBubble ? _bubbleImageView : _currentContentView;
|
|
|
[_readStateLbl mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.mas_equalTo(_currentContentView.mas_right).offset(6);
|
|
|
+ make.left.mas_equalTo(content.mas_right).offset(3);
|
|
|
make.height.mas_equalTo(14);
|
|
|
- make.bottom.mas_equalTo(_currentContentView.mas_bottom);
|
|
|
+ make.bottom.mas_equalTo(content.mas_bottom);
|
|
|
}];
|
|
|
}
|
|
|
} else {
|
|
|
@@ -1597,13 +1586,13 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
if (_messageModel.messageType == ChatMessageTypeImage) {
|
|
|
// 处理图片点击
|
|
|
NSLog(@"点击了图片: %@", _messageModel.url);
|
|
|
- if(_messageModel.fileError==1){
|
|
|
- weakSelf(self);
|
|
|
- if(weakself.bubbleCellLongPressMenuBlock){
|
|
|
- weakself.bubbleCellLongPressMenuBlock(8);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
+// if(_messageModel.fileError==1){
|
|
|
+// weakSelf(self);
|
|
|
+// if(weakself.bubbleCellLongPressMenuBlock){
|
|
|
+// weakself.bubbleCellLongPressMenuBlock(8);
|
|
|
+// }
|
|
|
+// return;
|
|
|
+// }
|
|
|
if (_messageModel.url.length == 0 && !_messageModel.isSender) {
|
|
|
[MBProgressHUD showWithText:@"图片正在上传"];
|
|
|
return;
|
|
|
@@ -1617,13 +1606,13 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
if (_messageModel.messageType == ChatMessageTypeVideo) {
|
|
|
// 处理视频点击
|
|
|
NSLog(@"点击了视频: %@", _messageModel.url);
|
|
|
- if(_messageModel.fileError==1){
|
|
|
- weakSelf(self);
|
|
|
- if(weakself.bubbleCellLongPressMenuBlock){
|
|
|
- weakself.bubbleCellLongPressMenuBlock(8);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
+// if(_messageModel.fileError==1){
|
|
|
+// weakSelf(self);
|
|
|
+// if(weakself.bubbleCellLongPressMenuBlock){
|
|
|
+// weakself.bubbleCellLongPressMenuBlock(8);
|
|
|
+// }
|
|
|
+// return;
|
|
|
+// }
|
|
|
if (_messageModel.url.length == 0 && !_messageModel.isSender) {
|
|
|
[MBProgressHUD showWithText:@"视频正在上传"];
|
|
|
return;
|
|
|
@@ -1642,13 +1631,13 @@ static const CGFloat kMediaCornerRadius = 4.0f;
|
|
|
if (_messageModel.messageType == ChatMessageTypeFile) {
|
|
|
// 处理视频点击
|
|
|
NSLog(@"点击了文件: %@", _messageModel.url);
|
|
|
- if(_messageModel.fileError==1){
|
|
|
- weakSelf(self);
|
|
|
- if(weakself.bubbleCellLongPressMenuBlock){
|
|
|
- weakself.bubbleCellLongPressMenuBlock(8);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
+// if(_messageModel.fileError==1){
|
|
|
+// weakSelf(self);
|
|
|
+// if(weakself.bubbleCellLongPressMenuBlock){
|
|
|
+// weakself.bubbleCellLongPressMenuBlock(8);
|
|
|
+// }
|
|
|
+// return;
|
|
|
+// }
|
|
|
if (_messageModel.url.length == 0 && !_messageModel.isSender) {
|
|
|
[MBProgressHUD showWithText:@"文件正在上传"];
|
|
|
return;
|