| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- //
- // 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 ()<UITableViewDelegate,UITableViewDataSource>
- @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
|