2021-09-16 19:30:22 +08:00
|
|
|
|
//
|
|
|
|
|
// XPMineHeadView.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by 冯硕 on 2021/9/16.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "XPMineHeadView.h"
|
|
|
|
|
///Third
|
|
|
|
|
#import <Masonry/Masonry.h>
|
2021-12-21 18:10:33 +08:00
|
|
|
|
#import <YYText/YYText.h>
|
2021-09-16 19:30:22 +08:00
|
|
|
|
///Tool
|
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
|
#import "XPMacro.h"
|
2021-12-21 18:10:33 +08:00
|
|
|
|
#import "UIImage+Utils.h"
|
2021-09-16 19:30:22 +08:00
|
|
|
|
///View
|
|
|
|
|
#import "XPMineAccountView.h"
|
2021-11-03 18:11:27 +08:00
|
|
|
|
#import "NetImageView.h"
|
2021-12-28 02:07:11 +08:00
|
|
|
|
#import "UIImage+Utils.h"
|
2021-12-21 18:10:33 +08:00
|
|
|
|
#import "XPMineFriendNumberView.h"
|
2022-01-06 17:50:59 +08:00
|
|
|
|
#import "XPNobleCenterEntranceView.h"
|
2021-09-16 19:30:22 +08:00
|
|
|
|
///Model
|
|
|
|
|
#import "UserInfoModel.h"
|
|
|
|
|
|
|
|
|
|
@interface XPMineHeadView ()
|
|
|
|
|
///头像
|
2021-11-03 18:11:27 +08:00
|
|
|
|
@property (nonatomic,strong) NetImageView * avatarImageView;
|
2021-09-16 19:30:22 +08:00
|
|
|
|
///name的容器
|
|
|
|
|
@property (nonatomic,strong) UIStackView *nameStackView;
|
|
|
|
|
///名字
|
|
|
|
|
@property (nonatomic,strong) UILabel *nameLabel;
|
|
|
|
|
///编辑
|
|
|
|
|
@property (nonatomic,strong) UIButton *editButton;
|
|
|
|
|
///id 的容器
|
|
|
|
|
@property (nonatomic,strong) UIStackView *idStackView;
|
|
|
|
|
///id
|
|
|
|
|
@property (nonatomic,strong) UILabel *idLabel;
|
|
|
|
|
///性别
|
|
|
|
|
@property (nonatomic,strong) UIImageView *sexImageView;
|
|
|
|
|
///显示等级
|
|
|
|
|
@property (nonatomic,strong) YYLabel *levelLabel;
|
|
|
|
|
///我的账户 推荐给好友
|
|
|
|
|
@property (nonatomic,strong) XPMineAccountView *accountView;
|
2021-12-21 18:10:33 +08:00
|
|
|
|
///分割线
|
|
|
|
|
@property (nonatomic,strong) UIView * lineView;
|
|
|
|
|
///关注
|
|
|
|
|
@property (nonatomic,strong) XPMineFriendNumberView *attentionView;
|
|
|
|
|
///粉丝
|
|
|
|
|
@property (nonatomic,strong) XPMineFriendNumberView *fansView;
|
2022-01-06 17:50:59 +08:00
|
|
|
|
///贵族中心
|
|
|
|
|
@property (nonatomic, strong) XPNobleCenterEntranceView *nobleEntranceView;
|
|
|
|
|
|
2021-09-16 19:30:22 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation XPMineHeadView
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
|
|
|
{
|
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
|
if (self) {
|
|
|
|
|
[self initSubViews];
|
|
|
|
|
[self initSubViewConstraints];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Response
|
|
|
|
|
- (void)tapAvatarImageView {
|
|
|
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineHeadView:didClickAvatar:)]) {
|
|
|
|
|
[self.delegate xPMineHeadView:self didClickAvatar:self.userInfo];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-17 19:41:09 +08:00
|
|
|
|
- (void)tapAccountView {
|
|
|
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineHeadView:didClickAccount:)]) {
|
|
|
|
|
[self.delegate xPMineHeadView:self didClickAccount:self.userInfo];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)tapRecommendView {
|
|
|
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineHeadView:didClickInviteFriend:)]) {
|
|
|
|
|
[self.delegate xPMineHeadView:self didClickInviteFriend:self.userInfo];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-21 18:10:33 +08:00
|
|
|
|
- (void)tapFansRecognizer {
|
|
|
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickFans)]) {
|
|
|
|
|
[self.delegate xpMineHeadViewClickFans];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)tapAttentionRecognizer {
|
|
|
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickAttention)]) {
|
|
|
|
|
[self.delegate xpMineHeadViewClickAttention];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-06 17:50:59 +08:00
|
|
|
|
- (void)tapNobleCenterrecognizer {
|
|
|
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineHeadViewCliekNobleCenter)]) {
|
|
|
|
|
[self.delegate xPMineHeadViewCliekNobleCenter];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 19:30:22 +08:00
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
- (void)initSubViews {
|
|
|
|
|
self.backgroundColor = [UIColor clearColor];
|
|
|
|
|
[self addSubview:self.avatarImageView];
|
|
|
|
|
[self addSubview:self.nameStackView];
|
|
|
|
|
[self addSubview:self.idStackView];
|
|
|
|
|
[self addSubview:self.levelLabel];
|
2021-12-21 18:10:33 +08:00
|
|
|
|
[self addSubview:self.lineView];
|
|
|
|
|
[self addSubview:self.attentionView];
|
|
|
|
|
[self addSubview:self.fansView];
|
2021-09-16 19:30:22 +08:00
|
|
|
|
[self addSubview:self.accountView];
|
2022-01-06 17:50:59 +08:00
|
|
|
|
[self addSubview:self.nobleEntranceView];
|
|
|
|
|
|
2021-09-16 19:30:22 +08:00
|
|
|
|
[self.nameStackView addArrangedSubview:self.nameLabel];
|
|
|
|
|
[self.nameStackView addArrangedSubview:self.editButton];
|
|
|
|
|
[self.idStackView addArrangedSubview:self.idLabel];
|
|
|
|
|
[self.idStackView addArrangedSubview:self.sexImageView];
|
|
|
|
|
|
|
|
|
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAvatarImageView)];
|
|
|
|
|
[self.avatarImageView addGestureRecognizer:tap];
|
2021-09-17 19:41:09 +08:00
|
|
|
|
|
|
|
|
|
UITapGestureRecognizer * accountTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAccountView)];
|
|
|
|
|
[self.accountView.accountView addGestureRecognizer:accountTap];
|
|
|
|
|
|
|
|
|
|
UITapGestureRecognizer * recommendTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecommendView)];
|
|
|
|
|
[self.accountView.recommendView addGestureRecognizer:recommendTap];
|
2021-09-16 19:30:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(50, 50));
|
|
|
|
|
make.left.mas_equalTo(self).offset(20);
|
2021-12-21 18:10:33 +08:00
|
|
|
|
make.top.mas_equalTo(self).offset(30 + kSafeAreaTopHeight);
|
2021-09-16 19:30:22 +08:00
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.nameStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self.avatarImageView.mas_right).offset(17);
|
|
|
|
|
make.top.mas_equalTo(self.avatarImageView).offset(8);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.idStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self.nameStackView);
|
|
|
|
|
make.top.mas_equalTo(self.nameStackView.mas_bottom).offset(6);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.levelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self.nameStackView);
|
|
|
|
|
make.top.mas_equalTo(self.idStackView.mas_bottom).offset(4);
|
|
|
|
|
}];
|
|
|
|
|
|
2021-12-21 18:10:33 +08:00
|
|
|
|
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(1, 30));
|
|
|
|
|
make.centerY.mas_equalTo(self.idLabel.mas_bottom).offset(2);
|
|
|
|
|
make.left.mas_equalTo(self.idLabel.mas_right).offset(30);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.attentionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self.lineView.mas_right);
|
|
|
|
|
make.centerY.mas_equalTo(self.lineView);
|
|
|
|
|
make.width.mas_equalTo(80);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.fansView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.width.centerY.mas_equalTo(self.attentionView);
|
|
|
|
|
make.left.mas_equalTo(self.attentionView.mas_right);
|
|
|
|
|
}];
|
|
|
|
|
|
2021-09-16 19:30:22 +08:00
|
|
|
|
[self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.mas_equalTo(self);
|
|
|
|
|
make.height.mas_equalTo(60);
|
2021-12-21 18:10:33 +08:00
|
|
|
|
make.top.mas_equalTo(self.avatarImageView.mas_bottom).offset(30 + 20);
|
|
|
|
|
}];
|
2022-01-06 17:50:59 +08:00
|
|
|
|
|
|
|
|
|
CGFloat nobleH = (KScreenWidth - 30.0)/ 345.0 * 44;
|
|
|
|
|
[self.nobleEntranceView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.mas_equalTo(self);
|
|
|
|
|
make.height.mas_equalTo(nobleH);
|
|
|
|
|
make.top.mas_equalTo(self.accountView.mas_bottom).offset(12);
|
|
|
|
|
}];
|
2021-12-21 18:10:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - NSMutableAttributedString
|
|
|
|
|
-(NSInteger) getMonth:(long )time
|
|
|
|
|
{
|
|
|
|
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
|
|
|
|
|
NSCalendar* calendar = [NSCalendar currentCalendar];
|
|
|
|
|
NSDateComponents* components = [calendar components:NSCalendarUnitMonth fromDate:date];
|
|
|
|
|
NSInteger month = components.month;
|
|
|
|
|
return month;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSInteger) getDay:(long) time
|
|
|
|
|
{
|
|
|
|
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
|
|
|
|
|
NSCalendar* calendar = [NSCalendar currentCalendar];
|
|
|
|
|
NSDateComponents* components = [calendar components:NSCalendarUnitDay fromDate:date];
|
|
|
|
|
NSInteger day = components.day;
|
|
|
|
|
return day;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)calculateConstellationWithMonth:(long)time
|
|
|
|
|
{
|
|
|
|
|
NSString *astroString = @"魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
|
|
|
|
|
NSString *astroFormat = @"102123444543";
|
|
|
|
|
NSString *result;
|
|
|
|
|
|
|
|
|
|
NSInteger month = [self getMonth:time];
|
|
|
|
|
NSInteger day = [self getDay:time];
|
|
|
|
|
|
|
|
|
|
if (month<1 || month>12 || day<1 || day>31){
|
|
|
|
|
return @"错误日期格式!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(month==2 && day>29)
|
|
|
|
|
{
|
|
|
|
|
return @"错误日期格式!!";
|
|
|
|
|
}else if(month==4 || month==6 || month==9 || month==11) {
|
|
|
|
|
if (day>30) {
|
|
|
|
|
return @"错误日期格式!!!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result=[NSString stringWithFormat:@"%@",[astroString substringWithRange:NSMakeRange(month*2-(day < [[astroFormat substringWithRange:NSMakeRange((month-1), 1)] intValue] - (-19))*2,2)]];
|
|
|
|
|
|
|
|
|
|
return [NSString stringWithFormat:@"%@座",result];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 生成一个图片的富文本
|
|
|
|
|
/// @param imageUrl 网络图片的地址
|
|
|
|
|
- (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl {
|
|
|
|
|
NetImageConfig *config = [[NetImageConfig alloc]init];
|
|
|
|
|
///先这样吧
|
|
|
|
|
config.autoLoad = YES;
|
|
|
|
|
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config];
|
|
|
|
|
UIImage* image = imageView.image;
|
|
|
|
|
if (image) {
|
|
|
|
|
CGFloat scale = image.size.width / image.size.height;
|
|
|
|
|
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
|
|
|
|
} else {
|
|
|
|
|
NSURL *imgUrl = [NSURL URLWithString:imageUrl];
|
|
|
|
|
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
|
|
|
|
CGFloat scale = myImage.size.width / myImage.size.height;
|
|
|
|
|
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
|
|
|
|
}
|
|
|
|
|
imageView.layer.masksToBounds = YES;
|
|
|
|
|
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
|
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
|
|
|
|
return attrString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 占位的富文本
|
|
|
|
|
/// @param width 需要的间隙
|
|
|
|
|
- (NSMutableAttributedString *)createSapceAttribute:(CGFloat)width {
|
|
|
|
|
UIView *spaceView = [[UIView alloc]init];
|
|
|
|
|
spaceView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
spaceView.bounds = CGRectMake(0, 0, width, 10);
|
|
|
|
|
NSMutableAttributedString * attribute = [NSMutableAttributedString yy_attachmentStringWithContent:spaceView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(spaceView.frame.size.width, spaceView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
|
|
|
|
return attribute;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//dateLabel
|
|
|
|
|
- (NSMutableAttributedString *)makeDateLabel:(long)birth{
|
|
|
|
|
NSString *dateStr = [NSString stringWithFormat:@" %@ ",[self calculateConstellationWithMonth:birth]];
|
|
|
|
|
UIButton *dataButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[dataButton setTitle:dateStr forState:UIControlStateNormal];
|
|
|
|
|
dataButton.titleLabel.font = [UIFont boldSystemFontOfSize:10];
|
|
|
|
|
[dataButton setTitleColor:UIColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
|
|
|
|
|
dataButton.frame = CGRectMake(0, 0, 45, 17);
|
|
|
|
|
dataButton.layer.masksToBounds = YES;
|
|
|
|
|
dataButton.layer.cornerRadius = 17/2;
|
|
|
|
|
[dataButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
|
|
|
|
NSMutableAttributedString * dateLabelString = [NSMutableAttributedString yy_attachmentStringWithContent:dataButton contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(dataButton.frame.size.width, dataButton.frame.size.height) alignToFont:[UIFont systemFontOfSize:11] alignment:YYTextVerticalAlignmentCenter];
|
|
|
|
|
return dateLabelString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///铭牌
|
|
|
|
|
- (NSMutableAttributedString *)createNameplateAttibute:(NSString *)tagName image:(NSString *)imageName textFont:(UIFont *)textFont {
|
|
|
|
|
NetImageConfig *config = [[NetImageConfig alloc]init];
|
|
|
|
|
///先这样吧
|
|
|
|
|
config.autoLoad = YES;
|
|
|
|
|
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageName config:config];
|
|
|
|
|
UIImage* image = imageView.image;
|
|
|
|
|
if (image) {
|
|
|
|
|
CGFloat scale = image.size.width / image.size.height;
|
|
|
|
|
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
|
|
|
|
} else {
|
|
|
|
|
NSURL *imgUrl = [NSURL URLWithString:imageName];
|
|
|
|
|
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
|
|
|
|
CGFloat scale = myImage.size.width / myImage.size.height;
|
|
|
|
|
if (scale == 0) {
|
|
|
|
|
imageView.bounds = CGRectMake(0, 0, 60, 20);
|
|
|
|
|
}else {
|
|
|
|
|
imageView.bounds = CGRectMake(0, 0, 20* scale, 20);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
|
// 铭牌文字
|
|
|
|
|
UILabel *label = [[UILabel alloc] init];
|
|
|
|
|
label.textAlignment = NSTextAlignmentCenter;
|
|
|
|
|
label.font = [UIFont boldSystemFontOfSize:12];
|
|
|
|
|
label.adjustsFontSizeToFitWidth = YES;
|
|
|
|
|
label.textColor = UIColor.whiteColor;
|
|
|
|
|
label.text = tagName;
|
|
|
|
|
[imageView addSubview:label];
|
|
|
|
|
[label mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(27);
|
|
|
|
|
make.right.mas_equalTo(-8);
|
|
|
|
|
make.centerY.mas_equalTo(0);
|
2021-09-16 19:30:22 +08:00
|
|
|
|
}];
|
2021-12-21 18:10:33 +08:00
|
|
|
|
NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.bounds.size alignToFont:[UIFont boldSystemFontOfSize:12] alignment:YYTextVerticalAlignmentCenter];
|
|
|
|
|
return string;
|
2021-09-16 19:30:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-21 18:10:33 +08:00
|
|
|
|
///当装扮铭牌时,我的页面中不需要显示铭牌标识
|
|
|
|
|
- (NSMutableAttributedString *)creatNameplateLevleAttribute:(UserInfoModel *)userInfo {
|
|
|
|
|
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
|
|
|
|
|
|
|
|
|
|
if (!userInfo) {
|
|
|
|
|
return attributedString;
|
|
|
|
|
}
|
|
|
|
|
//主播认证
|
|
|
|
|
if (userInfo.nameplateWord.length > 0 && userInfo.nameplatePic.length>0) {
|
|
|
|
|
[self createNameplateAttibute:userInfo.nameplateWord image:userInfo.nameplatePic textFont:[UIFont systemFontOfSize:9]];
|
|
|
|
|
[attributedString appendAttributedString:[self createSapceAttribute:2]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// userRank 用户级别
|
|
|
|
|
if (userInfo.userLevelVo.experUrl) {
|
|
|
|
|
[attributedString appendAttributedString:[self createUrlImageAttribute:userInfo.userLevelVo.experUrl]];
|
|
|
|
|
[attributedString appendAttributedString:[self createSapceAttribute:2]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//charmRank 魅力等级
|
|
|
|
|
if (userInfo.userLevelVo.charmUrl) {
|
|
|
|
|
[attributedString appendAttributedString:[self createUrlImageAttribute:userInfo.userLevelVo.charmUrl]];
|
|
|
|
|
[attributedString appendAttributedString:[self createSapceAttribute:2]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// constellation 星座
|
|
|
|
|
if (userInfo.birth) {
|
|
|
|
|
[attributedString appendAttributedString:[self makeDateLabel:userInfo.birth]];
|
|
|
|
|
}
|
|
|
|
|
return attributedString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-09-16 19:30:22 +08:00
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
|
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
|
|
|
|
_userInfo = userInfo;
|
|
|
|
|
if (_userInfo) {
|
2021-12-17 19:31:26 +08:00
|
|
|
|
self.idLabel.text = [NSString stringWithFormat:@"大鹅号:%ld", (long)_userInfo.erbanNo];
|
2021-09-16 19:30:22 +08:00
|
|
|
|
self.nameLabel.text = _userInfo.nick.length > 0 ? _userInfo.nick : @"";
|
2021-11-03 18:11:27 +08:00
|
|
|
|
self.avatarImageView.imageUrl = userInfo.avatar;
|
2021-12-28 02:07:11 +08:00
|
|
|
|
if (userInfo.isReview) {
|
|
|
|
|
[self.avatarImageView loadImageWithUrl:userInfo.reviewingAvatar completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
|
|
|
|
|
UIImage * waterImage = [UIImage imageNamed:@"mine_avatar_reviewing"];
|
|
|
|
|
float ratio = waterImage.size.height / waterImage.size.width;
|
|
|
|
|
float rectY = image.size.height * (1 - ratio);
|
|
|
|
|
self.avatarImageView.image = [UIImage waterImageWithImage:image waterImage:waterImage waterImageRect:CGRectMake(0, rectY, image.size.width, image.size.height * ratio)];
|
|
|
|
|
}];
|
|
|
|
|
} else {
|
|
|
|
|
self.avatarImageView.imageUrl = userInfo.avatar;
|
|
|
|
|
}
|
2021-09-16 19:30:22 +08:00
|
|
|
|
NSString * sexName;
|
|
|
|
|
if (userInfo.gender == GenderType_Male) {
|
2021-09-17 19:41:09 +08:00
|
|
|
|
sexName = @"common_male";
|
2021-09-16 19:30:22 +08:00
|
|
|
|
} else {
|
2021-09-17 19:41:09 +08:00
|
|
|
|
sexName = @"common_female";
|
2021-09-16 19:30:22 +08:00
|
|
|
|
}
|
|
|
|
|
self.sexImageView.image = [UIImage imageNamed:sexName];
|
2021-12-21 18:10:33 +08:00
|
|
|
|
self.levelLabel.attributedText = [self creatNameplateLevleAttribute:_userInfo];
|
|
|
|
|
self.fansView.number = [NSString stringWithFormat:@"%ld",_userInfo.fansNum];
|
|
|
|
|
self.attentionView.number = [NSString stringWithFormat:@"%ld",_userInfo.followNum];
|
2022-01-10 20:31:56 +08:00
|
|
|
|
self.nobleEntranceView.hadNoble = userInfo.userVipInfoVO;
|
2021-09-16 19:30:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-03 18:11:27 +08:00
|
|
|
|
- (NetImageView *)avatarImageView {
|
2021-09-16 19:30:22 +08:00
|
|
|
|
if (!_avatarImageView) {
|
2021-11-25 17:35:31 +08:00
|
|
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
|
|
|
config.imageType = ImageTypeUserIcon;
|
|
|
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
|
|
|
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
2021-09-16 19:30:22 +08:00
|
|
|
|
_avatarImageView.userInteractionEnabled = YES;
|
|
|
|
|
_avatarImageView.layer.masksToBounds = YES;
|
|
|
|
|
_avatarImageView.layer.cornerRadius = 25;
|
|
|
|
|
}
|
|
|
|
|
return _avatarImageView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIStackView *)nameStackView {
|
|
|
|
|
if (!_nameStackView) {
|
|
|
|
|
_nameStackView = [[UIStackView alloc] init];
|
|
|
|
|
_nameStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
|
|
|
_nameStackView.distribution = UIStackViewDistributionFill;
|
|
|
|
|
_nameStackView.alignment = UIStackViewAlignmentCenter;
|
|
|
|
|
_nameStackView.spacing = 5;
|
|
|
|
|
}
|
|
|
|
|
return _nameStackView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)nameLabel {
|
|
|
|
|
if (!_nameLabel) {
|
|
|
|
|
_nameLabel = [[UILabel alloc] init];
|
|
|
|
|
_nameLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
|
|
|
|
|
_nameLabel.textColor = [ThemeColor mainTextColor];
|
|
|
|
|
}
|
|
|
|
|
return _nameLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)editButton {
|
|
|
|
|
if (!_editButton) {
|
|
|
|
|
_editButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_editButton setImage:[UIImage imageNamed:@"mine_head_name_edit"] forState:UIControlStateNormal];
|
|
|
|
|
[_editButton setImage:[UIImage imageNamed:@"mine_head_name_edit"] forState:UIControlStateSelected];
|
|
|
|
|
}
|
|
|
|
|
return _editButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (UIStackView *)idStackView {
|
|
|
|
|
if (!_idStackView) {
|
|
|
|
|
_idStackView = [[UIStackView alloc] init];
|
|
|
|
|
_idStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
|
|
|
_idStackView.distribution = UIStackViewDistributionFill;
|
|
|
|
|
_idStackView.alignment = UIStackViewAlignmentCenter;
|
|
|
|
|
_idStackView.spacing = 5;
|
|
|
|
|
}
|
|
|
|
|
return _idStackView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)idLabel {
|
|
|
|
|
if (!_idLabel) {
|
|
|
|
|
_idLabel = [[UILabel alloc] init];
|
|
|
|
|
_idLabel.font = [UIFont systemFontOfSize:13];
|
|
|
|
|
_idLabel.textColor = [ThemeColor secondTextColor];
|
|
|
|
|
}
|
|
|
|
|
return _idLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIImageView *)sexImageView {
|
|
|
|
|
if (!_sexImageView) {
|
|
|
|
|
_sexImageView = [[UIImageView alloc] init];
|
|
|
|
|
_sexImageView.userInteractionEnabled = YES;
|
|
|
|
|
}
|
|
|
|
|
return _sexImageView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (YYLabel *)levelLabel {
|
|
|
|
|
if (!_levelLabel) {
|
|
|
|
|
_levelLabel = [[YYLabel alloc] init];
|
|
|
|
|
_levelLabel.preferredMaxLayoutWidth = KScreenWidth - 88;
|
|
|
|
|
}
|
|
|
|
|
return _levelLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPMineAccountView *)accountView {
|
|
|
|
|
if (!_accountView) {
|
|
|
|
|
_accountView = [[XPMineAccountView alloc] init];
|
|
|
|
|
}
|
|
|
|
|
return _accountView;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-21 18:10:33 +08:00
|
|
|
|
- (UIView *)lineView {
|
|
|
|
|
if (!_lineView) {
|
|
|
|
|
_lineView = [[UIView alloc] init];
|
|
|
|
|
_lineView.backgroundColor = [ThemeColor dividerColor];
|
|
|
|
|
}
|
|
|
|
|
return _lineView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPMineFriendNumberView *)attentionView {
|
|
|
|
|
if (!_attentionView) {
|
|
|
|
|
_attentionView = [[XPMineFriendNumberView alloc] init];
|
|
|
|
|
_attentionView.title = @"关注";
|
|
|
|
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAttentionRecognizer)];
|
|
|
|
|
[_attentionView addGestureRecognizer:tap];
|
|
|
|
|
}
|
|
|
|
|
return _attentionView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPMineFriendNumberView *)fansView {
|
|
|
|
|
if (!_fansView) {
|
|
|
|
|
_fansView = [[XPMineFriendNumberView alloc] init];
|
|
|
|
|
_fansView.title = @"粉丝";
|
|
|
|
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapFansRecognizer)];
|
|
|
|
|
[_fansView addGestureRecognizer:tap];
|
|
|
|
|
}
|
|
|
|
|
return _fansView;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-06 17:50:59 +08:00
|
|
|
|
- (XPNobleCenterEntranceView *)nobleEntranceView {
|
|
|
|
|
if (!_nobleEntranceView) {
|
|
|
|
|
_nobleEntranceView = [[XPNobleCenterEntranceView alloc] init];
|
|
|
|
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapNobleCenterrecognizer)];
|
|
|
|
|
[_nobleEntranceView addGestureRecognizer:tap];
|
|
|
|
|
}
|
|
|
|
|
return _nobleEntranceView;
|
|
|
|
|
}
|
2021-09-16 19:30:22 +08:00
|
|
|
|
|
|
|
|
|
@end
|