// // ASMessageListViewController.m // Asteria // // Created by iOS on 2023/7/4. // #import "ASMessageListViewController.h" #import "ASMessageListCell.h" @interface ASMessageListViewController () @property (nonatomic, strong) UITableView *tableV; @property (nonatomic, strong) NSMutableArray *msgDataArray; @end @implementation ASMessageListViewController - (void)viewDidLoad { [super viewDidLoad]; [self loadSubVs]; // self.vm = [KWMessageListViewModel new]; self.titleStr = @"Message"; self.msgDataArray = [[NSMutableArray alloc] initWithCapacity:1]; [self setNav]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.tableV.mj_header beginRefreshing]; } - (void)getData { [self.tableV.mj_header endRefreshing]; // [self.msgDataArray addObjectsFromArray:@[@"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1"]]; if (AS_Array_valid(self.msgDataArray)) { [self hiddenEmpty]; } else { [self showEmptyV:self.tableV]; } [self.tableV reloadData]; // [MBProgressHUD showHUDAddedTo:self.view animated:true]; // @weakify(self); // [self.vm getMessageList:self.tableV page:1 complate:^{ // @strongify(self); // [MBProgressHUD hideHUDForView:self.view animated:true]; // if (self.vm.messageList.count == 0) { // [self showNoDataV:self.tableV mes:@"No News Yet"]; // } else { // [self hideNoDataV]; // } // [self.tableV reloadData]; // }]; } - (void)setNav { self.customNavBar.backgroundColor = UIColor.whiteColor; self.statusBgV.backgroundColor = UIColor.whiteColor; [self setNavRightSearch:^{ }]; return; UIButton *readAllBt = [UIButton buttonWithType:UIButtonTypeCustom]; [readAllBt setImage:[UIImage imageNamed:@"nav_message_read"] forState:UIControlStateNormal]; UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; v.backgroundColor = UIColor.clearColor; readAllBt.frame = v.bounds; [readAllBt addTarget:self action:@selector(rightBtAction) forControlEvents:UIControlEventTouchUpInside]; [v addSubview:readAllBt]; [self.customNavBar addSubview:v]; [v mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.customNavBar); make.right.equalTo(self.customNavBar).offset(-15); make.width.height.equalTo(@40); }]; // UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:v]; // self.navigationItem.rightBarButtonItem = rightItem; } - (void)rightBtAction { [MBProgressHUD showHUDAddedTo:self.view animated:true]; // @weakify(self); // [self.vm getMessageRead:self.tableV messageId:@"" type:@"2" complate:^{ // [MBProgressHUD hideHUDForView:weak_self.view animated:true]; // [self.tableV.mj_header beginRefreshing]; // }]; } - (void)loadSubVs { [self.view addSubview:self.tableV]; [self.tableV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.equalTo(self.customNavBar.mas_bottom); make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom); }]; } - (UITableView *)tableV { if (!_tableV) { UITableView *tabV = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; tabV.backgroundColor = [UIColor colorWithHexString:@"#ffffff"]; [tabV registerClass:[ASMessageListCell class] forCellReuseIdentifier:@"ASMessageListCell"]; tabV.delegate = self; tabV.dataSource = self; tabV.rowHeight = UITableViewAutomaticDimension; tabV.estimatedRowHeight = 100; tabV.separatorStyle = UITableViewCellSeparatorStyleNone; @weakify(self); tabV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ [weak_self getData]; }]; _tableV = tabV; } return _tableV; } -(void)pushToProductList:(NSString *)name typeid:(NSString *)typeId { if (typeId == nil || [typeId isEqualToString:@""]) { return; } if (name == nil || [name isEqualToString:@""]) { name = @"Products"; } // KWProductListViewController *vc = [[KWProductListViewController alloc] init]; // vc.titleName = name; // vc.type = typeId; // [self.navigationController pushViewController:vc animated:YES]; } -(void)goto_WKM_GoodsDetailsC:(NSString *)entity_id { // WKM_GoodsDetailsC *vc = [[WKM_GoodsDetailsC alloc]init]; // vc.entity_id = entity_id; // [self.navigationController pushViewController:vc animated:YES]; } #pragma mark - UITableViewDelegate,UITableViewDataSource - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // KWMessageListModel *m = self.vm.messageList[indexPath.row]; // // [[KWPushMessageHandler shareInstance] handleMessage:m.title messageId:m.message_id pushPara:m.push_para pushType:m.push_type]; UIViewController *vc = [CTMediator.sharedInstance getWebViewVc:@{ @"title":@"Message", @"url":@"https://baidu.com" }]; [self.navigationController pushViewController:vc animated:true]; return; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.msgDataArray.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ASMessageListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASMessageListCell" forIndexPath:indexPath]; // KWMessageListModel *m = self.vm.messageList[indexPath.row]; // [cell setData:m]; return cell; } @end