ASMessageListViewController.m 5.4 KB

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