downLoadPreviewViewController.m 7.9 KB

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