2021-09-23 18:38:33 +08:00
|
|
|
|
//
|
|
|
|
|
// XPMineHeaderView.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by 冯硕 on 2021/9/22.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "XPMineUserInfoHeaderView.h"
|
|
|
|
|
///Third
|
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
|
#import <SDCycleScrollView/SDCycleScrollView.h>
|
|
|
|
|
#import "SDPhotoBrowser.h"
|
|
|
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
|
|
|
|
///Tool
|
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
|
#import "XPMacro.h"
|
2021-11-03 18:11:27 +08:00
|
|
|
|
#import "UIImage+ImageEffects.h"
|
2021-09-23 18:38:33 +08:00
|
|
|
|
///Model
|
|
|
|
|
#import "UserInfoModel.h"
|
|
|
|
|
|
2021-11-03 18:11:27 +08:00
|
|
|
|
#import "NetImageView.h"
|
|
|
|
|
|
2021-09-27 11:15:28 +08:00
|
|
|
|
@interface XPMineUserInfoImageCollectionViewCell : UICollectionViewCell
|
|
|
|
|
///
|
2021-11-03 18:11:27 +08:00
|
|
|
|
@property (nonatomic,strong) NetImageView *logoImageView;
|
2021-09-27 11:15:28 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation XPMineUserInfoImageCollectionViewCell
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
|
|
|
{
|
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
|
if (self) {
|
|
|
|
|
[self initSubViews];
|
|
|
|
|
[self initSubViewConstraints];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
- (void)initSubViews {
|
|
|
|
|
[self.contentView addSubview:self.logoImageView];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
|
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.edges.mas_equalTo(self.contentView);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Getters And Setters
|
2021-11-03 18:11:27 +08:00
|
|
|
|
- (NetImageView *)logoImageView {
|
2021-09-27 11:15:28 +08:00
|
|
|
|
if (!_logoImageView) {
|
2021-11-25 17:35:31 +08:00
|
|
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
|
|
|
config.imageType = ImageTypeUserInfoAlbum;
|
|
|
|
|
_logoImageView = [[NetImageView alloc] initWithConfig:config];
|
2021-09-27 11:15:28 +08:00
|
|
|
|
_logoImageView.userInteractionEnabled = YES;
|
|
|
|
|
_logoImageView.layer.masksToBounds = YES;
|
|
|
|
|
_logoImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
|
|
}
|
|
|
|
|
return _logoImageView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
2021-09-23 18:38:33 +08:00
|
|
|
|
@interface XPMineUserInfoHeaderView ()<SDCycleScrollViewDelegate, SDPhotoBrowserDelegate>
|
|
|
|
|
///轮播图
|
|
|
|
|
@property (nonatomic,strong) SDCycleScrollView *cycleScrollView;
|
|
|
|
|
///显示当前的页数
|
|
|
|
|
@property (nonatomic,strong) UILabel *pageLabel;
|
2021-12-28 02:07:11 +08:00
|
|
|
|
///审核中图标
|
|
|
|
|
@property (nonatomic,strong) UIImageView *reviewIcon;
|
2021-09-23 18:38:33 +08:00
|
|
|
|
///图片数组
|
|
|
|
|
@property (nonatomic,strong) NSArray *imageUrls;
|
2021-12-02 20:34:48 +08:00
|
|
|
|
///背景
|
|
|
|
|
@property (nonatomic,strong) UIView * backView;
|
|
|
|
|
///名字
|
|
|
|
|
@property (nonatomic,strong) UILabel *nameLabel;
|
|
|
|
|
///sex
|
|
|
|
|
@property (nonatomic,strong) UIImageView *sexImageView;
|
|
|
|
|
///id
|
|
|
|
|
@property (nonatomic,strong) UILabel *idLabel;
|
|
|
|
|
///签名
|
|
|
|
|
@property (nonatomic,strong) UILabel *signLabel;
|
|
|
|
|
///正在直播中
|
|
|
|
|
@property (nonatomic,strong) UIButton *onlineButton;
|
2021-09-23 18:38:33 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation XPMineUserInfoHeaderView
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
|
if (self) {
|
|
|
|
|
[self initSubViews];
|
|
|
|
|
[self initSubViewConstraints];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
2021-10-14 21:10:04 +08:00
|
|
|
|
|
2021-09-23 18:38:33 +08:00
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
|
[self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.edges.mas_equalTo(self);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.pageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.right.mas_equalTo(-15);
|
|
|
|
|
make.width.mas_equalTo(35);
|
|
|
|
|
make.height.mas_equalTo(16);
|
|
|
|
|
make.top.mas_equalTo(self).offset(148 + kSafeAreaTopHeight);
|
|
|
|
|
}];
|
2021-12-28 02:07:11 +08:00
|
|
|
|
|
|
|
|
|
[self.reviewIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.right.mas_equalTo(self);
|
|
|
|
|
make.width.mas_equalTo(85);
|
|
|
|
|
make.height.mas_equalTo(50);
|
|
|
|
|
}];
|
2021-12-02 20:34:48 +08:00
|
|
|
|
|
|
|
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.mas_equalTo(self).inset(15);
|
|
|
|
|
make.bottom.mas_equalTo(self).offset(20);
|
|
|
|
|
make.height.mas_equalTo(100);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self.backView).offset(15);
|
|
|
|
|
make.top.mas_equalTo(self.backView).offset(15);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self.nameLabel.mas_right).offset(5);
|
|
|
|
|
make.centerY.mas_equalTo(self.nameLabel);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self.nameLabel);
|
|
|
|
|
make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(10);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self.nameLabel);
|
|
|
|
|
make.top.mas_equalTo(self.idLabel.mas_bottom).offset(18);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(55, 18));
|
|
|
|
|
make.right.mas_equalTo(self.backView).offset(-15);
|
|
|
|
|
make.top.mas_equalTo(self.backView).offset(10);
|
|
|
|
|
}];
|
2021-09-23 18:38:33 +08:00
|
|
|
|
}
|
2021-12-02 20:34:48 +08:00
|
|
|
|
|
|
|
|
|
- (void)initSubViews {
|
|
|
|
|
[self addSubview:self.cycleScrollView];
|
|
|
|
|
[self addSubview:self.pageLabel];
|
2021-12-28 02:07:11 +08:00
|
|
|
|
[self addSubview:self.reviewIcon];
|
2021-12-02 20:34:48 +08:00
|
|
|
|
[self addSubview:self.backView];
|
|
|
|
|
[self.backView addSubview:self.nameLabel];
|
|
|
|
|
[self.backView addSubview:self.sexImageView];
|
|
|
|
|
[self.backView addSubview:self.idLabel];
|
|
|
|
|
[self.backView addSubview:self.signLabel];
|
|
|
|
|
[self.backView addSubview:self.onlineButton];
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 18:38:33 +08:00
|
|
|
|
#pragma mark - SDPhotoBrowserDelegate
|
|
|
|
|
- (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index {
|
|
|
|
|
NSString * photoUrl = [self.imageUrls objectAtIndex:index];
|
|
|
|
|
return [NSURL URLWithString:photoUrl];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index {
|
2021-09-27 11:15:28 +08:00
|
|
|
|
return [UIImageConstant defalutBannerPlaceholder];
|
2021-09-23 18:38:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - SDCycleScrollViewDelegate
|
2021-09-27 11:15:28 +08:00
|
|
|
|
/** 如果你需要自定义cell样式,请在实现此代理方法返回你的自定义cell的class。 */
|
|
|
|
|
- (Class)customCollectionViewCellClassForCycleScrollView:(SDCycleScrollView *)view {
|
|
|
|
|
return [XPMineUserInfoImageCollectionViewCell class];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setupCustomCell:(UICollectionViewCell *)cell forIndex:(NSInteger)index cycleScrollView:(SDCycleScrollView *)view {
|
2021-11-03 18:11:27 +08:00
|
|
|
|
XPMineUserInfoImageCollectionViewCell * imageCell = (XPMineUserInfoImageCollectionViewCell *)cell;
|
|
|
|
|
NSString *url = [self.imageUrls objectAtIndex:index];
|
2021-11-30 19:18:57 +08:00
|
|
|
|
imageCell.logoImageView.imageUrl = url;
|
2021-09-27 11:15:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 18:38:33 +08:00
|
|
|
|
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index {
|
2021-12-02 20:34:48 +08:00
|
|
|
|
self.pageLabel.text = [NSString stringWithFormat:@"%ld/%lu",(index + 1), (unsigned long)self.imageUrls.count];
|
2021-12-28 02:07:11 +08:00
|
|
|
|
UserPhoto * photo = [self.userInfo.privatePhoto objectAtIndex:index];
|
|
|
|
|
self.reviewIcon.hidden = !photo.isReview;
|
2021-09-23 18:38:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 轮播图点击
|
|
|
|
|
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
|
|
|
|
|
NSInteger count = self.imageUrls.count;
|
|
|
|
|
SDPhotoBrowser *browser = [[SDPhotoBrowser alloc]init];
|
|
|
|
|
browser.sourceImagesContainerView = self.cycleScrollView;
|
|
|
|
|
browser.delegate = self;
|
|
|
|
|
browser.imageCount = count;
|
|
|
|
|
browser.currentImageIndex = index;
|
|
|
|
|
browser.isMe = NO;
|
|
|
|
|
[browser show];
|
|
|
|
|
}
|
2021-12-02 20:34:48 +08:00
|
|
|
|
|
|
|
|
|
#pragma mark - Event Response
|
|
|
|
|
- (void)onlineButtonAction:(UIButton *)sender {
|
|
|
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineUserInfoHeaderView:didClickGoToRoom:)]) {
|
|
|
|
|
[self.delegate xPMineUserInfoHeaderView:self didClickGoToRoom:self.userInfo.roomUid];
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-23 18:38:33 +08:00
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
|
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
|
|
|
|
_userInfo = userInfo;
|
2021-12-02 20:34:48 +08:00
|
|
|
|
if (_userInfo) {
|
|
|
|
|
self.nameLabel.text = _userInfo.nick;
|
|
|
|
|
self.idLabel.text = [NSString stringWithFormat:@"%@号:%ld",AppName, (long)_userInfo.erbanNo];
|
|
|
|
|
self.signLabel.text = _userInfo.userDesc.length > 0 ? _userInfo.userDesc : @"我是个默认签名";
|
|
|
|
|
NSString * sexStr;
|
|
|
|
|
if (_userInfo.gender == GenderType_Male) {
|
|
|
|
|
sexStr = @"common_male";
|
2021-09-23 18:38:33 +08:00
|
|
|
|
} else {
|
2021-12-02 20:34:48 +08:00
|
|
|
|
sexStr = @"common_female";
|
|
|
|
|
}
|
|
|
|
|
self.sexImageView.image = [UIImage imageNamed:sexStr];
|
|
|
|
|
self.onlineButton.hidden = _userInfo.roomUid.length <=0;
|
|
|
|
|
|
|
|
|
|
// 轮播图
|
|
|
|
|
NSMutableArray * imageUrls;
|
|
|
|
|
if (self.userInfo.privatePhoto.count > 0) {
|
|
|
|
|
imageUrls = [[[self.userInfo.privatePhoto.rac_sequence map:^id _Nullable(UserPhoto * _Nullable value) {
|
|
|
|
|
return value.photoUrl;
|
|
|
|
|
}] array] mutableCopy] ;
|
|
|
|
|
}
|
|
|
|
|
if (self.userInfo.avatar.length > 0) {
|
|
|
|
|
if (imageUrls.count >0) {
|
|
|
|
|
[imageUrls addObject:self.userInfo.avatar];
|
|
|
|
|
} else {
|
|
|
|
|
imageUrls = [NSMutableArray array];
|
|
|
|
|
[imageUrls addObject:self.userInfo.avatar];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (imageUrls.count > 0) {
|
|
|
|
|
self.imageUrls = imageUrls;
|
|
|
|
|
self.cycleScrollView.imageURLStringsGroup = imageUrls;
|
|
|
|
|
self.pageLabel.text = [NSString stringWithFormat:@"1/%lu",(unsigned long)imageUrls.count];
|
2021-12-28 02:07:11 +08:00
|
|
|
|
// 要初始化一下当前的审核状态
|
|
|
|
|
self.reviewIcon.hidden = ![self.userInfo.privatePhoto objectAtIndex:0].isReview;
|
2021-09-23 18:38:33 +08:00
|
|
|
|
}
|
2021-12-02 20:34:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIView *)backView {
|
|
|
|
|
if (!_backView) {
|
|
|
|
|
_backView = [[UIView alloc] init];
|
|
|
|
|
_backView.backgroundColor = [ThemeColor appCellBackgroundColor];
|
|
|
|
|
_backView.layer.masksToBounds = YES;
|
|
|
|
|
_backView.layer.cornerRadius = 12;
|
|
|
|
|
}
|
|
|
|
|
return _backView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)nameLabel {
|
|
|
|
|
if (!_nameLabel) {
|
|
|
|
|
_nameLabel = [[UILabel alloc] init];
|
|
|
|
|
_nameLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
|
|
|
|
|
_nameLabel.textColor = [ThemeColor mainTextColor];
|
|
|
|
|
}
|
|
|
|
|
return _nameLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIImageView *)sexImageView {
|
|
|
|
|
if (!_sexImageView) {
|
|
|
|
|
_sexImageView = [[UIImageView alloc] init];
|
|
|
|
|
_sexImageView.userInteractionEnabled = YES;
|
|
|
|
|
}
|
|
|
|
|
return _sexImageView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)idLabel {
|
|
|
|
|
if (!_idLabel) {
|
|
|
|
|
_idLabel = [[UILabel alloc] init];
|
|
|
|
|
_idLabel.font = [UIFont systemFontOfSize:11];
|
|
|
|
|
_idLabel.textColor = [ThemeColor textThirdColor];
|
|
|
|
|
}
|
|
|
|
|
return _idLabel;
|
|
|
|
|
}
|
2021-09-23 18:38:33 +08:00
|
|
|
|
|
2021-12-02 20:34:48 +08:00
|
|
|
|
- (UILabel *)signLabel {
|
|
|
|
|
if (!_signLabel) {
|
|
|
|
|
_signLabel = [[UILabel alloc] init];
|
|
|
|
|
_signLabel.font = [UIFont systemFontOfSize:11];;
|
|
|
|
|
_signLabel.textColor = [ThemeColor secondTextColor];
|
2021-09-23 18:38:33 +08:00
|
|
|
|
}
|
2021-12-02 20:34:48 +08:00
|
|
|
|
return _signLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)onlineButton {
|
|
|
|
|
if (!_onlineButton) {
|
|
|
|
|
_onlineButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_onlineButton setTitle:@"直播中" forState:UIControlStateNormal];
|
|
|
|
|
[_onlineButton setImage:[UIImage imageNamed:@"home_search_user_online"] forState:UIControlStateNormal];
|
2021-12-17 19:31:26 +08:00
|
|
|
|
[_onlineButton setTitleColor:[ThemeColor appEmphasizeColor] forState:UIControlStateNormal];
|
2021-12-02 20:34:48 +08:00
|
|
|
|
_onlineButton.backgroundColor = [UIColor clearColor];
|
|
|
|
|
_onlineButton.titleLabel.font = [UIFont systemFontOfSize:10];
|
|
|
|
|
_onlineButton.layer.masksToBounds = YES;
|
|
|
|
|
_onlineButton.layer.cornerRadius = 18/2;
|
2021-12-17 19:31:26 +08:00
|
|
|
|
_onlineButton.layer.borderColor = [ThemeColor appEmphasizeColor].CGColor;
|
2021-12-02 20:34:48 +08:00
|
|
|
|
_onlineButton.layer.borderWidth = 1;
|
|
|
|
|
_onlineButton.hidden = YES;
|
|
|
|
|
[_onlineButton addTarget:self action:@selector(onlineButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
2021-09-23 18:38:33 +08:00
|
|
|
|
}
|
2021-12-02 20:34:48 +08:00
|
|
|
|
return _onlineButton;
|
2021-09-23 18:38:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (SDCycleScrollView *)cycleScrollView {
|
|
|
|
|
if (!_cycleScrollView) {
|
|
|
|
|
_cycleScrollView = [[SDCycleScrollView alloc] init];
|
|
|
|
|
_cycleScrollView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
_cycleScrollView.delegate = self;
|
|
|
|
|
_cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
|
|
|
|
|
_cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;;
|
2021-09-27 11:15:28 +08:00
|
|
|
|
_cycleScrollView.placeholderImage = [UIImageConstant defaultAvatarPlaceholder];
|
2021-09-23 18:38:33 +08:00
|
|
|
|
_cycleScrollView.autoScroll = NO;
|
|
|
|
|
}
|
|
|
|
|
return _cycleScrollView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)pageLabel {
|
|
|
|
|
if (!_pageLabel) {
|
|
|
|
|
_pageLabel = [[UILabel alloc] init];
|
|
|
|
|
_pageLabel.font = [UIFont systemFontOfSize:10];
|
2021-12-11 17:10:33 +08:00
|
|
|
|
_pageLabel.textColor = [ThemeColor mainTextColor];
|
2021-09-23 18:38:33 +08:00
|
|
|
|
_pageLabel.textAlignment = NSTextAlignmentCenter;
|
2021-12-11 17:10:33 +08:00
|
|
|
|
_pageLabel.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1];
|
2021-09-23 18:38:33 +08:00
|
|
|
|
_pageLabel.layer.masksToBounds = YES;
|
|
|
|
|
_pageLabel.layer.cornerRadius = 8;
|
|
|
|
|
}
|
|
|
|
|
return _pageLabel;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-28 02:07:11 +08:00
|
|
|
|
- (UIImageView *)reviewIcon {
|
|
|
|
|
if (!_reviewIcon) {
|
|
|
|
|
_reviewIcon = [[UIImageView alloc] init];
|
|
|
|
|
_reviewIcon.image = [UIImage imageNamed:@"mine_album_reviewing"];
|
|
|
|
|
_reviewIcon.hidden = YES;
|
|
|
|
|
}
|
|
|
|
|
return _reviewIcon;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 18:38:33 +08:00
|
|
|
|
@end
|