previewFileAndFolderViewController.m 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. //
  2. // previewFileAndFolderViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/21.
  6. //
  7. #import "previewFileAndFolderViewController.h"
  8. #import "couldPhoneFileListModel.h"
  9. #import "downloadThumbnailManager.h"
  10. #import "downloadManager.h"
  11. #import "uploadFileRecordViewController.h"
  12. #import "UIScrollView+EmptyDataSet.h"
  13. #import "diskListBgView.h"
  14. #import "diskListTableView.h"
  15. #import "downLoadPreViewCell.h"
  16. #import "editTypeHeadView.h"
  17. #import "editTypeBottomView.h"
  18. #import "editShareView.h"
  19. #import "previewToUploadFileView.h"
  20. #import "netWorkManager.h"
  21. #import "NASFileAndFolderModel.h"
  22. #import "queryShareModel.h"
  23. #import "videoPlayByAVPlayerViewController.h"
  24. #import "audioPlayerViewController.h"
  25. #import "imageDetailsScrollViewController.h"
  26. @interface previewFileAndFolderViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  27. {
  28. UIButton *tapBtn;
  29. UIButton* rightTransferListButton;//传输列表
  30. UIView* rightRedView;
  31. BOOL hadUploadTaskType;
  32. BOOL hadDownloadTaskType;
  33. BOOL canShareType;
  34. }
  35. @property (nonatomic, strong) UITableView *tableView;
  36. @property (strong, nonatomic) UILabel *MytitleLabel;
  37. @property (strong, nonatomic) UIImageView *selectTip;
  38. @property (nonatomic, strong) diskListBgView *diskListBgV;
  39. @property (nonatomic, strong) diskListTableView *diskListTableV;
  40. @property (nonatomic, strong) NSMutableArray*diskListArr;
  41. @property (nonatomic, copy) NSString *defaultDiskPath;
  42. @property(nonatomic,assign) BOOL isEditType;
  43. @property(nonatomic,strong) editTypeHeadView*curEditTypeHeadView;
  44. @property(nonatomic,strong) editTypeBottomView*curEditTypeBottomView;
  45. @property(nonatomic,strong) UIButton*uploadFileButton;
  46. @property (nonatomic, strong) NSMutableArray*didSelectListArr;//选中的数据
  47. @property (nonatomic, strong)NASFileAndFolderModel * curNASFileAudioMod;
  48. @end
  49. @implementation previewFileAndFolderViewController
  50. - (void)viewDidLoad {
  51. [super viewDidLoad];
  52. // Do any additional setup after loading the view.
  53. [self.toolBar setHidden:YES];
  54. [self.navigationBar setHidden:YES];
  55. [self.navBarBGView setHidden:NO];
  56. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  57. [self.view setBackgroundColor:[UIColor whiteColor]];
  58. [self drawAnyView];
  59. _didSelectListArr = [NSMutableArray new];
  60. //数据埋点
  61. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"File"];
  62. }
  63. - (void)drawAnyView{
  64. [self initNavHeadUIFun];
  65. _curEditTypeHeadView = [[editTypeHeadView alloc] init];
  66. _curEditTypeHeadView.hidden = YES;
  67. [self.navBarBGView addSubview:_curEditTypeHeadView];
  68. [_curEditTypeHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.left.mas_equalTo(0);
  70. make.right.mas_equalTo(0);
  71. make.bottom.mas_equalTo(0);
  72. make.height.mas_equalTo(NAVIHEIGHT - AdaptNaviHeight);
  73. }];
  74. #pragma mark 编辑状态的 取消 和全选按钮 响应事件
  75. KWeakSelf
  76. _curEditTypeHeadView.didClickButtonFun = ^(NSInteger tag) {
  77. if(tag==1){
  78. [weakSelf userCancelEditTypeFun];
  79. }
  80. };
  81. _curEditTypeHeadView.didClickSelectAllFun = ^(UIButton * _Nonnull but) {
  82. [weakSelf didClickSelectAllButton:but];
  83. };
  84. _curEditTypeBottomView = [[editTypeBottomView alloc] init];
  85. _curEditTypeBottomView.hidden = YES;
  86. [self.view addSubview:_curEditTypeBottomView];
  87. [_curEditTypeBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.mas_equalTo(0);
  89. make.right.mas_equalTo(0);
  90. make.bottom.mas_equalTo(0);
  91. make.height.mas_equalTo(60 + AdaptTabHeight);
  92. }];
  93. #pragma mark 编辑状态的 下载 分享 删除 响应事件
  94. _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
  95. if(tag==1){
  96. [weakSelf gotoDownLoadFileFun];
  97. }
  98. else if(tag==2){
  99. [weakSelf gotoShareViewFun];
  100. }
  101. else if(tag==3){
  102. [weakSelf showDeleteAlearViewFun];
  103. }
  104. };
  105. [self.view addSubview:self.tableView];
  106. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.left.mas_equalTo(0);
  108. make.right.mas_equalTo(0);
  109. //make.bottom.mas_equalTo(-(safeArea));
  110. make.bottom.mas_equalTo(0);
  111. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  112. }];
  113. //大+号
  114. _uploadFileButton = [[UIButton alloc] init];
  115. [_uploadFileButton setBackgroundImage:[UIImage imageNamed:@"add_file_icon"] forState:UIControlStateNormal];
  116. [_uploadFileButton addTarget:self action:@selector(userDidClickUploadViewFun) forControlEvents:UIControlEventTouchUpInside];
  117. [self.view addSubview:_uploadFileButton];
  118. [_uploadFileButton mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.right.mas_equalTo(-15);
  120. make.width.mas_equalTo(52);
  121. make.height.mas_equalTo(52);
  122. make.bottom.mas_equalTo(-30 - AdaptTabHeight);
  123. }];
  124. NSMutableArray *arr = [NSMutableArray new];
  125. NSArray *diskList = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  126. if(diskList && [diskList isKindOfClass:[NSArray class]]){
  127. for (cloudPhoneExtraFileModel *model in diskList) {
  128. model.isCheckType = NO;
  129. [arr addObject:model];
  130. }
  131. }
  132. if(arr.count >0){
  133. cloudPhoneExtraFileModel *model = arr.firstObject;
  134. model.isCheckType = YES;
  135. _defaultDiskPath = model.extraPath;
  136. }
  137. _diskListArr = arr;
  138. [self setTitleAfterGetdiskFun];
  139. }
  140. - (void)initNavHeadUIFun
  141. {
  142. //title
  143. UILabel *titleLabel = [[UILabel alloc] init];
  144. titleLabel.textAlignment = NSTextAlignmentCenter;
  145. titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  146. titleLabel.textColor = [UIColor blackColor];
  147. titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
  148. [self.navBarBGView addSubview:titleLabel];
  149. self.MytitleLabel = titleLabel;
  150. //selectTipImageView
  151. UIImageView *selectTip = [[UIImageView alloc] init];
  152. selectTip.image = [UIImage imageNamed:@"upload_image_arrow"];
  153. selectTip.translatesAutoresizingMaskIntoConstraints = NO;
  154. [self.navBarBGView addSubview:selectTip];
  155. self.selectTip = selectTip;
  156. tapBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  157. tapBtn.backgroundColor = [UIColor clearColor];
  158. tapBtn.translatesAutoresizingMaskIntoConstraints = NO;
  159. [tapBtn addTarget:self action:@selector(selectDiskAction:) forControlEvents:UIControlEventTouchUpInside];
  160. [self.navBarBGView addSubview:tapBtn];
  161. [tapBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  162. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  163. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  164. make.width.mas_equalTo(100);
  165. make.height.mas_equalTo(30);
  166. }];
  167. [self setTitleLabelText:@""];
  168. rightTransferListButton = [[UIButton alloc] init];
  169. [rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  170. [rightTransferListButton addTarget:self action:@selector(didiClikRightButGotoTransferListFun:) forControlEvents:UIControlEventTouchUpInside];
  171. [self.navBarBGView addSubview:rightTransferListButton];
  172. [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
  173. make.width.mas_equalTo(40);
  174. make.height.mas_equalTo(40);
  175. make.right.mas_equalTo(-15);
  176. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  177. }];
  178. rightRedView = [[UIView alloc] init];
  179. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  180. [rightTransferListButton addSubview:rightRedView];
  181. rightRedView.layer.cornerRadius = 7;
  182. rightRedView.hidden = YES;
  183. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  184. make.width.mas_equalTo(14);
  185. make.height.mas_equalTo(14);
  186. make.right.mas_equalTo(0);
  187. make.top.mas_equalTo(6);
  188. }];
  189. }
  190. #pragma mark - 懒加载
  191. - (UITableView *)tableView{
  192. if (!_tableView) {
  193. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  194. _tableView.delegate = self;
  195. _tableView.dataSource = self;
  196. _tableView.showsVerticalScrollIndicator = NO;
  197. _tableView.showsHorizontalScrollIndicator = NO;
  198. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  199. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  200. [_tableView setSeparatorColor:[UIColor clearColor]];
  201. [_tableView setBackgroundColor:[UIColor clearColor]];
  202. [_tableView setTableFooterView:[UIView new]];
  203. [_tableView setBounces:YES];
  204. if (@available(iOS 15.0, *)) {
  205. _tableView.sectionHeaderTopPadding = 0;
  206. }
  207. //空数据引入第三方开源处理
  208. _tableView.emptyDataSetSource = self;
  209. _tableView.emptyDataSetDelegate = self;
  210. }
  211. return _tableView;
  212. }
  213. - (diskListBgView*)diskListBgV
  214. {
  215. if(!_diskListBgV){
  216. _diskListBgV = [[diskListBgView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
  217. _diskListBgV.hidden = YES;
  218. [self.view addSubview:_diskListBgV];
  219. KWeakSelf
  220. _diskListBgV.didTapWhitePlace = ^{
  221. [weakSelf hideDiskListVieFun];
  222. };
  223. [_diskListBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  224. make.left.mas_equalTo(0);
  225. make.bottom.mas_equalTo(0);
  226. make.right.mas_equalTo(0);
  227. make.top.mas_equalTo(self.navBarBGView.mas_bottom);
  228. }];
  229. [self.view addSubview:self.diskListTableV];
  230. self.diskListTableV.hidden = YES;
  231. [self.diskListTableV mas_makeConstraints:^(MASConstraintMaker *make) {
  232. make.left.mas_equalTo(0);
  233. make.height.mas_equalTo(3*70);
  234. make.right.mas_equalTo(0);
  235. make.top.mas_equalTo(self.navBarBGView.mas_bottom);
  236. }];
  237. self.diskListTableV.diskListArr = _diskListArr;
  238. self.diskListTableV.didClickDiskModel = ^(NSString * _Nonnull checkPath) {
  239. [weakSelf didCheckDiskFunByPath:checkPath];
  240. };
  241. }
  242. return _diskListBgV;
  243. }
  244. - (UITableView *)diskListTableV{
  245. if (!_diskListTableV) {
  246. _diskListTableV = [[diskListTableView alloc] init];
  247. //
  248. }
  249. return _diskListTableV;
  250. }
  251. #pragma mark 选中磁盘
  252. - (void)didCheckDiskFunByPath:(NSString*)pathStr
  253. {
  254. if(self.defaultDiskPath
  255. && self.defaultDiskPath.length>0
  256. && ![self.defaultDiskPath isEqualToString:pathStr]){
  257. //切换硬盘了 取消全选
  258. [_didSelectListArr removeAllObjects];
  259. }
  260. self.defaultDiskPath = pathStr;
  261. [self getFileListFun];
  262. [self setTitleAfterGetdiskFun];
  263. [self hideDiskListVieFun];
  264. }
  265. #pragma mark - 列表委托
  266. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  267. return 1;
  268. }
  269. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  270. if(!_curNASFileAudioMod){
  271. return 0;
  272. }
  273. return _curNASFileAudioMod.data.list.count;
  274. }
  275. - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  276. __block NSInteger row = indexPath.row;
  277. static NSString *identifier = @"downLoadPreViewCell";
  278. downLoadPreViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  279. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  280. if (!cell){
  281. cell = [[downLoadPreViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  282. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  283. [cell setBackgroundColor:[UIColor clearColor]];
  284. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  285. [cell.bgViewLayer removeFromSuperlayer];
  286. [cell.titleLabel2 setHidden:NO];
  287. [cell.rightImage setHidden:YES];
  288. [cell.lineView setHidden:YES];
  289. [cell.checkButton setHidden:NO];
  290. }
  291. if(row < _curNASFileAudioMod.data.list.count){
  292. NASFileAndFolderDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  293. cell.curNASFileAndFolderDataModel = dataModel;
  294. KWeakSelf
  295. cell.didClickSwitch = ^(BOOL SwitchOn) {
  296. //if([weakSelf userCheckFileModel:dataModel withShowTip:YES]){
  297. [weakSelf userCheckFilePreviewByRow:row];
  298. //}
  299. };
  300. }
  301. return cell;
  302. }
  303. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  304. return 70;
  305. }
  306. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  307. {
  308. NSInteger row = indexPath.row;
  309. if(row < _curNASFileAudioMod.data.list.count){
  310. NASFileAndFolderDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  311. if([dataModel.type isEqualToString:@"dir"])
  312. {
  313. previewFileAndFolderSecondViewController *vc = [previewFileAndFolderSecondViewController new];
  314. vc.curFolderDataModel = dataModel;
  315. vc.canShareType = canShareType;
  316. [self.navigationController pushViewController:vc animated:YES];
  317. }
  318. else if([dataModel.type isEqualToString:@"video"]){
  319. videoPlayByAVPlayerViewController *vc = [videoPlayByAVPlayerViewController new];
  320. vc.VideoDataMode = dataModel;
  321. [self.navigationController pushViewController:vc animated:YES];
  322. KWeakSelf
  323. vc.didNeedToRegetDataFun = ^{
  324. [weakSelf getFileListFun];
  325. };
  326. }
  327. else if([dataModel.type isEqualToString:@"audio"]){
  328. NSMutableArray *dataArr = [NSMutableArray new];
  329. [dataArr addObject:dataModel];
  330. audioPlayerViewController *vc = [audioPlayerViewController new];
  331. vc.index = 0;
  332. vc.audioOutSidedataArray = dataArr;
  333. [self.navigationController pushViewController:vc animated:YES];
  334. }
  335. else if([dataModel.type isEqualToString:@"jpg"]){
  336. NSMutableArray *jpgDataArr = [NSMutableArray new];
  337. NSInteger index = 0;
  338. [jpgDataArr addObject:dataModel];
  339. imageDetailsScrollViewController *vc = [imageDetailsScrollViewController new];
  340. vc.index = index;
  341. vc.totalDataArr = jpgDataArr;
  342. [self.navigationController pushViewController:vc animated:YES];
  343. vc.canShareType = canShareType;
  344. }
  345. }
  346. }
  347. #pragma mark 空数据
  348. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  349. NSString *imageName = @"common_no_data_pic";
  350. return [UIImage imageNamed:imageName];
  351. }
  352. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  353. NSString *text = NSLocalizedString(@"common_no_data_tip",nil);
  354. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  355. NSForegroundColorAttributeName: HW999999Color};
  356. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  357. }
  358. //调整图片位置
  359. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  360. return -150;
  361. }
  362. //ios端:
  363. //1、需求说明:解决除MP4 MOV 3GP M4V 总计4种格式外,其他格式下载失败的问题;
  364. //2、交互说明:下载列表勾选文件中含有其他格式,toast提示“IOS系统仅支持MP4、MOV、3GP、M4V 的视频格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载MP4、MOV、3GP、M4V 的视频格式文件;
  365. //ios支持图片格式: (SVG 不支持)
  366. //需求说明:解决除JPG PNG GIF TIFF BMP总计5种格式外,其他格式下载失败的问题
  367. //视觉交互:选择文件中含有其他格式,toast提示“IOS系统仅支持JPG 、PNG、GIF、TIFF、BMP的图片格式,其他格式无法下载”。点击下载按钮,过滤其他格式文件,仅下载JPG 、PNG、GIF、TIFF、BMP的图片格式文件;
  368. - (BOOL)userCheckFileModel:(couldPhoneFileModel*)fileModel withShowTip:(BOOL)canShow{
  369. // NSString*name = [fileModel.name lowercaseString];
  370. // NSArray *nameArr = [name componentsSeparatedByString:@"."];
  371. // if(nameArr.count >0 && !_isAudioType){
  372. // BOOL canDownLoadType = NO;
  373. //
  374. // NSString *lastName = nameArr.lastObject;
  375. // if([lastName isEqualToString:@"mp4"]
  376. // ||[lastName isEqualToString:@"mov"]
  377. // ||[lastName isEqualToString:@"3gp"]
  378. // ||[lastName isEqualToString:@"m4v"]){
  379. // canDownLoadType = YES;
  380. // }
  381. //
  382. // if(!canDownLoadType){
  383. // if(canShow){
  384. // [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
  385. // }
  386. //
  387. // return NO;
  388. // }
  389. // }
  390. //
  391. // if(nameArr.count >0 && _isAudioType){
  392. // BOOL canDownLoadType = NO;
  393. // //JPG 、PNG、GIF、TIFF、BMP
  394. // NSString *lastName = nameArr.lastObject;
  395. // if([lastName isEqualToString:@"jpg"]
  396. // ||[lastName isEqualToString:@"png"]
  397. // ||[lastName isEqualToString:@"gif"]
  398. // ||[lastName isEqualToString:@"tiff"]
  399. // ||[lastName isEqualToString:@"bmp"]
  400. // ||[lastName isEqualToString:@"heic"]
  401. // ||[lastName isEqualToString:@"jpeg"]
  402. // ||[lastName isEqualToString:@"heif"]){
  403. // canDownLoadType = YES;
  404. // }
  405. //
  406. // if(!canDownLoadType){
  407. // if(canShow){
  408. // [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
  409. // }
  410. // return NO;
  411. // }
  412. // }
  413. return YES;
  414. }
  415. #pragma mark 用户长按图片进入编辑
  416. - (void)setViewEditTypeFun
  417. {
  418. _isEditType = YES;
  419. //[self.tableView reloadData];
  420. _curEditTypeHeadView.hidden = NO;
  421. _curEditTypeBottomView.hidden = NO;
  422. _uploadFileButton.hidden = YES;
  423. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  424. make.left.mas_equalTo(0);
  425. make.right.mas_equalTo(0);
  426. make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
  427. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  428. }];
  429. }
  430. #pragma mark 用户取消编辑编辑
  431. - (void)userCancelEditTypeFun
  432. {
  433. //数据还原
  434. for (NASFileAndFolderDataModel*model in _didSelectListArr) {
  435. model.isSelectType = NO;
  436. }
  437. [_didSelectListArr removeAllObjects];
  438. _isEditType = NO;
  439. [self.tableView reloadData];
  440. _curEditTypeHeadView.hidden = YES;
  441. _curEditTypeBottomView.hidden = YES;
  442. _uploadFileButton.hidden = NO;
  443. [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  444. make.left.mas_equalTo(0);
  445. make.right.mas_equalTo(0);
  446. make.bottom.mas_equalTo(0);
  447. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  448. }];
  449. }
  450. - (void)userCheckFilePreviewByRow:(NSInteger)row
  451. {
  452. if(row < _curNASFileAudioMod.data.list.count){
  453. NASFileAudioDataModel* dataModel = _curNASFileAudioMod.data.list[row];
  454. if(dataModel.isSelectType){
  455. [_didSelectListArr removeObject:dataModel];
  456. }
  457. else{
  458. [_didSelectListArr addObject:dataModel];
  459. }
  460. dataModel.isSelectType = !dataModel.isSelectType;
  461. [self setEditTypeTitleFun];
  462. }
  463. }
  464. - (void)didClickSelectAllButton:(UIButton*)button
  465. {
  466. //button.selected = !button.selected;
  467. [_didSelectListArr removeAllObjects];
  468. for (NASFileAudioDataModel* dataModel in _curNASFileAudioMod.data.list) {
  469. if(!button.selected){
  470. dataModel.isSelectType = button.selected;
  471. }
  472. else{
  473. if(![dataModel.type isEqualToString:@"dir"]){
  474. [_didSelectListArr addObject:dataModel];
  475. dataModel.isSelectType = button.selected;
  476. }
  477. }
  478. }
  479. [self.tableView reloadData];
  480. //[self.dataCollectionView reloadData];
  481. [self setEditTypeTitleFun];
  482. }
  483. #pragma mark 设置选中标题
  484. - (void)setEditTypeTitleFun
  485. {
  486. [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
  487. if(_didSelectListArr.count > 0){
  488. [self setViewEditTypeFun];
  489. }
  490. else{
  491. [self userCancelEditTypeFun];
  492. }
  493. }
  494. #pragma mark 用户点击分享
  495. - (void)gotoShareViewFun
  496. {
  497. if (_didSelectListArr.count > 5) {
  498. [[iToast makeText:NSLocalizedString(@"share_max_count_tip2",nil)] show];
  499. return;
  500. }
  501. editShareView *editShareV = [[editShareView alloc] init];
  502. editShareV.didSelectListArr = _didSelectListArr;
  503. editShareV.shareFileType = @"6";
  504. [self.view addSubview:editShareV];
  505. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  506. make.left.mas_equalTo(0);
  507. make.right.mas_equalTo(0);
  508. make.bottom.mas_equalTo(0);
  509. make.top.mas_equalTo(0);
  510. }];
  511. }
  512. #pragma mark 用户点击上传文件
  513. - (void)userDidClickUploadViewFun
  514. {
  515. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  516. [self.view addSubview:previewToUploadFileV];
  517. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  518. make.left.mas_equalTo(0);
  519. make.right.mas_equalTo(0);
  520. make.bottom.mas_equalTo(0);
  521. make.top.mas_equalTo(0);
  522. }];
  523. KWeakSelf
  524. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  525. [weakSelf gotoUploadFileFunWith:tag];
  526. };
  527. }
  528. #pragma mark 设置标题
  529. - (void)setTitleLabelText:(NSString*)title
  530. {
  531. NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  532. if(diskNameArr && diskNameArr.count >= 2){
  533. NSString *name = diskNameArr.lastObject;
  534. if(name.length == 0)
  535. {
  536. name = diskNameArr[diskNameArr.count -2];
  537. }
  538. title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
  539. }
  540. self.MytitleLabel.text = title;
  541. CGFloat curWidth = [title boundingRectWithSize:CGSizeMake(SCREEN_W, 30) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.f]} context:nil].size.width;
  542. curWidth += 20;
  543. //HLog(@"title w:%f",curWidth);
  544. [self.MytitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  545. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX).offset(-10);
  546. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  547. make.width.mas_equalTo(curWidth);
  548. make.height.mas_equalTo(30);
  549. }];
  550. //self.MytitleLabel.backgroundColor = [UIColor greenColor];
  551. [self.selectTip mas_makeConstraints:^(MASConstraintMaker *make) {
  552. make.left.mas_equalTo(self.MytitleLabel.mas_right).offset(0);
  553. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  554. make.width.mas_equalTo(15);
  555. make.height.mas_equalTo(15);
  556. }];
  557. [tapBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  558. make.centerX.mas_equalTo(self.navBarBGView.mas_centerX);
  559. make.centerY.mas_equalTo(self.backBtn.mas_centerY);
  560. make.width.mas_equalTo(curWidth+15);
  561. make.height.mas_equalTo(30);
  562. }];
  563. }
  564. #pragma mark 选择硬盘
  565. - (void)selectDiskAction:(UIButton*)but
  566. {
  567. if(self.diskListBgV.hidden){
  568. [self showDiskListVieFun];
  569. }
  570. else{
  571. [self hideDiskListVieFun];
  572. }
  573. }
  574. - (void)showDiskListVieFun
  575. {
  576. self.diskListBgV.hidden = NO;
  577. self.diskListTableV.hidden = NO;
  578. [UIView animateWithDuration:0.3 animations:^{
  579. CGRect rect = self.diskListTableV.frame;
  580. rect.origin.y = CGRectGetMaxY(self.navBarBGView.frame);
  581. self.diskListTableV.frame = rect;
  582. self.selectTip.transform = CGAffineTransformMakeRotation(M_PI);
  583. }];
  584. }
  585. - (void)hideDiskListVieFun
  586. {
  587. self.diskListBgV.hidden = YES;
  588. [UIView animateWithDuration:0.3 animations:^{
  589. self.diskListTableV.hidden = YES;
  590. self.selectTip.transform = CGAffineTransformIdentity;
  591. }completion:^(BOOL finished) {
  592. CGRect rect = self.diskListTableV.frame;
  593. rect.origin.y = 0;
  594. self.diskListTableV.frame = rect;
  595. }];
  596. }
  597. #pragma mark 设置标题
  598. - (void)setTitleAfterGetdiskFun
  599. {
  600. [self setTitleLabelText:NSLocalizedString(@"my_set_no_file",nil)];
  601. }
  602. - (void)viewWillAppear:(BOOL)animated
  603. {
  604. [super viewWillAppear:animated];
  605. }
  606. - (void)viewDidAppear:(BOOL)animated{
  607. [super viewDidAppear:animated];
  608. [self showDownloadTipFun];
  609. [self checkFileTransferTask];
  610. if(!_curNASFileAudioMod){
  611. [self getFileListFun];
  612. [self queryShareSwitchFunFun];
  613. }
  614. }
  615. - (void)viewWillDisappear:(BOOL)animated{
  616. [super viewWillDisappear:animated];
  617. //[self removeNewIndicator];
  618. [self removeNewIndicatorHaveStr];
  619. }
  620. - (void)gotoDownloadloadFileRecordFun
  621. {
  622. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  623. [self.navigationController pushViewController:vc animated:YES];
  624. vc.isDownloadingType = YES;
  625. //[vc gotoDownloadFile:_downloadFileBottomV.indexPathsForSelectedItems];
  626. }
  627. - (void)showDownloadTipFun
  628. {
  629. BOOL didReadUploadTipType = [HWDataManager getBoolWithKey:Const_file_downLoad_need_read];
  630. if(didReadUploadTipType){
  631. return;
  632. }
  633. //KWeakSelf
  634. /*弹窗提示恢复出厂*/
  635. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:nil
  636. msg:NSLocalizedString(@"upload_download_need_read_msg",nil)
  637. imageStr:nil
  638. cancelTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil)
  639. okTitle:nil
  640. isOkBtnHighlight:NO
  641. didClickOk:^{
  642. } didClickCancel:^{
  643. [HWDataManager setBoolWithKey:Const_file_downLoad_need_read value:YES];
  644. }];
  645. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  646. [self presentViewController:nextVC animated:YES completion:^{
  647. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  648. }];
  649. }
  650. - (void)checkFileTransferTask
  651. {//有个偶现的闪退在BGFMDB
  652. [[uploadFileManager shareInstance] checkHadUploadTaskWithComplete:^(BOOL isSuccess) {
  653. self->hadUploadTaskType = isSuccess;
  654. [self setRightButtonRedTypeFun];
  655. }];
  656. KWeakSelf
  657. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  658. [[downloadManager shareInstance] checkHadDownloadTaskWithComplete:^(BOOL isSuccess) {
  659. self->hadDownloadTaskType = isSuccess;
  660. [weakSelf setRightButtonRedTypeFun];
  661. }];
  662. });
  663. }
  664. - (void)setRightButtonRedTypeFun
  665. {
  666. mainBlock(^{
  667. if(self->hadUploadTaskType || self->hadDownloadTaskType){
  668. self->rightRedView.hidden = NO;
  669. }
  670. else{
  671. self->rightRedView.hidden = YES;
  672. }
  673. });
  674. }
  675. - (void)didiClikRightButGotoTransferListFun:(UIButton*)but
  676. {
  677. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  678. [self.navigationController pushViewController:vc animated:YES];
  679. }
  680. #pragma mark 获取文件数据
  681. - (void)getFileListFun
  682. {
  683. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  684. // NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
  685. // if(diskNameArr && diskNameArr.count >= 2){
  686. //
  687. // NSString *name = diskNameArr.lastObject;
  688. // if(name.length == 0)
  689. // {
  690. // name = diskNameArr[diskNameArr.count -2];
  691. // }
  692. //
  693. // [paraDict setValue:name forKey:@"path"];
  694. // }
  695. if(_defaultDiskPath){
  696. [paraDict setValue:_defaultDiskPath forKey:@"path"];
  697. }
  698. [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
  699. KWeakSelf
  700. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getFileListByFolder" Parameters:paraDict success:^(id _Nonnull responseObject) {
  701. [weakSelf removeNewIndicatorHaveStr];
  702. weakSelf.curNASFileAudioMod = [[NASFileAndFolderModel alloc] initWithDictionary:responseObject error:nil];
  703. if(weakSelf.curNASFileAudioMod && weakSelf.curNASFileAudioMod.status == 0){
  704. [weakSelf.tableView reloadData];
  705. }
  706. } failure:^(NSError * _Nonnull error) {
  707. [weakSelf removeNewIndicatorHaveStr];
  708. }];
  709. }
  710. #pragma mark 调整文件上传
  711. - (void)gotoUploadFileFunWith:(NSInteger)tag
  712. {
  713. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  714. if(tag ==10){
  715. vc.isPhotoType = YES;
  716. }
  717. else{
  718. vc.isPhotoType = NO;
  719. }
  720. [self.navigationController pushViewController:vc animated:YES];
  721. }
  722. #pragma mark 文件下载
  723. - (void)gotoDownLoadFileFun
  724. {
  725. if(_didSelectListArr.count == 0){
  726. [[iToast makeText:@""] show];
  727. return;
  728. }
  729. NSMutableArray *arr = [NSMutableArray new];
  730. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  731. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  732. fileModel.fileType = @"audio";
  733. fileModel.path = dataModel.path;
  734. fileModel.name = dataModel.name;
  735. fileModel.length = dataModel.size;
  736. fileModel.time = dataModel.duration;
  737. [arr addObject:fileModel];
  738. }
  739. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  740. [self.navigationController pushViewController:vc animated:YES];
  741. vc.isDownloadingType = YES;
  742. [vc gotoDownloadFile:arr];
  743. }
  744. #pragma mark 删除图片
  745. - (void)showDeleteAlearViewFun
  746. {
  747. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  748. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  749. KWeakSelf
  750. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  751. msg:tipStr
  752. imageStr:nil
  753. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  754. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  755. didClickOk:^{
  756. [weakSelf delFileListFun];
  757. } didClickCancel:^{
  758. }];
  759. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  760. [self presentViewController:curAlretVC animated:YES completion:^{
  761. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  762. }];
  763. }
  764. #pragma mark 删除文件数据
  765. - (void)delFileListFun
  766. {
  767. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  768. NSMutableArray *pathArr = [NSMutableArray new];
  769. for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
  770. [pathArr addObject:dataModel.path];
  771. }
  772. [paraDict setValue:pathArr forKey:@"path"];
  773. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  774. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  775. KWeakSelf //@"delFile"
  776. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  777. [weakSelf removeNewIndicator];
  778. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  779. if(model && model.status == 0){
  780. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  781. [weakSelf didDeleteSucFun];
  782. }
  783. else{
  784. }
  785. } failure:^(NSError * _Nonnull error) {
  786. [weakSelf removeNewIndicator];
  787. }];
  788. }
  789. #pragma mark 删除成功
  790. - (void)didDeleteSucFun
  791. {
  792. [_didSelectListArr removeAllObjects];
  793. [self setEditTypeTitleFun];
  794. [self getFileListFun];
  795. }
  796. #pragma mark 获取分享开关
  797. -(void)queryShareSwitchFunFun
  798. {
  799. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  800. [paraDict setValue:@6 forKey:@"type"];
  801. KWeakSelf
  802. [[netWorkManager shareInstance] CommonGetWithCallBackCode:queryShareSwitchFun Parameters:paraDict success:^(id _Nonnull responseObject){
  803. queryShareModel *queryShareMod = [[queryShareModel alloc] initWithDictionary:responseObject error:nil];
  804. if(queryShareMod){
  805. self->canShareType = queryShareMod.data.configValue;
  806. [weakSelf.curEditTypeBottomView setCanShaewFunBy:queryShareMod.data.configValue];
  807. }
  808. } failure:^(NSError * _Nonnull error) {
  809. }];
  810. }
  811. @end