修改飘屏
This commit is contained in:
@@ -62,6 +62,7 @@ typedef NS_ENUM(NSInteger) {
|
||||
|
||||
@interface QXRoomChatListSystemCell : UITableViewCell
|
||||
@property(nonatomic,strong)UIView *bgView;
|
||||
@property(nonatomic,strong)UIImageView *bubbleImageView;
|
||||
@property(nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)QXRoomChatListModel *message;
|
||||
+(instancetype)cellWithTableView:(UITableView *)tableView;
|
||||
|
||||
@@ -41,10 +41,10 @@ NSInteger maxMessageCount = 20;
|
||||
@property (nonatomic,strong)NSMutableArray *giftArray;
|
||||
@property (nonatomic,strong)NSMutableArray *chatArray;
|
||||
@property (nonatomic,assign)NSInteger messageCount;
|
||||
@property (nonatomic,strong)UIButton *allBtn;
|
||||
@property (nonatomic,strong)UIButton *chatBtn;
|
||||
@property (nonatomic,strong)UIButton *giftBtn;
|
||||
@property (nonatomic,strong)UIButton *selectedBtn;
|
||||
//@property (nonatomic,strong)UIButton *allBtn;
|
||||
//@property (nonatomic,strong)UIButton *chatBtn;
|
||||
//@property (nonatomic,strong)UIButton *giftBtn;
|
||||
//@property (nonatomic,strong)UIButton *selectedBtn;
|
||||
@property (nonatomic,assign)BOOL isDragging;
|
||||
@property (nonatomic,strong)UILabel *messageLabel;
|
||||
@property (nonatomic,strong)UIButton *messageCountBtn;
|
||||
@@ -64,55 +64,55 @@ NSInteger maxMessageCount = 20;
|
||||
[self addSubview:self.tableView];
|
||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self);
|
||||
make.top.equalTo(self).offset(40);
|
||||
make.top.equalTo(self).offset(0);
|
||||
make.bottom.equalTo(self).offset(-10);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
self.allBtn = [[UIButton alloc] init];
|
||||
NSAttributedString *allAttrNor = [[NSAttributedString alloc] initWithString:QXText(@"全部") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
NSAttributedString *allAttrSel = [[NSAttributedString alloc] initWithString:QXText(@"全部") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
[self.allBtn setAttributedTitle:allAttrNor forState:UIControlStateNormal];
|
||||
[self.allBtn setAttributedTitle:allAttrSel forState:UIControlStateSelected];
|
||||
self.allBtn.selected = YES;
|
||||
self.selectedBtn = self.allBtn;
|
||||
[self.allBtn addTarget:self action:@selector(typeAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.allBtn];
|
||||
[self.allBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.top.equalTo(self);
|
||||
make.height.mas_equalTo(40);
|
||||
make.width.mas_equalTo(50);
|
||||
}];
|
||||
|
||||
self.chatBtn = [[UIButton alloc] init];
|
||||
NSAttributedString *chatAttrNor = [[NSAttributedString alloc] initWithString:QXText(@"聊天") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
NSAttributedString *chatAttrSel = [[NSAttributedString alloc] initWithString:QXText(@"聊天") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
[self.chatBtn setAttributedTitle:chatAttrNor forState:UIControlStateNormal];
|
||||
[self.chatBtn setAttributedTitle:chatAttrSel forState:UIControlStateSelected];
|
||||
[self.chatBtn addTarget:self action:@selector(typeAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.chatBtn];
|
||||
[self.chatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.allBtn.mas_right).offset(5);
|
||||
make.top.equalTo(self);
|
||||
make.height.mas_equalTo(40);
|
||||
make.width.mas_equalTo(50);
|
||||
}];
|
||||
|
||||
self.giftBtn = [[UIButton alloc] init];
|
||||
NSAttributedString *giftAttrNor = [[NSAttributedString alloc] initWithString:QXText(@"礼物") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
NSAttributedString *giftAttrSel = [[NSAttributedString alloc] initWithString:QXText(@"礼物") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
[self.giftBtn setAttributedTitle:giftAttrNor forState:UIControlStateNormal];
|
||||
[self.giftBtn setAttributedTitle:giftAttrSel forState:UIControlStateSelected];
|
||||
[self.giftBtn addTarget:self action:@selector(typeAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.giftBtn];
|
||||
[self.giftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.chatBtn.mas_right).offset(5);
|
||||
make.top.equalTo(self);
|
||||
make.height.mas_equalTo(40);
|
||||
make.width.mas_equalTo(50);
|
||||
}];
|
||||
// self.allBtn = [[UIButton alloc] init];
|
||||
// NSAttributedString *allAttrNor = [[NSAttributedString alloc] initWithString:QXText(@"全部") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
// NSAttributedString *allAttrSel = [[NSAttributedString alloc] initWithString:QXText(@"全部") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
// [self.allBtn setAttributedTitle:allAttrNor forState:UIControlStateNormal];
|
||||
// [self.allBtn setAttributedTitle:allAttrSel forState:UIControlStateSelected];
|
||||
// self.allBtn.selected = YES;
|
||||
// self.selectedBtn = self.allBtn;
|
||||
// [self.allBtn addTarget:self action:@selector(typeAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
// [self addSubview:self.allBtn];
|
||||
// [self.allBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.mas_equalTo(16);
|
||||
// make.top.equalTo(self);
|
||||
// make.height.mas_equalTo(40);
|
||||
// make.width.mas_equalTo(50);
|
||||
// }];
|
||||
//
|
||||
// self.chatBtn = [[UIButton alloc] init];
|
||||
// NSAttributedString *chatAttrNor = [[NSAttributedString alloc] initWithString:QXText(@"聊天") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
// NSAttributedString *chatAttrSel = [[NSAttributedString alloc] initWithString:QXText(@"聊天") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
// [self.chatBtn setAttributedTitle:chatAttrNor forState:UIControlStateNormal];
|
||||
// [self.chatBtn setAttributedTitle:chatAttrSel forState:UIControlStateSelected];
|
||||
// [self.chatBtn addTarget:self action:@selector(typeAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
// [self addSubview:self.chatBtn];
|
||||
// [self.chatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.equalTo(self.allBtn.mas_right).offset(5);
|
||||
// make.top.equalTo(self);
|
||||
// make.height.mas_equalTo(40);
|
||||
// make.width.mas_equalTo(50);
|
||||
// }];
|
||||
//
|
||||
// self.giftBtn = [[UIButton alloc] init];
|
||||
// NSAttributedString *giftAttrNor = [[NSAttributedString alloc] initWithString:QXText(@"礼物") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
// NSAttributedString *giftAttrSel = [[NSAttributedString alloc] initWithString:QXText(@"礼物") attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
// [self.giftBtn setAttributedTitle:giftAttrNor forState:UIControlStateNormal];
|
||||
// [self.giftBtn setAttributedTitle:giftAttrSel forState:UIControlStateSelected];
|
||||
// [self.giftBtn addTarget:self action:@selector(typeAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
// [self addSubview:self.giftBtn];
|
||||
// [self.giftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.equalTo(self.chatBtn.mas_right).offset(5);
|
||||
// make.top.equalTo(self);
|
||||
// make.height.mas_equalTo(40);
|
||||
// make.width.mas_equalTo(50);
|
||||
// }];
|
||||
|
||||
self.messageCountBtn = [[UIButton alloc] init];;
|
||||
[self.messageCountBtn setTitleColor:RGB16(0xB265FA) forState:(UIControlStateNormal)];
|
||||
@@ -142,22 +142,22 @@ NSInteger maxMessageCount = 20;
|
||||
// }];
|
||||
}
|
||||
-(void)typeAction:(UIButton*)sender{
|
||||
self.selectedBtn.selected = !self.selectedBtn.selected;
|
||||
sender.selected = !sender.selected;
|
||||
self.selectedBtn = sender;
|
||||
[self.tableView reloadData];
|
||||
[self scrollToBottom];
|
||||
// self.selectedBtn.selected = !self.selectedBtn.selected;
|
||||
// sender.selected = !sender.selected;
|
||||
// self.selectedBtn = sender;
|
||||
// [self.tableView reloadData];
|
||||
// [self scrollToBottom];
|
||||
}
|
||||
|
||||
-(void)scrollToBottom{
|
||||
NSArray *arr;
|
||||
if (self.selectedBtn == self.chatBtn) {
|
||||
arr = self.chatArray;
|
||||
}else if (self.selectedBtn == self.giftBtn) {
|
||||
arr = self.giftArray;
|
||||
}else{
|
||||
// if (self.selectedBtn == self.chatBtn) {
|
||||
// arr = self.chatArray;
|
||||
// }else if (self.selectedBtn == self.giftBtn) {
|
||||
// arr = self.giftArray;
|
||||
// }else{
|
||||
arr = self.dataArray;
|
||||
}
|
||||
// }
|
||||
if (arr.count > 0) {
|
||||
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:arr.count-1 inSection:0] atScrollPosition:(UITableViewScrollPositionBottom) animated:YES];
|
||||
}
|
||||
@@ -175,16 +175,16 @@ NSInteger maxMessageCount = 20;
|
||||
}
|
||||
-(void)insertMessage:(QXRoomChatListModel *)model{
|
||||
/// 非礼物插入
|
||||
if (model.messageType != QXRoomChatMessageTypeGift) {
|
||||
// if (model.messageType != QXRoomChatMessageTypeGift) {
|
||||
[self.dataArray addObject:model];
|
||||
}
|
||||
// }
|
||||
|
||||
if (model.messageType == QXRoomChatMessageTypeChat) {
|
||||
[self.chatArray addObject:model];
|
||||
}
|
||||
if (model.messageType == QXRoomChatMessageTypeGift) {
|
||||
[self.giftArray addObject:model];
|
||||
}
|
||||
// if (model.messageType == QXRoomChatMessageTypeChat) {
|
||||
// [self.chatArray addObject:model];
|
||||
// }
|
||||
// if (model.messageType == QXRoomChatMessageTypeGift) {
|
||||
// [self.giftArray addObject:model];
|
||||
// }
|
||||
// if (self.dataArray.count>maxMessageCount) {
|
||||
// [self.dataArray removeFirstObject];
|
||||
// }
|
||||
@@ -194,7 +194,10 @@ NSInteger maxMessageCount = 20;
|
||||
// if (self.giftArray.count>maxMessageCount) {
|
||||
// [self.giftArray removeFirstObject];
|
||||
// }
|
||||
[self.tableView reloadData];
|
||||
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:self.dataArray.count - 1 inSection:0];
|
||||
[self.tableView beginUpdates];
|
||||
[self.tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationNone];
|
||||
[self.tableView endUpdates];
|
||||
if (self.isDragging) {
|
||||
self.messageCount++;
|
||||
self.messageCountBtn.hidden = NO;
|
||||
@@ -216,23 +219,23 @@ NSInteger maxMessageCount = 20;
|
||||
}
|
||||
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
if (self.selectedBtn == self.chatBtn) {
|
||||
return self.chatArray.count;
|
||||
}
|
||||
if (self.selectedBtn == self.giftBtn) {
|
||||
return self.giftArray.count;
|
||||
}
|
||||
// if (self.selectedBtn == self.chatBtn) {
|
||||
// return self.chatArray.count;
|
||||
// }
|
||||
// if (self.selectedBtn == self.giftBtn) {
|
||||
// return self.giftArray.count;
|
||||
// }
|
||||
return self.dataArray.count;
|
||||
}
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXRoomChatListModel *model;
|
||||
if (self.selectedBtn == self.chatBtn) {
|
||||
model = self.chatArray[indexPath.row];
|
||||
}else if (self.selectedBtn == self.giftBtn) {
|
||||
model = self.giftArray[indexPath.row];
|
||||
}else{
|
||||
// if (self.selectedBtn == self.chatBtn) {
|
||||
// model = self.chatArray[indexPath.row];
|
||||
// }else if (self.selectedBtn == self.giftBtn) {
|
||||
// model = self.giftArray[indexPath.row];
|
||||
// }else{
|
||||
model = self.dataArray[indexPath.row];
|
||||
}
|
||||
// }
|
||||
// model.havBubble = indexPath.row%2;
|
||||
if (model.messageType == QXRoomChatMessageTypeChat) {
|
||||
QXRoomChatListCell *cell = [QXRoomChatListCell cellWithTableView:tableView];
|
||||
@@ -265,13 +268,13 @@ NSInteger maxMessageCount = 20;
|
||||
}
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXRoomChatListModel *model;
|
||||
if (self.selectedBtn == self.chatBtn) {
|
||||
model = self.chatArray[indexPath.row];
|
||||
}else if (self.selectedBtn == self.giftBtn) {
|
||||
model = self.giftArray[indexPath.row];
|
||||
}else{
|
||||
// if (self.selectedBtn == self.chatBtn) {
|
||||
// model = self.chatArray[indexPath.row];
|
||||
// }else if (self.selectedBtn == self.giftBtn) {
|
||||
// model = self.giftArray[indexPath.row];
|
||||
// }else{
|
||||
model = self.dataArray[indexPath.row];
|
||||
}
|
||||
// }
|
||||
CGFloat height = 0;
|
||||
if (model.messageType == QXRoomChatMessageTypeChat) {
|
||||
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16-28-6-8-8];
|
||||
@@ -295,13 +298,13 @@ NSInteger maxMessageCount = 20;
|
||||
}
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXRoomChatListModel *model;
|
||||
if (self.selectedBtn == self.chatBtn) {
|
||||
model = self.chatArray[indexPath.row];
|
||||
}else if (self.selectedBtn == self.giftBtn) {
|
||||
model = self.giftArray[indexPath.row];
|
||||
}else{
|
||||
// if (self.selectedBtn == self.chatBtn) {
|
||||
// model = self.chatArray[indexPath.row];
|
||||
// }else if (self.selectedBtn == self.giftBtn) {
|
||||
// model = self.giftArray[indexPath.row];
|
||||
// }else{
|
||||
model = self.dataArray[indexPath.row];
|
||||
}
|
||||
// }
|
||||
if (model.FromUserInfo.user_id.longValue > 0 && model.messageType == QXRoomChatMessageTypeSystem) {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(previewUserInfoWithUserId:)]) {
|
||||
[self.delegate previewUserInfoWithUserId:model.FromUserInfo.user_id];
|
||||
@@ -830,16 +833,6 @@ NSInteger maxMessageCount = 20;
|
||||
|
||||
-(void)setMessage:(QXRoomChatListModel *)message{
|
||||
_message = message;
|
||||
// NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:message.text];
|
||||
// if ([message.FromUserInfo.nickname isExist]) {
|
||||
// [attr yy_setColor:RGB16(0xFFE309) range:[message.text rangeOfString:message.FromUserInfo.nickname]];
|
||||
// }
|
||||
// if ([message.ToUserInfo.nickname isExist]) {
|
||||
// [attr yy_setColor:RGB16(0xFFE309) range:[message.text rangeOfString:message.ToUserInfo.nickname]];
|
||||
// }
|
||||
//// self.titleLabel.text = message.text;
|
||||
// self.titleLabel.attributedText = attr;
|
||||
|
||||
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:message.text];
|
||||
if ([message.FromUserInfo.nickname isExist]) {
|
||||
[attr yy_setColor:messageNameColor range:[message.text rangeOfString:message.FromUserInfo.nickname]];
|
||||
@@ -889,6 +882,12 @@ NSInteger maxMessageCount = 20;
|
||||
make.bottom.mas_equalTo(-6);
|
||||
}];
|
||||
|
||||
self.bubbleImageView = [[UIImageView alloc] init];
|
||||
[self.bgView addSubview:self.bubbleImageView];
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.bottom.equalTo(self.bgView);
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
// self.titleLabel.textColor = RGB16(0XD1A9FE);
|
||||
self.titleLabel.textColor = UIColor.whiteColor;
|
||||
|
||||
@@ -88,10 +88,10 @@
|
||||
if (!gift) return;
|
||||
|
||||
// 更新发送者名称
|
||||
self.senderLabel.text = [NSString stringWithFormat:@"%@ 送给 %@",gift.FromUserInfo.nickname?: @"",gift.ToUserInfo.nickname?: @""];
|
||||
self.senderLabel.text = [NSString stringWithFormat:@"%@",gift.FromUserInfo.nickname?: @""];
|
||||
|
||||
// 更新礼物信息
|
||||
self.giftLabel.text = [NSString stringWithFormat:@"%@", gift.GiftInfo.gift_name ?: @"礼物"];
|
||||
self.giftLabel.text = [NSString stringWithFormat:@"%@送给%@",gift.ToUserInfo.nickname?: @"", gift.GiftInfo.gift_name ?: @"礼物"];
|
||||
|
||||
// 更新礼物数量
|
||||
self.countLabel.text = [NSString stringWithFormat:@"x%@", gift.gift_num];
|
||||
|
||||
Reference in New Issue
Block a user