downLoadPreviewViewController.m 7.4 KB

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