CNMessageNotesController.m 2.99 KB
//
//  CNMessageNotesController.m
//  CNLiveCMineModule
//
//  Created by iOS on 2022/12/7.
//

#import "CNMessageNotesController.h"
#import "CNMessgeNoteCell.h"
#import "CNCSubMinePresent.h"

static NSString const*kCNMessgeNoteCellID = @"CNMessgeNoteCellID";
@interface CNMessageNotesController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong)CNLiveNavigationBar *navigationBar;
@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSArray *dataSource;
@end

@implementation CNMessageNotesController
- (void)dealloc{
    NSLog(@"%s",__func__);
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColorWhite;
    self.dataSource = [CNCSubMinePresent getMessageNotificationList];
    [self.view addSubview:self.navigationBar];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.top.equalTo(self.navigationBar.mas_bottom);
    }];
}
- (BOOL)preferredNavigationBarHidden{
    return YES;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    return 59;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 50;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(18, 10, kScreenWidth - 36, 40)];
    label.font = UIFontMake(14);
    label.textColor = UIColorHex(#999999);
    label.numberOfLines = 2;
    label.text = @"关闭后你将不会在下拉通知看到该类型的消息,但在网家家内会显示红点。";
    return label;
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSource.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CNMessgeNoteCell *cell = [tableView dequeueReusableCellWithIdentifier:kCNMessgeNoteCellID];
    return cell;
}
#pragma mark - Getting
- (CNLiveNavigationBar *)navigationBar{
    if (!_navigationBar) {
        _navigationBar = [CNLiveNavigationBar navigationBar];
        _navigationBar.title.text = @"消息通知";
        weakself
        _navigationBar.onClickLeftButton = ^{
            [weakSelf.navigationController popViewControllerAnimated:YES];
        };
    }
    return _navigationBar;
}
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.backgroundColor = UIColorHex(#F2F2F2);
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        [_tableView registerClass:[CNMessgeNoteCell class] forCellReuseIdentifier:kCNMessgeNoteCellID];
    }
    return _tableView;
}
@end