Files
peko-ios/YuMi/Modules/YMMine/View/Friend/XPMineContactViewController.m
2023-09-27 12:35:29 +08:00

193 lines
6.2 KiB
Objective-C

//
// YMMineContactViewController.m
// YUMI
//
// Created by YUMI on 2022/5/29.
//
#import "XPMineContactViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <JXCategoryView/JXCategoryView.h>
#import <JXCategoryView/JXCategoryListContainerView.h>
///Tool
#import "DJDKMIMOMColor.h"
#import "YUMIMacroUitls.h"
///View
#import "SessionViewController.h"
#import "SessionListViewController.h"
#import "XPMineFriendViewController.h"
#import "XPMineAttentionViewController.h"
#import "XPMineFansViewController.h"
@interface XPMineContactViewController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
///标题
@property (nonatomic,strong) NSArray<NSString *> *titles;
///滑块
@property (nonatomic,strong) JXCategoryTitleView *titleView;
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
///回话
@property (nonatomic,strong) SessionListViewController *sessionListVC;
///好友
@property (nonatomic,strong) XPMineFriendViewController *friendVC;
///关注
@property (nonatomic,strong) XPMineAttentionViewController *attentionVC;
///粉丝
@property (nonatomic,strong) XPMineFansViewController *fansVC;
@end
@implementation XPMineContactViewController
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
}
#pragma mark - Private Method
- (void)initSubViews {
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.titleView];
[self.view addSubview:self.listContainerView];
}
- (void)initSubViewConstraints {
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self.view);
make.height.mas_equalTo(50);
}];
[self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self.view);
make.top.mas_equalTo(self.titleView.mas_bottom);
}];
}
#pragma mark - JXCategoryListContainerViewDelegate
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
return self.titles.count;
}
// 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
if (index == 0) {
// [self addChildViewController:self.sessionListVC];
return self.sessionListVC;
}else if (index == 1) {
// [self addChildViewController:self.friendVC];
return self.friendVC;
} else if(index == 2) {
// [self addChildViewController:self.fansVC];
return self.fansVC;
} else {
// [self addChildViewController:self.attentionVC];
return self.attentionVC;
}
}
#pragma mark - Getters And Setters
- (void)setChatUserId:(NSString *)chatUserId {
_chatUserId = chatUserId;
if (_chatUserId) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NIMSession *recentSession = [NIMSession session:self.chatUserId type:NIMSessionTypeP2P];
SessionViewController * sessionVC =[[SessionViewController alloc] initWithSession:recentSession];
sessionVC.openType = SessionListOpenTypeRoom;
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:sessionVC.view];
[self addChildViewController:sessionVC];
});
}
}
- (JXCategoryListContainerView *)listContainerView {
if (!_listContainerView) {
_listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
_listContainerView.listCellBackgroundColor = [UIColor clearColor];
}
return _listContainerView;
}
- (NSArray<NSString *> *)titles {
if (!_titles) {
_titles = @[YMLocalizedString(@"TabbarViewController4"), YMLocalizedString(@"XPMonentsTooBarView2"),YMLocalizedString(@"XPMineHeadView5"), YMLocalizedString(@"XPMineContactViewController3")];
}
return _titles;
}
- (JXCategoryTitleView *)titleView {
if (!_titleView) {
_titleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectZero];
_titleView.backgroundColor =[UIColor clearColor];
_titleView.titleColor = UIColorFromRGB(0x444444);
_titleView.titleSelectedColor = [DJDKMIMOMColor mainTextColor];
_titleView.titleFont = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
_titleView.titleSelectedFont = [UIFont systemFontOfSize:18 weight:UIFontWeightHeavy];
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
_titleView.averageCellSpacingEnabled = NO;
_titleView.defaultSelectedIndex = 0;
_titleView.titles = self.titles;
_titleView.delegate = self;
_titleView.cellSpacing = 0;
_titleView.cellWidth = (CGFloat)KScreenWidth/ 4.0;
_titleView.listContainer = self.listContainerView;
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
lineView.indicatorColor = [DJDKMIMOMColor appMainColor];
lineView.indicatorWidth = 8.f;
lineView.indicatorHeight = 4.f;
lineView.indicatorCornerRadius = 2.f;
_titleView.indicators = @[lineView];
}
return _titleView;
}
- (SessionListViewController *)sessionListVC {
if (!_sessionListVC) {
_sessionListVC = [[SessionListViewController alloc] initWithType:SessionListOpenTypeRoom];
_sessionListVC.mainController = self;
}
return _sessionListVC;
}
- (XPMineAttentionViewController *)attentionVC {
if (!_attentionVC) {
_attentionVC = [[XPMineAttentionViewController alloc] init];
_attentionVC.type = ContactUseingType_In_Room;
_attentionVC.mainController = self;
}
return _attentionVC;
}
- (XPMineFriendViewController *)friendVC {
if (!_friendVC) {
_friendVC = [[XPMineFriendViewController alloc] init];
_friendVC.type = ContactUseingType_In_Room;
_friendVC.mainController = self;
}
return _friendVC;
}
- (XPMineFansViewController *)fansVC {
if (!_fansVC) {
_fansVC = [[XPMineFansViewController alloc] init];
_fansVC.type = ContactUseingType_In_Room;
_fansVC.mainController = self;
}
return _fansVC;
}
@end