123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- //
- // XYLiveNobleListBottomView.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/1/17.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYLiveNobleListBottomView.h"
- #import "XYLiveNobleListCellModel.h"
- @interface XYLiveNobleListBottomView ()
- // 非贵族显示的view
- @property (nonatomic, readwrite, strong) UIView *noNobleView;
- @property (nonatomic, readwrite, strong) UILabel *noNoblerTitleLabel;
- // 贵族view
- @property (nonatomic, readwrite, strong) UIView *nobleView;
- @property (nonatomic, readwrite, strong) UIImageView *headImageView;
- @property (nonatomic, readwrite, strong) UILabel *userNameLabel;
- @property (nonatomic, readwrite, strong) UILabel *timeLabel;
- /// 等级标志
- @property (nonatomic, readwrite, strong) XYUserLevelLabel *userLevelLabel;
- /// 贵族标志
- @property (nonatomic, readwrite, strong) UIImageView *nobleImageView;
- /// 守护标志
- @property (nonatomic, readwrite, strong) UIImageView *guardImageView;
- /// 粉丝团标志
- @property (nonatomic, readwrite, strong) UIImageView *fansImageView;
- @property (nonatomic, readwrite, strong) UIView *iphonexBottomEdgeView;
- @property (nonatomic, readwrite, strong) MASConstraint *userLevelWidthConstraint;
- @property (nonatomic, readwrite, strong) MASConstraint *nobleImageLeftConstraint;
- @property (nonatomic, readwrite, strong) MASConstraint *nobleImageWithConstraint;
- @property (nonatomic, readwrite, strong) MASConstraint *guardImageLeftConstraint;
- @property (nonatomic, readwrite, strong) MASConstraint *guardImageWithConstraint;
- @property (nonatomic, readwrite, strong) MASConstraint *fansImageLeftConstraint;
- @property (nonatomic, readwrite, strong) MASConstraint *fansImageWithConstraint;
- @end
- @implementation XYLiveNobleListBottomView
- #pragma mark - Public Method
- - (void)configureViewWithModel:(XYLiveNobleListCellModel *)model {
-
- if (StringIsNotEmpty(model.expirationTime)) {
- self.nobleView.hidden = NO;
- self.noNobleView.hidden = YES;
- [self.headImageView sd_setImageWithURL:UrlForString(model.userAvatar) placeholderImage:placeholderUserMainBgImage(model.userSex)];
- self.userNameLabel.text = model.userName;
- [self.userLevelLabel configUserLevel:model.wealthLevel shinyStatus:model.wealthMedalStatus];
- self.timeLabel.text = [NSString stringWithFormat:@"%@%@", kLocalizedString(@"到期时间:"), [SystemTimeObject timestampSwitchTime:model.expirationTime andFormatter:@"YYYY.MM.dd"]];
-
- if (model.wealthLevel == 0) {
- self.userLevelWidthConstraint.equalTo(@0);
- self.nobleImageLeftConstraint.equalTo(@0);
- }else {
- self.userLevelWidthConstraint.equalTo(@44);
- self.nobleImageLeftConstraint.equalTo(@4);
- }
- UIImage *nobleImage = [XYLevelImageHander getNobleImageWithLevel:model.nobleLevel];
- if (nobleImage) {
- self.nobleImageView.image = nobleImage;
- self.nobleImageWithConstraint.equalTo(@20.0f);
- self.guardImageLeftConstraint.equalTo(@4.0f);
- }else {
- self.nobleImageView.image = nil;
- self.nobleImageWithConstraint.equalTo(@0.0f);
- self.guardImageLeftConstraint.equalTo(@0.0f);
- }
- UIImage *guardImage = [XYLevelImageHander getGuardImageWithLevel:model.guardLevel];
- if (guardImage) {
- self.guardImageView.image = guardImage;
- self.guardImageWithConstraint.equalTo(@20.0f);
- self.fansImageLeftConstraint.equalTo(@4.0f);
- }else {
- self.guardImageView.image = nil;
- self.guardImageWithConstraint.equalTo(@0.0f);
- self.fansImageLeftConstraint.equalTo(@0.0f);
- }
- UIImage *fansImage = [XYLevelImageHander getFansImageWithLevel:model.fansLevel];
- if (fansImage) {
- self.fansImageView.image = fansImage;
- self.fansImageWithConstraint.equalTo(@20.0f);
- }else {
- self.fansImageView.image = nil;
- self.fansImageWithConstraint.equalTo(@0.0f);
- }
- }else {
- self.nobleView.hidden = YES;
- self.noNobleView.hidden = NO;
- }
- }
- #pragma mark - Private Method
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
- // 初始化
- [self _setup];
-
- // 创建子控件
- [self _setupSubViews];
-
- // 布局子控件
- [self _makeSubViewsConstraints];
- }
- return self;
- }
- #pragma mark - 事件处理Or辅助方法
- #pragma mark - Private Method
- - (void)_setup{
-
- }
- #pragma mark - 创建子控件
- - (void)_setupSubViews{
- [self addSubview:self.noNobleView];
- [self.noNobleView addSubview:self.noNoblerTitleLabel];
- [self.noNobleView addSubview:self.openNoNobleButton];
-
- [self addSubview:self.nobleView];
- [self.nobleView addSubview:self.headImageView];
- [self.nobleView addSubview:self.userNameLabel];
- [self.nobleView addSubview:self.timeLabel];
- [self.nobleView addSubview:self.renewalButton];
- [self.nobleView addSubview:self.userLevelLabel];
- [self.nobleView addSubview:self.nobleImageView];
- [self.nobleView addSubview:self.guardImageView];
- [self.nobleView addSubview:self.fansImageView];
- [self iphonexBottomEdgeView];
- }
- #pragma mark - 布局子控件
- - (void)_makeSubViewsConstraints{
- [self.noNobleView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- }];
- [self.noNoblerTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.noNobleView).offset(SPACING_EDGE);
- make.top.equalTo(self.noNobleView).offset(20.0f);
- }];
- [self.openNoNobleButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.noNobleView).offset(-SPACING_EDGE);
- make.centerY.equalTo(self.noNoblerTitleLabel.mas_centerY).offset(0);
- make.width.equalTo(@95.0f);
- make.height.equalTo(@29.0f);
- }];
- [self.nobleView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- }];
- [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.nobleView).offset(SPACING_EDGE);
- make.top.equalTo(self.nobleView).offset(10.0f);
- make.width.height.equalTo(@40.0f);
- }];
- [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.headImageView.mas_right).offset(10.0f);
- make.top.equalTo(self.nobleView).offset(12.0f);
- make.height.equalTo(@22.0f);
- }];
- [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.headImageView.mas_right).offset(10.0f);
- make.top.equalTo(self.userNameLabel.mas_bottom).offset(4.0f);
- make.height.equalTo(@14.0f);
- }];
- [self.userLevelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.userNameLabel.mas_right).offset(4.0f);
- make.centerY.equalTo(self.userNameLabel);
- self.userLevelWidthConstraint = make.width.equalTo(@44.0f);
- make.height.equalTo(@20.0f);
- }];
- [self.nobleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- self.nobleImageLeftConstraint = make.left.equalTo(self.userLevelLabel.mas_right).offset(4.0f);
- make.centerY.equalTo(self.userNameLabel);
- self.nobleImageWithConstraint = make.width.equalTo(@20.0f);
- make.height.equalTo(@20.0f);
- }];
- [self.guardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- self.guardImageLeftConstraint = make.left.equalTo(self.nobleImageView.mas_right).offset(4.0f);
- make.centerY.equalTo(self.userNameLabel);
- self.guardImageWithConstraint = make.width.equalTo(@20.0f);
- make.height.equalTo(@20.0f);
- }];
- [self.fansImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- self.fansImageLeftConstraint = make.left.equalTo(self.guardImageView.mas_right).offset(4.0f);
- make.centerY.equalTo(self.userNameLabel);
- self.fansImageWithConstraint = make.width.equalTo(@20.0f);
- make.height.equalTo(@20.0f);
- make.right.lessThanOrEqualTo(self.renewalButton.mas_left).offset(-10.0f);
- }];
- [self.renewalButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.nobleView).offset(-SPACING_EDGE);
- make.centerY.equalTo(self.headImageView.mas_centerY).offset(0);
- make.width.equalTo(@95.0f);
- make.height.equalTo(@30.0f);
- }];
- [self.openNoNobleButton addViewBorder:Color_Clear redian:16.0f];
- [self.headImageView addViewBorder:Color_Clear redian:20.0f];
- }
- - (UIView *)noNobleView {
- if (!_noNobleView) {
- _noNobleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.f_width, self.f_heigh)];
- }
- return _noNobleView;
- }
- - (UILabel *)noNoblerTitleLabel {
- if (!_noNoblerTitleLabel) {
- _noNoblerTitleLabel = [UILabel createLabelTextColor:[UIColor colorWithHexString:@"#999999" alpha:1] fount:Font(16)];
- _noNoblerTitleLabel.text = kLocalizedString(@"成为贵族,尊享不凡");
- if (ApplicationDelegate.isVersionStatus) {
- _noNoblerTitleLabel.hidden = YES;
- }
- }
- return _noNoblerTitleLabel;
- }
- - (UIView *)nobleView {
- if (!_nobleView) {
- _nobleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.f_width, self.f_heigh)];
- }
- return _nobleView;
- }
- - (UIImageView *)headImageView {
- if (!_headImageView) {
- _headImageView = [UIImageView new];
- _headImageView.contentMode = UIViewContentModeScaleToFill;
- }
- return _headImageView;
- }
- - (UILabel *)userNameLabel {
- if (!_userNameLabel) {
- _userNameLabel = [UILabel createLabelTextColor:Color_White fount:Font(16)];
- }
- return _userNameLabel;
- }
- - (UILabel *)timeLabel {
- if (!_timeLabel) {
- _timeLabel = [UILabel createLabelTextColor:ColorFromHexStringWithAlpha(@"#FFFFFF", 0.5f) fount:Font(10)];
- }
- return _timeLabel;
- }
- - (XYUserLevelLabel *)userLevelLabel {
- if (!_userLevelLabel) {
- _userLevelLabel = [[XYUserLevelLabel alloc] init];
- }
- return _userLevelLabel;
- }
- - (UIImageView *)nobleImageView {
- if (!_nobleImageView) {
- _nobleImageView = [UIImageView new];
- }
- return _nobleImageView;
- }
- - (UIImageView *)guardImageView {
- if (!_guardImageView) {
- _guardImageView = [UIImageView new];
- }
- return _guardImageView;
- }
- - (UIImageView *)fansImageView {
- if (!_fansImageView) {
- _fansImageView = [UIImageView new];
- }
- return _fansImageView;
- }
- - (UIButton *)openNoNobleButton {
- if (!_openNoNobleButton) {
- _openNoNobleButton = [UIButton createButtonTextColor:[UIColor colorWithHexString:@"#5D3106" alpha:1] textFont:Font(14)];
- [_openNoNobleButton setTitle:kLocalizedString(@"开通贵族") forState:UIControlStateNormal];
- _openNoNobleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
- _openNoNobleButton.backgroundColor = [UIColor colorGradientChangeWithSize:CGSizeMake(95, 30) direction:GradientChangeDirectionLevel startColor:ColorFromHexString(@"#CEA46E") endColor:ColorFromHexString(@"#F5D0A2")];
- [_openNoNobleButton setTitleColor:[UIColor colorWithHexString:@"#15061A" alpha:1] forState:UIControlStateNormal];
- if (ApplicationDelegate.isVersionStatus) {
- _openNoNobleButton.hidden = YES;
- }
- kViewRadius(_openNoNobleButton, 15);
- }
- return _openNoNobleButton;
- }
- - (UIButton *)renewalButton {
- if (!_renewalButton) {
- _renewalButton = [UIButton createButtonTextColor:[UIColor colorWithHexString:@"#5D3106" alpha:1] textFont:Font(14)];
- [_renewalButton setTitle:[NSString stringWithFormat:@"%@ >", kLocalizedString(@"续费贵族 ")] forState:UIControlStateNormal];
- _renewalButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
- _renewalButton.backgroundColor = [UIColor colorGradientChangeWithSize:CGSizeMake(95, 30) direction:GradientChangeDirectionLevel startColor:ColorFromHexString(@"#CEA46E") endColor:ColorFromHexString(@"#F5D0A2")];
- [_renewalButton setTitleColor:[UIColor colorWithHexString:@"#15061A" alpha:1] forState:UIControlStateNormal];
- if (ApplicationDelegate.isVersionStatus) {
- _renewalButton.hidden = YES;
- }
- kViewRadius(_renewalButton, 15);
- }
- return _renewalButton;
- }
- - (UIView *)iphonexBottomEdgeView{
- if (_iphonexBottomEdgeView == nil) {
- _iphonexBottomEdgeView = [[UIView alloc] initWithFrame:CGRectZero];
- _iphonexBottomEdgeView.backgroundColor = ColorFromHexStringWithAlpha(@"#15061A", 0.8f);
- [self addSubview:_iphonexBottomEdgeView];
- [_iphonexBottomEdgeView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(kiPhoneXBottomEdge);
- make.height.offset(kiPhoneXBottomEdge);
- }];
- }
- return _iphonexBottomEdgeView;
- }
- @end
|