downLoadPreviewViewController.m 8.2 KB

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