ASMessageListViewController.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. //
  2. // ASMessageListViewController.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/7/4.
  6. //
  7. #import "ASMessageListViewController.h"
  8. #import "ASMessageListCell.h"
  9. @interface ASMessageListViewController () <UITableViewDelegate,UITableViewDataSource>
  10. @property (nonatomic, strong) UITableView *tableV;
  11. @property (nonatomic, strong) NSMutableArray *msgDataArray;
  12. @end
  13. @implementation ASMessageListViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. [self loadSubVs];
  17. // self.vm = [KWMessageListViewModel new];
  18. self.titleStr = @"Message";
  19. self.msgDataArray = [[NSMutableArray alloc] initWithCapacity:1];
  20. [self setNav];
  21. }
  22. - (void)viewWillAppear:(BOOL)animated {
  23. [super viewWillAppear:animated];
  24. [self.tableV.mj_header beginRefreshing];
  25. }
  26. - (void)getData {
  27. [self.tableV.mj_header endRefreshing];
  28. // [self.msgDataArray addObjectsFromArray:@[@"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1"]];
  29. if (AS_Array_valid(self.msgDataArray)) {
  30. [self hiddenEmpty];
  31. } else {
  32. [self showEmptyV:self.tableV];
  33. }
  34. [self.tableV reloadData];
  35. // [MBProgressHUD showHUDAddedTo:self.view animated:true];
  36. // @weakify(self);
  37. // [self.vm getMessageList:self.tableV page:1 complate:^{
  38. // @strongify(self);
  39. // [MBProgressHUD hideHUDForView:self.view animated:true];
  40. // if (self.vm.messageList.count == 0) {
  41. // [self showNoDataV:self.tableV mes:@"No News Yet"];
  42. // } else {
  43. // [self hideNoDataV];
  44. // }
  45. // [self.tableV reloadData];
  46. // }];
  47. }
  48. - (void)setNav {
  49. self.customNavBar.backgroundColor = UIColor.whiteColor;
  50. self.statusBgV.backgroundColor = UIColor.whiteColor;
  51. [self setNavRightSearch:^{
  52. }];
  53. return;
  54. UIButton *readAllBt = [UIButton buttonWithType:UIButtonTypeCustom];
  55. [readAllBt setImage:[UIImage imageNamed:@"nav_message_read"] forState:UIControlStateNormal];
  56. UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  57. v.backgroundColor = UIColor.clearColor;
  58. readAllBt.frame = v.bounds;
  59. [readAllBt addTarget:self action:@selector(rightBtAction) forControlEvents:UIControlEventTouchUpInside];
  60. [v addSubview:readAllBt];
  61. [self.customNavBar addSubview:v];
  62. [v mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.centerY.equalTo(self.customNavBar);
  64. make.right.equalTo(self.customNavBar).offset(-15);
  65. make.width.height.equalTo(@40);
  66. }];
  67. // UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:v];
  68. // self.navigationItem.rightBarButtonItem = rightItem;
  69. }
  70. - (void)rightBtAction {
  71. [MBProgressHUD showHUDAddedTo:self.view animated:true];
  72. // @weakify(self);
  73. // [self.vm getMessageRead:self.tableV messageId:@"" type:@"2" complate:^{
  74. // [MBProgressHUD hideHUDForView:weak_self.view animated:true];
  75. // [self.tableV.mj_header beginRefreshing];
  76. // }];
  77. }
  78. - (void)loadSubVs {
  79. [self.view addSubview:self.tableV];
  80. [self.tableV mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.right.equalTo(self.view);
  82. make.top.equalTo(self.customNavBar.mas_bottom);
  83. make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
  84. }];
  85. }
  86. - (UITableView *)tableV {
  87. if (!_tableV) {
  88. UITableView *tabV = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  89. tabV.backgroundColor = [UIColor colorWithHexString:@"#ffffff"];
  90. [tabV registerClass:[ASMessageListCell class] forCellReuseIdentifier:@"ASMessageListCell"];
  91. tabV.delegate = self;
  92. tabV.dataSource = self;
  93. tabV.rowHeight = UITableViewAutomaticDimension;
  94. tabV.estimatedRowHeight = 100;
  95. tabV.separatorStyle = UITableViewCellSeparatorStyleNone;
  96. @weakify(self);
  97. tabV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  98. [weak_self getData];
  99. }];
  100. _tableV = tabV;
  101. }
  102. return _tableV;
  103. }
  104. -(void)pushToProductList:(NSString *)name typeid:(NSString *)typeId {
  105. if (typeId == nil || [typeId isEqualToString:@""]) {
  106. return;
  107. }
  108. if (name == nil || [name isEqualToString:@""]) {
  109. name = @"Products";
  110. }
  111. // KWProductListViewController *vc = [[KWProductListViewController alloc] init];
  112. // vc.titleName = name;
  113. // vc.type = typeId;
  114. // [self.navigationController pushViewController:vc animated:YES];
  115. }
  116. -(void)goto_WKM_GoodsDetailsC:(NSString *)entity_id {
  117. // WKM_GoodsDetailsC *vc = [[WKM_GoodsDetailsC alloc]init];
  118. // vc.entity_id = entity_id;
  119. // [self.navigationController pushViewController:vc animated:YES];
  120. }
  121. #pragma mark - UITableViewDelegate,UITableViewDataSource
  122. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  123. // KWMessageListModel *m = self.vm.messageList[indexPath.row];
  124. //
  125. // [[KWPushMessageHandler shareInstance] handleMessage:m.title messageId:m.message_id pushPara:m.push_para pushType:m.push_type];
  126. UIViewController *vc = [CTMediator.sharedInstance getWebViewVc:@{
  127. @"title":@"Message",
  128. @"url":@"https://baidu.com"
  129. }];
  130. [self.navigationController pushViewController:vc animated:true];
  131. return;
  132. }
  133. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  134. return self.msgDataArray.count;
  135. }
  136. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  137. ASMessageListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASMessageListCell" forIndexPath:indexPath];
  138. // KWMessageListModel *m = self.vm.messageList[indexPath.row];
  139. // [cell setData:m];
  140. return cell;
  141. }
  142. @end