NASViewController.m 13 KB

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