| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439 |
- //
- // 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 ()<UITableViewDelegate,UITableViewDataSource>
- @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<self.arr.count;i++){
- [self.selArr addObject:@(1)];
- }
- self.view.backgroundColor = rgba(18, 23, 41, 1);
- [self.view addSubview:self.customerbar];
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.equalTo(self.view);
- make.top.equalTo(self.customerbar.mas_bottom);
- }];
-
- [self addBottomView];
- if(self.arr.count == 0) {
- [self addNotDataView];
- }
- }
- -(void)addNotDataView{
- UIImageView *iv = [UIImageView new];
- iv.image = [UIImage imageNamed:@"nocollect_1"];
- [self.view addSubview:iv];
- [iv mas_makeConstraints:^(MASConstraintMaker *make) {
- make.size.mas_equalTo(CGSizeMake(246, 180));
- make.centerX.equalTo(self.view);
- make.top.equalTo(self.customerbar.mas_bottom).offset(188);
- }];
-
- UILabel *label = [UILabel new];
- label.textColor = rgba(255, 255, 255, 0.4);
- label.text = @"暂无内容";
- label.font = [UIFont systemFontOfSize:16];
- [self.view addSubview:label];
- [label mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(iv);
- make.bottom.equalTo(iv);
- }];
- }
- -(void)addBottomView{
- UIView *bottomView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 48+safebottom)];
- self.bottomView = bottomView;
- self.bottomView.hidden = true;
- bottomView.backgroundColor = rgba(25, 29, 49, 1);
- [self.view addSubview:bottomView];
- [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.view);
- make.height.mas_equalTo(@(48+safebottom));
- make.width.mas_equalTo(@(SCREEN_WIDTH));
- }];
-
- UIButton *leftbtn =[UIButton buttonWithType:UIButtonTypeCustom];
- // [leftbtn setImage:[UIImage imageNamed:@"Frame 9423"] forState:UIControlStateNormal];
- [leftbtn setTitle:@"取消全选" forState:UIControlStateNormal];
- [leftbtn setTitleColor:rgba(255, 255, 255, 1) forState:UIControlStateNormal];
- leftbtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
- leftbtn.adjustsImageWhenHighlighted = false;
- [bottomView addSubview:leftbtn];
- [leftbtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.equalTo(bottomView);
- make.right.equalTo(bottomView.mas_centerX);
- make.height.mas_equalTo(@48);
- }];
-
- UIView *line = [UIView new];
- line.backgroundColor = rgba(255, 255, 255, 0.2);
- [bottomView addSubview:line];
- [line mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(bottomView).offset(12);
- make.centerX.equalTo(bottomView);
- make.height.mas_equalTo(@24);
- make.width.mas_equalTo(@2);
- }];
-
- UIButton *rightbtn =[UIButton buttonWithType:UIButtonTypeCustom];
- // [leftbtn setImage:[UIImage imageNamed:@"Frame 9423"] forState:UIControlStateNormal];
- [rightbtn setTitle:@"删除" forState:UIControlStateNormal];
- [rightbtn setTitleColor:rgba(255, 212, 0, 1) forState:UIControlStateNormal];
- rightbtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
- rightbtn.adjustsImageWhenHighlighted = false;
- [bottomView addSubview:rightbtn];
- [rightbtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.top.equalTo(bottomView);
- make.left.equalTo(bottomView.mas_centerX);
- make.height.mas_equalTo(@48);
- }];
-
-
- // 创建圆角路径
- UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:bottomView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)];
- // 创建圆角图层
- CAShapeLayer *maskLayer = [CAShapeLayer layer];
- maskLayer.path = path.CGPath;
- bottomView.layer.mask = maskLayer;
-
- line.layer.cornerRadius = 2;
- line.layer.masksToBounds = true;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.arr.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- FavCell *cell = [FavCell cellWithTableView:tableView];
- cell.isEdit = self.isEdit;
- cell.dic = self.arr[indexPath.row];
- cell.isSel = [self.selArr[indexPath.row] intValue];
- cell.tapBlock = ^(int index) {
- self.selArr[indexPath.row] = @(index);
- };
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- NSDictionary *dic = self.arr[indexPath.row];
- ZFNormalViewController *vc = [[ZFNormalViewController alloc] init];
- vc.vid = [dic[@"vid"] intValue];
- vc.hidesBottomBarWhenPushed = true;
- [self.navigationController pushViewController:vc animated:true];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 112+16;
- }
- -(UITableView *)tableView{
- if(!_tableView){
- _tableView =[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.showsVerticalScrollIndicator = false;
- _tableView.showsHorizontalScrollIndicator = false;
- _tableView.backgroundColor = rgba(18, 23, 41, 1);
- // _tableView.backgroundColor = [UIColor redColor];
- if (@available(iOS 11, *)) {
- _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- _tableView.estimatedRowHeight = 0;
- _tableView.estimatedSectionFooterHeight = 0;
- _tableView.estimatedSectionHeaderHeight = 0;
-
- UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
- UIEdgeInsets safeAreaInsets = keyWindow.safeAreaInsets;
- CGFloat topSafeArea = safeAreaInsets.top;
- _tableView.contentInset = UIEdgeInsetsMake(-topSafeArea, 0, BAR_HEIGHT, 0);
- // _tableView2.contentInset = UIEdgeInsetsMake(-35, 0, 0, 0);
- }
- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 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
|