238 lines
7.8 KiB
Objective-C
238 lines
7.8 KiB
Objective-C
//
|
|
// XPRoomRankViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/12/14.
|
|
//
|
|
|
|
#import "XPRoomRankViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|
#import <JXCategoryView/JXCategoryListContainerView.h>
|
|
///Tool
|
|
#import "ThemeColor+RoomRank.h"
|
|
#import "XPMacro.h"
|
|
///Model
|
|
#import "MicroQueueModel.h"
|
|
#import "UserInfoModel.h"
|
|
#import "MicroStateModel.h"
|
|
#import "RoomInfoModel.h"
|
|
///View
|
|
#import "XPRoomDayRankViewController.h"
|
|
#import "XPUserCardViewController.h"
|
|
@interface XPRoomRankViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate, XPRoomRankHostDelegate>
|
|
///顶部的View
|
|
@property (nonatomic,strong) UIView * topView;
|
|
///显示内容的
|
|
@property (nonatomic,strong) UIView * backView;
|
|
///分页标题
|
|
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
|
///分页控件
|
|
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
|
///分页lineView
|
|
@property (nonatomic, strong) JXCategoryListContainerView *contentView;
|
|
///顶部的背景视图
|
|
@property (nonatomic,strong) UIImageView *headBackImageView;
|
|
///财富榜
|
|
@property (nonatomic,strong) XPRoomDayRankViewController *wealthRankVC;
|
|
///魅力榜
|
|
@property (nonatomic,strong) XPRoomDayRankViewController *charmRankVC;
|
|
///房间的uid
|
|
@property (nonatomic,copy) NSString *roomUid;
|
|
///host
|
|
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
|
|
@end
|
|
|
|
@implementation XPRoomRankViewController
|
|
|
|
- (instancetype)initWithRoomUid:(NSString *)roomUid delegate:(id<RoomHostDelegate>)delegate; {
|
|
if (self = [super init]) {
|
|
self.roomUid = roomUid;
|
|
self.hostDelegate = delegate;
|
|
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
|
|
#pragma mark - JXCategoryViewDelegate
|
|
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
|
return self.titles.count;
|
|
}
|
|
|
|
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
|
if (index == 0) {
|
|
return self.wealthRankVC;
|
|
}
|
|
return self.charmRankVC;
|
|
}
|
|
|
|
#pragma mark - XPRoomRankHostDelegate
|
|
- (NSString *)getRoomUid {
|
|
return self.roomUid;
|
|
}
|
|
|
|
- (void)didSelectUser:(NSString *)uid {
|
|
if (uid.integerValue <=0) return;
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
|
NSString * targetUid = uid;
|
|
XPUserCardInfoModel * model = [[XPUserCardInfoModel alloc] init];
|
|
[[self.hostDelegate.getMicroQueue allValues] enumerateObjectsUsingBlock:^(MicroQueueModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if (uid.integerValue == obj.userInfo.uid) {
|
|
model.position = [NSString stringWithFormat:@"%d", obj.microState.position];
|
|
model.posState = (UserCardMicroPosStateType)obj.microState.posState;
|
|
model.micState = (UserCardMicroMicStateType)obj.microState.micState;
|
|
*stop = YES;
|
|
}
|
|
}];
|
|
model.uid = targetUid;
|
|
model.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
|
|
model.leaveMode = roomInfo.leaveMode;
|
|
model.showGiftValue = roomInfo.showGiftValue;
|
|
model.avatar = roomInfo.avatar;
|
|
model.roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
|
model.nick = self.hostDelegate.getUserInfo.nick;
|
|
model.delegate = self.hostDelegate;
|
|
XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model];
|
|
[self.hostDelegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil];
|
|
}
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.view.backgroundColor = [UIColor clearColor];
|
|
[self.view addSubview:self.topView];
|
|
[self.view addSubview:self.backView];
|
|
|
|
[self.backView addSubview:self.headBackImageView];
|
|
[self.backView addSubview:self.titleView];
|
|
[self.backView addSubview:self.contentView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.top.mas_equalTo(self.view);
|
|
make.bottom.mas_equalTo(self.backView.mas_top);
|
|
}];
|
|
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.bottom.right.mas_equalTo(self.view);
|
|
make.height.mas_equalTo(550);
|
|
}];
|
|
|
|
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.backView).inset(30);
|
|
make.height.mas_equalTo(36);
|
|
make.top.mas_equalTo(self.backView).offset(25);
|
|
}];
|
|
|
|
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.bottom.mas_equalTo(self.backView);
|
|
make.top.mas_equalTo(self.titleView.mas_bottom);
|
|
}];
|
|
|
|
[self.headBackImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.left.top.mas_equalTo(self.backView);
|
|
make.height.mas_equalTo(100);
|
|
}];
|
|
}
|
|
#pragma mark - Event Response
|
|
- (void)disMissRoomRankCongnizer {
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (JXCategoryTitleView *)titleView {
|
|
if (!_titleView) {
|
|
_titleView = [[JXCategoryTitleView alloc] init];
|
|
_titleView.delegate = self;
|
|
_titleView.titles = self.titles;
|
|
_titleView.layer.masksToBounds= YES;
|
|
_titleView.layer.cornerRadius = 36/2;
|
|
_titleView.backgroundColor = [ThemeColor roomRankTitleBackColor];
|
|
_titleView.titleColor = [ThemeColor roomRankNormalTitleColor];
|
|
_titleView.titleSelectedColor = [ThemeColor roomRankSelectTitleColor];
|
|
_titleView.titleFont = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
|
|
_titleView.titleSelectedFont = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
|
|
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
|
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|
_titleView.defaultSelectedIndex = 0;
|
|
_titleView.cellWidth = (KScreenWidth - 30* 2)/2;
|
|
_titleView.cellSpacing = 0;
|
|
_titleView.averageCellSpacingEnabled = YES;
|
|
_titleView.listContainer = self.contentView;
|
|
|
|
JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
|
|
backgroundView.indicatorHeight = 34;
|
|
backgroundView.indicatorColor = [UIColor whiteColor];
|
|
backgroundView.indicatorWidth = (KScreenWidth - 30* 2)/2;
|
|
backgroundView.layer.cornerRadius = 17;
|
|
backgroundView.layer.masksToBounds = YES;
|
|
_titleView.indicators = @[backgroundView];
|
|
}
|
|
return _titleView;
|
|
}
|
|
|
|
- (JXCategoryListContainerView *)contentView {
|
|
if (!_contentView) {
|
|
_contentView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
|
_contentView.defaultSelectedIndex = 0;
|
|
}
|
|
return _contentView;
|
|
}
|
|
|
|
- (NSArray<NSString *> *)titles {
|
|
return @[@"贡献榜", @"魅力榜"];
|
|
}
|
|
|
|
- (UIView *)topView {
|
|
if (!_topView) {
|
|
_topView = [[UIView alloc] init];
|
|
_topView.backgroundColor = [UIColor clearColor];
|
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disMissRoomRankCongnizer)];
|
|
[_topView addGestureRecognizer:tap];
|
|
}
|
|
return _topView;
|
|
}
|
|
|
|
- (UIView *)backView {
|
|
if (!_backView) {
|
|
_backView = [[UIView alloc] init];
|
|
_backView.backgroundColor = [UIColor clearColor];
|
|
}
|
|
return _backView;
|
|
}
|
|
|
|
- (UIImageView *)headBackImageView {
|
|
if (!_headBackImageView) {
|
|
_headBackImageView = [[UIImageView alloc] init];
|
|
_headBackImageView.userInteractionEnabled = YES;
|
|
_headBackImageView.image = [UIImage imageNamed:@"room_rank_header_bg"];
|
|
}
|
|
return _headBackImageView;
|
|
}
|
|
|
|
- (XPRoomDayRankViewController *)charmRankVC {
|
|
if (!_charmRankVC) {
|
|
_charmRankVC = [[XPRoomDayRankViewController alloc] initWithDelegate:self];
|
|
_charmRankVC.type = RoomRankType_Charm;
|
|
}
|
|
return _charmRankVC;
|
|
}
|
|
|
|
- (XPRoomDayRankViewController *)wealthRankVC {
|
|
if (!_wealthRankVC) {
|
|
_wealthRankVC = [[XPRoomDayRankViewController alloc] initWithDelegate:self];
|
|
_wealthRankVC.type = RoomRankType_Contribute;
|
|
}
|
|
return _wealthRankVC;
|
|
}
|
|
|
|
@end
|