Browse Source

1.下载预览界面逻辑

huangxiaodong 1 year ago
parent
commit
392d6ed2a2

+ 8 - 0
创维盒子/双子星云手机.xcodeproj/project.pbxproj

@@ -218,6 +218,8 @@
 		6B5D40282B4BC402000965CF /* couldPhoneFileListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B5D40262B4BC402000965CF /* couldPhoneFileListModel.m */; };
 		6B5D402F2B4BCBC1000965CF /* downLoadPreViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B5D402D2B4BCBC1000965CF /* downLoadPreViewCell.h */; };
 		6B5D40302B4BCBC1000965CF /* downLoadPreViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B5D402E2B4BCBC1000965CF /* downLoadPreViewCell.m */; };
+		6B5D40332B4BE358000965CF /* downloadFileBottomView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B5D40312B4BE358000965CF /* downloadFileBottomView.h */; };
+		6B5D40342B4BE358000965CF /* downloadFileBottomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B5D40322B4BE358000965CF /* downloadFileBottomView.m */; };
 		6B72724B2B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B7272492B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.h */; };
 		6B72724C2B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B72724A2B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.m */; };
 		6B72724F2B0B58E500C03F87 /* uploadFileRecordEditBottomView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B72724D2B0B58E500C03F87 /* uploadFileRecordEditBottomView.h */; };
@@ -637,6 +639,8 @@
 		6B5D40262B4BC402000965CF /* couldPhoneFileListModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = couldPhoneFileListModel.m; sourceTree = "<group>"; };
 		6B5D402D2B4BCBC1000965CF /* downLoadPreViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = downLoadPreViewCell.h; sourceTree = "<group>"; };
 		6B5D402E2B4BCBC1000965CF /* downLoadPreViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = downLoadPreViewCell.m; sourceTree = "<group>"; };
+		6B5D40312B4BE358000965CF /* downloadFileBottomView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = downloadFileBottomView.h; sourceTree = "<group>"; };
+		6B5D40322B4BE358000965CF /* downloadFileBottomView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = downloadFileBottomView.m; sourceTree = "<group>"; };
 		6B7272492B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = uploadFileRecordTableViewHeadView.h; sourceTree = "<group>"; };
 		6B72724A2B0AF59200C03F87 /* uploadFileRecordTableViewHeadView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = uploadFileRecordTableViewHeadView.m; sourceTree = "<group>"; };
 		6B72724D2B0B58E500C03F87 /* uploadFileRecordEditBottomView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = uploadFileRecordEditBottomView.h; sourceTree = "<group>"; };
@@ -1436,6 +1440,8 @@
 			children = (
 				6B5D402D2B4BCBC1000965CF /* downLoadPreViewCell.h */,
 				6B5D402E2B4BCBC1000965CF /* downLoadPreViewCell.m */,
+				6B5D40312B4BE358000965CF /* downloadFileBottomView.h */,
+				6B5D40322B4BE358000965CF /* downloadFileBottomView.m */,
 			);
 			path = view;
 			sourceTree = "<group>";
@@ -1922,6 +1928,7 @@
 				6B7B65582AD9227700BE8CB3 /* PlayerViewController+otherDelegate.h in Headers */,
 				6B7272572B0DAF7600C03F87 /* couldPhoneBaseInfoModel.h in Headers */,
 				186820212AB98600005702A6 /* QRCodeScanViewController.h in Headers */,
+				6B5D40332B4BE358000965CF /* downloadFileBottomView.h in Headers */,
 				6B1FBD222B43DAD200926382 /* backupsSetViewController.h in Headers */,
 				6B8FF6B92B04E19600800981 /* uploadFileRecordheadView.h in Headers */,
 				18FCE5482AD15E750020F623 /* PlayerViewController+AppDelegate.h in Headers */,
@@ -2406,6 +2413,7 @@
 				A031DD7127EC34E500909527 /* HWBookmarkHeader.m in Sources */,
 				A003F6D227D8425C00715CBF /* HWDataManager.m in Sources */,
 				18C475502A8E0DB5006129C0 /* MySetViewController.m in Sources */,
+				6B5D40342B4BE358000965CF /* downloadFileBottomView.m in Sources */,
 				A003F6C127D841FF00715CBF /* FLAnimatedImageView.m in Sources */,
 				6BF0F3D62AD3937B000AA133 /* DeviceThirdIdModel.m in Sources */,
 				184C8ACD2A94557200F26650 /* HidenMaskSetViewController.m in Sources */,

+ 22 - 0
创维盒子/双子星云手机/Assets.xcassets/Set/donwload_file_white_100.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "donwload_file_white_100@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "donwload_file_white_100@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
创维盒子/双子星云手机/Assets.xcassets/Set/donwload_file_white_100.imageset/donwload_file_white_100@2x.png


BIN
创维盒子/双子星云手机/Assets.xcassets/Set/donwload_file_white_100.imageset/donwload_file_white_100@3x.png


+ 39 - 2
创维盒子/双子星云手机/Class/Set/uploadFile/downLoadFile/downLoadPreviewViewController.m

@@ -8,10 +8,13 @@
 #import "downLoadPreviewViewController.h"
 #import "couldPhoneFileListModel.h"
 #import "downLoadPreViewCell.h"
+#import "downloadFileBottomView.h"
 
 @interface downLoadPreviewViewController ()<UITableViewDelegate,UITableViewDataSource>
 @property (nonatomic, strong) UITableView *tableView;
 @property (nonatomic, strong) UIButton *rightButton;
+@property (nonatomic, strong) downloadFileBottomView *downloadFileBottomV;
+
 @property(nonatomic,strong) couldPhoneFileListModel *curCouldPhoneFileListMod;
 @end
 
@@ -57,10 +60,27 @@
     [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(0);
         make.right.mas_equalTo(0);
-        make.bottom.mas_equalTo(0);
+        make.bottom.mas_equalTo(-(60 + safeArea));
         make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
     }];
     
+    _downloadFileBottomV = [[downloadFileBottomView alloc] init];
+    [self.view insertSubview:_downloadFileBottomV atIndex:0];
+    
+    [_downloadFileBottomV mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
+        make.right.mas_equalTo(0);
+        make.bottom.mas_equalTo(0);
+        make.height.mas_equalTo(60 + safeArea);
+    }];
+    
+    [self RefreshBottomViewUIFun];
+    
+    KWeakSelf
+    _downloadFileBottomV.didClickDownloadFile = ^{
+        //[weakSelf gotoUploadFileRecordFun];
+    };
+    
 }
 
 #pragma mark - 懒加载
@@ -143,8 +163,9 @@
 {
     if(row < _curCouldPhoneFileListMod.data.list.count){
         couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
-         fileModel.isSelectType = YES;
+         fileModel.isSelectType = !fileModel.isSelectType;
         [self.tableView reloadData];
+        [self RefreshBottomViewUIFun];
     }
 }
 
@@ -157,6 +178,22 @@
     }
     
     [self.tableView reloadData];
+    [self RefreshBottomViewUIFun];
+}
+
+#pragma mark 刷新底部
+- (void)RefreshBottomViewUIFun
+{
+    NSMutableArray *selectArr = [NSMutableArray new];
+    
+    for (couldPhoneFileModel* fileModel in _curCouldPhoneFileListMod.data.list) {
+        
+        if(fileModel.isSelectType){
+            [selectArr addObject:fileModel];
+        }
+    }
+    
+    _downloadFileBottomV.indexPathsForSelectedItems = selectArr;
 }
 
 - (void)viewWillAppear:(BOOL)animated

+ 20 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/downLoadFile/view/downloadFileBottomView.h

@@ -0,0 +1,20 @@
+//
+//  downloadFileBottomView.h
+//  隐私保护
+//
+//  Created by xd h on 2024/1/8.
+//
+
+#import <UIKit/UIKit.h>
+#import "couldPhoneFileListModel.h"
+NS_ASSUME_NONNULL_BEGIN
+
+@interface downloadFileBottomView : UIView
+//选中的项 
+@property (nonatomic,strong) NSMutableArray *indexPathsForSelectedItems;
+@property (nonatomic,copy) NSString *availableStorage;
+//点击上传
+@property (nonatomic,copy) void (^didClickDownloadFile)(void);
+@end
+
+NS_ASSUME_NONNULL_END

+ 188 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/downLoadFile/view/downloadFileBottomView.m

@@ -0,0 +1,188 @@
+//
+//  downloadFileBottomView.m
+//  隐私保护
+//
+//  Created by xd h on 2024/1/8.
+//
+
+#import "downloadFileBottomView.h"
+#import <sys/mount.h>
+#include <sys/param.h>
+
+@interface downloadFileBottomView ()
+@property(nonatomic,strong)UILabel *selectNumLabel;
+@property(nonatomic,strong)UILabel *uploadFileRoutelabel;
+@property(nonatomic,strong)UIButton *uploadButon;
+@end
+
+@implementation downloadFileBottomView
+
+- (id)initWithFrame:(CGRect)frame{
+    self = [super initWithFrame:frame];
+    [self setBackgroundColor:[UIColor whiteColor]];
+    [self drawAnyView];
+    
+    _availableStorage = [self freeDiskSpaceInBytes];
+    return self;
+}
+
+- (NSString *)freeDiskSpaceInBytes{
+    struct statfs buf;
+    unsigned long long freeSpace = -1;
+    if (statfs("/var", &buf) >= 0) {
+        freeSpace = (unsigned long long)(buf.f_bsize * buf.f_bavail);
+    }
+     NSString *str = [NSString stringWithFormat:@"%0.2f GB",freeSpace/1024.0/1024.0/1024.0];
+    return str;
+}
+
+- (void)drawAnyView{
+    _selectNumLabel = [[UILabel alloc] init];
+    _selectNumLabel.font = [UIFont boldSystemFontOfSize:16.0];
+    [self addSubview:_selectNumLabel];
+    
+    [_selectNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(15);
+        make.top.mas_equalTo(10);
+        make.right.mas_equalTo(-110);
+        make.height.mas_equalTo(20);
+    }];
+    
+    //设置即得标题
+    self.indexPathsForSelectedItems = [NSMutableArray new];
+    
+    _uploadFileRoutelabel = [[UILabel alloc] init];
+    _uploadFileRoutelabel.font = [UIFont systemFontOfSize:14.0];
+    _uploadFileRoutelabel.textColor = [UIColor hwColor:@"#959799" alpha:1.0];
+    _uploadFileRoutelabel.text = NSLocalizedString(@"File_download_Path_default",nil);
+    [self addSubview:_uploadFileRoutelabel];
+    
+    [_uploadFileRoutelabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(15);
+        make.top.mas_equalTo(_selectNumLabel.mas_bottom).offset(10);
+        make.right.mas_equalTo(-110);
+        make.height.mas_equalTo(20);
+    }];
+    
+    //图片上传
+    NSString* curImgUploadStr = [[NSString alloc] initWithFormat:@"%@ %@",@"  ",NSLocalizedString(@"my_set_no_File_download",nil)];
+    
+    
+    // gradient
+    CAGradientLayer *gl_But = [CAGradientLayer layer];
+    gl_But.frame = CGRectMake(0,0,88.f,40.f);
+    gl_But.startPoint = CGPointMake(0, 0.5);
+    gl_But.endPoint = CGPointMake(1, 0.5);
+    gl_But.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
+    gl_But.locations = @[@(0), @(1.0f)];
+    gl_But.cornerRadius = 8;
+    
+    
+    UIButton *imageUploadBut = [[UIButton alloc] init];
+    
+    
+    [imageUploadBut setImage:[UIImage imageNamed:@"donwload_file_white_100"] forState:UIControlStateNormal];
+    [imageUploadBut setTitle:curImgUploadStr forState:UIControlStateNormal];
+   
+    [imageUploadBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+    imageUploadBut.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];
+    imageUploadBut.tag = 2;
+    [imageUploadBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
+    [self addSubview:imageUploadBut];
+    [imageUploadBut.layer insertSublayer:gl_But atIndex:0];
+    [imageUploadBut bringSubviewToFront:imageUploadBut.imageView];
+    
+    self.uploadButon = imageUploadBut;
+    
+    //imageUploadBut.backgroundColor = [UIColor redColor];
+    
+    [imageUploadBut mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.right.mas_equalTo(-15);
+        make.top.mas_equalTo(10);
+        make.width.mas_equalTo(88);
+        make.height.mas_equalTo(40);
+    }];
+    
+    imageUploadBut.enabled = NO;
+    imageUploadBut.alpha = 0.5;
+}
+
+
+#pragma mark 数据处理
+- (void)setIndexPathsForSelectedItems:(NSMutableArray *)indexPathsForSelectedItems
+{
+    
+    _indexPathsForSelectedItems = indexPathsForSelectedItems;
+    if(!_indexPathsForSelectedItems){
+        _indexPathsForSelectedItems = [NSMutableArray new];
+    }
+    
+    //TZAssetModel imageData (以字节为单位)
+    NSUInteger allImageData = 0;
+    
+    for (couldPhoneFileModel* model in _indexPathsForSelectedItems) {
+        
+        allImageData += model.length;
+        
+    }
+    
+    allImageData /= 1024;
+    
+    NSString *byteStr = nil;
+    NSString *unitStr = @"KB";
+    
+    if(allImageData < 1024){
+        byteStr = [[NSString alloc] initWithFormat:@"%ld",allImageData];
+    }
+    else if( allImageData >= 1024 && allImageData < 1024*1024){
+        byteStr = [[NSString alloc] initWithFormat:@"%.1f",allImageData/1024.0];
+        unitStr = @"MB";
+    }
+    else{
+        byteStr = [[NSString alloc] initWithFormat:@"%.2f",allImageData/1024.0/1024.0];
+        unitStr = @"G";
+    }
+    
+    if(!_availableStorage){
+        _availableStorage = @"--";
+    }
+    
+    NSString *curStr1 = [NSString stringWithFormat:@"已选%ld项",_indexPathsForSelectedItems.count];
+    NSString *curStr2 = [NSString stringWithFormat:@"(%@%@,%@)",byteStr,unitStr,_availableStorage];
+    NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",curStr1,curStr2];
+    
+    NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
+    
+    NSRange redRange = NSMakeRange([totalStr rangeOfString:curStr2].location, [totalStr rangeOfString:curStr2].length);
+    [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#959799" alpha:1.0] range:redRange];
+    [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:redRange];
+    // 设置行间距
+    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
+    [paragraphStyle setLineSpacing:5];        //设置行间距
+    
+    [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr  length])];
+
+    _selectNumLabel.attributedText = noteStr;
+    
+    if(_indexPathsForSelectedItems.count > 0){
+        self.uploadButon.enabled = YES;
+        self.uploadButon.alpha = 1;
+    }
+    else
+    {
+        self.uploadButon.enabled = NO;
+        self.uploadButon.alpha = 0.5;
+    }
+}
+
+#pragma mark 按钮点击
+- (void)didClickButFun:(UIButton*)but
+{
+    if(_didClickDownloadFile)
+    {
+        _didClickDownloadFile();
+    }
+}
+
+@end
+

+ 1 - 0
创维盒子/双子星云手机/zh-Hans.lproj/Localizable.strings

@@ -356,3 +356,4 @@
 "File_Transfer_List_head_title_done"   = "已完成";
 "File_backups_Record_tip_Suspend"   = "已暂停";
 "File_backups_set_default_path_tip"   = "请停止备份操作后再更改路径";
+"File_download_Path_default"   = "下载路径  相册";