130 lines
4.0 KiB
Objective-C
130 lines
4.0 KiB
Objective-C
//
|
|
// XPHomeHotRoomViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/2/25.
|
|
//
|
|
|
|
#import "XPHomeHotRoomViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///View
|
|
#import "XPHomeHapppyRoomTableViewCell.h"
|
|
#import "XPHomeListEmptyTableViewCell.h"
|
|
///VC
|
|
#import "XPWebViewController.h"
|
|
#import "XPRoomViewController.h"
|
|
///Model
|
|
#import "HomePlayRoomModel.h"
|
|
|
|
@interface XPHomeHotRoomViewController ()<UITableViewDelegate, UITableViewDataSource>
|
|
///列表
|
|
@property (nonatomic,strong) UITableView *tableView;
|
|
@property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView);
|
|
@end
|
|
|
|
@implementation XPHomeHotRoomViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
|
|
- (BOOL)isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.view.backgroundColor = [UIColor clearColor];
|
|
[self.view addSubview:self.tableView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self.view);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
return self.roomList.count > 0 ? self.roomList.count : 1;
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
if (self.roomList.count > 0) {
|
|
return 94;
|
|
}
|
|
return 300;
|
|
}
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
if (self.roomList.count > 0) {
|
|
HomePlayRoomModel * model = [self.roomList objectAtIndex:indexPath.row];
|
|
XPHomeHapppyRoomTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPHomeHapppyRoomTableViewCell class])];
|
|
if (cell == nil) {
|
|
cell = [[XPHomeHapppyRoomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPHomeHapppyRoomTableViewCell class])];
|
|
}
|
|
cell.roomInfo = model;
|
|
return cell;
|
|
}
|
|
|
|
XPHomeListEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPHomeListEmptyTableViewCell class])];
|
|
if (cell == nil) {
|
|
cell = [[XPHomeListEmptyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPHomeListEmptyTableViewCell class])];
|
|
}
|
|
return cell;
|
|
}
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
if (self.roomList.count > 0) {
|
|
HomePlayRoomModel * model = [self.roomList objectAtIndex:indexPath.row];
|
|
if (!model.isBanner && model.uid.integerValue > 0) {
|
|
[XPRoomViewController openRoom:model.uid viewController:self];
|
|
}
|
|
}
|
|
}
|
|
#pragma mark - JXPagingViewListViewDelegate
|
|
- (UIView *)listView {
|
|
return self.view;
|
|
}
|
|
|
|
- (UIScrollView *)listScrollView {
|
|
return self.tableView;
|
|
}
|
|
|
|
- (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
|
|
self.scrollCallback = callback;
|
|
}
|
|
|
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
|
self.scrollCallback(scrollView);
|
|
}
|
|
#pragma mark - Getters And Setters
|
|
- (void)setRoomList:(NSArray *)roomList {
|
|
_roomList = roomList;
|
|
[self.tableView reloadData];
|
|
}
|
|
|
|
- (UITableView *)tableView {
|
|
if (!_tableView) {
|
|
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
|
_tableView.delegate = self;
|
|
_tableView.dataSource = self;
|
|
_tableView.tableFooterView = [UIView new];
|
|
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
_tableView.backgroundColor = [UIColor clearColor];
|
|
if (@available(iOS 11.0, *)) {
|
|
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
}
|
|
[_tableView registerClass:[XPHomeHapppyRoomTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPHomeHapppyRoomTableViewCell class])];
|
|
[_tableView registerClass:[XPHomeListEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPHomeListEmptyTableViewCell class])];
|
|
}
|
|
return _tableView;
|
|
}
|
|
|
|
|
|
@end
|