downLoadPreviewViewController.m 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // downLoadPreviewViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2024/1/7.
  6. //
  7. #import "downLoadPreviewViewController.h"
  8. #import "couldPhoneFileListModel.h"
  9. #import "downLoadPreViewCell.h"
  10. @interface downLoadPreviewViewController ()<UITableViewDelegate,UITableViewDataSource>
  11. @property (nonatomic, strong) UITableView *tableView;
  12. @property (nonatomic, strong) UIButton *rightButton;
  13. @property(nonatomic,strong) couldPhoneFileListModel *curCouldPhoneFileListMod;
  14. @end
  15. @implementation downLoadPreviewViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view.
  19. [self.toolBar setHidden:YES];
  20. [self.navigationBar setHidden:YES];
  21. [self.navBarBGView setHidden:NO];
  22. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  23. [self.view setBackgroundColor:[UIColor whiteColor]];
  24. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(searchFileListDoneFun:) name:searchFileListDoneNotification object:nil];
  25. [self drawAnyView];
  26. }
  27. - (void)drawAnyView{
  28. _rightButton = [[UIButton alloc] init];
  29. [_rightButton setTitle:NSLocalizedString(@"File_upload_Record_select_all",nil) forState:UIControlStateNormal];
  30. [_rightButton setTitle:NSLocalizedString(@"File_upload_cancel_select_all",nil) forState:UIControlStateSelected];
  31. [_rightButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  32. _rightButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
  33. _rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  34. [_rightButton addTarget:self action:@selector(didClickSelectAllButton:) forControlEvents:UIControlEventTouchUpInside];
  35. [self.navBarBGView addSubview:_rightButton];
  36. [_rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.width.mas_equalTo(120);
  38. make.height.mas_equalTo(40);
  39. make.right.mas_equalTo(-15);
  40. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  41. }];
  42. [self.view addSubview:self.tableView];
  43. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.mas_equalTo(0);
  45. make.right.mas_equalTo(0);
  46. make.bottom.mas_equalTo(0);
  47. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  48. }];
  49. }
  50. #pragma mark - 懒加载
  51. - (UITableView *)tableView{
  52. if (!_tableView) {
  53. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  54. _tableView.delegate = self;
  55. _tableView.dataSource = self;
  56. _tableView.showsVerticalScrollIndicator = NO;
  57. _tableView.showsHorizontalScrollIndicator = NO;
  58. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  59. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  60. [_tableView setSeparatorColor:[UIColor clearColor]];
  61. [_tableView setBackgroundColor:[UIColor clearColor]];
  62. [_tableView setTableFooterView:[UIView new]];
  63. [_tableView setBounces:YES];
  64. if (@available(iOS 15.0, *)) {
  65. _tableView.sectionHeaderTopPadding = 0;
  66. }
  67. }
  68. return _tableView;
  69. }
  70. #pragma mark - 列表委托
  71. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  72. return 1;
  73. }
  74. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  75. if(!_curCouldPhoneFileListMod){
  76. return 0;
  77. }
  78. return _curCouldPhoneFileListMod.data.list.count;
  79. }
  80. - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  81. __block NSInteger row = indexPath.row;
  82. static NSString *identifier = @"downLoadPreViewCell";
  83. downLoadPreViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  84. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  85. if (!cell){
  86. cell = [[downLoadPreViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  87. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  88. [cell setBackgroundColor:[UIColor clearColor]];
  89. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  90. [cell.bgViewLayer removeFromSuperlayer];
  91. [cell.titleLabel2 setHidden:NO];
  92. [cell.rightImage setHidden:YES];
  93. [cell.lineView setHidden:YES];
  94. [cell.checkButton setHidden:NO];
  95. }
  96. if(row < _curCouldPhoneFileListMod.data.list.count){
  97. couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  98. cell.curFileModel = fileModel;
  99. }
  100. KWeakSelf
  101. cell.didClickSwitch = ^(BOOL SwitchOn) {
  102. [weakSelf userCheckFilePreviewByRow:row];
  103. };
  104. return cell;
  105. }
  106. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  107. return 70;
  108. }
  109. - (void)userCheckFilePreviewByRow:(NSInteger)row
  110. {
  111. if(row < _curCouldPhoneFileListMod.data.list.count){
  112. couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  113. fileModel.isSelectType = YES;
  114. [self.tableView reloadData];
  115. }
  116. }
  117. - (void)didClickSelectAllButton:(UIButton*)button
  118. {
  119. button.selected = !button.selected;
  120. for (couldPhoneFileModel* fileModel in _curCouldPhoneFileListMod.data.list) {
  121. fileModel.isSelectType = button.selected;
  122. }
  123. [self.tableView reloadData];
  124. }
  125. - (void)viewWillAppear:(BOOL)animated
  126. {
  127. [super viewWillAppear:animated];
  128. if(_isPhotoType){
  129. self.titleLabel.text = NSLocalizedString(@"my_set_no_image_upload",nil) ;
  130. }
  131. else{
  132. self.titleLabel.text = NSLocalizedString(@"my_set_no_video_upload",nil) ;
  133. }
  134. [self searchFileListFun];
  135. }
  136. - (void)searchFileListFun
  137. {
  138. NSNumber *curNum = [NSNumber numberWithBool:_isPhotoType];
  139. [[NSNotificationCenter defaultCenter] postNotificationName:searchFileListBeginNotification object:curNum];/*发送通知*/
  140. }
  141. - (void)searchFileListDoneFun:(NSNotification*)notification
  142. {
  143. NSDictionary *dataDict = [notification object];
  144. if(!dataDict || ![dataDict isKindOfClass:[NSDictionary class]]){
  145. return;
  146. }
  147. _curCouldPhoneFileListMod = [[couldPhoneFileListModel alloc] initWithDictionary:dataDict error:nil];
  148. [self.tableView reloadData];
  149. }
  150. @end