imageDetailsScrollViewController.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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.placeholderImage = [UIImage imageNamed:@"uploadFile_image"];
  87. [self.view addSubview:_curScrollView];
  88. _curScrollView.backgroundColor = [UIColor lightGrayColor];
  89. //_curScrollView.hidden = YES;
  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. self->_curScrollView.hidden = NO;
  102. });
  103. _curScrollView.itemDidScrollOperationBlock = ^(NSInteger currentIndex) {
  104. weakSelf.index = currentIndex;
  105. [weakSelf setTitleLabelTextFunBy:currentIndex];
  106. };
  107. }
  108. - (void)setTitleLabelTextFunBy:(NSInteger)index
  109. {
  110. if(index >=0 && index < _totalDataArr.count){
  111. NASFilePicDataArrModel *dataModel = _totalDataArr[index];
  112. self.titleLabel.text = dataModel.name;
  113. }
  114. }
  115. #pragma mark 删除图片
  116. - (void)showDeleteAlearViewFun
  117. {
  118. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  119. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  120. KWeakSelf
  121. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  122. msg:tipStr
  123. imageStr:nil
  124. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  125. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  126. didClickOk:^{
  127. [weakSelf delFileListFun];
  128. } didClickCancel:^{
  129. }];
  130. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  131. [self presentViewController:curAlretVC animated:YES completion:^{
  132. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  133. }];
  134. }
  135. #pragma mark 删除文件数据
  136. - (void)delFileListFun
  137. {
  138. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  139. if(_index >=0 && _index < _totalDataArr.count){
  140. NASFilePicDataArrModel *dataModel = _totalDataArr[_index];
  141. NSArray *pathArr = @[dataModel.path];
  142. //NSArray *pathArr = @[dataModel.path,dataModel.path];
  143. [paraDict setValue:pathArr forKey:@"path"];
  144. }
  145. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  146. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  147. KWeakSelf //@"delFile"
  148. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  149. [weakSelf removeNewIndicator];
  150. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  151. if(model && model.status == 0){
  152. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  153. if(weakSelf.didNeedToRegetDataFun){
  154. weakSelf.didNeedToRegetDataFun();
  155. }
  156. [weakSelf.navigationController popViewControllerAnimated:YES];
  157. }
  158. else{
  159. }
  160. } failure:^(NSError * _Nonnull error) {
  161. [weakSelf removeNewIndicator];
  162. }];
  163. }
  164. - (void)gotoDownLoadFileFun
  165. {
  166. if(_index >=0 && _index < _totalDataArr.count){
  167. NASFilePicDataArrModel *dataModel = _totalDataArr[_index];
  168. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  169. fileModel.fileType = @".jpg";
  170. fileModel.path = dataModel.path;
  171. fileModel.name = dataModel.name;
  172. fileModel.length = dataModel.size;
  173. NSMutableArray *arr = [NSMutableArray new];
  174. [arr addObject:fileModel];
  175. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  176. [self.navigationController pushViewController:vc animated:YES];
  177. vc.isDownloadingType = YES;
  178. [vc gotoDownloadFile:arr];
  179. }
  180. }
  181. - (void)setCanShareType:(BOOL)canShareType
  182. {
  183. _canShareType = canShareType;
  184. [_curEditTypeBottomView setCanShaewFunBy:canShareType];
  185. }
  186. @end