提交
This commit is contained in:
328
QXLive/Mine(音域)/View/个人主页/QXUserHomeHeaderView.m
Normal file
328
QXLive/Mine(音域)/View/个人主页/QXUserHomeHeaderView.m
Normal file
@@ -0,0 +1,328 @@
|
||||
//
|
||||
// QXUserHomeHeaderView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/20.
|
||||
//
|
||||
|
||||
#import "QXUserHomeHeaderView.h"
|
||||
#import "QXSeatHeaderView.h"
|
||||
#import "QXSearchCell.h"
|
||||
#import "NSDate+BRPickerView.h"
|
||||
#import "NSString+QX.h"
|
||||
#import "QXDynamicNetwork.h"
|
||||
#import "QXChatViewController.h"
|
||||
|
||||
@interface QXUserHomeHeaderView()<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
@property (nonatomic,strong) QXSeatHeaderView* headerView;
|
||||
@property (nonatomic,strong) UIView * whiteBgView;
|
||||
@property (nonatomic,strong) UIView * grayBgView;
|
||||
@property (nonatomic,strong) UILabel * nameLabel;
|
||||
@property (nonatomic,strong) UILabel * idLabel;
|
||||
@property (nonatomic,strong) UILabel * ageLabel;
|
||||
@property (nonatomic,strong) UICollectionView * collectionView;
|
||||
@property (nonatomic,strong) NSMutableArray * tagArray;
|
||||
@property (nonatomic,strong) UILabel *introduceLabel;
|
||||
@property (nonatomic,strong) UICollectionView *inCollectionView;
|
||||
@property (nonatomic, strong) UIImageView *useCodeImageView;
|
||||
@property (nonatomic, strong)UIImageView *sexImageView;
|
||||
|
||||
@property (nonatomic,strong) UIButton *followBtn;
|
||||
@property (nonatomic,strong) UIButton *playBtn;
|
||||
@end
|
||||
|
||||
@implementation QXUserHomeHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
|
||||
self.headerView = [[QXSeatHeaderView alloc] initWithFrame:CGRectMake(32, 46, 70, 70)];
|
||||
[self.headerView addRoundedCornersWithRadius:35];
|
||||
[self addSubview:self.headerView];
|
||||
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(32);
|
||||
make.height.width.mas_equalTo(70);
|
||||
make.top.mas_equalTo(26);
|
||||
}];
|
||||
|
||||
self.sexImageView = [[UIImageView alloc] init];
|
||||
[self addSubview:self.sexImageView];
|
||||
[self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.bottom.equalTo(self.headerView);
|
||||
make.height.width.mas_equalTo(16);
|
||||
}];
|
||||
|
||||
self.nameLabel = [[UILabel alloc] init];
|
||||
self.nameLabel.textColor = QXConfig.textColor;
|
||||
self.nameLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
[self addSubview:self.nameLabel];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.headerView);
|
||||
make.height.mas_equalTo(24);
|
||||
make.top.equalTo(self.headerView.mas_bottom).offset(4);
|
||||
}];
|
||||
|
||||
self.idLabel = [[UILabel alloc] init];
|
||||
self.idLabel.textColor = RGB16(0x999999);
|
||||
self.idLabel.font = [UIFont boldSystemFontOfSize:12];
|
||||
[self addSubview:self.idLabel];
|
||||
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.nameLabel.mas_right).offset(12);
|
||||
make.height.mas_equalTo(24);
|
||||
make.centerY.equalTo(self.nameLabel);
|
||||
}];
|
||||
|
||||
self.useCodeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_usercode_isLiang"]];
|
||||
self.useCodeImageView.hidden = YES;
|
||||
[self addSubview:self.useCodeImageView];
|
||||
[self.useCodeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.idLabel.mas_right).offset(5);
|
||||
make.height.mas_equalTo(11);
|
||||
make.width.mas_equalTo(31);
|
||||
make.centerY.equalTo(self.idLabel);
|
||||
}];
|
||||
|
||||
self.ageLabel = [[UILabel alloc] init];
|
||||
self.ageLabel.textColor = RGB16(0x999999);
|
||||
self.ageLabel.font = [UIFont boldSystemFontOfSize:12];
|
||||
[self addSubview:self.ageLabel];
|
||||
[self.ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.headerView);
|
||||
make.height.mas_equalTo(18);
|
||||
make.top.equalTo(self.nameLabel.mas_bottom).offset(8);
|
||||
make.width.mas_greaterThanOrEqualTo(35);
|
||||
}];
|
||||
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake(42, 16);
|
||||
layout.minimumLineSpacing = 7;
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
[self.collectionView registerClass:[QXTagImageCell class] forCellWithReuseIdentifier:@"QXTagImageCell"];
|
||||
[self addSubview:self.collectionView];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.ageLabel.mas_right).offset(8);
|
||||
make.height.mas_equalTo(18);
|
||||
make.centerY.equalTo(self.ageLabel);
|
||||
make.width.mas_equalTo(300);
|
||||
}];
|
||||
|
||||
|
||||
self.introduceLabel = [[UILabel alloc] init];
|
||||
self.introduceLabel.textColor = QXConfig.textColor;
|
||||
self.introduceLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.introduceLabel.numberOfLines = 0;
|
||||
[self addSubview:self.introduceLabel];
|
||||
[self.introduceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.headerView);
|
||||
make.top.equalTo(self.ageLabel.mas_bottom).offset(4);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH-64);
|
||||
make.height.mas_greaterThanOrEqualTo(22);
|
||||
}];
|
||||
|
||||
UICollectionViewFlowLayout *inlayout = [[UICollectionViewFlowLayout alloc] init];
|
||||
inlayout.itemSize = CGSizeMake(77, 22);
|
||||
inlayout.minimumLineSpacing = 12;
|
||||
inlayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
self.inCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:inlayout];
|
||||
self.inCollectionView.delegate = self;
|
||||
self.inCollectionView.dataSource = self;
|
||||
self.inCollectionView.showsHorizontalScrollIndicator = NO;
|
||||
[self.inCollectionView registerClass:[QXSearchCell class] forCellWithReuseIdentifier:@"QXSearchCell"];
|
||||
[self addSubview:self.inCollectionView];
|
||||
[self.inCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.headerView);
|
||||
make.height.mas_equalTo(22);
|
||||
make.top.equalTo(self.introduceLabel.mas_bottom).offset(4);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH-64);
|
||||
}];
|
||||
|
||||
|
||||
self.whiteBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 46, self.width, 167)];
|
||||
self.whiteBgView.backgroundColor = [UIColor whiteColor];
|
||||
[self.whiteBgView addRoundedCornersWithRadius:16];
|
||||
[self insertSubview:self.whiteBgView belowSubview:self.headerView];
|
||||
[self.whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH-32);
|
||||
make.top.equalTo(self.headerView.mas_top).offset(20);
|
||||
make.bottom.equalTo(self);
|
||||
}];
|
||||
|
||||
self.grayBgView = [[UIView alloc] initWithFrame:CGRectMake(0, self.whiteBgView.top+75, self.width, 92)];
|
||||
self.grayBgView.backgroundColor = RGB16(0xF6F6F6);
|
||||
[self.grayBgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
||||
[self insertSubview:self.grayBgView belowSubview:self.whiteBgView];
|
||||
[self.grayBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self);
|
||||
make.height.mas_equalTo(92);
|
||||
make.bottom.equalTo(self.whiteBgView);
|
||||
}];
|
||||
|
||||
self.playBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.playBtn.left-6-91, self.whiteBgView.top+10, 91, 35)];
|
||||
[self.playBtn setTitle:QXText(@"私信") forState:(UIControlStateNormal)];
|
||||
[self.playBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
|
||||
self.playBtn.backgroundColor = RGB16(0x333333);
|
||||
self.playBtn.hidden = YES;
|
||||
self.playBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.playBtn addRoundedCornersWithRadius:17.5];
|
||||
[self.playBtn addTarget:self action:@selector(playAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.playBtn];
|
||||
[self.playBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(-27);
|
||||
make.width.mas_equalTo(91);
|
||||
make.height.mas_equalTo(35);
|
||||
make.top.equalTo(self.whiteBgView).offset(10);
|
||||
}];
|
||||
|
||||
self.followBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.playBtn.left-6-91, self.whiteBgView.top+10, 91, 35)];
|
||||
[self.followBtn setTitle:QXText(@"关注") forState:(UIControlStateNormal)];
|
||||
[self.followBtn setTitle:QXText(@"已关注") forState:(UIControlStateSelected)];
|
||||
[self.followBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
[self.followBtn setTitleColor:RGB16(0x999999) forState:(UIControlStateSelected)];
|
||||
[self.followBtn setBackgroundImage:[UIImage imageWithColor:QXConfig.themeColor] forState:UIControlStateNormal];
|
||||
[self.followBtn setBackgroundImage:[UIImage imageWithColor:RGB16(0xF1F2F3)] forState:UIControlStateSelected];
|
||||
self.followBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.followBtn addRoundedCornersWithRadius:17.5];
|
||||
self.followBtn.hidden = YES;
|
||||
[self.followBtn addTarget:self action:@selector(followAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.followBtn];
|
||||
[self.followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.playBtn.mas_left).offset(-6);
|
||||
make.width.mas_equalTo(91);
|
||||
make.height.mas_equalTo(35);
|
||||
make.centerY.equalTo(self.playBtn);
|
||||
}];
|
||||
// self.nameLabel.text = @"张三";
|
||||
// self.idLabel.text = @"313213213";
|
||||
// self.ageLabel.text = @"36岁";
|
||||
// self.introduceLabel.text = @"个人简介个人简介个人简介个人简个人简介";
|
||||
[self.inCollectionView reloadData];
|
||||
}
|
||||
|
||||
-(void)followAction{
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork followWithUserId:self.model.user_id type:@"1" successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
weakSelf.followBtn.selected = !weakSelf.followBtn.selected;
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
-(void)playAction{
|
||||
if (self.model.room_id.intValue > 0) {
|
||||
// 去房间
|
||||
[[QXGlobal shareGlobal] joinRoomWithRoomId:self.model.room_id isRejoin:NO navagationController:self.navigationController];
|
||||
}else{
|
||||
// 去聊天
|
||||
[[QXGlobal shareGlobal] chatWithUserID:self.model.user_id nickname:self.model.nickname avatar:self.model.avatar navagationController:self.navigationController];
|
||||
}
|
||||
}
|
||||
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
if (collectionView == self.collectionView) {
|
||||
return self.model.icon.count;
|
||||
}else{
|
||||
return self.model.tag_list.count;
|
||||
}
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if (collectionView == self.collectionView) {
|
||||
QXTagImageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXTagImageCell" forIndexPath:indexPath];
|
||||
cell.imageUrl = self.model.icon[indexPath.row];
|
||||
return cell;
|
||||
}else{
|
||||
QXSearchCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSearchCell" forIndexPath:indexPath];
|
||||
cell.cellType = QXSearchCellTypeIntroduce;
|
||||
cell.userTag = self.model.tag_list[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
}
|
||||
-(void)setModel:(QXUserHomeModel *)model{
|
||||
_model = model;
|
||||
[self.headerView setHeadIcon:model.avatar dress:model.dress];
|
||||
self.nameLabel.text = model.nickname;
|
||||
self.idLabel.text = [NSString stringWithFormat:@"ID:%@",model.user_code];
|
||||
self.ageLabel.text = [NSString stringWithFormat:@"%@|%ld岁",model.sex.intValue==1?QXText(@"男"):QXText(@"女"),[model.birthday ageWithDateOfBirth]];
|
||||
self.introduceLabel.text = model.profile;
|
||||
[self.inCollectionView reloadData];
|
||||
[self.collectionView reloadData];
|
||||
if ([model.user_id isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) {
|
||||
self.followBtn.hidden = YES;
|
||||
self.playBtn.hidden = YES;
|
||||
}else{
|
||||
self.followBtn.hidden = NO;
|
||||
self.playBtn.hidden = NO;
|
||||
self.followBtn.selected = model.is_follow==0?NO:YES;
|
||||
if (model.room_id.intValue > 0) {
|
||||
[self.playBtn setTitle:QXText(@"跟随") forState:(UIControlStateNormal)];
|
||||
}else{
|
||||
[self.playBtn setTitle:QXText(@"私信") forState:(UIControlStateNormal)];
|
||||
}
|
||||
}
|
||||
|
||||
if (model.is_use_code.intValue == 1) {
|
||||
self.useCodeImageView.hidden = NO;
|
||||
}else{
|
||||
self.useCodeImageView.hidden = YES;
|
||||
}
|
||||
UIImage *sexImage = [UIImage imageNamed:model.sex.intValue==1?@"user_sex_boy":@"user_sex_girl"];
|
||||
self.sexImageView.image = sexImage;
|
||||
}
|
||||
|
||||
-(NSMutableArray *)tagArray{
|
||||
if (!_tagArray) {
|
||||
_tagArray = [NSMutableArray array];
|
||||
}
|
||||
return _tagArray;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXTagImageCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setImageUrl:(NSString *)imageUrl{
|
||||
_imageUrl = imageUrl;
|
||||
if ([imageUrl hasPrefix:@"http"] || [imageUrl hasPrefix:@"https"]) {
|
||||
[self.imageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:nil];
|
||||
}else{
|
||||
if ([imageUrl isEqualToString:@"mine_room_cover_add"]) {
|
||||
self.imageView.image = [UIImage imageNamed:imageUrl];
|
||||
}else{
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,imageUrl];
|
||||
[self.imageView sd_setImageWithURL:[NSURL URLWithString:fileUrl] placeholderImage:nil];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.imageView = [[UIImageView alloc] initWithFrame:self.bounds];
|
||||
[self.contentView addSubview:self.imageView];
|
||||
self.imageView.contentMode = UIViewContentModeScaleToFill;
|
||||
self.imageView.clipsToBounds = YES;
|
||||
// [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.top.bottom.left.right.equalTo(self.contentView);
|
||||
// }];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user