466 lines
17 KiB
Objective-C
466 lines
17 KiB
Objective-C
//
|
||
// YMMineSimpleUserInfoHeaderView.m
|
||
// YUMI
|
||
//
|
||
// Created by XY on 2023/2/21.
|
||
//
|
||
|
||
#import "XPMineSimpleUserInfoHeaderView.h"
|
||
#import "NetImageView.h"
|
||
#import <Masonry.h>
|
||
#import "DJDKMIMOMColor.h"
|
||
#import <JXCategoryView/JXCategoryView.h>
|
||
#import <JXCategoryView/JXCategoryIndicatorBackgroundView.h>
|
||
#import <JXCategoryView/JXCategoryListContainerView.h>
|
||
|
||
///Tool
|
||
#import "YUMIMacroUitls.h"
|
||
#import "DJDKMIMOMColor.h"
|
||
#import "UIImageConstant.h"
|
||
#import "UIButton+EnlargeTouchArea.h"
|
||
#import "UIImage+Utils.h"
|
||
|
||
///View
|
||
#import "XPMineUserInfoGiftView.h"
|
||
|
||
#import "UserGiftWallInfoModel.h"
|
||
#import "UserInfoModel.h"
|
||
|
||
|
||
@interface XPMineSimpleUserInfoHeaderView()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
|
||
|
||
/// 背景图
|
||
@property (nonatomic, strong) NetImageView *bgImageView;
|
||
/// 毛玻璃
|
||
@property (nonatomic, strong) UIVisualEffectView *effectView;
|
||
/// 昵称
|
||
@property (nonatomic, strong) UILabel *nicknameLabel;
|
||
/// ID
|
||
@property (nonatomic, strong) UILabel *idLabel;
|
||
/// 头像
|
||
@property (nonatomic, strong) NetImageView *avatarImageView;
|
||
/// 个人简介
|
||
@property (nonatomic, strong) UILabel *introduceLabel;
|
||
/// 粉丝
|
||
@property (nonatomic, strong) UILabel *fansLabel;
|
||
/// 直播中
|
||
@property (nonatomic,strong) UIButton *onlineBtn;
|
||
|
||
// ---------- 礼物部分
|
||
|
||
///背景
|
||
@property (nonatomic,strong) UIImageView * backImageView;
|
||
///灰色背景
|
||
@property (nonatomic,strong) UIView *giftBgView;
|
||
///显示更多
|
||
@property (nonatomic,strong) UIButton *arrowButton;
|
||
///标题
|
||
@property (nonatomic,strong) UILabel *titleLabel;
|
||
///分页标题
|
||
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
||
///分页控件
|
||
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
||
///分页lineView
|
||
@property (nonatomic, strong) JXCategoryListContainerView *containerView;
|
||
///普通礼物
|
||
@property (nonatomic,strong) XPMineUserInfoGiftView *normalGiftView;
|
||
///幸运礼物
|
||
@property (nonatomic,strong) XPMineUserInfoGiftView *luckyGiftView;
|
||
///动态
|
||
@property (nonatomic,strong) UILabel *dynamicLabel;
|
||
|
||
///礼物墙中的礼物
|
||
@property (nonatomic,strong) NSArray<UserGiftWallInfoModel *> *userGiftWall;
|
||
///礼物墙中的幸运礼物礼物
|
||
@property (nonatomic,strong) NSArray<UserGiftWallInfoModel *> *userLuckyBagGiftWall;
|
||
|
||
@end
|
||
|
||
@implementation XPMineSimpleUserInfoHeaderView
|
||
|
||
- (instancetype)initWithFrame:(CGRect)frame {
|
||
self = [super initWithFrame:frame];
|
||
if (self) {
|
||
[self createUI];
|
||
}
|
||
return self;
|
||
}
|
||
|
||
- (void)createUI {
|
||
[self addSubview:self.bgImageView];
|
||
[self.bgImageView addSubview:self.effectView];
|
||
[self addSubview:self.nicknameLabel];
|
||
[self addSubview:self.idLabel];
|
||
[self addSubview:self.avatarImageView];
|
||
[self addSubview:self.introduceLabel];
|
||
[self addSubview:self.fansLabel];
|
||
[self addSubview:self.onlineBtn];
|
||
|
||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.left.right.mas_equalTo(0);
|
||
make.height.mas_equalTo(260);
|
||
}];
|
||
[self.effectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.edges.mas_equalTo(self.bgImageView);
|
||
}];
|
||
[self.nicknameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.centerY.mas_equalTo(self.avatarImageView).offset(-5);
|
||
make.left.mas_equalTo(16);
|
||
make.right.mas_equalTo(self.avatarImageView.mas_left).offset(-5);
|
||
}];
|
||
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.mas_equalTo(self.nicknameLabel.mas_bottom).offset(2);
|
||
make.left.mas_equalTo(self.nicknameLabel);
|
||
make.right.mas_equalTo(self.nicknameLabel);
|
||
}];
|
||
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.centerY.mas_equalTo(self.bgImageView);
|
||
make.right.mas_equalTo(-16);
|
||
make.width.height.mas_equalTo(86);
|
||
}];
|
||
[self.fansLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.mas_equalTo(self.avatarImageView.mas_bottom).offset(16);
|
||
make.centerX.mas_equalTo(self.avatarImageView);
|
||
make.width.mas_equalTo(self.avatarImageView);
|
||
}];
|
||
[self.introduceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(self.nicknameLabel);
|
||
make.top.mas_equalTo(self.fansLabel);
|
||
make.right.mas_equalTo(self.avatarImageView.mas_left).offset(-10);
|
||
}];
|
||
[self.onlineBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(0);
|
||
make.bottom.mas_equalTo(self.nicknameLabel.mas_top).offset(-12);
|
||
make.width.mas_equalTo(56);
|
||
make.height.mas_equalTo(24);
|
||
}];
|
||
|
||
// 礼物部分
|
||
|
||
[self addSubview:self.backImageView];
|
||
[self.backImageView addSubview:self.titleLabel];
|
||
[self.backImageView addSubview:self.giftBgView];
|
||
[self.backImageView addSubview:self.arrowButton];
|
||
[self.giftBgView addSubview:self.titleView];
|
||
[self.giftBgView addSubview:self.containerView];
|
||
[self.backImageView addSubview:self.dynamicLabel];
|
||
|
||
CGFloat itemHeight = 65;
|
||
CGFloat topHeight = 100;
|
||
CGFloat bottomHeight = 45;
|
||
CGFloat giftHeight = itemHeight * 3 + 10 * 3 + topHeight + bottomHeight;
|
||
|
||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.right.mas_equalTo(0);
|
||
make.top.mas_equalTo(self.bgImageView.mas_bottom).offset(-20);
|
||
make.height.mas_equalTo(giftHeight);
|
||
}];
|
||
|
||
[self.giftBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(16);
|
||
make.right.mas_equalTo(-16);
|
||
make.top.mas_equalTo(47);
|
||
make.height.mas_equalTo(281);
|
||
}];
|
||
|
||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(self.backImageView).offset(16);
|
||
make.top.mas_equalTo(self.backImageView).offset(16);
|
||
}];
|
||
|
||
[self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.size.mas_equalTo(CGSizeMake(13, 22));
|
||
make.centerY.mas_equalTo(self.titleLabel);
|
||
make.right.mas_equalTo(self.backImageView).offset(-15);
|
||
}];
|
||
|
||
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.centerX.mas_equalTo(self.giftBgView);
|
||
make.width.mas_equalTo(90 * 2 + 20);
|
||
make.height.mas_equalTo(50);
|
||
make.top.mas_equalTo(0);
|
||
}];
|
||
|
||
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.right.mas_equalTo(0);
|
||
make.top.mas_equalTo(self.titleView.mas_bottom).offset(8);
|
||
make.bottom.mas_equalTo(0);
|
||
}];
|
||
|
||
[self.dynamicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(self.titleLabel);
|
||
make.top.mas_equalTo(self.giftBgView.mas_bottom).offset(20);
|
||
}];
|
||
|
||
}
|
||
|
||
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
||
_userInfo = userInfo;
|
||
if (_userInfo) {
|
||
self.idLabel.text = [NSString stringWithFormat:@"ID:%ld", (long)_userInfo.erbanNo];
|
||
self.nicknameLabel.text = _userInfo.nick.length > 0 ? _userInfo.nick : @"";
|
||
self.avatarImageView.imageUrl = userInfo.avatar;
|
||
self.bgImageView.imageUrl = userInfo.avatar;
|
||
self.introduceLabel.text = _userInfo.userDesc.length > 0 ? _userInfo.userDesc : YMLocalizedString(@"XPMineSimpleUserInfoHeaderView0");
|
||
self.fansLabel.text =[NSString stringWithFormat:@"%@:%ld",YMLocalizedString(@"XPMineHeadView5"), _userInfo.fansNum];
|
||
|
||
self.userGiftWall = self.userInfo.userGiftWall;
|
||
self.userLuckyBagGiftWall = self.userInfo.userLuckyBagGiftWall;
|
||
}
|
||
}
|
||
|
||
- (void)setRoomUid:(NSString *)roomUid {
|
||
_roomUid = roomUid;
|
||
self.onlineBtn.hidden = _roomUid.length <= 0;
|
||
}
|
||
|
||
#pragma mark - JXCategoryViewDelegate
|
||
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
||
return self.titles.count;
|
||
}
|
||
|
||
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
||
if (index == 0) {
|
||
return self.normalGiftView;
|
||
} else {
|
||
return self.luckyGiftView;
|
||
}
|
||
}
|
||
#pragma mark - Event Response
|
||
- (void)arrowButtonAction:(UIButton *)sender {
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(headerViewMoreGiftAction)]) {
|
||
[self.delegate headerViewMoreGiftAction];
|
||
}
|
||
}
|
||
|
||
- (void)onlineBtnAction {
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(headerViewOnlineAction:)]) {
|
||
[self.delegate headerViewOnlineAction:self.roomUid];
|
||
}
|
||
}
|
||
|
||
#pragma mark - Getters And Setters
|
||
- (void)setUserGiftWall:(NSArray<UserGiftWallInfoModel *> *)userGiftWall {
|
||
_userGiftWall = userGiftWall;
|
||
if (_userGiftWall.count > 12) {
|
||
NSMutableArray * array = [_userGiftWall mutableCopy];
|
||
_userGiftWall = [array subarrayWithRange:NSMakeRange(0, 12)];
|
||
}
|
||
self.normalGiftView.datasource = _userGiftWall;
|
||
}
|
||
|
||
- (void)setUserLuckyBagGiftWall:(NSArray<UserGiftWallInfoModel *> *)userLuckyBagGiftWall {
|
||
_userLuckyBagGiftWall = userLuckyBagGiftWall;
|
||
if (_userLuckyBagGiftWall.count > 12) {
|
||
NSMutableArray * array = [_userLuckyBagGiftWall mutableCopy];
|
||
_userLuckyBagGiftWall = [array subarrayWithRange:NSMakeRange(0, 12)];
|
||
}
|
||
self.luckyGiftView.datasource = _userLuckyBagGiftWall;
|
||
}
|
||
|
||
|
||
#pragma mark - 懒加载
|
||
|
||
- (NetImageView *)bgImageView {
|
||
if (!_bgImageView) {
|
||
_bgImageView = [[NetImageView alloc] init];
|
||
_bgImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||
_bgImageView.clipsToBounds = YES;
|
||
}
|
||
return _bgImageView;
|
||
}
|
||
|
||
- (UIVisualEffectView *)effectView {
|
||
if (!_effectView) {
|
||
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
||
_effectView = [[UIVisualEffectView alloc] initWithEffect:blur];
|
||
_effectView.alpha = 0.9;
|
||
}
|
||
return _effectView;
|
||
}
|
||
|
||
- (UILabel *)nicknameLabel {
|
||
if (!_nicknameLabel) {
|
||
_nicknameLabel = [[UILabel alloc] init];
|
||
_nicknameLabel.textColor = UIColor.whiteColor;
|
||
_nicknameLabel.font = [UIFont systemFontOfSize:20 weight:UIFontWeightMedium];
|
||
}
|
||
return _nicknameLabel;
|
||
}
|
||
|
||
- (UILabel *)idLabel {
|
||
if (!_idLabel) {
|
||
_idLabel = [[UILabel alloc] init];
|
||
_idLabel.textColor = [UIColor.whiteColor colorWithAlphaComponent:0.4];
|
||
_idLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
|
||
}
|
||
return _idLabel;
|
||
}
|
||
|
||
- (UILabel *)introduceLabel {
|
||
if (!_introduceLabel) {
|
||
_introduceLabel = [[UILabel alloc] init];
|
||
_introduceLabel.textColor = UIColor.whiteColor;
|
||
_introduceLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
|
||
_introduceLabel.numberOfLines = 2;
|
||
}
|
||
return _introduceLabel;
|
||
}
|
||
|
||
- (UILabel *)fansLabel {
|
||
if (!_fansLabel) {
|
||
_fansLabel = [[UILabel alloc] init];
|
||
_fansLabel.textColor = UIColor.whiteColor;
|
||
_fansLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
|
||
_fansLabel.textAlignment = NSTextAlignmentCenter;
|
||
}
|
||
return _fansLabel;
|
||
}
|
||
|
||
- (NetImageView *)avatarImageView {
|
||
if (!_avatarImageView) {
|
||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||
config.imageType = ImageTypeUserIcon;
|
||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
||
_avatarImageView.userInteractionEnabled = YES;
|
||
_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||
_avatarImageView.layer.borderWidth = 2;
|
||
_avatarImageView.layer.borderColor = [UIColor.whiteColor colorWithAlphaComponent:0.4].CGColor;
|
||
_avatarImageView.layer.cornerRadius = 86/2;
|
||
_avatarImageView.clipsToBounds = YES;
|
||
|
||
}
|
||
return _avatarImageView;
|
||
}
|
||
|
||
- (UIButton *)onlineBtn {
|
||
if(!_onlineBtn) {
|
||
_onlineBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
[_onlineBtn setTitle:YMLocalizedString(@"XPMineSimpleUserInfoHeaderView2") forState:UIControlStateNormal];
|
||
[_onlineBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
|
||
_onlineBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||
[_onlineBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
||
_onlineBtn.layer.masksToBounds = YES;
|
||
_onlineBtn.layer.cornerRadius = 24/2;
|
||
_onlineBtn.layer.maskedCorners = kCALayerMaxXMinYCorner | kCALayerMaxXMaxYCorner;
|
||
[_onlineBtn addTarget:self action:@selector(onlineBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
||
_onlineBtn.hidden = YES;
|
||
}
|
||
return _onlineBtn;
|
||
}
|
||
|
||
#pragma mark - 礼物部分
|
||
|
||
- (UIImageView *)backImageView {
|
||
if (!_backImageView) {
|
||
_backImageView = [[UIImageView alloc] init];
|
||
_backImageView.userInteractionEnabled = YES;
|
||
_backImageView.layer.cornerRadius = 20;
|
||
_backImageView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
|
||
_backImageView.backgroundColor =[DJDKMIMOMColor appCellBackgroundColor];
|
||
}
|
||
return _backImageView;
|
||
}
|
||
|
||
- (UIView *)giftBgView {
|
||
if (!_giftBgView) {
|
||
_giftBgView = [[UIView alloc] init];
|
||
_giftBgView.backgroundColor = UIColorFromRGB(0xF6F7F9);
|
||
_giftBgView.layer.cornerRadius = 12;
|
||
}
|
||
return _giftBgView;
|
||
}
|
||
|
||
- (UILabel *)titleLabel {
|
||
if (!_titleLabel) {
|
||
_titleLabel = [[UILabel alloc] init];
|
||
_titleLabel.text = YMLocalizedString(@"XPMineSimpleUserInfoHeaderView3");
|
||
_titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
|
||
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
|
||
}
|
||
return _titleLabel;
|
||
}
|
||
|
||
- (UIButton *)arrowButton {
|
||
if (!_arrowButton) {
|
||
_arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
[_arrowButton setImage:[UIImage imageNamed:@"room_setting_arrow"] forState:UIControlStateNormal];
|
||
[_arrowButton setImage:[UIImage imageNamed:@"room_setting_arrow"] forState:UIControlStateSelected];
|
||
[_arrowButton addTarget:self action:@selector(arrowButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
[_arrowButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
|
||
}
|
||
return _arrowButton;
|
||
}
|
||
|
||
- (JXCategoryTitleView *)titleView {
|
||
if (!_titleView) {
|
||
_titleView = [[JXCategoryTitleView alloc] init];
|
||
_titleView.delegate = self;
|
||
_titleView.titles = self.titles;
|
||
_titleView.backgroundColor = [UIColor clearColor];
|
||
_titleView.titleColor = [DJDKMIMOMColor secondTextColor];
|
||
_titleView.titleSelectedColor = [DJDKMIMOMColor appMainColor];
|
||
_titleView.titleFont = [UIFont systemFontOfSize:14];
|
||
_titleView.titleSelectedFont = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
|
||
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
||
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
||
_titleView.defaultSelectedIndex = 0;
|
||
_titleView.cellSpacing = 20;
|
||
_titleView.cellWidthIncrement = 5;
|
||
_titleView.cellWidth = 60;
|
||
_titleView.listContainer = self.containerView;
|
||
|
||
// JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
|
||
// lineView.indicatorImageViewSize = CGSizeMake(60, 8);
|
||
// lineView.verticalMargin = 6;
|
||
// lineView.indicatorImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFC000), UIColorFromRGB(0xFFD15A)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(60, 8)];
|
||
// lineView.indicatorImageView.layer.masksToBounds = YES;
|
||
// lineView.indicatorImageView.layer.cornerRadius = 6;
|
||
// _titleView.indicators = @[lineView];
|
||
}
|
||
return _titleView;
|
||
}
|
||
|
||
- (JXCategoryListContainerView *)containerView {
|
||
if (!_containerView) {
|
||
_containerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
||
_containerView.defaultSelectedIndex = 0;
|
||
_containerView.scrollView.tag = 1009;
|
||
}
|
||
return _containerView;
|
||
}
|
||
|
||
- (NSArray<NSString *> *)titles {
|
||
if (!_titles) {
|
||
_titles = @[YMLocalizedString(@"XPWishGiftCreateItemViewController0"), YMLocalizedString(@"XPMineSimpleUserInfoHeaderView5")];
|
||
}
|
||
return _titles;
|
||
}
|
||
|
||
- (XPMineUserInfoGiftView *)normalGiftView {
|
||
if (!_normalGiftView) {
|
||
_normalGiftView = [[XPMineUserInfoGiftView alloc] init];
|
||
}
|
||
return _normalGiftView;
|
||
}
|
||
|
||
- (XPMineUserInfoGiftView *)luckyGiftView {
|
||
if (!_luckyGiftView) {
|
||
_luckyGiftView = [[XPMineUserInfoGiftView alloc] init];
|
||
}
|
||
return _luckyGiftView;
|
||
}
|
||
|
||
- (UILabel *)dynamicLabel {
|
||
if (!_dynamicLabel) {
|
||
_dynamicLabel = [[UILabel alloc] init];
|
||
_dynamicLabel.text = YMLocalizedString(@"XPMineSimpleUserInfoHeaderView6");
|
||
_dynamicLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
|
||
_dynamicLabel.textColor = [DJDKMIMOMColor mainTextColor];
|
||
}
|
||
return _dynamicLabel;
|
||
}
|
||
|
||
@end
|