236 lines
7.6 KiB
Objective-C
236 lines
7.6 KiB
Objective-C
//
|
|
// YMMonentTopicContainerViewController.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/8/18.
|
|
//
|
|
|
|
#import "XPMonentTopicContainerViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|
#import <JXPagingView/JXPagerView.h>
|
|
#import <JXPagingView/JXPagerListRefreshView.h>
|
|
///Tool
|
|
#import "DJDKMIMOMColor.h"
|
|
#import "YUMIMacroUitls.h"
|
|
#import "Api+Monents.h"
|
|
#import "AccountInfoStorage.h"
|
|
///Model
|
|
#import "MonentsTopicModel.h"
|
|
///View
|
|
#import "XPMonentsTopicRecommondViewController.h"
|
|
#import "XPMonentsTopicLatestViewController.h"
|
|
#import "XPMonentsTopicHeaderView.h"
|
|
#import "XPMonentsPublishViewController.h"
|
|
|
|
@interface XPMonentTopicContainerViewController ()<JXPagerViewDelegate,JXCategoryViewDelegate>
|
|
@property (nonatomic,strong) JXCategoryTitleView *pi_categoryView;
|
|
@property (nonatomic,strong) JXCategoryIndicatorLineView *lineView;
|
|
@property (nonatomic,strong) JXPagerListRefreshView *pagerContentView;
|
|
@property (nonatomic,strong) NSArray<NSString *> *titles;
|
|
@property (nonatomic,strong) XPMonentsTopicRecommondViewController *recommendVC;
|
|
@property (nonatomic,strong) XPMonentsTopicLatestViewController *latestVC;
|
|
@property (nonatomic,strong) XPMonentsTopicHeaderView *headerView;
|
|
@property (nonatomic,strong) UIButton *backButton;
|
|
@property (nonatomic,strong) UIButton *enterTopicButton;
|
|
@property (nonatomic,strong) MonentsTopicModel *topicInfo;
|
|
@end
|
|
|
|
@implementation XPMonentTopicContainerViewController
|
|
|
|
- (BOOL)isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self requestTopicDetail];
|
|
[self initSubViews];
|
|
}
|
|
|
|
- (void)viewDidLayoutSubviews {
|
|
[super viewDidLayoutSubviews];
|
|
self.pagerContentView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight - 50);
|
|
}
|
|
|
|
- (void)initSubViews {
|
|
[self.view addSubview:self.pagerContentView];
|
|
[self.view addSubview:self.backButton];
|
|
[self.view addSubview:self.enterTopicButton];
|
|
|
|
[self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.view);
|
|
make.top.mas_equalTo(statusbarHeight);
|
|
make.height.width.mas_equalTo(44);
|
|
}];
|
|
|
|
[self.enterTopicButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(50);
|
|
make.left.right.bottom.mas_equalTo(self.view);
|
|
}];
|
|
}
|
|
|
|
- (void)requestTopicDetail {
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
[Api monentsTopicDetailInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200) {
|
|
MonentsTopicModel * info = [MonentsTopicModel modelWithDictionary:data.data];
|
|
self.topicInfo = info;
|
|
self.headerView.topicInfo = info;
|
|
} else if(code == 7903) {
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
} else {
|
|
[self showErrorToast:msg];
|
|
}
|
|
} worldId:self.worldId uid:uid];
|
|
}
|
|
|
|
|
|
#pragma mark - JXPagerViewDelegate
|
|
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
|
return self.headerView;
|
|
}
|
|
|
|
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
|
return 150 + kNavigationHeight;
|
|
}
|
|
|
|
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
return 46;
|
|
}
|
|
|
|
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
return self.pi_categoryView;
|
|
}
|
|
|
|
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
|
return self.titles.count;
|
|
}
|
|
|
|
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
|
if (index == 0) {
|
|
return self.recommendVC;
|
|
} else {
|
|
return self.latestVC;
|
|
}
|
|
}
|
|
|
|
#pragma mark - Event Response
|
|
- (void)backButtonAction:(UIButton *)sender {
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
|
|
- (void)enterTopicButtonAction:(UIButton *)sender {
|
|
XPMonentsPublishViewController * publishVC = [[XPMonentsPublishViewController alloc] init];
|
|
self.topicInfo.worldName = self.topicInfo.name;
|
|
self.topicInfo.worldId = self.topicInfo.tId;
|
|
publishVC.topicInfo = self.topicInfo;
|
|
[self.navigationController pushViewController:publishVC animated:YES];
|
|
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setWorldId:(NSString *)worldId {
|
|
_worldId = worldId;
|
|
self.recommendVC.worldId = _worldId;
|
|
self.latestVC.worldId = _worldId;
|
|
}
|
|
|
|
- (JXCategoryTitleView *)pi_categoryView {
|
|
if (!_pi_categoryView) {
|
|
_pi_categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 46)];
|
|
_pi_categoryView.titles = self.titles;
|
|
_pi_categoryView.backgroundColor = [UIColor whiteColor];
|
|
_pi_categoryView.delegate = self;
|
|
_pi_categoryView.titleSelectedColor = [DJDKMIMOMColor mainTextColor];
|
|
_pi_categoryView.titleColor = [DJDKMIMOMColor secondTextColor];
|
|
_pi_categoryView.titleSelectedFont = [UIFont boldSystemFontOfSize:18];
|
|
_pi_categoryView.titleFont = [UIFont systemFontOfSize:15];
|
|
_pi_categoryView.titleColorGradientEnabled = YES;
|
|
_pi_categoryView.titleLabelZoomEnabled = NO;
|
|
_pi_categoryView.indicators = @[self.lineView];
|
|
_pi_categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerContentView.listContainerView;
|
|
_pi_categoryView.averageCellSpacingEnabled = NO;
|
|
_pi_categoryView.contentEdgeInsetLeft = 20;
|
|
_pi_categoryView.contentEdgeInsetRight = 20;
|
|
_pi_categoryView.cellSpacing = 30;
|
|
|
|
}
|
|
return _pi_categoryView;
|
|
}
|
|
|
|
- (JXCategoryIndicatorLineView *)lineView {
|
|
if (!_lineView) {
|
|
_lineView = [[JXCategoryIndicatorLineView alloc] init];
|
|
_lineView.indicatorColor = [DJDKMIMOMColor appMainColor];
|
|
_lineView.indicatorWidth = 9;
|
|
_lineView.indicatorHeight = 4;
|
|
_lineView.verticalMargin = 2;
|
|
}
|
|
return _lineView;
|
|
}
|
|
|
|
- (JXPagerListRefreshView *)pagerContentView {
|
|
if (!_pagerContentView) {
|
|
_pagerContentView = [[JXPagerListRefreshView alloc] initWithDelegate:self];
|
|
_pagerContentView.listContainerView.scrollView.backgroundColor = UIColor.clearColor;
|
|
_pagerContentView.pinSectionHeaderVerticalOffset = (NSInteger) kNavigationHeight;
|
|
}
|
|
return _pagerContentView;
|
|
}
|
|
|
|
- (NSArray<NSString *> *)titles {
|
|
if (!_titles) {
|
|
_titles = @[YMLocalizedString(@"XPMonentsViewController0" ), YMLocalizedString(@"XPMonentTopicContainerViewController1")];
|
|
}
|
|
return _titles;
|
|
}
|
|
|
|
- (XPMonentsTopicHeaderView *)headerView {
|
|
if (!_headerView) {
|
|
_headerView = [[XPMonentsTopicHeaderView alloc] init];
|
|
}
|
|
return _headerView;
|
|
}
|
|
|
|
- (XPMonentsTopicLatestViewController *)latestVC {
|
|
if (!_latestVC) {
|
|
_latestVC = [[XPMonentsTopicLatestViewController alloc] init];
|
|
}
|
|
return _latestVC;
|
|
}
|
|
|
|
- (XPMonentsTopicRecommondViewController *)recommendVC {
|
|
if (!_recommendVC) {
|
|
_recommendVC = [[XPMonentsTopicRecommondViewController alloc] init];
|
|
}
|
|
return _recommendVC;
|
|
}
|
|
|
|
|
|
- (UIButton *)backButton {
|
|
if (!_backButton) {
|
|
_backButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_backButton setImage:[UIImage imageNamed:@"home_search_white_back"] forState:UIControlStateNormal];
|
|
[_backButton setImage:[UIImage imageNamed:@"home_search_white_back"] forState:UIControlStateSelected];
|
|
[_backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _backButton;
|
|
}
|
|
|
|
- (UIButton *)enterTopicButton {
|
|
if (!_enterTopicButton) {
|
|
_enterTopicButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_enterTopicButton setTitle:YMLocalizedString(@"XPMonentTopicContainerViewController2") forState:UIControlStateNormal];
|
|
[_enterTopicButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
_enterTopicButton.titleLabel.font = [UIFont systemFontOfSize:15];
|
|
[_enterTopicButton setBackgroundColor:[DJDKMIMOMColor appMainColor]];
|
|
[_enterTopicButton setImage:[UIImage imageNamed:@"monents_topic_camera"] forState:UIControlStateNormal];
|
|
[_enterTopicButton addTarget:self action:@selector(enterTopicButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _enterTopicButton;
|
|
}
|
|
|
|
@end
|