NASViewController.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. //
  2. // NASViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/19.
  6. //
  7. #import "NASViewController.h"
  8. #import "NASMySpaceView.h"
  9. #import "NASCommonUsedView.h"
  10. #import "shareSecretTableViewCell.h"
  11. #import "NASLastFileView.h"
  12. #import "previewImageOrVideoViewController.h"
  13. #import "previewAudioOrDocumentViewController.h"
  14. #import "previewFileAndFolderViewController.h"
  15. #import "shareRecordViewController.h"
  16. #import "backupsOptionViewController.h"
  17. #import "fileTransfeSetViewController.h"
  18. #import "uploadFileRecordViewController.h"
  19. #import "previewToUploadFileView.h"
  20. #import "NASMySpaceViewController.h"
  21. #import "NasPreviewVideoViewController.h"
  22. @interface NASViewController ()<UITableViewDelegate,UITableViewDataSource>
  23. @property (nonatomic,strong)UITableView*tableView;
  24. @property (nonatomic, strong) UIView*tableHeadView;
  25. @property (nonatomic, strong) NASMySpaceView* NASMySpaceV;
  26. @property (nonatomic, strong) NASCommonUsedView* NASCommonUsedV;
  27. @property (nonatomic,strong)NASLastFileView*NASLastFileV;
  28. @end
  29. @implementation NASViewController
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. // Do any additional setup after loading the view.
  33. [self.view setBackgroundColor:HWF5F7FAColor];
  34. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getExtraFilesDoneFun:) name:getExtraFilesDoneNotification object:nil];
  35. [self.toolBar setHidden:YES];
  36. [self.navigationBar setHidden:YES];
  37. [self.navBarBGView setHidden:YES];
  38. [self drawAnyView];
  39. }
  40. - (void)drawAnyView{
  41. //顶底底部图片
  42. UIImageView *topImageV = [UIImageView new];
  43. topImageV.image = [UIImage imageNamed:@"Nas_top_img"];
  44. [self.view addSubview:topImageV];
  45. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.mas_equalTo(0);
  47. make.left.mas_equalTo(0);
  48. make.right.mas_equalTo(0);
  49. make.height.mas_equalTo(280.0*AUTOSCALE);
  50. }];
  51. NSString *welcomeImageStr = @"nas_welcome_cs";
  52. //欢迎
  53. //en-US 英文 ja-JP 日文
  54. NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
  55. NSLog(@"arLanguages:%@",arLanguages);
  56. ///获取设备当前地区的代码和APP语言环境
  57. NSString *languageCode = [NSLocale preferredLanguages][0];
  58. //目前支持 中文(简体 繁体) 英文 日语
  59. if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
  60. {
  61. welcomeImageStr = @"nas_welcome_cs";
  62. }
  63. else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
  64. {
  65. welcomeImageStr = @"nas_welcome_ct";
  66. }
  67. else{
  68. welcomeImageStr = @"nas_welcome_en";
  69. }
  70. CGFloat imageTopY = 54.0;
  71. UIImageView *welcomeImageV = [UIImageView new];
  72. welcomeImageV.image = [UIImage imageNamed:welcomeImageStr];
  73. [self.view addSubview:welcomeImageV];
  74. [welcomeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.top.mas_equalTo(imageTopY);
  76. make.left.mas_equalTo(16);
  77. make.width.mas_equalTo(210);
  78. make.height.mas_equalTo(24);
  79. }];
  80. //添加按钮
  81. UIButton *addButton = [[UIButton alloc] init];
  82. [addButton setBackgroundImage:[UIImage imageNamed:@"nas_add_icon"] forState:UIControlStateNormal];
  83. addButton.tag = 1;
  84. [addButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  85. [self.view addSubview:addButton];
  86. [addButton mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.top.mas_equalTo(imageTopY);
  88. make.right.mas_equalTo(-16);
  89. make.width.mas_equalTo(24);
  90. make.height.mas_equalTo(24);
  91. }];
  92. UIButton *rightTransferListButton = [[UIButton alloc] init];
  93. //[rightTransferListButton setImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  94. [rightTransferListButton setBackgroundImage:[UIImage imageNamed:@"icon_file_transfer"] forState:UIControlStateNormal];
  95. rightTransferListButton.tag = 2;
  96. [rightTransferListButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  97. [self.view addSubview:rightTransferListButton];
  98. [rightTransferListButton mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.top.mas_equalTo(imageTopY);
  100. make.right.equalTo(addButton.mas_left).offset(-24);
  101. make.width.mas_equalTo(24);
  102. make.height.mas_equalTo(24);
  103. }];
  104. [self.view addSubview:self.tableView];
  105. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.mas_equalTo(0);
  107. make.right.mas_equalTo(0);
  108. make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  109. make.bottom.mas_equalTo(-TABBARHEIGHT);
  110. }];
  111. _tableHeadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 165+ 15 +120 + 15)];
  112. //_tableHeadView.backgroundColor = [UIColor hwColor:@"#F6F8FA"];
  113. _tableHeadView.backgroundColor = [UIColor clearColor];
  114. self.tableView.tableHeaderView = _tableHeadView;
  115. //我的空间
  116. _NASMySpaceV = [[NASMySpaceView alloc] init];
  117. [_tableHeadView addSubview:_NASMySpaceV];
  118. [_NASMySpaceV mas_makeConstraints:^(MASConstraintMaker *make) {
  119. //make.top.equalTo(welcomeImageV.mas_bottom).offset(20);
  120. make.top.mas_equalTo(0);;
  121. make.left.mas_equalTo(0);
  122. make.right.mas_equalTo(0);
  123. make.height.mas_equalTo(165);
  124. }];
  125. //常用功能
  126. _NASCommonUsedV = [[NASCommonUsedView alloc] init];
  127. [_tableHeadView addSubview:_NASCommonUsedV];
  128. [_NASCommonUsedV mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.top.equalTo(_NASMySpaceV.mas_bottom).offset(15);
  130. make.left.mas_equalTo(0);
  131. make.right.mas_equalTo(0);
  132. make.height.mas_equalTo(120);
  133. }];
  134. KWeakSelf
  135. _NASMySpaceV.didClickButtonFun = ^(NSInteger tag) {
  136. [weakSelf didClickMySpaceFunBy:tag];
  137. };
  138. _NASCommonUsedV.didClickButtonFun = ^(NSInteger tag) {
  139. [weakSelf didClickCommonUsedFunBy:tag];
  140. };
  141. self.NASLastFileV.didClickButtonFun = ^(NSInteger tag) {
  142. [weakSelf didClickLastFileFunBy:tag];
  143. };
  144. [self setMySpaceDataFun];
  145. }
  146. #pragma mark - 懒加载
  147. - (UITableView *)tableView{
  148. if (!_tableView) {
  149. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
  150. _tableView.delegate = self;
  151. _tableView.dataSource = self;
  152. _tableView.showsVerticalScrollIndicator = NO;
  153. _tableView.showsHorizontalScrollIndicator = NO;
  154. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  155. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  156. [_tableView setSeparatorColor:[UIColor clearColor]];
  157. //[_tableView setBackgroundColor:[UIColor hwColor:@"#FFFFFF"]];
  158. [_tableView setBackgroundColor:[UIColor clearColor]];
  159. //[_tableView setTableFooterView:[UIView new]];
  160. [_tableView setBounces:YES];
  161. if (@available(iOS 15.0, *)) {
  162. _tableView.sectionHeaderTopPadding = 0;
  163. }
  164. _tableView.layer.cornerRadius = 8;
  165. _tableView.layer.masksToBounds = YES;
  166. }
  167. return _tableView;
  168. }
  169. - (NASLastFileView*)NASLastFileV
  170. {
  171. if(!_NASLastFileV){
  172. _NASLastFileV = [NASLastFileView new];
  173. }
  174. return _NASLastFileV;
  175. }
  176. #pragma mark - 列表委托
  177. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  178. return 1;
  179. }
  180. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  181. return 0;
  182. }
  183. - (shareSecretTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  184. __block NSInteger row = indexPath.row;
  185. static NSString *identifier = @"shareSecretTableViewCell";
  186. shareSecretTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  187. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  188. if (!cell){
  189. cell = [[shareSecretTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  190. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  191. [cell setBackgroundColor:[UIColor clearColor]];
  192. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  193. }
  194. // if(row < _didSelectListArr.count){
  195. // NASFilePicDataArrModel*dataModel = _didSelectListArr[row];
  196. // cell.dataModel = dataModel;
  197. // }
  198. return cell;
  199. }
  200. - (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  201. return self.NASLastFileV;
  202. }
  203. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  204. //return 54;//隐藏
  205. return 54 + 200;//无数据
  206. }
  207. - (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  208. {
  209. NSString *text = NSLocalizedString(@"NAS_bottom_tip",nil);
  210. UILabel *label = [[UILabel alloc] init];
  211. label.text = [[NSString alloc] initWithFormat:@"- %@ -",text];
  212. label.textColor = [UIColor hwColor:@"#959799"];
  213. label.font = [UIFont systemFontOfSize:12];
  214. label.textAlignment = NSTextAlignmentCenter;
  215. return label;
  216. }
  217. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  218. return 60.0;
  219. }
  220. #pragma mark 点击头部
  221. - (void)didClickHeadButtonFun:(UIButton*)but
  222. {
  223. NSInteger tag = but.tag;
  224. switch (tag) {
  225. case 1:
  226. {
  227. [self userDidClickUploadViewFun];
  228. }
  229. break;
  230. case 2:
  231. {
  232. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  233. [self pushViewController:vc animated:YES];
  234. }
  235. break;
  236. default:
  237. break;
  238. }
  239. }
  240. #pragma mark 点击我的空间模块
  241. - (void)didClickMySpaceFunBy:(NSInteger)tag
  242. {
  243. switch (tag)
  244. {
  245. case 1:
  246. {
  247. NASMySpaceViewController *vc = [NASMySpaceViewController new];
  248. [self pushViewController:vc animated:YES];
  249. }
  250. break;
  251. case 10:{
  252. previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
  253. vc.isPhotoType = YES;
  254. [self pushViewController:vc animated:YES];
  255. }
  256. break;
  257. case 11:{
  258. // previewImageOrVideoViewController *vc = [previewImageOrVideoViewController new];
  259. // vc.isPhotoType = NO;
  260. // [self pushViewController:vc animated:YES];
  261. NasPreviewVideoViewController *vc = [NasPreviewVideoViewController new];
  262. [self pushViewController:vc animated:YES];
  263. }
  264. break;
  265. case 12:{
  266. previewAudioOrDocumentViewController *vc = [previewAudioOrDocumentViewController new];
  267. vc.isAudioType = YES;
  268. [self pushViewController:vc animated:YES];
  269. }
  270. break;
  271. case 13:{
  272. previewFileAndFolderViewController *vc = [previewFileAndFolderViewController new];
  273. [self pushViewController:vc animated:YES];
  274. }
  275. break;
  276. default:
  277. break;
  278. }
  279. }
  280. #pragma mark 点击常用模块模块
  281. - (void)didClickCommonUsedFunBy:(NSInteger)tag
  282. {
  283. switch (tag)
  284. {
  285. case 10:{
  286. backupsOptionViewController *vc = [backupsOptionViewController new];
  287. [self pushViewController:vc animated:YES];
  288. }
  289. break;
  290. case 11:
  291. {
  292. if(!ksharedAppDelegate.isWebSockLinkOKAginType){
  293. [[iToast makeText:NSLocalizedString(@"check_could_phone_state",nil)] show];
  294. return;
  295. }
  296. fileTransfeSetViewController *nextVC = [fileTransfeSetViewController new];
  297. [self pushViewController:nextVC animated:YES];
  298. }
  299. break;
  300. case 12:{
  301. shareRecordViewController *vc = [shareRecordViewController new];
  302. [self pushViewController:vc animated:YES];
  303. }
  304. break;
  305. default:
  306. break;
  307. }
  308. }
  309. #pragma mark 点击最近文件模块
  310. - (void)didClickLastFileFunBy:(NSInteger)tag
  311. {
  312. }
  313. #pragma mark 用户点击上传文件
  314. - (void)userDidClickUploadViewFun
  315. {
  316. [self hideTabbarFun];
  317. previewToUploadFileView *previewToUploadFileV = [[previewToUploadFileView alloc] init];
  318. [self.view addSubview:previewToUploadFileV];
  319. [previewToUploadFileV mas_makeConstraints:^(MASConstraintMaker *make) {
  320. make.left.mas_equalTo(0);
  321. make.right.mas_equalTo(0);
  322. make.bottom.mas_equalTo(10);
  323. make.top.mas_equalTo(0);
  324. }];
  325. KWeakSelf
  326. previewToUploadFileV.didClickButtonFun = ^(NSInteger tag) {
  327. [weakSelf gotoUploadFileFunWith:tag];
  328. };
  329. previewToUploadFileV.didClickCloseFun = ^{
  330. [weakSelf showTabbarFun];
  331. };
  332. }
  333. #pragma mark 调整文件上传
  334. - (void)gotoUploadFileFunWith:(NSInteger)tag
  335. {
  336. uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
  337. if(tag ==10){
  338. vc.isPhotoType = YES;
  339. }
  340. else{
  341. vc.isPhotoType = NO;
  342. }
  343. [self pushViewController:vc animated:YES];
  344. }
  345. #pragma mark 获取到云机基本新
  346. - (void)getExtraFilesDoneFun:(NSNotification*)not
  347. {
  348. [self setMySpaceDataFun];
  349. }
  350. #pragma mark 设置我的空间信息
  351. - (void)setMySpaceDataFun
  352. {
  353. if(ksharedAppDelegate.cloudPhoneExtraFileListMod){
  354. [_NASMySpaceV setProgressFun];
  355. }
  356. }
  357. - (void)viewWillAppear:(BOOL)animated{
  358. [super viewWillAppear:animated];
  359. }
  360. - (void)viewWillDisappear:(BOOL)animated{
  361. [super viewWillDisappear:animated];
  362. }
  363. - (void)pushViewController:(UIViewController*)vc animated:(BOOL)animated
  364. {
  365. [self.navigationController pushViewController:vc animated:animated];
  366. [self hideTabbarFun];
  367. }
  368. - (void)showTabbarFun
  369. {
  370. // 显示 tab bar
  371. self.tabBarController.tabBar.hidden = NO;
  372. }
  373. - (void)hideTabbarFun
  374. {
  375. // 隐藏 tab bar
  376. self.tabBarController.tabBar.hidden = YES;
  377. }
  378. @end