PhotoAlbumListViewController.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. //
  2. // PhotoAlbumListViewController.m
  3. // LenzCameraNativeModuleForRN
  4. //
  5. // Created by 伯爵 on 2023/2/6.
  6. //
  7. #import "PhotoAlbumListViewController.h"
  8. #import "PhotoCollectionViewCell.h"
  9. #import "PhotoListCellModel.h"
  10. #import "PhotoCell.h"
  11. @interface PhotoAlbumListViewController ()
  12. @property (nonatomic ,strong)UIButton *selectBtn;
  13. @end
  14. @implementation PhotoAlbumListViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. self.panoramaLabWidth.constant = 0;
  18. self.intelligenceLabWidth.constant = 0;
  19. [self setTypeLab:self.typeArray];
  20. self.datasLab.text = [NSString stringWithFormat:@"共%lu笔数据",(unsigned long)self.typeArray.count];
  21. [self showPhotoAndMovie];
  22. }
  23. - (void)showPhotoAndMovie{
  24. // [self.photoListVC.view removeFromSuperview];
  25. // [self.movieListVC.view removeFromSuperview];
  26. NSString *typeStr = self.typeArray.lastObject;
  27. if ([typeStr isEqualToString:@"photo"]) {
  28. self.selectBtn = self.continuousBtn;
  29. self.oldVC = self.photoListVC;
  30. [self.continuousBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
  31. self.photoListVC.view.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height);
  32. [self addChildViewController:self.photoListVC];
  33. [self.contentView addSubview:self.photoListVC.view];
  34. [self.photoListVC didMoveToParentViewController:self];
  35. }else if ([typeStr isEqualToString:@"movie"]) {
  36. self.selectBtn = self.movieBtn;
  37. self.oldVC = self.movieListVC;
  38. [self.movieBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
  39. self.movieListVC.view.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height);
  40. [self addChildViewController:self.movieListVC];
  41. [self.contentView addSubview:self.movieListVC.view];
  42. [self.movieListVC didMoveToParentViewController:self];
  43. }
  44. }
  45. - (PhotoListViewController *)photoListVC{
  46. if (!_photoListVC) {
  47. _photoListVC = [PhotoListViewController makeViewController];
  48. }
  49. return _photoListVC;
  50. }
  51. - (MovieListViewController *)movieListVC{
  52. if (!_movieListVC) {
  53. _movieListVC = [MovieListViewController movieMakeViewController];
  54. }
  55. return _movieListVC;
  56. }
  57. - (void)setTypeLab:(NSMutableArray *)types{
  58. if([types indexOfObject:@"photo"] != NSNotFound) {
  59.     self.continuousLabWidth.constant = 50;
  60. }else{
  61.     self.continuousLabWidth.constant = 0;
  62. NSLog(@"不存在");
  63. }
  64. if([types indexOfObject:@"movie"] != NSNotFound) {
  65.     self.movieLabWidth.constant = 50;
  66. }else{
  67.      
  68.   self.movieLabWidth.constant = 0;
  69. }
  70. }
  71. - (UIViewController *)newVC{
  72. if (self.oldVC == self.photoListVC) {
  73. [self addChildViewController:self.movieListVC];
  74. return self.movieListVC;
  75. }else if (self.oldVC == self.movieListVC) {
  76. [self addChildViewController:self.photoListVC];
  77. return self.photoListVC;
  78. }
  79. return nil;
  80. }
  81. - (IBAction)buttonsBtnClick:(UIButton *)sender {
  82. if (self.selectBtn == sender) {
  83. return;
  84. }
  85. self.selectBtn = sender;
  86. if (self.oldVC == self.photoListVC) {
  87. [self addChildViewController:self.movieListVC];
  88. self.movieListVC.view.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height);
  89. }else if (self.oldVC == self.movieListVC) {
  90. [self addChildViewController:self.photoListVC];
  91. self.photoListVC.view.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height);
  92. }
  93. [self addChildViewController:self.photoListVC];
  94. UIViewController *newVC = [self newVC];
  95. [self transitionFromViewController:self.oldVC toViewController:newVC duration:0 options:UIViewAnimationTransitionNone animations:nil completion:^(BOOL finished) {
  96. if (finished) {
  97. [newVC didMoveToParentViewController:self];
  98. [self.oldVC willMoveToParentViewController:nil];
  99. [self.oldVC removeFromParentViewController];
  100. self.oldVC = newVC;
  101. }
  102. }];
  103. for (UIButton *btn in self.buttons) {
  104. if (btn == sender) {
  105. [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
  106. }else{
  107. [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  108. }
  109. }
  110. }
  111. @end