// // diskListTableView.m // 隐私保护 // // Created by xd h on 2024/1/23. // #import "diskListTableView.h" #import "diskListTableCell.h" #import "cloudPhoneExtraFileListModel.h" @interface diskListTableView() @end @implementation diskListTableView #pragma mark - init - (instancetype)init { self = [super init]; if (self) { [self initCommon]; } return self; } - (instancetype)initWithCoder:(NSCoder *)coder { self = [super initWithCoder:coder]; if (self) { [self initCommon]; } return self; } - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initCommon]; } return self; } - (void)initCommon { self.delegate = self; self.dataSource = self; self.separatorStyle = UITableViewCellSeparatorStyleNone; //self.backgroundColor = [UIColor colorWithRed:235.0/255.0 green:235.0/255.0 blue:235.0/255.0 alpha:1.0]; self.backgroundColor = [UIColor clearColor]; } #pragma mark - uitableviewDelegate - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifer = @"diskListTableCell"; diskListTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer]; if(cell == nil){ cell = [[diskListTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifer]; cell.accessoryType = UITableViewCellAccessoryNone; } NSInteger row = indexPath.row; if(row < _diskListArr.count){ cloudPhoneExtraFileModel *model = _diskListArr[row]; cell.curModel = model; } KWeakSelf cell.didClickSwitch = ^(BOOL SwitchOn) { [weakSelf setModelSelectInRow:row]; }; return cell; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return _diskListArr.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 70.0; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (void)setDiskListArr:(NSMutableArray *)diskListArr { _diskListArr = diskListArr; [self reloadData]; } - (void)setModelSelectInRow:(NSInteger)row { for (int i=0; i<_diskListArr.count; i++) { cloudPhoneExtraFileModel *model = _diskListArr[i]; model.isCheckType = NO; if(i == row){ model.isCheckType = YES; if(_didClickDiskModel){ _didClickDiskModel(model.extraPath); } } } [self reloadData]; } @end