
通过 [ClientConfig shareConfig].canOpen 控制页面,现在已没有相关配置,删除/调整相关内容,[ClientConfig shareConfig].canOpen == YES 的部分将保留等价逻辑/代码
215 lines
7.0 KiB
Objective-C
215 lines
7.0 KiB
Objective-C
//
|
|
// YMMonentsInteractiveViewController.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/5/18.
|
|
//
|
|
|
|
#import "XPMonentsInteractiveViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <MJRefresh/MJRefresh.h>
|
|
///Tool
|
|
#import "DJDKMIMOMColor.h"
|
|
#import "TTPopup.h"
|
|
#import "YUMIMacroUitls.h"
|
|
#import "NSArray+Safe.h"
|
|
#import "ClientConfig.h"
|
|
///Model
|
|
#import "MonentsInteractiveModel.h"
|
|
///P
|
|
#import "XPMonentsInteractivePresenter.h"
|
|
#import "XPMonentsInteractiveProtocol.h"
|
|
///View
|
|
#import "XPMonentsInteractiveTableViewCell.h"
|
|
#import "XPMonentsEmptyTableViewCell.h"
|
|
#import "XPMonentsDetailViewController.h"
|
|
#import "XPMomentsSimpleDetailViewController.h"
|
|
|
|
@interface XPMonentsInteractiveViewController ()<UITableViewDelegate, UITableViewDataSource,XPMonentsInteractiveProtocol>
|
|
///列表
|
|
@property (nonatomic,strong) UITableView *tableView;
|
|
///数据源
|
|
@property (nonatomic,strong) NSMutableArray<MonentsInteractiveModel *> *datasource;
|
|
///当前的页数
|
|
@property (nonatomic,assign) NSInteger page;
|
|
///是否有更多的数据
|
|
@property (nonatomic,assign) BOOL hasNoMoreData;
|
|
@end
|
|
|
|
@implementation XPMonentsInteractiveViewController
|
|
|
|
- (__kindof id)createPresenter {
|
|
return [[XPMonentsInteractivePresenter alloc] init];
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initHeaderAndFooterRrfresh];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.title = YMLocalizedString(@"XPMonentsInteractiveViewController0");
|
|
[self.view addSubview:self.tableView];
|
|
[self addNavigationItemWithImageNames:@[@"monents_interactive_delete_message"] isLeft:NO target:self action:@selector(rightButtonAction:) tags:nil];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self.view);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - 下拉刷新
|
|
- (void)initHeaderAndFooterRrfresh {
|
|
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
|
|
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
|
|
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0];
|
|
header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
|
header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
|
self.tableView.mj_header = header;
|
|
|
|
MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
|
|
footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
|
footer.stateLabel.font = [UIFont systemFontOfSize:10.0];
|
|
self.tableView.mj_footer = footer;
|
|
|
|
[self headerRefresh];
|
|
}
|
|
|
|
#pragma mark - 刷新的fangfa
|
|
- (void)headerRefresh {
|
|
self.page = 1;
|
|
[self.presenter getMonentsInteractiveList:@"" pageSize:20 state:0];
|
|
}
|
|
|
|
- (void)footerRefresh {
|
|
if (self.hasNoMoreData) {
|
|
[self showErrorToast:YMLocalizedString(@"XPMonentsInteractiveViewController1")];
|
|
[self.tableView.mj_footer endRefreshing];
|
|
return;
|
|
}
|
|
self.page++;
|
|
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
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
return self.datasource.count > 0 ? self.datasource.count : 1;
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
if (self.datasource.count > 0) {
|
|
MonentsInteractiveModel * model = [self.datasource safeObjectAtIndex1:indexPath.row];
|
|
return model.worldName.length > 0? 130 : 90;
|
|
}
|
|
return KScreenHeight - kNavigationHeight;
|
|
}
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
if (self.datasource.count > 0) {
|
|
XPMonentsInteractiveTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsInteractiveTableViewCell class])];
|
|
MonentsInteractiveModel * model = [self.datasource safeObjectAtIndex1:indexPath.row];
|
|
cell.interactiveInfo = model;
|
|
return cell;
|
|
}
|
|
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
|
return cell;
|
|
}
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
if (self.datasource.count > 0) {
|
|
MonentsInteractiveModel * model = [self.datasource safeObjectAtIndex1:indexPath.row];
|
|
MonentsInfoModel * monents = [[MonentsInfoModel alloc] init];
|
|
monents.dynamicId = model.dynamicId;
|
|
|
|
XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init];
|
|
detailVC.monentsInfo = monents;
|
|
[self.navigationController pushViewController:detailVC animated:YES];
|
|
}
|
|
}
|
|
#pragma mark -JXCategoryListContainerViewDelegate
|
|
- (UIView *)listView {
|
|
return self.view;
|
|
}
|
|
|
|
#pragma mark - XPMonentsLatestProtocol
|
|
- (void)getMonentsInteractiveListSueccess:(NSArray *)array state:(int)state{
|
|
if (state == 0) {
|
|
[self.datasource removeAllObjects];
|
|
}
|
|
if (array.count > 0) {
|
|
[self.datasource addObjectsFromArray:array];
|
|
}
|
|
|
|
if (state == 0) {
|
|
self.hasNoMoreData = NO;
|
|
[self.tableView.mj_header endRefreshing];
|
|
} else {
|
|
if (array.count > 0) {
|
|
self.hasNoMoreData = NO;
|
|
} else {
|
|
self.hasNoMoreData = YES;
|
|
}
|
|
[self.tableView.mj_footer endRefreshing];
|
|
}
|
|
[self.tableView reloadData];
|
|
}
|
|
|
|
- (void)getMonentsInteractiveListFail:(NSString *)msg state:(int)state {
|
|
if (state == 0) {
|
|
[self.tableView.mj_header endRefreshing];
|
|
} else {
|
|
[self.tableView.mj_footer endRefreshing];
|
|
}
|
|
}
|
|
|
|
- (void)clearInteractiveMessageSuccess {
|
|
[self.datasource removeAllObjects];
|
|
[self.tableView reloadData];
|
|
}
|
|
|
|
#pragma mark - Event Response
|
|
- (void)rightButtonAction:(UIButton *)sender {
|
|
[TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsInteractiveViewController2") confirmHandler:^{
|
|
[[self presenter] clearInteractiveMessage];
|
|
} cancelHandler:^{
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (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:[XPMonentsInteractiveTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsInteractiveTableViewCell class])];
|
|
[_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
|
}
|
|
return _tableView;
|
|
}
|
|
|
|
|
|
- (NSMutableArray<MonentsInteractiveModel *> *)datasource {
|
|
if (!_datasource) {
|
|
_datasource = [NSMutableArray array];
|
|
}
|
|
return _datasource;
|
|
}
|
|
@end
|