Files
peko-ios/YuMi/Modules/YMMine/View/MineInfo/XPMineSimpleUserInfoHeaderView.m

430 lines
15 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// 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
2023-08-10 18:44:46 +08:00
@property (nonatomic, strong) JXCategoryListContainerView *pi_containerView;
2023-07-14 18:50:55 +08:00
///
@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];
2023-08-10 18:44:46 +08:00
[self.giftBgView addSubview:self.pi_containerView];
2023-07-14 18:50:55 +08:00
[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);
}];
2023-08-10 18:44:46 +08:00
[self.pi_containerView mas_makeConstraints:^(MASConstraintMaker *make) {
2023-07-14 18:50:55 +08:00
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");
2023-08-04 11:47:43 +08:00
self.fansLabel.text =[NSString stringWithFormat:@"%@%ld",YMLocalizedString(@"XPMineHeadView5"), _userInfo.fansNum];
2023-07-14 18:50:55 +08:00
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;
}
- (NSArray<NSString *> *)titles {
if (!_titles) {
2023-08-04 11:47:43 +08:00
_titles = @[YMLocalizedString(@"XPWishGiftCreateItemViewController0"), YMLocalizedString(@"XPMineSimpleUserInfoHeaderView5")];
2023-07-14 18:50:55 +08:00
}
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