From 3e4be5ed4d2c0395dd60e392baf86c59762059b1 Mon Sep 17 00:00:00 2001 From: Davin <591807572@qq.com> Date: 星期五, 30 六月 2023 10:14:50 +0800 Subject: [PATCH] feature 猫眼全屏布局调整 && UI细节适配 --- EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZDeviceMsgListView.m | 69 +++++++++++++++++++++++++++++++--- 1 files changed, 63 insertions(+), 6 deletions(-) diff --git a/EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZDeviceMsgListView.m b/EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZDeviceMsgListView.m index a8e76b8..0596bbe 100644 --- a/EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZDeviceMsgListView.m +++ b/EZSDK/EZSDK/EZ/TempPassword/Views/HDLEZDeviceMsgListView.m @@ -7,6 +7,14 @@ #import "HDLEZDeviceMsgListView.h" #import "HDLEZDeviceMsgCell.h" +#import "HDLEZVideoDoorMsgCell.h" + +@interface HDLEZDeviceMsgListView () + +@property (copy, nonatomic) void(^previewPic)(NSString *pictureUrl); + +@end + @implementation HDLEZDeviceMsgListView{ CGFloat cellHeight; } @@ -21,7 +29,10 @@ self.showsVerticalScrollIndicator=NO; self.delegate = self; self.dataSource = self; - cellHeight=65; + cellHeight=80; + self.rowHeight = UITableViewAutomaticDimension; + self.estimatedRowHeight = 80; + [self registerClass:[HDLEZVideoDoorMsgCell class] forCellReuseIdentifier:@"HDLEZVideoDoorMsgCell"]; [self setSeparatorInset:UIEdgeInsetsZero]; // [self setLayoutMargins:UIEdgeInsetsZero]; } @@ -38,23 +49,69 @@ } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ - return cellHeight; + return UITableViewAutomaticDimension; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ HDLEZLog(@"鍒濆鍖朿ell"); - HDLEZDeviceMsgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HDLEZDeviceMsgCell"]; + HDLEZVideoDoorMsgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HDLEZVideoDoorMsgCell" forIndexPath:indexPath]; if(cell == nil){ - cell=[[HDLEZDeviceMsgCell alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, cellHeight)]; + cell=[[HDLEZVideoDoorMsgCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"HDLEZVideoDoorMsgCell"]; } - HDLEZDeviceMsgInfoModel *model=self.msgList[indexPath.row]; - cell.msgInfo=model; + [self configCell:cell indexPath:indexPath]; +// HDLEZDeviceMsgCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HDLEZDeviceMsgCell"]; +// if(cell == nil){ +// cell=[[HDLEZDeviceMsgCell alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, cellHeight)]; +// } +// HDLEZDeviceMsgInfoModel *model=self.msgList[indexPath.row]; +// cell.msgInfo=model; // HDLEZLog(@"鍒濆鍖朿ell ID:%@",model.extVisitorId); return cell; } +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (self.msgList.count <= indexPath.row) return; + HDLEZDeviceMsgInfoModel *messageModel = self.msgList[indexPath.row]; + if (self.previewPic && messageModel.imageUrl && messageModel.imageUrl.length > 0) { + self.previewPic(messageModel.imageUrl); + } +} + +#pragma mark - PublishMethod +- (void)previewPicture:(void(^)(NSString *pictureUrl))previewPic { + self.previewPic = previewPic; +} + +#pragma mark - PrivateMethod +- (void)configCell:(HDLEZVideoDoorMsgCell *)cell indexPath:(NSIndexPath *)indexPath { + if (self.msgList.count <= indexPath.row) return; + + HDLEZDeviceMsgInfoModel *messageModel = self.msgList[indexPath.row]; + +#warning mock + NSString *stataus = @""; + if (indexPath.row == 0) { + stataus = @"鏈帴"; + messageModel.createTime = @""; + } else if (indexPath.row == 1) { + stataus = @"宸叉帴"; + } + if (messageModel.createTime && messageModel.createTime.length == 13) { + messageModel.createTime = [messageModel.createTime substringToIndex:10]; + } + NSString *messageTime = [self turnDate:messageModel.createTime]; + [cell configMessageInfoWithTitle:messageModel.content deviceStatus:stataus messageTime:messageTime messageImage:indexPath.row != 0 ? messageModel.imageUrl : @""]; + [cell showSpearator:(self.msgList.count != indexPath.row + 1)]; +} + +/*鏃堕棿鎴宠浆鏃堕棿 + */ +-(NSString *)turnDate:(NSString*)dateStr{ + return [HDLEZConstants timeStrWithFormate:@"yyyy.MM.dd HH:mm" data:[NSDate dateWithTimeIntervalSince1970:[dateStr integerValue]]];; +} + /*璁剧疆娑堟伅鍒楄〃鍊� */ -(void)setMsgList:(NSArray<HDLEZDeviceMsgInfoModel *> *)msgList{ -- Gitblit v1.8.0