imageDetailsScrollViewController.m 7.9 KB

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