// // MineViewController.m // AICity // // Created by 刘伟伟 on 2023/7/7. // Copyright © 2023 wei.z. All rights reserved. // #import "MineViewController.h" #import "FavViewController.h" #import "PlayHistoryViewController.h" #import "AccountCenterViewController.h" #import "ComonWKWebViewController.h" @interface MineViewController () @property(nonatomic,strong)UITableView *tableView; @property(nonatomic,strong)NSArray *imagesName; @property(nonatomic,strong)NSArray *titName; @end @implementation MineViewController -(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } - (void)viewDidLoad { [super viewDidLoad]; self.fd_prefersNavigationBarHidden = true; self.imagesName = @[@"Frame 9353",@"Frame 9355",@"Frame 9359",@"Frame 9363",@"Frame 9371"]; self.titName = @[@"我的收藏",@"账号中心",@"用户协议",@"隐私政策",@"当前版本"]; // Do any additional setup after loading the view. [self.view addSubview:self.tableView]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.view); }]; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 3; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if(section == 1){ return 24; }else if(section ==2){ return 12; }else{ return 0; } } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if(indexPath.section == 0){ // return 166; return 60; }else{ return 50; } } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 0.01; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if(section == 0){ return 1; }else if(section ==1){ return 1; }else{ return 5; } } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ if(indexPath.section == 1){ PlayHistoryViewController *fav = [PlayHistoryViewController new]; fav.hidesBottomBarWhenPushed = true; [self.navigationController pushViewController:fav animated:true]; } if(indexPath.row == 0 && indexPath.section == 2){ FavViewController *fav = [FavViewController new]; fav.hidesBottomBarWhenPushed = true; [self.navigationController pushViewController:fav animated:true]; } if(indexPath.row == 1 && indexPath.section == 2){ AccountCenterViewController *fav = [AccountCenterViewController new]; fav.hidesBottomBarWhenPushed = true; [self.navigationController pushViewController:fav animated:true]; } if(indexPath.row == 2 && indexPath.section == 2){ ComonWKWebViewController *vc =[[ComonWKWebViewController alloc] init]; vc.hidesBottomBarWhenPushed = true; vc.title = @"用户协议"; vc.url = @"https://backend.jsnoopyay.com/user_agreement.html"; [self.navigationController pushViewController:vc animated:true]; } if(indexPath.row == 3 && indexPath.section == 2){ //隐私协议 ComonWKWebViewController *vc =[[ComonWKWebViewController alloc] init]; vc.hidesBottomBarWhenPushed = true; vc.title = @"隐私协议"; vc.url = @"https://backend.jsnoopyay.com/private.html"; [self.navigationController pushViewController:vc animated:true]; } } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ if(indexPath.section == 0){ MineTopCell *cell = [MineTopCell cellWithTableView:tableView]; return cell; }else if(indexPath.section == 1){ MineCenterCell *cell = [MineCenterCell cellWithTableView:tableView]; cell.type = 3; cell.showContentType = 0; cell.icon.image = [UIImage imageNamed:@"Frame 9370"]; cell.tit.text=@"历史记录"; return cell; }else { MineCenterCell *cell = [MineCenterCell cellWithTableView:tableView]; if(indexPath.row == 0){ cell.type = 1; cell.showContentType = 0; }else if(indexPath.row == 4){ cell.type = 2; cell.showContentType = 1; NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; cell.titDetail.text = app_Version; }else{ cell.type = 0; cell.showContentType = 0; } cell.icon.image = [UIImage imageNamed:self.imagesName[indexPath.row]]; cell.tit.text = self.titName[indexPath.row]; return cell; } } -(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(24, 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; } @end @implementation MineTopCell + (instancetype)cellWithTableView:(UITableView *)tableView{ static NSString *identifier = @"MineTopCell"; MineTopCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (cell == nil) { cell = [[MineTopCell 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)creatView{ self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; UIImageView *bigimage=[UIImageView new]; bigimage.image = [UIImage imageNamed:@"Ellipse 128"]; [self.contentView addSubview:bigimage]; [bigimage mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(60, 60)); make.left.equalTo(self.contentView).offset(20); make.top.equalTo(self.contentView); }]; UIImageView *smallimage=[UIImageView new]; smallimage.image = [UIImage imageNamed:@"Frame 1"]; [bigimage addSubview:smallimage]; [smallimage mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(36, 36)); make.center.equalTo(bigimage); }]; UIImageView *smallimage2=[UIImageView new]; // smallimage.image = [UIImage imageNamed:@"Frame 1"]; NSDictionary * dic = [[NSUserDefaults standardUserDefaults] objectForKey:@"existUserData"]; [smallimage2 sd_setImageWithURL:dic[@"avatar"]]; [bigimage addSubview:smallimage2]; [smallimage2 mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(56, 56)); make.center.equalTo(bigimage); }]; UILabel *name = [UILabel new]; name.font = [UIFont systemFontOfSize:20]; // name.text = @"登录/注册"; name.text = dic[@"username"]; name.textColor = rgba(255, 255, 255, 1); [self.contentView addSubview:name]; [name mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(bigimage).offset(5); make.left.equalTo(bigimage.mas_right).offset(12); }]; UILabel *welcome = [UILabel new]; welcome.font = [UIFont systemFontOfSize:14]; welcome.text = @"Hi,欢迎来到快影"; welcome.textColor = rgba(246, 234, 167, 0.6); [self.contentView addSubview:welcome]; [welcome mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(name.mas_bottom).offset(6); make.left.equalTo(name); }]; // CGFloat top = 10; // 拉伸区域距离顶端高度 // CGFloat bottom = 10 ; //拉伸区域距离底端高度 // CGFloat left = 10; // 拉伸区域距离左端宽度 // CGFloat right = 10; // 拉伸区域距离右端宽度 // UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right); // UIImageView *bimage=[UIImageView new]; // bimage.image = [[UIImage imageNamed:@"Rectangle 18183"] resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];; // [self.contentView addSubview:bimage]; // [bimage mas_makeConstraints:^(MASConstraintMaker *make) { // make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-24, 81)); // make.top.equalTo(bigimage.mas_bottom).offset(25); // make.left.equalTo(self.contentView).offset(12); // }]; // // UIImageView *lefttopbg=[UIImageView new]; // lefttopbg.image =[UIImage imageNamed:@"Rectangle 18188"]; // [bimage addSubview:lefttopbg]; // [lefttopbg mas_makeConstraints:^(MASConstraintMaker *make) { // make.size.mas_equalTo(CGSizeMake(94, 19)); // make.top.left.equalTo(bimage); // }]; // // UIImageView *lefttoplock=[UIImageView new]; // lefttoplock.image = [UIImage imageNamed:@"Frame 4"]; // [lefttopbg addSubview:lefttoplock]; // [lefttoplock mas_makeConstraints:^(MASConstraintMaker *make) { // make.size.mas_equalTo(CGSizeMake(12, 12)); // make.top.equalTo(lefttopbg).offset(3); // make.left.equalTo(lefttopbg).offset(11); // }]; // // UILabel *lefttoptip=[UILabel new]; // lefttoptip.font = [UIFont systemFontOfSize:10]; // lefttoptip.text = @"未解锁"; // lefttoptip.textColor = rgba(255, 243, 181, 1); // [lefttopbg addSubview:lefttoptip]; // [lefttoptip mas_makeConstraints:^(MASConstraintMaker *make) { // make.centerY.equalTo(lefttoplock); // make.left.equalTo(lefttoplock.mas_right).offset(2); // }]; // // UILabel *viptit=[UILabel new]; // viptit.font = [UIFont systemFontOfSize:16]; // viptit.text = @"影视VIP"; // viptit.textColor = rgba(255, 212, 0, 1); // [bimage addSubview:viptit]; // [viptit mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(lefttopbg.mas_bottom).offset(8); // make.left.equalTo(bimage).offset(12); // }]; // // UILabel *openVip=[UILabel new]; // openVip.font = [UIFont systemFontOfSize:14]; // openVip.text = @"立即开通"; // openVip.textColor = rgba(246, 234, 167, 0.6); // [bimage addSubview:openVip]; // [openVip mas_makeConstraints:^(MASConstraintMaker *make) { // make.bottom.equalTo(bimage.mas_bottom).offset(-12); // make.left.equalTo(viptit); // }]; // // UIImageView *openVipTip=[UIImageView new]; // openVipTip.image = [UIImage imageNamed:@"Frame 9334"]; // [bimage addSubview:openVipTip]; // [openVipTip mas_makeConstraints:^(MASConstraintMaker *make) { // make.size.mas_equalTo(CGSizeMake(16, 16)); // make.centerY.equalTo(openVip); // make.left.equalTo(openVip.mas_right).offset(2); // }]; // // UIImageView *vipicon=[UIImageView new]; // vipicon.image = [UIImage imageNamed:@"image 96"]; // [self.contentView addSubview:vipicon]; // [vipicon mas_makeConstraints:^(MASConstraintMaker *make) { // make.size.mas_equalTo(CGSizeMake(119, 109)); // make.bottom.equalTo(bimage); // make.right.equalTo(bimage.mas_right).offset(-12); // }]; smallimage2.layer.cornerRadius = 28; smallimage2.layer.masksToBounds = 28; } @end @implementation MineCenterCell + (instancetype)cellWithTableView:(UITableView *)tableView{ static NSString *identifier = @"MineCenterCell"; MineCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (cell == nil) { cell = [[MineCenterCell 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)setShowContentType:(int)showContentType{ _showContentType = showContentType; if(showContentType==0){ [self.bgView viewWithTag:310].hidden = true; [self.bgView viewWithTag:311].hidden = false; }else{ [self.bgView viewWithTag:310].hidden = false; [self.bgView viewWithTag:311].hidden = true; } } -(void)setType:(int)type{ _type = type; self.bgView.layer.mask = nil; if(self.type != 0){ // 创建一个 UIView UIView *view = self.bgView; // 设置圆角大小和边框宽度 CGFloat cornerRadius = 12.0; // 设置圆角半径 // CGFloat borderWidth = 2.0; // 设置边框宽度 // 创建圆角路径 UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)]; if(self.type == 1){ path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)]; }else if(self.type ==2){ path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)]; }else if(self.type == 3){ path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)]; } // 创建圆角图层 CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.path = path.CGPath; view.layer.mask = maskLayer; } } //0.没有 1.上 2.下 3.全 -(void)creatView{ self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(12, 0, kScreenWidth - 24, 50)]; self.bgView = bgView; bgView.backgroundColor = rgba(52, 56, 68, 0.8); [self.contentView addSubview:bgView]; [bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.top.equalTo(self.contentView); make.left.equalTo(self.contentView).offset(12); make.right.equalTo(self.contentView).offset(-12); }]; UIImageView *icon=[UIImageView new]; self.icon = icon; [bgView addSubview:icon]; [icon mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(18, 18)); make.centerY.equalTo(bgView); make.left.equalTo(bgView).offset(12); }]; UILabel *tit=[UILabel new]; self.tit = tit; tit.font = [UIFont systemFontOfSize:16]; tit.text = @"历史记录"; tit.textColor = rgba(255, 255, 255, 0.8); [bgView addSubview:tit]; [tit mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(bgView); make.left.equalTo(icon.mas_right).offset(12); }]; UIImageView *tip=[UIImageView new]; tip.image = [UIImage imageNamed:@"Frame 9366"]; tip.tag = 311; [bgView addSubview:tip]; [tip mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(16, 16)); make.centerY.equalTo(bgView); make.right.equalTo(bgView).offset(-16); }]; UILabel *titDetail=[UILabel new]; self.titDetail = titDetail; titDetail.tag = 310; titDetail.font = [UIFont systemFontOfSize:14]; titDetail.text = @"1.0.0"; titDetail.textColor = rgba(255, 255, 255, 0.6); [bgView addSubview:titDetail]; [titDetail mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(bgView); make.right.equalTo(bgView).offset(-16); }]; } @end