123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- //
- // IndexAllCell.m
- // smartRhino
- //
- // Created by niuzhen on 2020/9/17.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "IndexAllCell.h"
- #import "HomeSubItemModel.h"
- #import "HomeWeiCousreCell.h"
- #import "BookSubArticeCell.h"
- #import "HomeTeacherCell.h"
- #import "HomeMusicCell.h"
- #import "HomeSchoolCell.h"
- #import "IndexGoodBookCell.h"
- @interface IndexAllCell ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) IndexAllModel * model;
- @property (nonatomic, copy) NSString * searchText;
- @end
- @implementation IndexAllCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- self.subTableV.delegate = self;
- self.subTableV.dataSource = self;
- self.backgroundColor = [UIColor clearColor];
- self.bgView.layer.cornerRadius = 8.f;
- self.bgView.layer.masksToBounds = YES;
- }
- + (IndexAllCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellIdentifer = @"IndexAllCell0";
- IndexAllCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"IndexAllCell" owner:nil options:nil] objectAtIndex:0];
- }
- return cell;
- }
- + (IndexAllCell *)configCell1:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellIdentifer = @"IndexAllCell1";
- IndexAllCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"IndexAllCell" owner:nil options:nil] objectAtIndex:1];
- }
- return cell;
- }
- - (void)setDataWithModel:(IndexAllModel *)model
- {
- self.model = model;
- self.nameL.text = self.model.LableName;
- self.subTableV.estimatedRowHeight = 80;
- self.subTableV.rowHeight = UITableViewAutomaticDimension;
- self.subTableV.showsVerticalScrollIndicator = NO;
- self.subTableV.showsHorizontalScrollIndicator = NO;
- [self.subTableV reloadData];
-
- HomeSubItemModel * smodel = self.model.Items.firstObject;
- switch ((CollectModelType)smodel.MediaType) {
- case CollectModel_StoreBook:
- {
- self.contant.constant = 120.f * self.model.Items.count;
- }
- break;
- case CollectModel_StoreVideo:
- {
- self.contant.constant = 110.f * self.model.Items.count;
- }
- break;
- case CollectModel_StoreSound:
- {
- self.contant.constant = 85.f * self.model.Items.count;
- }
- break;
- case CollectModel_Teacher:
- {
- self.contant.constant = 130.f * self.model.Items.count;
- }
- break;
- case CollectModel_Organization:
- {
- self.contant.constant = 130.f * self.model.Items.count;
- }
- break;
- default:
- {
- self.contant.constant = 120.f * self.model.Items.count;
- }
- break;
- }
- }
- - (void)setDataWithModel:(IndexAllModel *)model searchText:(NSString *)text
- {
- self.model = model;
- self.searchText = text;
- self.nameL.text = self.model.LableName;
- self.countL.text = [NSString stringWithFormat:@"(%ld)",self.model.Total];
- self.topBtn.selected = self.model.IsTop;
- [self.topBtn setTitle:@" 置顶 " forState:UIControlStateNormal];
- [self.topBtn setTitle:@" 取消置顶 " forState:UIControlStateSelected];
- [self.topBtn setTitleColor:UIColorHex(0x3979D3) forState:UIControlStateNormal];
- [self.topBtn setTitleColor:UIColorHex(0xBCBCBC) forState:UIControlStateSelected];
- if (self.topBtn.selected) {
- self.topBtn.layer.borderColor = UIColorHex(0xBCBCBC).CGColor;
- }else{
- self.topBtn.layer.borderColor = UIColorHex(0x3979D3).CGColor;
- }
- self.topBtn.layer.borderWidth = 1.f;
- self.topBtn.layer.cornerRadius = 4.f;
- self.topBtn.layer.masksToBounds = YES;
-
- self.subTableV.estimatedRowHeight = 80;
- self.subTableV.rowHeight = UITableViewAutomaticDimension;
- self.subTableV.showsVerticalScrollIndicator = NO;
- self.subTableV.showsHorizontalScrollIndicator = NO;
- [self.subTableV reloadData];
-
- HomeSubItemModel * smodel = self.model.Items.firstObject;
- switch ((CollectModelType)smodel.MediaType) {
- case CollectModel_StoreBook:
- {
- self.contant.constant = 120.f * self.model.Items.count;
- }
- break;
- case CollectModel_StoreVideo:
- {
- self.contant.constant = 110.f * self.model.Items.count;
- }
- break;
- case CollectModel_StoreSound:
- {
- self.contant.constant = 85.f * self.model.Items.count;
- }
- break;
- case CollectModel_Teacher:
- {
- self.contant.constant = 130.f * self.model.Items.count;
- }
- break;
- case CollectModel_Organization:
- {
- self.contant.constant = 130.f * self.model.Items.count;
- }
- break;
- default:
- {
- self.contant.constant = 120.f * self.model.Items.count;
- }
- break;
- }
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.model.Items.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- HomeSubItemModel * smodel = self.model.Items[indexPath.item];
- switch ((CollectModelType)smodel.MediaType) {
- case CollectModel_StoreBook:
- {
- IndexGoodBookCell * cell = [IndexGoodBookCell configCell0:tableView indexPath:indexPath];
- [cell setDataWithModel:smodel searchText:self.searchText];
- if (self.model.Items.count == indexPath.row + 1) {
- cell.lineV.hidden = YES;
- }
- return cell;
- }
- break;
- case CollectModel_StoreVideo:
- {
- HomeWeiCousreCell * cell = [HomeWeiCousreCell configCell0:tableView indexPath:indexPath];
- [cell setDataWithIndexModel:smodel searchText:self.searchText];
- if (self.model.Items.count == indexPath.row + 1) {
- cell.lineV.hidden = YES;
- }
- return cell;
- }
- break;
- case CollectModel_StoreSound:
- {
- HomeMusicCell * cell = [HomeMusicCell configCell:tableView indexPath:indexPath];
- [cell setDataWithModel:smodel searchText:self.searchText];
- if (self.model.Items.count == indexPath.row + 1) {
- cell.lineV.hidden = YES;
- }
- return cell;
- }
- break;
- case CollectModel_Teacher:
- {
- HomeTeacherCell * cell = [HomeTeacherCell configCell:tableView indexPath:indexPath];
- [cell setDataWithModel:smodel searchText:self.searchText];
- if (self.model.Items.count == indexPath.row + 1) {
- cell.lineV.hidden = YES;
- }
- return cell;
- }
- break;
- case CollectModel_Organization:
- {
- HomeSchoolCell * cell = [HomeSchoolCell configCell1:tableView indexPath:indexPath];
- [cell setDataIndexModel:smodel searchText:self.searchText];
- if (self.model.Items.count == indexPath.row + 1) {
- cell.lineV.hidden = YES;
- }
- return cell;
- }
- break;
- default:
- {
- IndexGoodBookCell * cell = [IndexGoodBookCell configCell1:tableView indexPath:indexPath];
- [cell setDataWithModel:smodel searchText:self.searchText];
- if (self.model.Items.count == indexPath.row + 1) {
- cell.lineV.hidden = YES;
- }
- return cell;
- }
- break;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- HomeSubItemModel * model = self.model.Items[indexPath.item];
- if (self.ClickRowBlock) {
- self.ClickRowBlock((CollectModelType)model.MediaType, model.Id);
- }
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- @end
|