// // PlayHistoryViewController.m // AICity // // Created by 刘伟伟 on 2023/7/13. // Copyright © 2023 wei.z. All rights reserved. // #import "FavViewController.h" #import "CommonBarView.h" #import "ZFNormalViewController.h" @interface FavViewController () @property(nonatomic,strong)CommonBarView *customerbar; @property(nonatomic,strong)UITableView *tableView; @property(nonatomic,strong)UIView *bottomView; @property(nonatomic,assign)BOOL isEdit; @property(nonatomic,strong)NSArray *arr; @property(nonatomic,strong)NSMutableArray *selArr; @end @implementation FavViewController -(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.fd_prefersNavigationBarHidden = true; self.arr = [UserModel getCollect]; self.selArr = [NSMutableArray array]; for(int i=0;i= 150000 // only Xcode 13+ needs and can compile this if (@available(iOS 15.0, *)) { _tableView.sectionHeaderTopPadding = 0; } #endif } return _tableView; } -(void)changeSelState:(UIButton *)btn{ if(!btn.isSelected){ //编辑状态 self.isEdit = true; self.bottomView.hidden = false; [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.bottom.equalTo(self.bottomView.mas_top); make.top.equalTo(self.customerbar.mas_bottom); }]; }else{ //取消编辑 self.isEdit = false; self.bottomView.hidden = true; [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.equalTo(self.view); make.top.equalTo(self.customerbar.mas_bottom); }]; } [self.tableView reloadData]; btn.selected = !btn.isSelected; } -(CommonBarView *)customerbar{ if(!_customerbar){ CGFloat h=0; if(@available(iOS 13.0, *)){ UIStatusBarManager *sc= [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager; CGRect f=sc.statusBarFrame; h=f.size.height; }else{ h=[UIApplication sharedApplication].statusBarFrame.size.height; } if(h>=40){ h=30; } _customerbar =[[CommonBarView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 72-20+h)]; _customerbar.bgView.backgroundColor = [UIColor clearColor]; _customerbar.label.text=@"我的收藏"; _customerbar.bgView.alpha = 1; _customerbar.label.textColor = rgba(255, 255, 255, 1); // _customerbar.leftButton.hidden = true; // [_customerbar.leftButton setImage:[UIImage imageNamed:@"his_back"] forState:UIControlStateNormal]; [_customerbar.rightButton setImage:[UIImage imageNamed:@"Frame 9411"] forState:UIControlStateNormal]; [_customerbar.rightButton setTitle:@"编辑" forState:UIControlStateNormal]; [_customerbar.rightButton setImage:[self imageWithColor:[UIColor clearColor]] forState:UIControlStateSelected]; [_customerbar.rightButton setTitle:@"取消" forState:UIControlStateSelected]; [_customerbar.rightButton setTitleColor:rgba(255, 255, 255, 1) forState:UIControlStateNormal]; _customerbar.rightButton.titleLabel.font =[UIFont systemFontOfSize:14]; _customerbar.rightButton.hidden = true; [_customerbar.leftButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; [_customerbar.rightButton addTarget:self action:@selector(changeSelState:) forControlEvents:UIControlEventTouchUpInside]; // [_customerbar.rightButton addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside]; // [_customerbar.rightButton mas_remakeConstraints:^(MASConstraintMaker *make) { // make.centerY.equalTo(_customerbar.leftButton); // make.right.equalTo(_customerbar).offset(-15); // make.size.mas_equalTo(CGSizeMake(23, 23)); // }]; } return _customerbar; } -(void)backAction{ [self.navigationController popViewControllerAnimated:true]; } - (UIImage *)imageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; } @end @interface FavCell() @property(nonatomic,strong)UIButton *sel; @end @implementation FavCell + (instancetype)cellWithTableView:(UITableView *)tableView{ static NSString *identifier = @"FavCell"; FavCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (cell == nil) { cell = [[FavCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; } return cell; } - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self creatView]; } return self; } -(void)setIsEdit:(BOOL)isEdit{ _isEdit = isEdit; if(isEdit){ self.sel.hidden = false; }else{ self.sel.hidden = true; } } -(void)setDic:(NSDictionary *)dic{ _dic = dic; UIImageView *iv = [self.contentView viewWithTag:100]; [iv sd_setImageWithURL:[NSURL URLWithString:dic[@"vertical_cover_url"]]]; UILabel *nameLabel = [[self.contentView viewWithTag:200] viewWithTag:201]; nameLabel.text = dic[@"ch_name"]; UILabel *nameLabel2 = [[self.contentView viewWithTag:200] viewWithTag:202]; nameLabel2.text = [NSString stringWithFormat:@"未观看 | %d集全",[dic[@"total_episodes"] intValue]]; UILabel *nameLabel3 = [[self.contentView viewWithTag:200] viewWithTag:203]; nameLabel3.text = @"观看至 2023-05-08期"; } -(void)setIsSel:(int)isSel{ _isSel = isSel; self.sel.selected = isSel; } -(void)changeSel{ self.sel.selected = !self.sel.isSelected; if(self.tapBlock){ self.tapBlock(self.sel.isSelected); } } -(void)creatView{ self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; UIView *cview = [UIView new]; cview.tag = 200; cview.backgroundColor = rgba(27, 31, 48, 1); [self.contentView addSubview:cview]; [cview mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.contentView); make.top.equalTo(self.contentView).offset(8); make.left.equalTo(self.contentView).offset(12); make.right.equalTo(self.contentView).offset(-12); }]; UIImageView *iv = [UIImageView new]; iv.tag = 100; // iv.backgroundColor = [UIColor redColor]; [self.contentView addSubview:iv]; [iv mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView); make.left.equalTo(cview).offset(12); make.size.mas_equalTo(CGSizeMake(72, 100)); }]; UIButton *sel = [UIButton new]; self.sel = sel; sel.hidden = true; //Frame 9517 nosel [sel setBackgroundImage:[UIImage imageNamed:@"Frame 9465"] forState:UIControlStateNormal]; [sel setBackgroundImage:[UIImage imageNamed:@"Frame 9517"] forState:UIControlStateSelected]; [sel addTarget:self action:@selector(changeSel) forControlEvents:UIControlEventTouchUpInside]; [cview addSubview:sel]; [sel mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(16, 16)); make.right.equalTo(cview).offset(-8); make.top.equalTo(cview).offset(8); }]; //58 // UIView *bview =[UIView new]; // bview.backgroundColor = rgba(27, 31, 48, 1); // [cview addSubview:bview]; // [bview mas_makeConstraints:^(MASConstraintMaker *make) { // make.height.mas_equalTo(@58); // make.left.right.bottom.equalTo(cview); // }]; UILabel *nameLabel = [UILabel new]; nameLabel.tag = 201; nameLabel.font= [UIFont boldSystemFontOfSize:14]; nameLabel.textColor = rgba(255, 255, 255, 1); nameLabel.text = @"复仇者联盟"; [cview addSubview:nameLabel]; [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(cview).offset(96); make.top.equalTo(cview).offset(16); }]; UILabel *playStateLabel = [UILabel new]; playStateLabel.tag = 202; playStateLabel.font= [UIFont boldSystemFontOfSize:12]; playStateLabel.textColor = rgba(255, 255, 255, 0.4); playStateLabel.text = @"未观看 | 10集全"; [cview addSubview:playStateLabel]; [playStateLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nameLabel); make.top.equalTo(nameLabel.mas_bottom).offset(12); }]; UILabel *playStateLabel2 = [UILabel new]; playStateLabel2.font= [UIFont boldSystemFontOfSize:12]; playStateLabel2.textColor = rgba(255, 255, 255, 0.4); playStateLabel2.tag = 203; playStateLabel2.text = @"观看至 2023-05-08期"; [cview addSubview:playStateLabel2]; [playStateLabel2 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nameLabel); make.top.equalTo(playStateLabel.mas_bottom).offset(4); }]; UIButton *cplayBtn =[UIButton buttonWithType:UIButtonTypeCustom]; [cplayBtn setBackgroundImage:[UIImage imageNamed:@"Frame 9433"] forState:UIControlStateNormal]; cplayBtn.adjustsImageWhenHighlighted = false; cplayBtn.userInteractionEnabled = false; [cview addSubview:cplayBtn]; [cplayBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(cview).offset(-12); make.centerY.equalTo(playStateLabel2); make.size.mas_equalTo(CGSizeMake(76, 24)); }]; // UIView *lineProcess = [UIView new]; // lineProcess.backgroundColor = rgba(255, 255, 255, 0.4); // [bview addSubview:lineProcess]; // [lineProcess mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(bview).offset(12); // make.right.equalTo(bview).offset(-12); // make.bottom.equalTo(bview).offset(-10); // make.height.mas_equalTo(@2); // }]; // // UIView *lineProcess2 = [UIView new]; // lineProcess2.backgroundColor = rgba(255, 212, 0, 1); // [bview addSubview:lineProcess2]; // [lineProcess2 mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(bview).offset(12); // make.width.mas_equalTo(@((SCREEN_WIDTH-48)*0.4)); // make.bottom.equalTo(bview).offset(-10); // make.height.mas_equalTo(@2); // }]; cview.layer.cornerRadius = 8; cview.layer.masksToBounds = true; iv.layer.cornerRadius = 8; iv.layer.masksToBounds = true; // lineProcess2.layer.cornerRadius = 1; // lineProcess2.layer.masksToBounds = true; } -(void)setFrame:(CGRect)frame{ frame.origin.y += 16; frame.size.height -= 16; [super setFrame:frame]; } @end