NASMySpaceViewController.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // NASMySpaceViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/21.
  6. //
  7. #import "NASMySpaceViewController.h"
  8. #import "NASMySpaceTableViewCell.h"
  9. @interface NASMySpaceViewController ()<UITableViewDelegate,UITableViewDataSource>
  10. @property (nonatomic, strong) UITableView *tableView;
  11. @property (nonatomic, strong) NSArray *allDataArr;
  12. @end
  13. @implementation NASMySpaceViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. // Do any additional setup after loading the view.
  17. [self.toolBar setHidden:YES];
  18. [self.navigationBar setHidden:YES];
  19. [self.navBarBGView setHidden:NO];
  20. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  21. [self.view setBackgroundColor:[UIColor hwColor:@"#F6F8FA"]];
  22. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getExtraFilesDoneFun:) name:getExtraFilesDoneNotification object:nil];
  23. self.titleLabel.text = NSLocalizedString(@"NAS_mySpace_title",nil);
  24. [self drawAnyView];
  25. }
  26. - (void)drawAnyView{
  27. [self.view addSubview:self.tableView];
  28. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.left.mas_equalTo(0);
  30. make.right.mas_equalTo(0);
  31. //make.bottom.mas_equalTo(-(safeArea));
  32. make.bottom.mas_equalTo(0);
  33. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  34. }];
  35. }
  36. #pragma mark - 懒加载
  37. - (UITableView *)tableView{
  38. if (!_tableView) {
  39. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
  40. _tableView.delegate = self;
  41. _tableView.dataSource = self;
  42. _tableView.showsVerticalScrollIndicator = NO;
  43. _tableView.showsHorizontalScrollIndicator = NO;
  44. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  45. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  46. [_tableView setSeparatorColor:[UIColor clearColor]];
  47. [_tableView setBackgroundColor:[UIColor clearColor]];
  48. [_tableView setTableFooterView:[UIView new]];
  49. [_tableView setBounces:YES];
  50. if (@available(iOS 15.0, *)) {
  51. _tableView.sectionHeaderTopPadding = 0;
  52. }
  53. }
  54. return _tableView;
  55. }
  56. #pragma mark - 列表委托
  57. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  58. return 1;
  59. }
  60. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  61. return _allDataArr.count;
  62. }
  63. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  64. __block NSInteger row = indexPath.row;
  65. static NSString *identifier = @"NASMySpaceTableViewCell";
  66. NASMySpaceTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  67. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  68. if (!cell){
  69. cell = [[NASMySpaceTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  70. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  71. [cell setBackgroundColor:[UIColor clearColor]];
  72. }
  73. if(row < _allDataArr.count){
  74. cell.extraFileModel = _allDataArr[row];
  75. }
  76. return cell;
  77. }
  78. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  79. return 112 + 15;
  80. }
  81. #pragma mark 获取到云机基本新
  82. - (void)getExtraFilesDoneFun:(NSNotification*)not
  83. {
  84. _allDataArr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  85. [_tableView reloadData];
  86. }
  87. - (void)viewWillAppear:(BOOL)animated
  88. {
  89. [super viewWillAppear:animated];
  90. if(!ksharedAppDelegate.cloudPhoneExtraFileListMod.data){
  91. _allDataArr = @[];
  92. [[webSocketManager shareInstance] getExtraFilesListFun];
  93. }
  94. else{
  95. _allDataArr = ksharedAppDelegate.cloudPhoneExtraFileListMod.data;
  96. [_tableView reloadData];
  97. }
  98. }
  99. @end