imageDetailsScrollViewController.m 7.6 KB

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