334 lines
12 KiB
Objective-C
334 lines
12 KiB
Objective-C
//
|
|
// XPSessionMainViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by duoban on 2022/10/12.
|
|
//
|
|
|
|
#import "XPSessionMainViewController.h"
|
|
///Tool
|
|
#import <JXPagingView/JXPagerView.h>
|
|
#import <JXPagingView/JXPagerListRefreshView.h>
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|
///vc
|
|
#import "XPMineAttentionViewController.h"
|
|
#import "SessionListViewController.h"
|
|
#import "XPMineFriendViewController.h"
|
|
#import "XPMineFansViewController.h"
|
|
#import "MSSessionScrollingView.h"
|
|
#import "MSSessionScrollingItemView.h"
|
|
#import "MessagePresenter.h"
|
|
#import "MessageProtocol.h"
|
|
#import "MSSessionPublicChatHallVC.h"
|
|
@interface XPSessionMainViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate,JXPagerMainTableViewGestureDelegate,MSSessionScrollingViewDelegate>
|
|
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
|
@property (nonatomic, strong) JXCategoryIndicatorImageView *lineView;
|
|
@property (nonatomic, strong) JXPagerView *pagingView;
|
|
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
|
@property (nonatomic,strong) UIView *headView;
|
|
@property (nonatomic,strong) UIImageView *headBgImageView;
|
|
|
|
@property (nonatomic,strong) SessionListViewController *sessionListVC;
|
|
///好友
|
|
@property (nonatomic,strong) XPMineFriendViewController *friendVC;
|
|
///关注
|
|
@property (nonatomic,strong) XPMineAttentionViewController *attentionVC;
|
|
///粉丝
|
|
@property (nonatomic,strong) XPMineFansViewController *fansVC;
|
|
///清除已读
|
|
@property (nonatomic,strong) UIButton * allCleanBtn;
|
|
@property(nonatomic,strong) MSSessionScrollingView *scrollingView;
|
|
@property(nonatomic,strong) UIImageView *bgImageView;
|
|
@property(nonatomic,strong) UILabel *textView;
|
|
@end
|
|
|
|
@implementation XPSessionMainViewController
|
|
- (MessagePresenter *)createPresenter {
|
|
return [[MessagePresenter alloc] init];
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
[self getDataList];
|
|
|
|
}
|
|
- (BOOL)isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
-(void)dealloc{
|
|
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
|
}
|
|
-(void)getDataList{
|
|
[self.presenter getPublicChatHallList];
|
|
}
|
|
-(void)getPublicChatHallListSuccess:(NSArray<MSSessionScrollingModel *> *)list{
|
|
NSMutableArray *l = [NSMutableArray new];
|
|
for (MSSessionScrollingModel *obj in list) {
|
|
obj.beginTime = 3;
|
|
obj.endTime = 8;
|
|
}
|
|
self.scrollingView.modelList = [[NSMutableArray alloc]initWithArray:list];
|
|
}
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getTabBarItemBadge:) name:@"kGetTabBarItemBadge" object:nil];
|
|
self.view.backgroundColor = [UIColor clearColor];
|
|
self.headView = [UIView new];
|
|
|
|
[self.view addSubview:self.headBgImageView];
|
|
[self.view addSubview:self.pagingView];
|
|
[self.view addSubview:self.allCleanBtn];
|
|
[self.view addSubview:self.bgImageView];
|
|
[self.bgImageView addSubview:self.textView];
|
|
[self.bgImageView addSubview:self.scrollingView];
|
|
}
|
|
- (void)initSubViewConstraints {
|
|
[self.headBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.top.trailing.equalTo(self.view);
|
|
make.height.mas_equalTo(196);
|
|
}];
|
|
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kStatusBarHeight);
|
|
make.height.mas_equalTo(kGetScaleWidth(99));
|
|
make.leading.trailing.equalTo(self.view);
|
|
}];
|
|
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kGetScaleWidth(13));
|
|
make.centerX.equalTo(self.bgImageView);
|
|
}];
|
|
[self.scrollingView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(0);
|
|
make.top.mas_equalTo(kGetScaleWidth(35));
|
|
make.trailing.mas_equalTo(-kGetScaleWidth(0));
|
|
make.bottom.mas_equalTo(kGetScaleWidth(10));
|
|
}];
|
|
|
|
[self.pagingView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.equalTo(self.view);
|
|
make.bottom.mas_equalTo(-1);
|
|
make.top.equalTo(self.bgImageView.mas_bottom).mas_offset(-50);
|
|
}];
|
|
[self.allCleanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.height.mas_equalTo(30);
|
|
make.top.mas_equalTo(67+kGetScaleWidth(115));
|
|
make.trailing.mas_equalTo(-15);
|
|
}];
|
|
|
|
UIView *lineView = [UIView new];
|
|
lineView.backgroundColor = UIColorFromRGB(0xF5F6FA);
|
|
[self.view addSubview:lineView];
|
|
[lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.leading.trailing.equalTo(self.view);
|
|
make.height.mas_equalTo(1);
|
|
}];
|
|
}
|
|
#pragma mark - SessionListViewController通知
|
|
-(void)getTabBarItemBadge:(NSNotification *)not{
|
|
NSInteger badgeValue = [not.userInfo[@"BadgeValue"] integerValue];
|
|
if (badgeValue > 0) {
|
|
[self.tabBarItem setBadgeValue:[NSString stringWithFormat:@"%ld", badgeValue]];
|
|
} else {
|
|
[self.tabBarItem setBadgeValue:nil];
|
|
}
|
|
}
|
|
|
|
#pragma mark - JXCategoryViewDelegate
|
|
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
|
return 57;
|
|
}
|
|
|
|
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
|
return self.headView;
|
|
}
|
|
|
|
- (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) {
|
|
return self.sessionListVC;
|
|
}else if (index == 1){
|
|
return self.friendVC;
|
|
}
|
|
else if (index == 2){
|
|
return self.attentionVC;
|
|
}else{
|
|
return self.fansVC;
|
|
}
|
|
|
|
|
|
return (id <JXPagerViewListViewDelegate>)viewController;
|
|
}
|
|
- (NSArray<NSString *> *)titles {
|
|
if (!_titles) {
|
|
_titles = @[YMLocalizedString(@"XPSessionMainViewController0"), YMLocalizedString(@"XPSessionMainViewController1"),YMLocalizedString(@"XPSessionMainViewController2"),YMLocalizedString(@"XPSessionMainViewController3")];
|
|
}
|
|
return _titles;
|
|
}
|
|
#pragma mark- 清除消息
|
|
- (void)allReadButtonClick:(UIButton *)sender {
|
|
[[NSNotificationCenter defaultCenter]postNotificationName:@"kAllReadAction" object:nil];
|
|
}
|
|
#pragma mark- MSSessionScrollingViewDelegate
|
|
- (UIView *)MSSessionScrollingView:(MSSessionScrollingView *)view scrollingWithModel:(MSSessionScrollingModel*)model{
|
|
MSSessionScrollingItemView *scrollingView = [[MSSessionScrollingItemView alloc]initWithFrame:CGRectMake(0, 0, model.width + kGetScaleWidth(32.5), kGetScaleWidth(27))];
|
|
scrollingView.model = model;
|
|
|
|
return scrollingView;
|
|
}
|
|
- (void)MSSessionScrollingView:(MSSessionScrollingView *)view didClickView:(UIView *)scrollingView atPoint:(CGPoint)point{
|
|
|
|
}
|
|
-(void)clickPublicChatHallAction{
|
|
MSSessionPublicChatHallVC *vc =[MSSessionPublicChatHallVC new];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
-(NSTimeInterval)curTime {
|
|
static double time = 0;
|
|
time += 0.1 ;
|
|
return time;
|
|
}
|
|
#pragma mark -懒加载
|
|
- (JXCategoryTitleView *)titleView {
|
|
if (!_titleView) {
|
|
_titleView = [[JXCategoryTitleView alloc] init];
|
|
_titleView.delegate = self;
|
|
_titleView.backgroundColor = [UIColor clearColor];
|
|
_titleView.titleColor = UIColorFromRGB(0x6D6B89);
|
|
_titleView.titleSelectedColor = UIColorFromRGB(0x1F1A4E);
|
|
_titleView.titleFont = [UIFont fontWithName:@"PingFang-SC-Medium" size:16];
|
|
_titleView.titleSelectedFont = [UIFont boldSystemFontOfSize:22];
|
|
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
|
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|
_titleView.defaultSelectedIndex = 0;
|
|
_titleView.averageCellSpacingEnabled = NO;
|
|
_titleView.contentEdgeInsetLeft = 20;
|
|
_titleView.titles = self.titles;
|
|
_titleView.cellSpacing = 20;
|
|
_titleView.titles = self.titles;
|
|
_titleView.listContainer = (id<JXCategoryViewListContainer>)self.pagingView.listContainerView;
|
|
|
|
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
|
|
lineView.indicatorImageViewSize = CGSizeMake(45, 10);
|
|
lineView.verticalMargin = 10;
|
|
lineView.indicatorImageView.layer.masksToBounds = YES;
|
|
lineView.indicatorImageView.layer.cornerRadius = 3;
|
|
lineView.indicatorImageView.image = [UIImage imageNamed:@"mine_dynamic"];
|
|
_titleView.indicators = @[lineView];
|
|
}
|
|
return _titleView;
|
|
}
|
|
|
|
- (JXPagerView *)pagingView {
|
|
if (!_pagingView) {
|
|
_pagingView = [[JXPagerView alloc] initWithDelegate:self listContainerType:0];
|
|
_pagingView.backgroundColor = [UIColor clearColor];
|
|
_pagingView.listContainerView.backgroundColor = [UIColor clearColor];
|
|
_pagingView.mainTableView.backgroundColor = [UIColor clearColor];
|
|
_pagingView.listContainerView.listCellBackgroundColor = UIColor.clearColor;
|
|
_pagingView.pinSectionHeaderVerticalOffset = 57;
|
|
_pagingView.isListHorizontalScrollEnabled = NO;
|
|
_pagingView.mainTableView.gestureDelegate = self;
|
|
|
|
}
|
|
return _pagingView;
|
|
}
|
|
-(UIImageView *)headBgImageView{
|
|
if (!_headBgImageView){
|
|
_headBgImageView = [UIImageView new];
|
|
_headBgImageView.image = [UIImage imageNamed:@"message_main_bg"];
|
|
}
|
|
return _headBgImageView;
|
|
}
|
|
- (XPMineAttentionViewController *)attentionVC {
|
|
if (!_attentionVC) {
|
|
_attentionVC = [[XPMineAttentionViewController alloc] init];
|
|
_attentionVC.type = ContactUseingType_In_Session;
|
|
_attentionVC.isClearColor = YES;
|
|
}
|
|
return _attentionVC;
|
|
}
|
|
|
|
- (XPMineFriendViewController *)friendVC {
|
|
if (!_friendVC) {
|
|
_friendVC = [[XPMineFriendViewController alloc] init];
|
|
_friendVC.isClearColor = YES;
|
|
_friendVC.type = ContactUseingType_In_Session;
|
|
|
|
}
|
|
return _friendVC;
|
|
}
|
|
|
|
- (XPMineFansViewController *)fansVC {
|
|
if (!_fansVC) {
|
|
_fansVC = [[XPMineFansViewController alloc] init];
|
|
_fansVC.type = ContactUseingType_In_Session;
|
|
_fansVC.isClearColor = YES;
|
|
|
|
}
|
|
return _fansVC;
|
|
}
|
|
- (SessionListViewController *)sessionListVC{
|
|
if (!_sessionListVC){
|
|
_sessionListVC = [[SessionListViewController alloc]init];
|
|
}
|
|
return _sessionListVC;
|
|
}
|
|
- (UIButton *)allCleanBtn{
|
|
if (!_allCleanBtn){
|
|
_allCleanBtn = [UIButton new];
|
|
[_allCleanBtn setCornerWithLeftTopCorner:10 rightTopCorner:10 bottomLeftCorner:10 bottomRightCorner:10 size:CGSizeMake(30, 30)];
|
|
[_allCleanBtn setImage:[UIImage imageNamed:@"sessionList_clear"] forState:UIControlStateNormal];
|
|
[_allCleanBtn addTarget:self action:@selector(allReadButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _allCleanBtn;
|
|
}
|
|
- (MSSessionScrollingView *)scrollingView{
|
|
if(!_scrollingView){
|
|
_scrollingView = [[MSSessionScrollingView alloc]initWithFrame:CGRectZero];
|
|
_scrollingView.delegate = self;
|
|
}
|
|
return _scrollingView;
|
|
}
|
|
- (UIImageView *)bgImageView{
|
|
if(!_bgImageView){
|
|
_bgImageView = [UIImageView new];
|
|
_bgImageView.userInteractionEnabled = YES;
|
|
_bgImageView.image = kImage(@"ms_public_chat_hall_head_enter_bg");
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickPublicChatHallAction)];
|
|
[_bgImageView addGestureRecognizer:tap];
|
|
}
|
|
return _bgImageView;
|
|
}
|
|
- (UILabel *)textView{
|
|
if(!_textView){
|
|
_textView = [UILabel labelInitWithText:YMLocalizedString(@"MSSessionPublicChatHallVC0") font:kFontBold(17) textColor:UIColorFromRGB(0xFFDDA2)];
|
|
}
|
|
return _textView;
|
|
}
|
|
/*
|
|
#pragma mark - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
// Get the new view controller using [segue destinationViewController].
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
@end
|