imageDetailsScrollViewController.m 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. //
  2. // imageDetailsScrollViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/16.
  6. //
  7. #import "imageDetailsScrollViewController.h"
  8. #import <SDCycleScrollView/SDCycleScrollView.h>
  9. #import "editTypeBottomView.h"
  10. #import "editShareView.h"
  11. #import "NASFilePicModel.h"
  12. #import "uploadFileRecordViewController.h"
  13. @interface imageDetailsScrollViewController ()
  14. {
  15. NSMutableArray *imageURLStringsGroup;
  16. }
  17. @property (nonatomic,strong) SDCycleScrollView *curScrollView;
  18. @property(nonatomic,strong) editTypeBottomView*curEditTypeBottomView;
  19. @end
  20. @implementation imageDetailsScrollViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. [self.toolBar setHidden:YES];
  25. [self.navigationBar setHidden:YES];
  26. [self.navBarBGView setHidden:NO];
  27. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  28. [self.view setBackgroundColor:[UIColor whiteColor]];
  29. [self drawAnyView];
  30. }
  31. - (void)drawAnyView
  32. {
  33. _curEditTypeBottomView = [[editTypeBottomView alloc] init];
  34. [self.view addSubview:_curEditTypeBottomView];
  35. _curEditTypeBottomView.hidden = YES;
  36. [_curEditTypeBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.mas_equalTo(0);
  38. make.right.mas_equalTo(0);
  39. make.bottom.mas_equalTo(0);
  40. make.height.mas_equalTo(60 + AdaptTabHeight);
  41. }];
  42. KWeakSelf
  43. #pragma mark 编辑状态的 下载 分享 删除 响应事件
  44. _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
  45. if(tag==1){
  46. //[[iToast makeText:@"点击下载"] show];
  47. [weakSelf gotoDownLoadFileFun];
  48. }
  49. else if(tag==2){
  50. [weakSelf gotoShareViewFun];
  51. }
  52. else if(tag==3){
  53. //[[iToast makeText:@"点击删除"] show];
  54. [weakSelf showDeleteAlearViewFun];
  55. }
  56. };
  57. }
  58. #pragma mark 用户点击分享
  59. - (void)gotoShareViewFun
  60. {
  61. editShareView *editShareV = [[editShareView alloc] init];
  62. NASFilePicDataArrModel *dataModel = _totalDataArr[_index];
  63. editShareV.didSelectListArr = [NSMutableArray arrayWithArray:@[dataModel]];
  64. editShareV.shareFileType = @"2";
  65. [self.view addSubview:editShareV];
  66. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.mas_equalTo(0);
  68. make.right.mas_equalTo(0);
  69. make.bottom.mas_equalTo(0);
  70. make.top.mas_equalTo(0);
  71. }];
  72. }
  73. - (void)setTotalDataArr:(NSMutableArray *)totalDataArr
  74. {
  75. _totalDataArr = totalDataArr;
  76. imageURLStringsGroup = [NSMutableArray new];
  77. for (NASFilePicDataArrModel*dataModel in _totalDataArr) {
  78. NSString * URLString = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",ksharedAppDelegate.NASFileByBoxService,dataModel.path];
  79. URLString = [URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  80. [imageURLStringsGroup addObject:URLString];
  81. }
  82. //HLog(@"URLString:\n%@",imageURLStringsGroup);
  83. _curScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero imageURLStringsGroup:imageURLStringsGroup];
  84. _curScrollView.autoScroll = NO;
  85. _curScrollView.infiniteLoop = NO;
  86. _curScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
  87. //_curScrollView.placeholderImage = [UIImage imageNamed:@"uploadFile_image"];
  88. [self.view addSubview:_curScrollView];
  89. _curScrollView.backgroundColor = [UIColor blackColor];
  90. [_curScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.left.mas_equalTo(0);
  92. make.right.mas_equalTo(0);
  93. make.top.equalTo(self.navBarBGView.mas_bottom).offset(0);
  94. //make.bottom.mas_equalTo(-(60+ AdaptTabHeight));
  95. make.bottom.mas_equalTo(0);
  96. }];
  97. KWeakSelf
  98. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  99. [self->_curScrollView makeScrollViewScrollToIndex:self->_index];
  100. [weakSelf setTitleLabelTextFunBy:self->_index];
  101. [weakSelf cycleScrollViewDidScrollToIndex:self->_index];
  102. self->_curScrollView.hidden = NO;
  103. });
  104. _curScrollView.itemDidScrollOperationBlock = ^(NSInteger currentIndex) {
  105. weakSelf.index = currentIndex;
  106. [weakSelf setTitleLabelTextFunBy:currentIndex];
  107. [weakSelf cycleScrollViewDidScrollToIndex:currentIndex];
  108. };
  109. }
  110. - (void)setTitleLabelTextFunBy:(NSInteger)index
  111. {
  112. if(index >=0 && index < _totalDataArr.count){
  113. NASFilePicDataArrModel *dataModel = _totalDataArr[index];
  114. self.titleLabel.text = dataModel.name;
  115. }
  116. }
  117. #pragma mark 删除图片
  118. - (void)showDeleteAlearViewFun
  119. {
  120. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  121. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  122. KWeakSelf
  123. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  124. msg:tipStr
  125. imageStr:nil
  126. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  127. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  128. didClickOk:^{
  129. [weakSelf delFileListFun];
  130. } didClickCancel:^{
  131. }];
  132. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  133. [self presentViewController:curAlretVC animated:YES completion:^{
  134. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  135. }];
  136. }
  137. #pragma mark 删除文件数据
  138. - (void)delFileListFun
  139. {
  140. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  141. if(_index >=0 && _index < _totalDataArr.count){
  142. NASFilePicDataArrModel *dataModel = _totalDataArr[_index];
  143. NSArray *pathArr = @[dataModel.path];
  144. //NSArray *pathArr = @[dataModel.path,dataModel.path];
  145. [paraDict setValue:pathArr forKey:@"path"];
  146. }
  147. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  148. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  149. KWeakSelf //@"delFile"
  150. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  151. [weakSelf removeNewIndicator];
  152. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  153. if(model && model.status == 0){
  154. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  155. if(weakSelf.didNeedToRegetDataFun){
  156. weakSelf.didNeedToRegetDataFun();
  157. }
  158. [weakSelf.navigationController popViewControllerAnimated:YES];
  159. }
  160. else{
  161. }
  162. } failure:^(NSError * _Nonnull error) {
  163. [weakSelf removeNewIndicator];
  164. }];
  165. }
  166. - (void)gotoDownLoadFileFun
  167. {
  168. if(_index >=0 && _index < _totalDataArr.count){
  169. NASFilePicDataArrModel *dataModel = _totalDataArr[_index];
  170. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  171. fileModel.fileType = @".jpg";
  172. fileModel.path = dataModel.path;
  173. fileModel.name = dataModel.name;
  174. fileModel.length = dataModel.size;
  175. NSMutableArray *arr = [NSMutableArray new];
  176. [arr addObject:fileModel];
  177. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  178. [self.navigationController pushViewController:vc animated:YES];
  179. vc.isDownloadingType = YES;
  180. [vc gotoDownloadFile:arr];
  181. }
  182. }
  183. - (void)setCanShareType:(BOOL)canShareType
  184. {
  185. _canShareType = canShareType;
  186. [_curEditTypeBottomView setCanShaewFunBy:canShareType];
  187. }
  188. #pragma mark 图片滑动
  189. - (void)cycleScrollViewDidScrollToIndex:(NSInteger)index{
  190. if(index >=0 && index < _totalDataArr.count){
  191. NASFilePicDataArrModel *dataModel = _totalDataArr[index];
  192. lastFileModel *lastFileMod = [lastFileModel new];
  193. lastFileMod.path = dataModel.path;
  194. lastFileMod.name = dataModel.name;
  195. lastFileMod.time = dataModel.time;
  196. lastFileMod.size = dataModel.size;
  197. lastFileMod.duration = dataModel.duration;
  198. lastFileMod.type = @"jpg";
  199. lastFileMod.lastPreTime = [iTools getNowTimeStamp];
  200. [[lastFileManager shareManager] saveFileInfoWith:lastFileMod with:dataModel.path];
  201. }
  202. }
  203. @end