动态消息列表

This commit is contained in:
fengshuo
2022-05-20 20:50:35 +08:00
parent 465e73b6f1
commit fe8747ce5e
21 changed files with 638 additions and 18 deletions

View File

@@ -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];
}