Browse Source

1.需求:app安装到TV --进行中(UI初步完成)

huangxiaodong 9 months ago
parent
commit
7595cbf1f2

+ 123 - 17
创维盒子/code/NAS/NasPreviewAPPViewController.m

@@ -25,6 +25,7 @@
 #import "videoPlayByAVPlayerViewController.h"
 #import "MJRefresh.h"
 #import "getInstalledAppListModel.h"
+#import "appInstallTypeView.h"
 
 @interface NasPreviewAPPViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
 {
@@ -36,6 +37,8 @@
     BOOL hadUploadTaskType;
     BOOL hadDownloadTaskType;
     BOOL canShareType;
+    
+    BOOL isDefaultTabType;//默认云机
 }
 @property (nonatomic, strong) UITableView *tableView;
 
@@ -50,8 +53,12 @@
 @property(nonatomic,strong) editTypeBottomView*curEditTypeBottomView;
 @property(nonatomic,strong) UIButton*uploadFileButton;
 
+@property(nonatomic,strong) appInstallTypeView* appInstallTypeV;//tab
+
 @property (nonatomic, strong)  NSMutableArray*didSelectListArr;//选中的数据
-@property (nonatomic, strong)getInstalledAppListModel*getInstalledAppListMod;
+@property (nonatomic, strong)getInstalledAppListModel*getInstalledAppListMod;//已安装的数据
+@property (nonatomic, strong)getInstalledAppListModel*getUninstalledAppListMod;//未安装的数据
+@property (nonatomic, strong)getInstalledAppListModel*curInstalledAppListMod;//当前选中的数据
 @end
 
 @implementation NasPreviewAPPViewController
@@ -126,13 +133,30 @@
         }
     };
     
+    //安装类型
+    _appInstallTypeV = [[appInstallTypeView alloc] init];
+    [self.view addSubview:_appInstallTypeV];
+    
+    [_appInstallTypeV mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
+        make.right.mas_equalTo(0);
+        make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
+        make.height.mas_equalTo(40);
+    }];
+    
+#pragma mark 点击接收的下载或者保存
+    _appInstallTypeV.didClickbuttonFun = ^(NSInteger tag) {
+        [weakSelf didClickHeadTabButtonFun:tag];
+    };
+    
     [self.view addSubview:self.tableView];
     [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(0);
         make.right.mas_equalTo(0);
         //make.bottom.mas_equalTo(-(safeArea));
         make.bottom.mas_equalTo(0);
-        make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
+        //make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
+        make.top.equalTo(self.appInstallTypeV.mas_bottom).offset(10.f);
     }];
     
     //大+号
@@ -352,8 +376,9 @@
     }
     
     self.defaultDiskPath = pathStr;
-    _getInstalledAppListMod = nil;
-    [self getFileListFun:NO];
+    
+    //[self getFileListFun:NO];
+    [self getUninstallAppListFun:NO];
     [self setTitleAfterGetdiskFun];
     [self hideDiskListVieFun];
 }
@@ -364,10 +389,10 @@
 }
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    if(!_getInstalledAppListMod){
+    if(!_curInstalledAppListMod){
         return 0;
     }
-    return _getInstalledAppListMod.data.count;
+    return _curInstalledAppListMod.data.count;
 }
 
 - (downLoadPreViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
@@ -391,8 +416,8 @@
         
     }
     
-    if(row < _getInstalledAppListMod.data.count){
-        getInstalledAppModel* dataModel = _getInstalledAppListMod.data[row];
+    if(row < _curInstalledAppListMod.data.count){
+        getInstalledAppModel* dataModel = _curInstalledAppListMod.data[row];
         cell.curGetInstalledAppMod = dataModel;
         
         KWeakSelf
@@ -515,13 +540,9 @@
     _curEditTypeHeadView.hidden = NO;
     _curEditTypeBottomView.hidden = NO;
     _uploadFileButton.hidden = YES;
+    _appInstallTypeV.userInteractionEnabled = NO;
     
-    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
-        make.left.mas_equalTo(0);
-        make.right.mas_equalTo(0);
-        make.bottom.mas_equalTo(_curEditTypeBottomView.mas_top);
-        make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
-    }];
+    [self RefreshAllUIFun];
 }
 
 #pragma mark 用户取消编辑编辑
@@ -534,17 +555,33 @@
     [_didSelectListArr removeAllObjects];
     
     _isEditType = NO;
-    [self.tableView  reloadData];
+    //[self.tableView  reloadData];
     
     _curEditTypeHeadView.hidden = YES;
     _curEditTypeBottomView.hidden = YES;
     _uploadFileButton.hidden = NO;
+    _appInstallTypeV.userInteractionEnabled = YES;
+    
+    [self RefreshAllUIFun];
+}
+
+#pragma mark 更新UI界面
+- (void)RefreshAllUIFun
+{
+    self.appInstallTypeV.hidden = !isDefaultTabType;
+    
+    [self.tableView  reloadData];
     
     [self.tableView  mas_remakeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(0);
         make.right.mas_equalTo(0);
         make.bottom.mas_equalTo(0);
-        make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
+        if(isDefaultTabType){
+            make.top.equalTo(self.appInstallTypeV.mas_bottom).offset(10.f);
+        }
+        else{
+            make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
+        }
     }];
 }
 
@@ -657,6 +694,18 @@
         name = [iTools changePathToShowPathBy:name];
         
         title = [[NSString alloc] initWithFormat:@"[%@]%@",name,title];
+        
+        //判断是否为云机
+        if([name isEqualToString:NSLocalizedString(@"disk_phone_default_tip",nil)]){
+            isDefaultTabType = YES;
+            _curInstalledAppListMod = _getInstalledAppListMod;
+        }
+        else{
+            isDefaultTabType = NO;
+            _curInstalledAppListMod = _getUninstalledAppListMod;
+        }
+        
+        [self RefreshAllUIFun];
     }
     
     
@@ -752,6 +801,7 @@
     
     if(!_getInstalledAppListMod){
         [self getFileListFun:NO];
+        [self getUninstallAppListFun:NO];
         [self queryShareSwitchFunFun];
     }
 }
@@ -868,7 +918,8 @@
         [weakSelf removeNewIndicatorHaveStr];
         weakSelf.getInstalledAppListMod = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
         
-        if(weakSelf.getInstalledAppListMod && weakSelf.getInstalledAppListMod.status == 0){
+        if(weakSelf.getInstalledAppListMod && weakSelf.getInstalledAppListMod.status == 0 && weakSelf.appInstallTypeV.installButton.selected){
+            weakSelf.curInstalledAppListMod = weakSelf.getInstalledAppListMod;
             [weakSelf.tableView reloadData];
         }
         
@@ -913,6 +964,49 @@
 //    }
 }
 
+#pragma mark 获取未安装数据
+- (void)getUninstallAppListFun:(BOOL)isMoreDataType
+{
+    NSMutableDictionary*paraDict = [NSMutableDictionary new];
+    
+    
+//    if(!isMoreDataType){
+//        self.pageIndex = 0;
+//    }
+//    else{
+//        self.pageIndex ++;
+//    }
+//
+//    [paraDict setValue:[NSNumber numberWithInteger:self.pageIndex] forKey:@"index"];
+//    [paraDict setValue:[NSNumber numberWithInteger:pageSizeNum] forKey:@"pageSize"];
+    
+    [self showNewIndicatorHaveStrWithCanBack:YES canTouch:NO showText:NSLocalizedString(@"common_loading_tip",nil)];
+    
+    KWeakSelf
+    [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"getUninstallApk" Parameters:paraDict success:^(id  _Nonnull responseObject) {
+        //[weakSelf.tableView.mj_footer endRefreshing];
+        [weakSelf removeNewIndicatorHaveStr];
+        weakSelf.getUninstalledAppListMod = [[getInstalledAppListModel alloc] initWithDictionary:responseObject error:nil];
+        
+        if(weakSelf.getUninstalledAppListMod && weakSelf.getUninstalledAppListMod.status == 0 && weakSelf.appInstallTypeV.unInstallButton.selected){
+            weakSelf.curInstalledAppListMod = weakSelf.getUninstalledAppListMod;
+            [weakSelf.tableView reloadData];
+        }
+        
+    } failure:^(NSError * _Nonnull error) {
+        //[weakSelf.tableView.mj_footer endRefreshing];
+        [weakSelf removeNewIndicatorHaveStr];
+        if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
+        {
+            [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
+            
+        }
+        else{
+            [[iToast makeText:NSLocalizedString(@"netWork_error_show_tip",nil)] show];
+        }
+    }];
+}
+
 #pragma mark 调整文件上传
 - (void)gotoUploadFileFunWith:(NSInteger)tag
 {
@@ -1083,5 +1177,17 @@
     }];
 }
 
+#pragma mark 点击了已安装和未安装
+- (void)didClickHeadTabButtonFun:(NSInteger)tag
+{
+    if(tag == 1){
+        _curInstalledAppListMod = _getInstalledAppListMod;
+    }
+    else{
+        _curInstalledAppListMod = _getUninstalledAppListMod;
+    }
+    
+    [_tableView reloadData];
+}
 @end
 

+ 5 - 0
创维盒子/code/NAS/view/appInstallTypeView.h

@@ -10,7 +10,12 @@
 NS_ASSUME_NONNULL_BEGIN
 
 @interface appInstallTypeView : UIView
+@property(nonatomic,strong) UIButton * installButton;
+@property(nonatomic,strong) UIButton * unInstallButton;
 
+@property (nonatomic,copy) void (^didClickbuttonFun)(NSInteger tag);
+
+- (void)didClickButFun:(UIButton*)but;
 @end
 
 NS_ASSUME_NONNULL_END

+ 113 - 3
创维盒子/code/NAS/view/appInstallTypeView.m

@@ -7,20 +7,130 @@
 
 #import "appInstallTypeView.h"
 
+@interface appInstallTypeView ()
+{
+    
+}
+
+@property(nonatomic,strong) UIView * selectBgView;
+
+@end
+
 @implementation appInstallTypeView
 
 - (id)initWithFrame:(CGRect)frame{
     self = [super initWithFrame:frame];
-    
-    self.backgroundColor = [UIColor clearColor];//[UIColor hwColor:@"#000000" alpha:0.6];
+    [self setBackgroundColor:[UIColor whiteColor]];
     [self drawAnyView];
     
     return self;
 }
 
--(void)drawAnyView
+- (void)drawAnyView{
+    CGFloat curButtonW = SCREEN_W/2.0;
+    CGFloat curButtonH = 40.0;
+    
+    
+    _installButton = [[UIButton alloc] init];
+    _installButton.tag = 1;
+    [_installButton setTitle:NSLocalizedString(@"nas_did_install_app_title",nil) forState:UIControlStateNormal];
+    [_installButton setTitleColor:[UIColor hwColor:@"#666666" alpha:1.0] forState:UIControlStateNormal];
+    [_installButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateSelected];
+    _installButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
+    [_installButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
+    [self addSubview:_installButton];
+    
+    [_installButton mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
+        make.width.mas_equalTo(curButtonW);
+        make.top.mas_equalTo(0);
+        make.height.mas_equalTo(curButtonH);
+    }];
+    
+    _unInstallButton = [[UIButton alloc] init];
+    _unInstallButton.tag = 2;
+    [_unInstallButton setTitle:NSLocalizedString(@"nas_un_install_app_title",nil) forState:UIControlStateNormal];
+    [_unInstallButton setTitleColor:[UIColor hwColor:@"#666666" alpha:1.0] forState:UIControlStateNormal];
+    [_unInstallButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateSelected];
+    _unInstallButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
+    [_unInstallButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
+    [self addSubview:_unInstallButton];
+    
+    [_unInstallButton mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(curButtonW);
+        make.width.mas_equalTo(curButtonW);
+        make.top.mas_equalTo(0);
+        make.height.mas_equalTo(curButtonH);
+    }];
+    
+    UIView *lineView = [[UIView alloc] init];
+    lineView.backgroundColor = [UIColor hwColor:@"#F9F9F9"];
+    [self addSubview:lineView];
+    
+    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
+        make.right.mas_equalTo(0);
+        make.height.mas_equalTo(1);
+        make.bottom.mas_equalTo(0);
+    }];
+    
+    _installButton.selected = YES;
+    _selectBgView = [[UIView alloc] init];
+    
+    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
+    gradientLayer.frame = CGRectMake(0, 0, 60, 3);
+    gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor];
+    gradientLayer.locations = @[@(0), @(1.0f)];
+    [_selectBgView.layer addSublayer:gradientLayer];
+    
+    //_selectBgView.backgroundColor = [UIColor whiteColor];
+    _selectBgView.layer.cornerRadius = 1.5;
+    [self insertSubview:_selectBgView atIndex:0];
+    
+    [_selectBgView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.centerX.mas_equalTo(_installButton.mas_centerX);
+        make.width.mas_equalTo(60);
+        make.height.mas_equalTo(3);
+        make.bottom.mas_equalTo(0);
+    }];
+    
+}
+
+- (void)didClickButFun:(UIButton*)but
 {
+    NSInteger tag = but.tag;
+    //but.selected = !but.selected;
+    
+    [self changeSelectViewIndex:tag];
     
+    if(_didClickbuttonFun){
+        _didClickbuttonFun(tag);
+    }
+}
+
+- (void)changeSelectViewIndex:(NSInteger)index
+{
+    BOOL isSelectLeftType = YES;
+    
+    if(index == 2){
+        isSelectLeftType = NO;
+    }
+    
+    _installButton.selected = isSelectLeftType;
+    _unInstallButton.selected = !isSelectLeftType;
+    
+    [_selectBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
+        if(isSelectLeftType){
+            make.centerX.mas_equalTo(_installButton.mas_centerX);
+        }
+        else{
+            make.centerX.mas_equalTo(_unInstallButton.mas_centerX);
+        }
+        make.width.mas_equalTo(60);
+        make.height.mas_equalTo(3);
+        make.bottom.mas_equalTo(0);
+    }];
 }
 
 @end
+

+ 2 - 1
创维盒子/code/zh-Hans.lproj/Localizable.strings

@@ -670,4 +670,5 @@
 "cloudPhone_restarting_box_title"      = "盒子重启中...";
 "cloudPhone_restarting_box_msg"      = "重启设备预计需要5分钟";
 "nas_app_title"      = "应用";
-
+"nas_did_install_app_title"      = "已安装应用";
+"nas_un_install_app_title"      = "未安装应用";