Kaynağa Gözat

1.图片关联原来下载逻辑完成

huangxiaodong 1 yıl önce
ebeveyn
işleme
2d23af527d

+ 76 - 39
创维盒子/双子星云手机/Class/Set/previewFile/previewImageOrVideoViewController.m

@@ -112,7 +112,7 @@
 #pragma mark 编辑状态的 下载 分享 删除 响应事件
     _curEditTypeBottomView.didClickButtonFun = ^(NSInteger tag) {
         if(tag==1){
-            [[iToast makeText:@"点击下载"] show];
+            [weakSelf gotoDownLoadFileFun];
         }
         else if(tag==2){
             [weakSelf gotoShareViewFun];
@@ -373,7 +373,7 @@
             KWeakSelf
             cell.didClckSelectBut = ^(BOOL selectType){
                 if([weakSelf userCheckFileModel:dataModel withShowTip:YES]){
-                    [weakSelf userCheckFilePreviewByRow:row];
+                    [weakSelf userCheckFilePreviewByRow:row withSection:section];
                 }
             };
             
@@ -513,6 +513,8 @@
     _curEditTypeBottomView.hidden = NO;
     _uploadFileButton.hidden = YES;
     
+    [self setEditTypeTitleFun];
+    
     [self.dataCollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(0);
         make.right.mas_equalTo(0);
@@ -525,6 +527,7 @@
 - (void)userCancelEditTypeFun
 {
     _isEditType = NO;
+    [_didSelectListArr removeAllObjects];
     [_dataCollectionView reloadData];
     
     _curEditTypeHeadView.hidden = YES;
@@ -539,23 +542,26 @@
     }];
 }
 
-- (void)userCheckFilePreviewByRow:(NSInteger)row
+- (void)userCheckFilePreviewByRow:(NSInteger)row withSection:(NSInteger)section
 {
-//    if(row < _curCouldPhoneFileListMod.data.list.count){
-//        couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
-//        
-//        if(fileModel.isSelectType){
-//            [_didSelectListArr removeObject:fileModel];
-//        }
-//        else{
-//            [_didSelectListArr addObject:fileModel];
-//        }
-//        
-//         fileModel.isSelectType = !fileModel.isSelectType;
-//        //[self.tableView reloadData];
-//        //[self.dataCollectionView reloadData];
-//        [self setEditTypeTitleFun];
-//    }
+    if(_curNASFilePicModel && _curNASFilePicModel.data.fileList.count > section){
+        NASFilePicTimeArrModel *timeArrModel = _curNASFilePicModel.data.fileList[section];
+        if (timeArrModel.list.count > row) {
+            NASFilePicDataArrModel * dataModel = timeArrModel.list[row];
+            if(dataModel.isSelectType)
+            {
+                [_didSelectListArr removeObject:dataModel];
+            }
+            else{
+                [_didSelectListArr addObject:dataModel];
+            }
+            
+            dataModel.isSelectType = !dataModel.isSelectType;
+            
+            [self setEditTypeTitleFun];
+            
+        }
+    }
 }
 
 - (void)didClickSelectAllButton:(UIButton*)button
@@ -565,32 +571,34 @@
     
     [_didSelectListArr removeAllObjects];
     
-//    for (couldPhoneFileModel* fileModel in _curCouldPhoneFileListMod.data.list) {
-//        
-//        if(!button.selected){
-//            fileModel.isSelectType = button.selected;
+    for (NASFilePicTimeArrModel* fileModel in _curNASFilePicModel.data.fileList) {
+        
+        for (NASFilePicDataArrModel*dataModel in fileModel.list) {
+            if(!button.selected){
+                dataModel.isSelectType = button.selected;
+            }
+            else{
+                [_didSelectListArr addObject:dataModel];
+                if([self userCheckFileModel:dataModel withShowTip:NO]){
+                    dataModel.isSelectType = button.selected;
+                }
+                else{
+                    isNeedShowTip = YES;
+                }
+            }
+        }
+        
+    }
+    
+//    if(isNeedShowTip){
+//        if(_isPhotoType){
+//            [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
 //        }
 //        else{
-//            [_didSelectListArr addObject:fileModel];
-//            if([self userCheckFileModel:fileModel withShowTip:NO]){
-//                fileModel.isSelectType = button.selected;
-//            }
-//            else{
-//                isNeedShowTip = YES;
-//            }
+//            [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
 //        }
-//        
 //    }
     
-    if(isNeedShowTip){
-        if(_isPhotoType){
-            [[iToast makeText:NSLocalizedString(@"download_image_disable_state",nil)] show];
-        }
-        else{
-            [[iToast makeText:NSLocalizedString(@"download_video_disable_state",nil)] show];
-        }
-    }
-    
     //[self.tableView reloadData];
     [self.dataCollectionView reloadData];
     [self setEditTypeTitleFun];
@@ -600,6 +608,9 @@
 - (void)setEditTypeTitleFun
 {
     [_curEditTypeHeadView setTitleLabetextByNumbers:_didSelectListArr.count];
+    
+    BOOL canClick = _didSelectListArr.count >0 ? YES : NO;
+    [_curEditTypeBottomView setButtonStateFunBy:canClick];
 }
 
 #pragma mark 用户点击分享
@@ -895,4 +906,30 @@
         
     }
 }
+
+- (void)gotoDownLoadFileFun
+{
+    if(_didSelectListArr.count == 0){
+        [[iToast makeText:@""] show];
+        return;
+    }
+    
+    NSMutableArray *arr = [NSMutableArray new];
+    for (NASFilePicDataArrModel *dataModel in _didSelectListArr) {
+        
+        couldPhoneFileModel* fileModel =  [couldPhoneFileModel new];
+        fileModel.fileType = @".jpg";
+        fileModel.path = dataModel.path;
+        fileModel.name = dataModel.name;
+        fileModel.length = dataModel.size;
+        
+        [arr addObject:fileModel];
+    }
+    
+    uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
+    [self.navigationController pushViewController:vc animated:YES];
+    vc.isDownloadingType = YES;
+    [vc gotoDownloadFile:arr];
+}
+
 @end

+ 3 - 0
创维盒子/双子星云手机/Class/Set/previewFile/view/editTypeBottomView.h

@@ -11,6 +11,9 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface editTypeBottomView : UIView
 @property (nonatomic,copy) void (^didClickButtonFun)(NSInteger tag);
+
+
+- (void)setButtonStateFunBy:(BOOL)canClick;
 @end
 
 NS_ASSUME_NONNULL_END

+ 12 - 0
创维盒子/双子星云手机/Class/Set/previewFile/view/editTypeBottomView.m

@@ -149,4 +149,16 @@
     }
 }
 
+
+- (void)setButtonStateFunBy:(BOOL)canClick
+{
+    CGFloat alpha = canClick ? 1.0 : 0.5;
+    _leftButton.enabled = canClick;
+    _rightButton.enabled = canClick;
+    _midButton.enabled = canClick;
+    
+    _leftButton.alpha = alpha;
+    _rightButton.alpha = alpha;
+    _midButton.alpha = alpha;
+}
 @end