262 lines
8.9 KiB
Objective-C
262 lines
8.9 KiB
Objective-C
//
|
|
// XPGiftWeekStarBroadcastView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by GreenLand on 2022/10/8.
|
|
//
|
|
|
|
#import "XPGiftWeekStarBroadcastView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
#import "NetImageView.h"
|
|
|
|
@interface XPGiftWeekStarBroadcastView()
|
|
|
|
///背景
|
|
@property (nonatomic, strong) UIImageView *bgImageView;
|
|
///周星榜入口
|
|
@property (nonatomic, strong) UIButton *weekStarButton;
|
|
///魅力头像
|
|
@property (nonatomic, strong) NetImageView *charmImageView;
|
|
///贡献头像
|
|
@property (nonatomic, strong) NetImageView *contributeImageView;
|
|
///魅力标题
|
|
@property (nonatomic, strong) UILabel *charmLabel;
|
|
///贡献标题
|
|
@property (nonatomic, strong) UILabel *contributeLabel;
|
|
///魅力昵称背景
|
|
@property (nonatomic, strong) UIView *charmBgView;
|
|
///魅力昵称
|
|
@property (nonatomic, strong) UILabel *charmNickLabel;
|
|
///贡献昵称背景
|
|
@property (nonatomic, strong) UIView *contributeBgView;
|
|
///贡献昵称
|
|
@property (nonatomic, strong) UILabel *contributeNickLabel;
|
|
|
|
@end
|
|
|
|
@implementation XPGiftWeekStarBroadcastView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self addSubview:self.bgImageView];
|
|
[self addSubview:self.weekStarButton];
|
|
[self addSubview:self.charmImageView];
|
|
[self addSubview:self.charmLabel];
|
|
[self addSubview:self.charmBgView];
|
|
[self addSubview:self.charmNickLabel];
|
|
[self addSubview:self.contributeImageView];
|
|
[self addSubview:self.contributeLabel];
|
|
[self addSubview:self.contributeBgView];
|
|
[self addSubview:self.contributeNickLabel];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(0);
|
|
make.left.right.mas_equalTo(self).inset(10);
|
|
make.height.mas_equalTo(44);
|
|
}];
|
|
[self.charmImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.bgImageView).mas_offset(10);
|
|
make.width.height.mas_equalTo(30);
|
|
make.centerY.mas_equalTo(self.bgImageView);
|
|
}];
|
|
[self.charmLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.charmImageView);
|
|
make.height.mas_equalTo(12);
|
|
make.left.mas_equalTo(self.charmImageView.mas_right).mas_offset(12);
|
|
}];
|
|
[self.charmBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self.charmNickLabel);
|
|
make.height.mas_equalTo(16);
|
|
make.left.right.mas_equalTo(self.charmNickLabel).inset(-6);
|
|
}];
|
|
[self.charmNickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.charmLabel.mas_bottom).mas_offset(6);
|
|
make.height.mas_equalTo(12);
|
|
make.left.mas_equalTo(self.charmLabel);
|
|
}];
|
|
|
|
[self.contributeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.charmLabel.mas_right).mas_offset(24);
|
|
make.width.height.mas_equalTo(30);
|
|
make.centerY.mas_equalTo(self.bgImageView);
|
|
}];
|
|
[self.contributeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.contributeImageView);
|
|
make.height.mas_equalTo(12);
|
|
make.left.mas_equalTo(self.contributeImageView.mas_right).mas_offset(12);
|
|
}];
|
|
[self.contributeBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self.contributeNickLabel);
|
|
make.height.mas_equalTo(16);
|
|
make.left.right.mas_equalTo(self.contributeNickLabel).inset(-6);
|
|
}];
|
|
[self.contributeNickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.contributeLabel.mas_bottom).mas_offset(6);
|
|
make.height.mas_equalTo(12);
|
|
make.left.mas_equalTo(self.contributeLabel);
|
|
}];
|
|
[self.weekStarButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(30);
|
|
make.centerY.mas_equalTo(self.bgImageView);
|
|
make.right.mas_equalTo(self.bgImageView).mas_offset(-7);
|
|
make.width.mas_equalTo(38);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - action
|
|
- (void)playButtonAction:(UIButton *)sender {
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftWeekStarBroadcastViewWeekStarClick)]) {
|
|
[self.delegate xPGiftWeekStarBroadcastViewWeekStarClick];
|
|
}
|
|
}
|
|
|
|
- (void)setGiftInfo:(GiftInfoModel *)giftInfo {
|
|
if (giftInfo.firstCharmRankUser) {
|
|
self.charmImageView.imageUrl = giftInfo.firstCharmRankUser.avatar;
|
|
NSString * nick = giftInfo.firstCharmRankUser.nick;
|
|
if (nick.length > 8) {
|
|
nick = [nick substringFromIndex:8];
|
|
}
|
|
self.charmNickLabel.text = nick;
|
|
} else {
|
|
self.charmImageView.image = [UIImageConstant defaultEmptyAvatarPlaceholder];
|
|
self.charmNickLabel.text = @"虚位以待";
|
|
}
|
|
|
|
if (giftInfo.firstLevelRankUser) {
|
|
self.contributeImageView.imageUrl = giftInfo.firstLevelRankUser.avatar;
|
|
NSString * nick = giftInfo.firstLevelRankUser.nick;
|
|
if (nick.length > 8) {
|
|
nick = [nick substringFromIndex:8];
|
|
}
|
|
self.contributeNickLabel.text = nick;
|
|
} else {
|
|
self.contributeImageView.image = [UIImageConstant defaultEmptyAvatarPlaceholder];
|
|
self.contributeNickLabel.text = @"虚位以待";
|
|
}
|
|
}
|
|
|
|
- (UIImageView *)bgImageView {
|
|
if (!_bgImageView) {
|
|
_bgImageView = [[UIImageView alloc] init];
|
|
_bgImageView.image = [UIImage imageNamed:@"gift_weekStar_background"];
|
|
_bgImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
}
|
|
return _bgImageView;
|
|
}
|
|
|
|
- (NetImageView *)charmImageView {
|
|
if (!_charmImageView) {
|
|
NetImageConfig *config = [[NetImageConfig alloc] init];
|
|
config.placeHolder = [UIImageConstant defaultEmptyAvatarPlaceholder];
|
|
_charmImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_charmImageView.userInteractionEnabled = YES;
|
|
_charmImageView.layer.masksToBounds = YES;
|
|
_charmImageView.layer.cornerRadius = 15;
|
|
}
|
|
return _charmImageView;
|
|
}
|
|
|
|
- (UILabel *)charmLabel {
|
|
if (!_charmLabel) {
|
|
UILabel *label = [[UILabel alloc] init];
|
|
label.font = [UIFont systemFontOfSize:10];
|
|
label.textColor = [ThemeColor mainTextColor];
|
|
label.text = @"本周该礼物冠名者";
|
|
_charmLabel = label;
|
|
}
|
|
return _charmLabel;
|
|
}
|
|
|
|
- (UIView *)charmBgView {
|
|
if (!_charmBgView) {
|
|
UIView *view = [[UIView alloc] init];
|
|
view.backgroundColor = UIColorRGBAlpha(0xffffff, 0.2);
|
|
view.layer.cornerRadius = 8;
|
|
view.layer.masksToBounds = YES;
|
|
_charmBgView = view;
|
|
}
|
|
return _charmBgView;
|
|
}
|
|
|
|
- (UILabel *)charmNickLabel {
|
|
if (!_charmNickLabel) {
|
|
UILabel *label = [[UILabel alloc] init];
|
|
label.font = [UIFont systemFontOfSize:10];
|
|
label.textColor = [UIColor whiteColor];
|
|
label.text = @"虚位以待";
|
|
_charmNickLabel = label;
|
|
}
|
|
return _charmNickLabel;
|
|
}
|
|
|
|
- (NetImageView *)contributeImageView {
|
|
if (!_contributeImageView) {
|
|
NetImageConfig *config = [[NetImageConfig alloc] init];
|
|
config.placeHolder = [UIImageConstant defaultEmptyAvatarPlaceholder];
|
|
_contributeImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_contributeImageView.userInteractionEnabled = YES;
|
|
_contributeImageView.layer.masksToBounds = YES;
|
|
_contributeImageView.layer.cornerRadius = 15;
|
|
}
|
|
return _contributeImageView;
|
|
}
|
|
|
|
- (UILabel *)contributeLabel {
|
|
if (!_contributeLabel) {
|
|
UILabel *label = [[UILabel alloc] init];
|
|
label.font = [UIFont systemFontOfSize:10];
|
|
label.textColor = [ThemeColor mainTextColor];
|
|
label.text = @"本周该礼物星神豪";
|
|
_contributeLabel = label;
|
|
}
|
|
return _contributeLabel;
|
|
}
|
|
|
|
- (UIView *)contributeBgView {
|
|
if (!_contributeBgView) {
|
|
UIView *view = [[UIView alloc] init];
|
|
view.backgroundColor = UIColorRGBAlpha(0xffffff, 0.2);
|
|
view.layer.cornerRadius = 8;
|
|
view.layer.masksToBounds = YES;
|
|
_contributeBgView = view;
|
|
}
|
|
return _contributeBgView;
|
|
}
|
|
- (UILabel *)contributeNickLabel {
|
|
if (!_contributeNickLabel) {
|
|
UILabel *label = [[UILabel alloc] init];
|
|
label.font = [UIFont systemFontOfSize:10];
|
|
label.textColor = [UIColor whiteColor];
|
|
label.text = @"虚位以待";
|
|
_contributeNickLabel = label;
|
|
}
|
|
return _contributeNickLabel;
|
|
}
|
|
|
|
- (UIButton *)weekStarButton {
|
|
if (!_weekStarButton) {
|
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[button setImage:[UIImage imageNamed:@"gift_weekStar_entrance"] forState:UIControlStateNormal];
|
|
[button addTarget:self action:@selector(playButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
_weekStarButton = button;
|
|
}
|
|
return _weekStarButton;
|
|
}
|
|
|
|
@end
|