MineViewController.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. //
  2. // MineViewController.m
  3. // AICity
  4. //
  5. // Created by 刘伟伟 on 2023/7/7.
  6. // Copyright © 2023 wei.z. All rights reserved.
  7. //
  8. #import "MineViewController.h"
  9. #import "FavViewController.h"
  10. #import "PlayHistoryViewController.h"
  11. #import "AccountCenterViewController.h"
  12. #import "ComonWKWebViewController.h"
  13. @interface MineViewController ()<UITableViewDelegate,UITableViewDataSource>
  14. @property(nonatomic,strong)UITableView *tableView;
  15. @property(nonatomic,strong)NSArray *imagesName;
  16. @property(nonatomic,strong)NSArray *titName;
  17. @end
  18. @implementation MineViewController
  19. -(UIStatusBarStyle)preferredStatusBarStyle{
  20. return UIStatusBarStyleLightContent;
  21. }
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. self.fd_prefersNavigationBarHidden = true;
  25. self.imagesName = @[@"Frame 9353",@"Frame 9355",@"Frame 9359",@"Frame 9363",@"Frame 9371"];
  26. self.titName = @[@"我的收藏",@"账号中心",@"用户协议",@"隐私政策",@"当前版本"];
  27. // Do any additional setup after loading the view.
  28. [self.view addSubview:self.tableView];
  29. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.edges.equalTo(self.view);
  31. }];
  32. }
  33. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  34. return 3;
  35. }
  36. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  37. if(section == 1){
  38. return 24;
  39. }else if(section ==2){
  40. return 12;
  41. }else{
  42. return 0;
  43. }
  44. }
  45. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  46. if(indexPath.section == 0){
  47. // return 166;
  48. return 60;
  49. }else{
  50. return 50;
  51. }
  52. }
  53. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  54. return 0.01;
  55. }
  56. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  57. if(section == 0){
  58. return 1;
  59. }else if(section ==1){
  60. return 1;
  61. }else{
  62. return 5;
  63. }
  64. }
  65. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  66. if(indexPath.section == 1){
  67. PlayHistoryViewController *fav = [PlayHistoryViewController new];
  68. fav.hidesBottomBarWhenPushed = true;
  69. [self.navigationController pushViewController:fav animated:true];
  70. }
  71. if(indexPath.row == 0 && indexPath.section == 2){
  72. FavViewController *fav = [FavViewController new];
  73. fav.hidesBottomBarWhenPushed = true;
  74. [self.navigationController pushViewController:fav animated:true];
  75. }
  76. if(indexPath.row == 1 && indexPath.section == 2){
  77. AccountCenterViewController *fav = [AccountCenterViewController new];
  78. fav.hidesBottomBarWhenPushed = true;
  79. [self.navigationController pushViewController:fav animated:true];
  80. }
  81. if(indexPath.row == 2 && indexPath.section == 2){
  82. ComonWKWebViewController *vc =[[ComonWKWebViewController alloc] init];
  83. vc.hidesBottomBarWhenPushed = true;
  84. vc.title = @"用户协议";
  85. vc.url = @"https://backend.jsnoopyay.com/user_agreement.html";
  86. [self.navigationController pushViewController:vc animated:true];
  87. }
  88. if(indexPath.row == 3 && indexPath.section == 2){
  89. //隐私协议
  90. ComonWKWebViewController *vc =[[ComonWKWebViewController alloc] init];
  91. vc.hidesBottomBarWhenPushed = true;
  92. vc.title = @"隐私协议";
  93. vc.url = @"https://backend.jsnoopyay.com/private.html";
  94. [self.navigationController pushViewController:vc animated:true];
  95. }
  96. }
  97. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  98. if(indexPath.section == 0){
  99. MineTopCell *cell = [MineTopCell cellWithTableView:tableView];
  100. return cell;
  101. }else if(indexPath.section == 1){
  102. MineCenterCell *cell = [MineCenterCell cellWithTableView:tableView];
  103. cell.type = 3;
  104. cell.showContentType = 0;
  105. cell.icon.image = [UIImage imageNamed:@"Frame 9370"];
  106. cell.tit.text=@"历史记录";
  107. return cell;
  108. }else {
  109. MineCenterCell *cell = [MineCenterCell cellWithTableView:tableView];
  110. if(indexPath.row == 0){
  111. cell.type = 1;
  112. cell.showContentType = 0;
  113. }else if(indexPath.row == 4){
  114. cell.type = 2;
  115. cell.showContentType = 1;
  116. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  117. NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
  118. cell.titDetail.text = app_Version;
  119. }else{
  120. cell.type = 0;
  121. cell.showContentType = 0;
  122. }
  123. cell.icon.image = [UIImage imageNamed:self.imagesName[indexPath.row]];
  124. cell.tit.text = self.titName[indexPath.row];
  125. return cell;
  126. }
  127. }
  128. -(UITableView *)tableView{
  129. if(!_tableView){
  130. _tableView =[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
  131. _tableView.delegate = self;
  132. _tableView.dataSource = self;
  133. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  134. _tableView.showsVerticalScrollIndicator = false;
  135. _tableView.showsHorizontalScrollIndicator = false;
  136. _tableView.backgroundColor = rgba(18, 23, 41, 1);
  137. // _tableView.backgroundColor = [UIColor redColor];
  138. if (@available(iOS 11, *)) {
  139. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  140. _tableView.estimatedRowHeight = 0;
  141. _tableView.estimatedSectionFooterHeight = 0;
  142. _tableView.estimatedSectionHeaderHeight = 0;
  143. // UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
  144. // UIEdgeInsets safeAreaInsets = keyWindow.safeAreaInsets;
  145. // CGFloat topSafeArea = safeAreaInsets.top;
  146. _tableView.contentInset = UIEdgeInsetsMake(24, 0, BAR_HEIGHT, 0);
  147. // _tableView2.contentInset = UIEdgeInsetsMake(-35, 0, 0, 0);
  148. }
  149. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 // only Xcode 13+ needs and can compile this
  150. if (@available(iOS 15.0, *)) {
  151. _tableView.sectionHeaderTopPadding = 0;
  152. }
  153. #endif
  154. }
  155. return _tableView;
  156. }
  157. @end
  158. @implementation MineTopCell
  159. + (instancetype)cellWithTableView:(UITableView *)tableView{
  160. static NSString *identifier = @"MineTopCell";
  161. MineTopCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  162. if (cell == nil) {
  163. cell = [[MineTopCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
  164. }
  165. return cell;
  166. }
  167. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  168. {
  169. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  170. if (self) {
  171. [self creatView];
  172. }
  173. return self;
  174. }
  175. -(void)creatView{
  176. self.selectionStyle = UITableViewCellSelectionStyleNone;
  177. self.backgroundColor = [UIColor clearColor];
  178. UIImageView *bigimage=[UIImageView new];
  179. bigimage.image = [UIImage imageNamed:@"Ellipse 128"];
  180. [self.contentView addSubview:bigimage];
  181. [bigimage mas_makeConstraints:^(MASConstraintMaker *make) {
  182. make.size.mas_equalTo(CGSizeMake(60, 60));
  183. make.left.equalTo(self.contentView).offset(20);
  184. make.top.equalTo(self.contentView);
  185. }];
  186. UIImageView *smallimage=[UIImageView new];
  187. smallimage.image = [UIImage imageNamed:@"Frame 1"];
  188. [bigimage addSubview:smallimage];
  189. [smallimage mas_makeConstraints:^(MASConstraintMaker *make) {
  190. make.size.mas_equalTo(CGSizeMake(36, 36));
  191. make.center.equalTo(bigimage);
  192. }];
  193. UIImageView *smallimage2=[UIImageView new];
  194. // smallimage.image = [UIImage imageNamed:@"Frame 1"];
  195. NSDictionary * dic = [[NSUserDefaults standardUserDefaults] objectForKey:@"existUserData"];
  196. [smallimage2 sd_setImageWithURL:dic[@"avatar"]];
  197. [bigimage addSubview:smallimage2];
  198. [smallimage2 mas_makeConstraints:^(MASConstraintMaker *make) {
  199. make.size.mas_equalTo(CGSizeMake(56, 56));
  200. make.center.equalTo(bigimage);
  201. }];
  202. UILabel *name = [UILabel new];
  203. name.font = [UIFont systemFontOfSize:20];
  204. // name.text = @"登录/注册";
  205. name.text = dic[@"username"];
  206. name.textColor = rgba(255, 255, 255, 1);
  207. [self.contentView addSubview:name];
  208. [name mas_makeConstraints:^(MASConstraintMaker *make) {
  209. make.top.equalTo(bigimage).offset(5);
  210. make.left.equalTo(bigimage.mas_right).offset(12);
  211. }];
  212. UILabel *welcome = [UILabel new];
  213. welcome.font = [UIFont systemFontOfSize:14];
  214. welcome.text = @"Hi,欢迎来到快影";
  215. welcome.textColor = rgba(246, 234, 167, 0.6);
  216. [self.contentView addSubview:welcome];
  217. [welcome mas_makeConstraints:^(MASConstraintMaker *make) {
  218. make.top.equalTo(name.mas_bottom).offset(6);
  219. make.left.equalTo(name);
  220. }];
  221. // CGFloat top = 10; // 拉伸区域距离顶端高度
  222. // CGFloat bottom = 10 ; //拉伸区域距离底端高度
  223. // CGFloat left = 10; // 拉伸区域距离左端宽度
  224. // CGFloat right = 10; // 拉伸区域距离右端宽度
  225. // UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
  226. // UIImageView *bimage=[UIImageView new];
  227. // bimage.image = [[UIImage imageNamed:@"Rectangle 18183"] resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];;
  228. // [self.contentView addSubview:bimage];
  229. // [bimage mas_makeConstraints:^(MASConstraintMaker *make) {
  230. // make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-24, 81));
  231. // make.top.equalTo(bigimage.mas_bottom).offset(25);
  232. // make.left.equalTo(self.contentView).offset(12);
  233. // }];
  234. //
  235. // UIImageView *lefttopbg=[UIImageView new];
  236. // lefttopbg.image =[UIImage imageNamed:@"Rectangle 18188"];
  237. // [bimage addSubview:lefttopbg];
  238. // [lefttopbg mas_makeConstraints:^(MASConstraintMaker *make) {
  239. // make.size.mas_equalTo(CGSizeMake(94, 19));
  240. // make.top.left.equalTo(bimage);
  241. // }];
  242. //
  243. // UIImageView *lefttoplock=[UIImageView new];
  244. // lefttoplock.image = [UIImage imageNamed:@"Frame 4"];
  245. // [lefttopbg addSubview:lefttoplock];
  246. // [lefttoplock mas_makeConstraints:^(MASConstraintMaker *make) {
  247. // make.size.mas_equalTo(CGSizeMake(12, 12));
  248. // make.top.equalTo(lefttopbg).offset(3);
  249. // make.left.equalTo(lefttopbg).offset(11);
  250. // }];
  251. //
  252. // UILabel *lefttoptip=[UILabel new];
  253. // lefttoptip.font = [UIFont systemFontOfSize:10];
  254. // lefttoptip.text = @"未解锁";
  255. // lefttoptip.textColor = rgba(255, 243, 181, 1);
  256. // [lefttopbg addSubview:lefttoptip];
  257. // [lefttoptip mas_makeConstraints:^(MASConstraintMaker *make) {
  258. // make.centerY.equalTo(lefttoplock);
  259. // make.left.equalTo(lefttoplock.mas_right).offset(2);
  260. // }];
  261. //
  262. // UILabel *viptit=[UILabel new];
  263. // viptit.font = [UIFont systemFontOfSize:16];
  264. // viptit.text = @"影视VIP";
  265. // viptit.textColor = rgba(255, 212, 0, 1);
  266. // [bimage addSubview:viptit];
  267. // [viptit mas_makeConstraints:^(MASConstraintMaker *make) {
  268. // make.top.equalTo(lefttopbg.mas_bottom).offset(8);
  269. // make.left.equalTo(bimage).offset(12);
  270. // }];
  271. //
  272. // UILabel *openVip=[UILabel new];
  273. // openVip.font = [UIFont systemFontOfSize:14];
  274. // openVip.text = @"立即开通";
  275. // openVip.textColor = rgba(246, 234, 167, 0.6);
  276. // [bimage addSubview:openVip];
  277. // [openVip mas_makeConstraints:^(MASConstraintMaker *make) {
  278. // make.bottom.equalTo(bimage.mas_bottom).offset(-12);
  279. // make.left.equalTo(viptit);
  280. // }];
  281. //
  282. // UIImageView *openVipTip=[UIImageView new];
  283. // openVipTip.image = [UIImage imageNamed:@"Frame 9334"];
  284. // [bimage addSubview:openVipTip];
  285. // [openVipTip mas_makeConstraints:^(MASConstraintMaker *make) {
  286. // make.size.mas_equalTo(CGSizeMake(16, 16));
  287. // make.centerY.equalTo(openVip);
  288. // make.left.equalTo(openVip.mas_right).offset(2);
  289. // }];
  290. //
  291. // UIImageView *vipicon=[UIImageView new];
  292. // vipicon.image = [UIImage imageNamed:@"image 96"];
  293. // [self.contentView addSubview:vipicon];
  294. // [vipicon mas_makeConstraints:^(MASConstraintMaker *make) {
  295. // make.size.mas_equalTo(CGSizeMake(119, 109));
  296. // make.bottom.equalTo(bimage);
  297. // make.right.equalTo(bimage.mas_right).offset(-12);
  298. // }];
  299. smallimage2.layer.cornerRadius = 28;
  300. smallimage2.layer.masksToBounds = 28;
  301. }
  302. @end
  303. @implementation MineCenterCell
  304. + (instancetype)cellWithTableView:(UITableView *)tableView{
  305. static NSString *identifier = @"MineCenterCell";
  306. MineCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  307. if (cell == nil) {
  308. cell = [[MineCenterCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
  309. }
  310. return cell;
  311. }
  312. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  313. {
  314. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  315. if (self) {
  316. [self creatView];
  317. }
  318. return self;
  319. }
  320. -(void)setShowContentType:(int)showContentType{
  321. _showContentType = showContentType;
  322. if(showContentType==0){
  323. [self.bgView viewWithTag:310].hidden = true;
  324. [self.bgView viewWithTag:311].hidden = false;
  325. }else{
  326. [self.bgView viewWithTag:310].hidden = false;
  327. [self.bgView viewWithTag:311].hidden = true;
  328. }
  329. }
  330. -(void)setType:(int)type{
  331. _type = type;
  332. self.bgView.layer.mask = nil;
  333. if(self.type != 0){
  334. // 创建一个 UIView
  335. UIView *view = self.bgView;
  336. // 设置圆角大小和边框宽度
  337. CGFloat cornerRadius = 12.0; // 设置圆角半径
  338. // CGFloat borderWidth = 2.0; // 设置边框宽度
  339. // 创建圆角路径
  340. UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
  341. if(self.type == 1){
  342. path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
  343. }else if(self.type ==2){
  344. path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
  345. }else if(self.type == 3){
  346. path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
  347. }
  348. // 创建圆角图层
  349. CAShapeLayer *maskLayer = [CAShapeLayer layer];
  350. maskLayer.path = path.CGPath;
  351. view.layer.mask = maskLayer;
  352. }
  353. }
  354. //0.没有 1.上 2.下 3.全
  355. -(void)creatView{
  356. self.selectionStyle = UITableViewCellSelectionStyleNone;
  357. self.backgroundColor = [UIColor clearColor];
  358. UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(12, 0, kScreenWidth - 24, 50)];
  359. self.bgView = bgView;
  360. bgView.backgroundColor = rgba(52, 56, 68, 0.8);
  361. [self.contentView addSubview:bgView];
  362. [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  363. make.bottom.top.equalTo(self.contentView);
  364. make.left.equalTo(self.contentView).offset(12);
  365. make.right.equalTo(self.contentView).offset(-12);
  366. }];
  367. UIImageView *icon=[UIImageView new];
  368. self.icon = icon;
  369. [bgView addSubview:icon];
  370. [icon mas_makeConstraints:^(MASConstraintMaker *make) {
  371. make.size.mas_equalTo(CGSizeMake(18, 18));
  372. make.centerY.equalTo(bgView);
  373. make.left.equalTo(bgView).offset(12);
  374. }];
  375. UILabel *tit=[UILabel new];
  376. self.tit = tit;
  377. tit.font = [UIFont systemFontOfSize:16];
  378. tit.text = @"历史记录";
  379. tit.textColor = rgba(255, 255, 255, 0.8);
  380. [bgView addSubview:tit];
  381. [tit mas_makeConstraints:^(MASConstraintMaker *make) {
  382. make.centerY.equalTo(bgView);
  383. make.left.equalTo(icon.mas_right).offset(12);
  384. }];
  385. UIImageView *tip=[UIImageView new];
  386. tip.image = [UIImage imageNamed:@"Frame 9366"];
  387. tip.tag = 311;
  388. [bgView addSubview:tip];
  389. [tip mas_makeConstraints:^(MASConstraintMaker *make) {
  390. make.size.mas_equalTo(CGSizeMake(16, 16));
  391. make.centerY.equalTo(bgView);
  392. make.right.equalTo(bgView).offset(-16);
  393. }];
  394. UILabel *titDetail=[UILabel new];
  395. self.titDetail = titDetail;
  396. titDetail.tag = 310;
  397. titDetail.font = [UIFont systemFontOfSize:14];
  398. titDetail.text = @"1.0.0";
  399. titDetail.textColor = rgba(255, 255, 255, 0.6);
  400. [bgView addSubview:titDetail];
  401. [titDetail mas_makeConstraints:^(MASConstraintMaker *make) {
  402. make.centerY.equalTo(bgView);
  403. make.right.equalTo(bgView).offset(-16);
  404. }];
  405. }
  406. @end