萤石云 iOSSDK,移植跨平台相关工程
Davin
2023-06-25 dd29df2e08ac87c878e26513f1b5ae06eae7a6d9
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,58 @@
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return cellHeight;
    return UITableViewAutomaticDimension;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HDLEZLog(@"初始化cell");
    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(@"初始化cell 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) {
        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 = @"未接";
    } else if (indexPath.row == 1) {
        stataus = @"已接";
    }
    [cell configMessageInfoWithTitle:messageModel.title deviceStatus:stataus messageTime:messageModel.createTime messageImage:indexPath.row != 0 ? messageModel.imageUrl : @""];
    [cell showSpearator:(self.msgList.count != indexPath.row + 1)];
}
/*设置消息列表值
 */
-(void)setMsgList:(NSArray<HDLEZDeviceMsgInfoModel *> *)msgList{