Bläddra i källkod

1.设置UI逻辑补充

huangxiaodong 1 år sedan
förälder
incheckning
74b32ddfec

+ 28 - 13
创维盒子/双子星云手机/Class/Set/MySetViewController.m

@@ -134,22 +134,18 @@
         case 3:
         {
             fileTransferPopView * fileTransferPopV = [[fileTransferPopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
-            [self.view.window addSubview:fileTransferPopV];
-            
-            return;
-            
-            if(self->_getBaseInfo){
-                self->_getBaseInfo();
-            }
-            
-            uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
-            if(tag ==2){
-                vc.isPhotoType = YES;
+            if(tag==2){
+                fileTransferPopV.fileTransferType =1;
             }
             else{
-                vc.isPhotoType = NO;
+                fileTransferPopV.fileTransferType =2;
             }
-            [self.navigationController pushViewController:vc animated:YES];
+            [self.view.window addSubview:fileTransferPopV];
+            
+            KWeakSelf
+            fileTransferPopV.didClickBut = ^(NSInteger tag) {
+                [weakSelf gotoFileTransferFunBy:tag];
+            };
             
         }
             break;
@@ -223,6 +219,25 @@
 
 }
 
+#pragma mark 点击图片或者视频
+- (void)gotoFileTransferFunBy:(NSInteger)tag
+{
+    if(tag == 11 ||tag == 21){
+        if(self->_getBaseInfo){
+            self->_getBaseInfo();
+        }
+        
+        uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
+        if(tag ==11){
+            vc.isPhotoType = YES;
+        }
+        else{
+            vc.isPhotoType = NO;
+        }
+        [self.navigationController pushViewController:vc animated:YES];
+    }
+}
+
 - (UIView *)tableFoorView{
     UIView *bgView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, SCREEN_W, 48.f))];
     [bgView setBackgroundColor:[UIColor clearColor]];

+ 2 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/fileTransferPopView.h

@@ -10,7 +10,9 @@
 NS_ASSUME_NONNULL_BEGIN
 
 @interface fileTransferPopView : UIView
+@property (nonatomic,assign) NSInteger fileTransferType;// 1 上传 2下载
 
+@property (nonatomic,copy) void (^didClickBut)(NSInteger tag);// 11 图片上传 12  图片下载 21视频上传 22 视频下载
 @end
 
 NS_ASSUME_NONNULL_END

+ 166 - 5
创维盒子/双子星云手机/Class/Set/uploadFile/fileTransferPopView.m

@@ -6,6 +6,12 @@
 //
 
 #import "fileTransferPopView.h"
+@interface fileTransferPopView ()
+{
+    UIButton *uploadButton;
+    UIButton *downButton;
+}
+@end
 
 @implementation fileTransferPopView
 
@@ -32,17 +38,172 @@
         make.bottom.mas_equalTo(10);
     }];
     
-    UIView *blackView = [[UIView alloc] init];
-    whiteBgView.backgroundColor = [UIColor blackColor];
-    whiteBgView.layer.cornerRadius = 2;
-    [self addSubview:whiteBgView];
+    UIView *tapView = [[UIView alloc] init];
+    [self addSubview:tapView];
     
-    [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
+    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapUpFun:)];
+    [tapView addGestureRecognizer:tap];
+    
+    [tapView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
+        make.right.mas_equalTo(0);
+        make.top.mas_equalTo(0);
+        make.bottom.mas_equalTo(whiteBgView.mas_top);
+    }];
+    
+    UIView *blackView = [[UIView alloc] init];
+    blackView.backgroundColor = [UIColor blackColor];
+    blackView.layer.cornerRadius = 2;
+    [whiteBgView addSubview:blackView];
+
+    [blackView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.width.mas_equalTo(40);
         make.height.mas_equalTo(4);
         make.centerX.mas_equalTo(0);
         make.top.mas_equalTo(8);
     }];
+    
+    CGFloat butW = SCREEN_W - 15*2;
+    CGFloat butH =  butW * 80.0/345.0;
+    
+    //
+    uploadButton = [[UIButton alloc] init];
+    [uploadButton setBackgroundImage:[UIImage imageNamed:@"uploadFile_bg_upload"] forState:UIControlStateNormal];
+    uploadButton.tag = 1;
+    [uploadButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
+    [whiteBgView addSubview:uploadButton];
+    
+    [uploadButton mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.width.mas_equalTo(butW);
+        make.height.mas_equalTo(butH);
+        make.centerX.mas_equalTo(0);
+        make.top.mas_equalTo(blackView.mas_bottom).offset(10);
+    }];
+    
+    
+    
+    downButton = [[UIButton alloc] init];
+    downButton.tag = 2;
+    [downButton setBackgroundImage:[UIImage imageNamed:@"uploadFile_bg_downLoad"] forState:UIControlStateNormal];
+    [downButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
+    [whiteBgView addSubview:downButton];
+    
+    [downButton mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.width.mas_equalTo(butW);
+        make.height.mas_equalTo(butH);
+        make.centerX.mas_equalTo(0);
+        make.top.mas_equalTo(uploadButton.mas_bottom).offset(15);
+    }];
 }
 
+- (void)setFileTransferType:(NSInteger)fileTransferType
+{
+    _fileTransferType = fileTransferType;
+    
+    NSString *uploadTitle = NSLocalizedString(@"File_upload_type_image",nil);
+    NSString *uploadTip = NSLocalizedString(@"File_upload_type_tip",nil);
+    
+    NSString *downloadTitle = NSLocalizedString(@"File_down_type_image",nil);
+    NSString *downloadTip = NSLocalizedString(@"File_down_type_tip",nil);
+    
+    if(fileTransferType == 2)
+    {
+        uploadTitle = NSLocalizedString(@"File_upload_type_video",nil);
+        downloadTitle = NSLocalizedString(@"File_down_type_video",nil);
+    }
+    
+    UILabel *uploadLabel = [[UILabel alloc] init];
+    uploadLabel.textColor = [UIColor whiteColor];
+    uploadLabel.font = [UIFont boldSystemFontOfSize:18.0];
+    uploadLabel.numberOfLines = 0;
+    [uploadButton addSubview:uploadLabel];
+    
+    NSString *totalStr = [[NSString alloc] initWithFormat:@"%@\n%@",uploadTitle,uploadTip];
+    
+    NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
+    
+    NSRange redRange = NSMakeRange([totalStr rangeOfString:uploadTip].location, [totalStr rangeOfString:uploadTip].length);
+    [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#FFFFFF" alpha:0.8] 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])];
+    
+    uploadLabel.attributedText = noteStr;
+    
+    [uploadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(15);
+        make.right.mas_equalTo(-15);
+        make.bottom.mas_equalTo(0);
+        make.top.mas_equalTo(0);
+    }];
+    
+    UILabel *downloadLabel = [[UILabel alloc] init];
+    downloadLabel.textColor = [UIColor whiteColor];
+    downloadLabel.font = [UIFont boldSystemFontOfSize:18.0];
+    downloadLabel.numberOfLines = 0;
+    [downButton addSubview:downloadLabel];
+    
+    NSString *downTotalStr = [[NSString alloc] initWithFormat:@"%@\n%@",downloadTitle,downloadTip];
+    
+    NSMutableAttributedString *downNoteStr = [[NSMutableAttributedString alloc] initWithString:downTotalStr];
+    
+    NSRange downredRange = NSMakeRange([downTotalStr rangeOfString:downloadTip].location, [downTotalStr rangeOfString:downloadTip].length);
+    [downNoteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#FFFFFF" alpha:0.8] range:downredRange];
+    [downNoteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:downredRange];
+    // 设置行间距
+//    NSMutableParagraphStyle *paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
+//    [paragraphStyle1 setLineSpacing:5];        //设置行间距
+    
+    [downNoteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [downTotalStr  length])];
+    
+    downloadLabel.attributedText = downNoteStr;
+    
+    [downloadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(15);
+        make.right.mas_equalTo(-15);
+        make.bottom.mas_equalTo(0);
+        make.top.mas_equalTo(0);
+    }];
+}
+
+- (void)tapUpFun:(UITapGestureRecognizer*)tap
+{
+    [self removeFromSuperview];
+}
+
+- (void)didClickButtonFun:(UIButton*)button
+{
+    [self tapUpFun:nil];
+    
+    NSInteger tag = button.tag;
+    
+    NSInteger didTag = -1;
+    
+    if(_fileTransferType == 1){
+        if(tag == 1){
+            didTag = 11;
+        }
+        else if(tag == 2){
+            didTag = 12;
+        }
+    }
+    else if(_fileTransferType == 2){
+        if(tag == 1){
+            didTag = 21;
+        }
+        else if(tag == 2){
+            didTag = 22;
+        }
+    }
+    
+    if(didTag){
+        if(_didClickBut)
+        {
+            _didClickBut(didTag);
+        }
+    }
+}
 @end

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

@@ -321,3 +321,9 @@
 "common_open" = "开启";
 "common_close" = "关闭";
 "set_other_title" = "其他功能";
+"File_upload_type_image"   = "图片上传";
+"File_upload_type_video"   = "视频上传";
+"File_upload_type_tip"   = "文件将上传到Privte-X";
+"File_down_type_image"   = "图片下载";
+"File_down_type_video"   = "视频下载";
+"File_down_type_tip"   = "文件将下载到本地手机";