175 lines
5.8 KiB
Objective-C
175 lines
5.8 KiB
Objective-C
//
|
|
// XPMessageViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by XY on 2023/3/8.
|
|
//
|
|
|
|
#import "XPMessageViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <JXCategoryView.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
#import "XPMacro.h"
|
|
#import "UIImage+Utils.h"
|
|
///VC
|
|
#import "SessionListViewController.h"
|
|
#import "XPMineFriendViewController.h"
|
|
|
|
@interface XPMessageViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
|
|
|
|
@property (nonatomic,strong) UIImageView *topGradientImageView;
|
|
///分页控制器
|
|
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
|
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
|
|
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
|
/// 全部已读
|
|
@property (nonatomic, strong) UIButton *allReadButton;
|
|
|
|
@property (nonatomic, strong) SessionListViewController *sessionVC;
|
|
@property (nonatomic, strong) XPMineFriendViewController *friendVC;
|
|
|
|
@end
|
|
|
|
@implementation XPMessageViewController
|
|
|
|
- (BOOL)isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self.view addSubview:self.topGradientImageView];
|
|
[self.view addSubview:self.titleView];
|
|
[self.view addSubview:self.allReadButton];
|
|
[self.view addSubview:self.listContainerView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.topGradientImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.top.right.mas_equalTo(0);
|
|
make.height.mas_equalTo(125);
|
|
}];
|
|
[self.allReadButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-15);
|
|
make.width.height.mas_equalTo(20);
|
|
make.centerY.mas_equalTo(self.titleView);
|
|
}];
|
|
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kStatusBarHeight);
|
|
make.left.mas_equalTo(5);
|
|
make.right.mas_equalTo(self.allReadButton.mas_left).offset(10);
|
|
make.height.mas_equalTo(50);
|
|
}];
|
|
[self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.titleView.mas_bottom);
|
|
make.left.right.mas_equalTo(0);
|
|
make.bottom.mas_equalTo(0);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - action
|
|
- (void)allReadButtonClick:(UIButton *)sender {
|
|
[self.sessionVC allRead];
|
|
}
|
|
|
|
#pragma mark - JXCategoryListContainerViewDelegate
|
|
|
|
// 返回列表的数量
|
|
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
|
return self.titles.count;
|
|
}
|
|
|
|
// 返回各个列表菜单下的实例,该实例需要遵守并实现 <JXCategoryListContentViewDelegate> 协议
|
|
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
|
if (index == 0) {
|
|
return self.sessionVC;
|
|
}else{
|
|
return self.friendVC;
|
|
}
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
- (UIImageView *)topGradientImageView {
|
|
if (!_topGradientImageView) {
|
|
_topGradientImageView = [[UIImageView alloc] init];
|
|
_topGradientImageView.image = [UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#DCF6FF"], [ThemeColor colorWithHexString:@"#F8F8FA"]] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(KScreenWidth, 125)];
|
|
_topGradientImageView.contentMode = UIViewContentModeScaleToFill;
|
|
}
|
|
return _topGradientImageView;
|
|
}
|
|
|
|
- (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:16 weight:UIFontWeightMedium];
|
|
_titleView.titleSelectedFont = [UIFont systemFontOfSize:22 weight:UIFontWeightSemibold];
|
|
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
|
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|
_titleView.defaultSelectedIndex = 0;
|
|
_titleView.averageCellSpacingEnabled = NO;
|
|
_titleView.titles = self.titles;
|
|
_titleView.cellSpacing = 20;
|
|
_titleView.listContainer = self.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;
|
|
}
|
|
|
|
// 列表容器视图
|
|
- (JXCategoryListContainerView *)listContainerView {
|
|
if (!_listContainerView) {
|
|
_listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
|
}
|
|
return _listContainerView;
|
|
}
|
|
|
|
- (UIButton *)allReadButton {
|
|
if (!_allReadButton) {
|
|
_allReadButton = [[UIButton alloc] init];
|
|
[_allReadButton setImage:[UIImage imageNamed:@"sessionList_clear"] forState:UIControlStateNormal];
|
|
[_allReadButton addTarget:self action:@selector(allReadButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _allReadButton;
|
|
}
|
|
|
|
- (NSArray<NSString *> *)titles {
|
|
if (!_titles) {
|
|
_titles = @[@"消息", @"好友"];
|
|
}
|
|
return _titles;
|
|
}
|
|
|
|
- (SessionListViewController *)sessionVC {
|
|
if (!_sessionVC) {
|
|
_sessionVC = [[SessionListViewController alloc] init];
|
|
}
|
|
return _sessionVC;
|
|
}
|
|
|
|
- (XPMineFriendViewController *)friendVC {
|
|
if (!_friendVC) {
|
|
_friendVC = [[XPMineFriendViewController alloc] init];
|
|
}
|
|
return _friendVC;
|
|
}
|
|
|
|
@end
|