downLoadPreviewViewController.m 7.7 KB

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