228 lines
7.2 KiB
Objective-C
228 lines
7.2 KiB
Objective-C
//
|
|
// XPNewMomentsViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by XY on 2023/3/6.
|
|
//
|
|
|
|
#import "XPNewMomentsViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <JXCategoryView.h>
|
|
#import <JXPagerView.h>
|
|
#import <JXPagerListRefreshView.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
#import "XPMacro.h"
|
|
/// View
|
|
#import "XPMomentTopicHeaderView.h"
|
|
/// VC
|
|
#import "XPMomentListViewController.h"
|
|
#import "XPMonentsPublishViewController.h"
|
|
#import "XPMonentTopicContainerViewController.h"
|
|
///P
|
|
#import "XPMonentsRecommendPresenter.h"
|
|
#import "XPMonentsRecommendProtocol.h"
|
|
|
|
@interface XPNewMomentsViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate,XPMonentsRecommendProtocol,XPMomentTopicHeaderViewDelegate>
|
|
|
|
///分页控制器
|
|
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
|
@property (nonatomic, strong) JXPagerListRefreshView *pagingView;
|
|
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
|
///分页控制器头部
|
|
@property (nonatomic,strong) XPMomentTopicHeaderView *headerView;
|
|
/// 发布
|
|
@property (nonatomic, strong) UIButton *publishBtn;
|
|
|
|
@property (nonatomic, strong) XPMomentListViewController *recommandVC;
|
|
@property (nonatomic, strong) XPMomentListViewController *latestVC;
|
|
@property (nonatomic, strong) XPMomentListViewController *attentionVC;
|
|
|
|
@end
|
|
|
|
@implementation XPNewMomentsViewController
|
|
|
|
- (__kindof id)createPresenter {
|
|
return [[XPMonentsRecommendPresenter alloc] init];
|
|
}
|
|
|
|
- (BOOL)isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubViews];
|
|
[self.presenter getMonentsTopicList:1 pageSize:20];
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self.view addSubview:self.pagingView];
|
|
[self.view addSubview:self.publishBtn];
|
|
|
|
[self.publishBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(45, 45));
|
|
make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 30);
|
|
make.right.mas_equalTo(self.view).offset(-15);
|
|
}];
|
|
}
|
|
|
|
- (void)viewDidLayoutSubviews {
|
|
[super viewDidLayoutSubviews];
|
|
CGRect frame = self.view.bounds;
|
|
frame.origin.y = kStatusBarHeight;
|
|
frame.size.height = frame.size.height - frame.origin.y;
|
|
self.pagingView.frame = frame;
|
|
}
|
|
|
|
/// 发布
|
|
- (void)publishBtnAction {
|
|
XPMonentsPublishViewController * publishVC = [[XPMonentsPublishViewController alloc] init];
|
|
[self.navigationController pushViewController:publishVC animated:YES];
|
|
}
|
|
|
|
#pragma mark - XPMomentTopicHeaderViewDelegate
|
|
|
|
- (void)momentTopicHeaderViewClickTopic:(MonentsTopicModel *)topicModel {
|
|
XPMonentTopicContainerViewController * topicVC = [[XPMonentTopicContainerViewController alloc] init];
|
|
topicVC.worldId = topicModel.tId;
|
|
[self.navigationController pushViewController:topicVC animated:YES];
|
|
}
|
|
|
|
#pragma mark - XPMonentsRecommendProtocol
|
|
|
|
- (void)monentsTopicListSuccess:(NSArray *)array {
|
|
self.headerView.topicList = array;
|
|
}
|
|
|
|
#pragma mark - JXCategoryViewDelegate
|
|
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
|
return [XPMomentTopicHeaderView getTopicHeaderViewHeight];
|
|
}
|
|
|
|
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
|
return self.headerView;
|
|
}
|
|
|
|
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
return 50;
|
|
}
|
|
|
|
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
return self.titleView;
|
|
}
|
|
|
|
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
|
return self.titles.count;
|
|
}
|
|
|
|
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
|
UIViewController *viewController;
|
|
if (index == 0) {
|
|
viewController = self.recommandVC;
|
|
}else if (index == 1) {
|
|
viewController = self.latestVC;
|
|
}else{
|
|
viewController = self.attentionVC;
|
|
}
|
|
return (id <JXPagerViewListViewDelegate>)viewController;
|
|
}
|
|
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
|
|
|
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
- (JXCategoryTitleView *)titleView {
|
|
if (!_titleView) {
|
|
_titleView = [[JXCategoryTitleView alloc] init];
|
|
_titleView.delegate = self;
|
|
_titleView.backgroundColor = [UIColor clearColor];
|
|
_titleView.titleColor = [ThemeColor textThirdColor];
|
|
_titleView.titleSelectedColor = [ThemeColor mainTextColor];
|
|
_titleView.titleFont = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
|
|
_titleView.titleSelectedFont = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
|
|
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
|
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|
_titleView.defaultSelectedIndex = 0;
|
|
_titleView.averageCellSpacingEnabled = NO;
|
|
_titleView.titles = self.titles;
|
|
_titleView.cellSpacing = 20;
|
|
_titleView.listContainer = (id<JXCategoryViewListContainer>)self.pagingView.listContainerView;
|
|
|
|
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
|
|
lineView.indicatorImageViewSize = CGSizeMake(13, 4);
|
|
lineView.verticalMargin = 5;
|
|
lineView.indicatorImageView.image = [UIImage imageNamed:@"home_segment_indicator"];
|
|
_titleView.indicators = @[lineView];
|
|
}
|
|
return _titleView;
|
|
}
|
|
|
|
- (JXPagerListRefreshView *)pagingView {
|
|
if (!_pagingView) {
|
|
_pagingView = [[JXPagerListRefreshView alloc] initWithDelegate:self];
|
|
_pagingView.backgroundColor = [UIColor clearColor];
|
|
_pagingView.listContainerView.backgroundColor = [UIColor clearColor];
|
|
_pagingView.mainTableView.backgroundColor = [UIColor clearColor];
|
|
_pagingView.listContainerView.listCellBackgroundColor = UIColor.clearColor;
|
|
}
|
|
return _pagingView;
|
|
}
|
|
|
|
- (NSArray<NSString *> *)titles {
|
|
if (!_titles) {
|
|
_titles = @[@"推荐", @"最新", @"关注"];
|
|
}
|
|
return _titles;
|
|
}
|
|
|
|
- (XPMomentTopicHeaderView *)headerView {
|
|
if (!_headerView) {
|
|
_headerView = [[XPMomentTopicHeaderView alloc] init];
|
|
_headerView.delegate = self;
|
|
}
|
|
return _headerView;
|
|
}
|
|
|
|
- (UIButton *)publishBtn {
|
|
if (!_publishBtn) {
|
|
_publishBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_publishBtn setImage:[UIImage imageNamed:@"monents_publish"] forState:UIControlStateNormal];
|
|
[_publishBtn setImage:[UIImage imageNamed:@"monents_publish"] forState:UIControlStateSelected];
|
|
[_publishBtn addTarget:self action:@selector(publishBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _publishBtn;
|
|
}
|
|
|
|
- (XPMomentListViewController *)recommandVC {
|
|
if (!_recommandVC) {
|
|
_recommandVC = [[XPMomentListViewController alloc] init];
|
|
_recommandVC.listType = XPMomentListRecommend;
|
|
}
|
|
return _recommandVC;
|
|
}
|
|
|
|
- (XPMomentListViewController *)latestVC {
|
|
if (!_latestVC) {
|
|
_latestVC = [[XPMomentListViewController alloc] init];
|
|
_latestVC.listType = XPMomentListTypeLatest;
|
|
}
|
|
return _latestVC;
|
|
}
|
|
|
|
- (XPMomentListViewController *)attentionVC {
|
|
if (!_attentionVC) {
|
|
_attentionVC = [[XPMomentListViewController alloc] init];
|
|
_attentionVC.listType = XPMomentListTypeAttent;
|
|
}
|
|
return _attentionVC;
|
|
}
|
|
|
|
|
|
@end
|