动态消息列表
This commit is contained in:
@@ -11,28 +11,26 @@
|
||||
#import <MJRefresh/MJRefresh.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "TTPopup.h"
|
||||
#import "XPMacro.h"
|
||||
#import "XPMonentsLayoutConfig.h"
|
||||
///Model
|
||||
#import "MonentsListInfoModel.h"
|
||||
#import "MonentsInteractiveModel.h"
|
||||
///P
|
||||
#import "XPMonentsInteractivePresenter.h"
|
||||
#import "XPMonentsInteractiveProtocol.h"
|
||||
///View
|
||||
#import "XPMonentsTableViewCell.h"
|
||||
#import "XPMonentsInteractiveTableViewCell.h"
|
||||
#import "XPMonentsEmptyTableViewCell.h"
|
||||
|
||||
@interface XPMonentsInteractiveViewController ()<UITableViewDelegate, UITableViewDataSource,XPMonentsInteractiveProtocol>
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
///数据源
|
||||
@property (nonatomic,strong) NSMutableArray<MonentsInfoModel *> *datasource;
|
||||
@property (nonatomic,strong) NSMutableArray<MonentsInteractiveModel *> *datasource;
|
||||
///当前的页数
|
||||
@property (nonatomic,assign) NSInteger page;
|
||||
///是否有更多的数据
|
||||
@property (nonatomic,assign) BOOL hasNoMoreData;
|
||||
///数据信息
|
||||
@property (nonatomic,strong) MonentsListInfoModel *listInfo;
|
||||
@end
|
||||
|
||||
@implementation XPMonentsInteractiveViewController
|
||||
@@ -50,7 +48,9 @@
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.title = @"全部消息";
|
||||
[self.view addSubview:self.tableView];
|
||||
[self addNavigationItemWithImageNames:@[@"monents_interactive_delete_message"] isLeft:NO target:self action:@selector(rightButtonAction:) tags:nil];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
@@ -79,7 +79,7 @@
|
||||
#pragma mark - 刷新的fangfa
|
||||
- (void)headerRefresh {
|
||||
self.page = 1;
|
||||
[self.presenter getMonentsInteractiveList:@"0" pageSize:20 state:0];
|
||||
[self.presenter getMonentsInteractiveList:@"" pageSize:20 state:0];
|
||||
}
|
||||
|
||||
- (void)footerRefresh {
|
||||
@@ -89,7 +89,12 @@
|
||||
return;
|
||||
}
|
||||
self.page++;
|
||||
[self.presenter getMonentsInteractiveList:@"0" pageSize:20 state:1];
|
||||
NSString * dynamicId = @"";
|
||||
if (self.datasource.count > 0) {
|
||||
MonentsInteractiveModel * model = [self.datasource lastObject];
|
||||
dynamicId = model.dynamicId;
|
||||
}
|
||||
[self.presenter getMonentsInteractiveList:dynamicId pageSize:20 state:1];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||
@@ -99,18 +104,17 @@
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.datasource.count > 0) {
|
||||
MonentsInfoModel * monentInfo= [self.datasource objectAtIndex:indexPath.row];
|
||||
[XPMonentsLayoutConfig layoutMonentsModel:monentInfo];
|
||||
return monentInfo.rowHeight;
|
||||
MonentsInteractiveModel * model = [self.datasource objectAtIndex:indexPath.row];
|
||||
return model.worldName.length > 0? 130 : 90;
|
||||
}
|
||||
return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight;
|
||||
return KScreenHeight - kNavigationHeight;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.datasource.count > 0) {
|
||||
XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])];
|
||||
MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row];
|
||||
cell.monentsInfo = monentsInfo;
|
||||
XPMonentsInteractiveTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsInteractiveTableViewCell class])];
|
||||
MonentsInteractiveModel * model = [self.datasource objectAtIndex:indexPath.row];
|
||||
cell.interactiveInfo = model;
|
||||
return cell;
|
||||
}
|
||||
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
@@ -152,6 +156,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clearInteractiveMessageSuccess {
|
||||
[self.datasource removeAllObjects];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
#pragma mark - Event Response
|
||||
- (void)rightButtonAction:(UIButton *)sender {
|
||||
[TTPopup alertWithMessage:@"清空后所有互动通知将被删除,确定清空吗?" confirmHandler:^{
|
||||
[[self presenter] clearInteractiveMessage];
|
||||
} cancelHandler:^{
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UITableView *)tableView {
|
||||
if (!_tableView) {
|
||||
@@ -164,14 +181,14 @@
|
||||
if (@available(iOS 11.0, *)) {
|
||||
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])];
|
||||
[_tableView registerClass:[XPMonentsInteractiveTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsInteractiveTableViewCell class])];
|
||||
[_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
|
||||
|
||||
- (NSMutableArray<MonentsInfoModel *> *)datasource {
|
||||
- (NSMutableArray<MonentsInteractiveModel *> *)datasource {
|
||||
if (!_datasource) {
|
||||
_datasource = [NSMutableArray array];
|
||||
}
|
||||
|
Reference in New Issue
Block a user