// // NASViewController.m // 双子星云手机 // // Created by xd h on 2024/6/19. // #import "NASViewController.h" #import "NASMySpaceView.h" #import "NASCommonUsedView.h" #import "shareSecretTableViewCell.h" #import "NASLastFileView.h" #import "previewImageOrVideoViewController.h" #import "previewAudioOrDocumentViewController.h" #import "previewFileAndFolderViewController.h" #import "shareRecordViewController.h" #import "backupsOptionViewController.h" #import "fileTransfeSetViewController.h" #import "uploadFileRecordViewController.h" #import "previewToUploadFileView.h" #import "NASMySpaceViewController.h" #import "NasPreviewVideoViewController.h" @interface NASViewController () @property (nonatomic,strong)UITableView*tableView; @property (nonatomic, strong) UIView*tableHeadView; @property (nonatomic, strong) NASMySpaceView* NASMySpaceV; @property (nonatomic, strong) NASCommonUsedView* NASCommonUsedV; @property (nonatomic,strong)NASLastFileView*NASLastFileV; @end @implementation NASViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self.view setBackgroundColor:HWF5F7FAColor]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getExtraFilesDoneFun:) name:getExtraFilesDoneNotification object:nil]; [self.toolBar setHidden:YES]; [self.navigationBar setHidden:YES]; [self.navBarBGView setHidden:YES]; [self drawAnyView]; } - (void)drawAnyView{ //顶底底部图片 UIImageView *topImageV = [UIImageView new]; topImageV.image = [UIImage imageNamed:@"Nas_top_img"]; [self.view addSubview:topImageV]; [topImageV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(0); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.height.mas_equalTo(280.0*AUTOSCALE); }]; NSString *welcomeImageStr = @"nas_welcome_cs"; //欢迎 //en-US 英文 ja-JP 日文 NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]; NSLog(@"arLanguages:%@",arLanguages); ///获取设备当前地区的代码和APP语言环境 NSString *languageCode = [NSLocale preferredLanguages][0]; //目前支持 中文(简体 繁体) 英文 日语 if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound) { welcomeImageStr = @"nas_welcome_cs"; } else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound) { welcomeImageStr = @"nas_welcome_ct"; } else{ welcomeImageStr = @"nas_welcome_en"; } CGFloat imageTopY = 54.0; UIImageView *welcomeImageV = [UIImageView new]; welcomeImageV.image = [UIImage imageNamed:welcomeImageStr]; [self.view addSubview:welcomeImageV]; [welcomeImageV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(imageTopY); make.left.mas_equalTo(16); make.width.mas_equalTo(210); make.height.mas_equalTo(24); }]; //添加按钮 UIButton *addButton = [[UIButton alloc] init]; [addButton setBackgroundImage:[UIImage imageNamed:@"nas_add_icon"] forState:UIControlStateNormal]; addButton.tag = 1; [addButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:addButton]; [addButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(imageTopY); make.right.mas_equalTo(-16); make.width.mas_equalTo(24); make.height.mas_equalTo(24); }]; UIButton *rightTransferListButton = [[UIButton alloc] init]; //[rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal]; [rightTransferListButton setBackgroundImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal]; rightTransferListButton.tag = 2; [rightTransferListButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:rightTransferListButton]; [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(imageTopY); make.right.equalTo(addButton.mas_left).offset(-24); make.width.mas_equalTo(24); make.height.mas_equalTo(24); }]; [self.view addSubview:self.tableView]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.top.equalTo(welcomeImageV.mas_bottom).offset(20); make.bottom.mas_equalTo(-TABBARHEIGHT); }]; _tableHeadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 + 15)]; //_tableHeadView.backgroundColor = [UIColor hwColor:@"#F6F8FA"]; _tableHeadView.backgroundColor = [UIColor clearColor]; self.tableView.tableHeaderView = _tableHeadView; //我的空间 _NASMySpaceV = [[NASMySpaceView alloc] init]; [_tableHeadView addSubview:_NASMySpaceV]; [_NASMySpaceV mas_makeConstraints:^(MASConstraintMaker *make) { //make.top.equalTo(welcomeImageV.mas_bottom).offset(20); make.top.mas_equalTo(0);; make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.height.mas_equalTo(165); }]; //常用功能 _NASCommonUsedV = [[NASCommonUsedView alloc] init]; [_tableHeadView addSubview:_NASCommonUsedV]; [_NASCommonUsedV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_NASMySpaceV.mas_bottom).offset(15); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.height.mas_equalTo(120); }]; KWeakSelf _NASMySpaceV.didClickButtonFun = ^(NSInteger tag) { [weakSelf didClickMySpaceFunBy:tag]; }; _NASCommonUsedV.didClickButtonFun = ^(NSInteger tag) { [weakSelf didClickCommonUsedFunBy:tag]; }; self.NASLastFileV.didClickButtonFun = ^(NSInteger tag) { [weakSelf didClickLastFileFunBy:tag]; }; [self setMySpaceDataFun]; } #pragma mark - 懒加载 - (UITableView *)tableView{ if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.showsVerticalScrollIndicator = NO; _tableView.showsHorizontalScrollIndicator = NO; // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0); [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)]; [_tableView setSeparatorColor:[UIColor clearColor]]; //[_tableView setBackgroundColor:[UIColor hwColor:@"#FFFFFF"]]; [_tableView setBackgroundColor:[UIColor clearColor]]; //[_tableView setTableFooterView:[UIView new]]; [_tableView setBounces:YES]; if (@available(iOS 15.0, *)) { _tableView.sectionHeaderTopPadding = 0; } _tableView.layer.cornerRadius = 8; _tableView.layer.masksToBounds = YES; } return _tableView; } - (NASLastFileView*)NASLastFileV { if(!_NASLastFileV){ _NASLastFileV = [NASLastFileView new]; } return _NASLastFileV; } #pragma mark - 列表委托 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 0; } - (shareSecretTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ __block NSInteger row = indexPath.row; static NSString *identifier = @"shareSecretTableViewCell"; shareSecretTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier]; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (!cell){ cell = [[shareSecretTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; [cell setBackgroundColor:[UIColor clearColor]]; [cell setAccessoryType:(UITableViewCellAccessoryNone)]; } // if(row < _didSelectListArr.count){ // NASFilePicDataArrModel*dataModel = _didSelectListArr[row]; // cell.dataModel = dataModel; // } return cell; } - (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ return self.NASLastFileV; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ //return 54;//隐藏 return 54 + 200;//无数据 } - (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { NSString *text = NSLocalizedString(@"NAS_bottom_tip",nil); UILabel *label = [[UILabel alloc] init]; label.text = [[NSString alloc] initWithFormat:@"- %@ -",text]; label.textColor = [UIColor hwColor:@"#959799"]; label.font = [UIFont systemFontOfSize:12]; label.textAlignment = NSTextAlignmentCenter; return label; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 60.0; } #pragma mark 点击头部 - (void)didClickHeadButtonFun:(UIButton*)but { NSInteger tag = but.tag; switch (tag) { case 1: { [self userDidClickUploadViewFun]; } break; case 2: { uploadFileRecordViewController *vc = [uploadFileRecordViewController new]; [self pushViewController:vc animated:YES]; } break; default: break; } } #pragma mark 点击我的空间模块 - (void)didClickMySpaceFunBy:(NSInteger)tag { switch (tag) { case 1: { NASMySpaceViewController *vc = [NASMySpaceViewController new]; [self pushViewController:vc animated:YES]; } break; case 10:{ previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new]; vc.isPhotoType = YES; [self pushViewController:vc animated:YES]; } break; case 11:{ // previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new]; // vc.isPhotoType = NO; // [self pushViewController:vc animated:YES]; NasPreviewVideoViewController *vc = [NasPreviewVideoViewController new]; [self pushViewController:vc animated:YES]; } break; case 12:{ previewAudioOrDocumentViewController *vc = [previewAudioOrDocumentViewController new]; vc.isAudioType = YES; [self pushViewController:vc animated:YES]; } break; case 13:{ previewFileAndFolderViewController *vc = [previewFileAndFolderViewController new]; [self pushViewController:vc animated:YES]; } break; default: break; } } #pragma mark 点击常用模块模块 - (void)didClickCommonUsedFunBy:(NSInteger)tag { switch (tag) { case 10:{ backupsOptionViewController *vc = [backupsOptionViewController new]; [self pushViewController:vc animated:YES]; } break; case 11: { if(!ksharedAppDelegate.isWebSockLinkOKAginType){ [[iToast makeText:NSLocalizedString(@"check_could_phone_state",nil)] show]; return; } fileTransfeSetViewController *nextVC = [fileTransfeSetViewController new]; [self pushViewController:nextVC animated:YES]; } break; case 12:{ shareRecordViewController *vc = [shareRecordViewController new]; [self pushViewController:vc animated:YES]; } break; default: break; } } #pragma mark 点击最近文件模块 - (void)didClickLastFileFunBy:(NSInteger)tag { } #pragma mark 用户点击上传文件 - (void)userDidClickUploadViewFun { [self hideTabbarFun]; previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init]; [self.view addSubview:previewToUploadFileV]; [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(10); make.top.mas_equalTo(0); }]; KWeakSelf previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) { [weakSelf gotoUploadFileFunWith:tag]; }; previewToUploadFileV.didClickCloseFun = ^{ [weakSelf showTabbarFun]; }; } #pragma mark 调整文件上传 - (void)gotoUploadFileFunWith:(NSInteger)tag { uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new]; if(tag ==10){ vc.isPhotoType = YES; } else{ vc.isPhotoType = NO; } [self pushViewController:vc animated:YES]; } #pragma mark 获取到云机基本新 - (void)getExtraFilesDoneFun:(NSNotification*)not { [self setMySpaceDataFun]; } #pragma mark 设置我的空间信息 - (void)setMySpaceDataFun { if(ksharedAppDelegate.cloudPhoneExtraFileListMod){ [_NASMySpaceV setProgressFun]; } } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; } - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated { [self.navigationController pushViewController:vc animated:animated]; [self hideTabbarFun]; } - (void)showTabbarFun { // 显示 tab bar self.tabBarController.tabBar.hidden = NO; } - (void)hideTabbarFun { // 隐藏 tab bar self.tabBarController.tabBar.hidden = YES; } @end