imageDetailsScrollViewController.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(0);
  37. make.right.mas_equalTo(0);
  38. make.bottom.mas_equalTo(0);
  39. make.height.mas_equalTo(60 + AdaptTabHeight);
  40. }];
  41. KWeakSelf
  42. #pragma mark 编辑状态的 下载 分享 删除 响应事件
  43. _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
  44. if(tag==1){
  45. //[[iToast makeText:@"点击下载"] show];
  46. [weakSelf gotoDownLoadFileFun];
  47. }
  48. else if(tag==2){
  49. [weakSelf gotoShareViewFun];
  50. }
  51. else if(tag==3){
  52. //[[iToast makeText:@"点击删除"] show];
  53. [weakSelf showDeleteAlearViewFun];
  54. }
  55. };
  56. }
  57. #pragma mark 用户点击分享
  58. - (void)gotoShareViewFun
  59. {
  60. editShareView *editShareV = [[editShareView alloc] init];
  61. NASFilePicDataArrModel *dataModel = _totalDataArr[_index];
  62. editShareV.didSelectListArr = [NSMutableArray arrayWithArray:@[dataModel]];
  63. editShareV.shareFileType = @"2";
  64. [self.view addSubview:editShareV];
  65. [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.mas_equalTo(0);
  67. make.right.mas_equalTo(0);
  68. make.bottom.mas_equalTo(0);
  69. make.top.mas_equalTo(0);
  70. }];
  71. }
  72. - (void)setTotalDataArr:(NSMutableArray *)totalDataArr
  73. {
  74. _totalDataArr = totalDataArr;
  75. imageURLStringsGroup = [NSMutableArray new];
  76. for (NASFilePicDataArrModel*dataModel in _totalDataArr) {
  77. NSString * URLString = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",ksharedAppDelegate.NASFileService,dataModel.path];
  78. [imageURLStringsGroup addObject:URLString];
  79. }
  80. _curScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero imageURLStringsGroup:imageURLStringsGroup];
  81. _curScrollView.autoScroll = NO;
  82. _curScrollView.infiniteLoop = NO;
  83. //_curScrollView.placeholderImage = [UIImage imageNamed:@"uploadFile_image"];
  84. [self.view addSubview:_curScrollView];
  85. _curScrollView.backgroundColor = [UIColor lightGrayColor];
  86. _curScrollView.hidden = YES;
  87. [_curScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.mas_equalTo(0);
  89. make.right.mas_equalTo(0);
  90. make.top.equalTo(self.navBarBGView.mas_bottom).offset(0);
  91. make.bottom.mas_equalTo(-(60+ AdaptTabHeight));
  92. }];
  93. KWeakSelf
  94. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  95. [self->_curScrollView makeScrollViewScrollToIndex:self->_index];
  96. [weakSelf setTitleLabelTextFunBy:self->_index];
  97. self->_curScrollView.hidden = NO;
  98. });
  99. _curScrollView.itemDidScrollOperationBlock = ^(NSInteger currentIndex) {
  100. weakSelf.index = currentIndex;
  101. [weakSelf setTitleLabelTextFunBy:currentIndex];
  102. };
  103. }
  104. - (void)setTitleLabelTextFunBy:(NSInteger)index
  105. {
  106. if(index >=0 && index < _totalDataArr.count){
  107. NASFilePicDataArrModel *dataModel = _totalDataArr[index];
  108. self.titleLabel.text = dataModel.name;
  109. }
  110. }
  111. #pragma mark 删除图片
  112. - (void)showDeleteAlearViewFun
  113. {
  114. NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
  115. NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
  116. KWeakSelf
  117. ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
  118. msg:tipStr
  119. imageStr:nil
  120. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  121. okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
  122. didClickOk:^{
  123. [weakSelf delFileListFun];
  124. } didClickCancel:^{
  125. }];
  126. curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  127. [self presentViewController:curAlretVC animated:YES completion:^{
  128. curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  129. }];
  130. }
  131. #pragma mark 删除文件数据
  132. - (void)delFileListFun
  133. {
  134. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  135. if(_index >=0 && _index < _totalDataArr.count){
  136. NASFilePicDataArrModel *dataModel = _totalDataArr[_index];
  137. NSArray *pathArr = @[dataModel.path];
  138. //NSArray *pathArr = @[dataModel.path,dataModel.path];
  139. [paraDict setValue:pathArr forKey:@"path"];
  140. }
  141. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  142. //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
  143. KWeakSelf //@"delFile"
  144. [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
  145. [weakSelf removeNewIndicator];
  146. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  147. if(model && model.status == 0){
  148. [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
  149. if(weakSelf.didNeedToRegetDataFun){
  150. weakSelf.didNeedToRegetDataFun();
  151. }
  152. [weakSelf.navigationController popViewControllerAnimated:YES];
  153. }
  154. else{
  155. }
  156. } failure:^(NSError * _Nonnull error) {
  157. [weakSelf removeNewIndicator];
  158. }];
  159. }
  160. - (void)gotoDownLoadFileFun
  161. {
  162. if(_index >=0 && _index < _totalDataArr.count){
  163. NASFilePicDataArrModel *dataModel = _totalDataArr[_index];
  164. couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
  165. fileModel.fileType = @".jpg";
  166. fileModel.path = dataModel.path;
  167. fileModel.name = dataModel.name;
  168. fileModel.length = dataModel.size;
  169. NSMutableArray *arr = [NSMutableArray new];
  170. [arr addObject:fileModel];
  171. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  172. [self.navigationController pushViewController:vc animated:YES];
  173. vc.isDownloadingType = YES;
  174. [vc gotoDownloadFile:arr];
  175. }
  176. }
  177. - (void)setCanShareType:(BOOL)canShareType
  178. {
  179. _canShareType = canShareType;
  180. [_curEditTypeBottomView setCanShaewFunBy:canShareType];
  181. }
  182. @end