316 lines
9.9 KiB
Objective-C
316 lines
9.9 KiB
Objective-C
//
|
|
// YMGiftItemCollectionViewCell.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2021/11/12.
|
|
//
|
|
|
|
#import "XPGiftItemCollectionViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor+SendGift.h"
|
|
#import "NetImageView.h"
|
|
///Model
|
|
#import "GiftInfoModel.h"
|
|
|
|
@interface XPGiftItemCollectionViewCell ()
|
|
///礼物图片
|
|
@property (nonatomic,strong) NetImageView *giftImageView;
|
|
///礼物名称
|
|
@property (nonatomic,strong) UILabel *giftNameLabel;
|
|
///
|
|
@property (nonatomic,strong) UIStackView *priceStackView;
|
|
///价格
|
|
@property (nonatomic,strong) UILabel *priceLabel;
|
|
///💎
|
|
@property (nonatomic,strong) UIImageView *logoImageView;
|
|
///
|
|
@property (nonatomic,strong) UIStackView *tagStackView;
|
|
///新的
|
|
@property (nonatomic,strong) UIImageView *giftNewImageView;
|
|
///特别的
|
|
@property (nonatomic,strong) UIImageView *specialImageView;
|
|
///限定
|
|
@property (nonatomic,strong) UIImageView *limitImageView;
|
|
///专属
|
|
@property (nonatomic,strong) UIImageView *exclusiveImageView;
|
|
///
|
|
@property (nonatomic,strong) UIView * coverView;
|
|
///
|
|
@property (nonatomic,strong) UILabel *giftNumLabel;
|
|
///贵族icon
|
|
@property (nonatomic, strong) NetImageView *nobleIconImageView;
|
|
///贵族礼物锁
|
|
@property (nonatomic, strong) UIImageView *lockImageView;
|
|
|
|
@end
|
|
|
|
@implementation XPGiftItemCollectionViewCell
|
|
|
|
- (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.giftImageView];
|
|
[self.contentView addSubview:self.giftNameLabel];
|
|
[self.contentView addSubview:self.priceStackView];
|
|
[self.contentView addSubview:self.coverView];
|
|
[self.contentView addSubview:self.giftNumLabel];
|
|
[self.contentView addSubview:self.lockImageView];
|
|
[self.contentView addSubview:self.tagStackView];
|
|
|
|
[self.tagStackView addArrangedSubview:self.nobleIconImageView];
|
|
[self.tagStackView addArrangedSubview:self.exclusiveImageView];
|
|
[self.tagStackView addArrangedSubview:self.giftNewImageView];
|
|
[self.tagStackView addArrangedSubview:self.limitImageView];
|
|
[self.tagStackView addArrangedSubview:self.specialImageView];
|
|
|
|
[self.priceStackView addArrangedSubview:self.priceLabel];
|
|
[self.priceStackView addArrangedSubview:self.logoImageView];
|
|
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.tagStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.top.mas_equalTo(self.contentView).inset(3);
|
|
make.height.mas_equalTo(18);
|
|
}];
|
|
[self.giftNewImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(28);
|
|
make.height.mas_equalTo(18);
|
|
}];
|
|
[self.limitImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(28);
|
|
make.height.mas_equalTo(18);
|
|
}];
|
|
[self.specialImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(28);
|
|
make.height.mas_equalTo(18);
|
|
}];
|
|
[self.exclusiveImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(28);
|
|
make.height.mas_equalTo(18);
|
|
}];
|
|
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self);
|
|
}];
|
|
|
|
|
|
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.contentView).offset(18);
|
|
make.centerX.mas_equalTo(self.contentView);
|
|
make.size.mas_equalTo(CGSizeMake(48, 48));
|
|
}];
|
|
|
|
[self.giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.giftImageView.mas_bottom).offset(3);
|
|
make.centerX.mas_equalTo(self.giftImageView);
|
|
}];
|
|
|
|
[self.priceStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.giftNameLabel.mas_bottom).offset(5);
|
|
make.centerX.equalTo(self.contentView);
|
|
make.height.mas_equalTo(10);
|
|
}];
|
|
|
|
[self.giftNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.contentView).offset(4.5);
|
|
make.left.equalTo(self.contentView).offset(6);
|
|
}];
|
|
|
|
[self.nobleIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.height.mas_equalTo(16);
|
|
|
|
}];
|
|
[self.lockImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.bottom.mas_equalTo(self.contentView).mas_offset(-4);
|
|
make.width.height.mas_equalTo(16);
|
|
}];
|
|
}
|
|
|
|
- (UIImageView *)createImageView:(NSString *)imageName {
|
|
UIImageView * imageView = [[UIImageView alloc] init];
|
|
imageView.userInteractionEnabled = YES;
|
|
imageView.image = [UIImage imageNamed:imageName];
|
|
return imageView;
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setGiftInfo:(GiftInfoModel *)giftInfo {
|
|
_giftInfo = giftInfo;
|
|
if (_giftInfo) {
|
|
self.giftImageView.imageUrl = giftInfo.giftUrl;
|
|
self.giftNameLabel.text = _giftInfo.giftName.length > 0 ? _giftInfo.giftName : @"";
|
|
self.coverView.hidden = !giftInfo.isSelected;
|
|
NSString *strr = [NSString stringWithFormat:@"%ld",(long)_giftInfo.goldPrice];
|
|
self.priceLabel.text = strr;
|
|
self.giftNumLabel.hidden = giftInfo.count <=0 ;
|
|
self.giftNumLabel.text = [NSString stringWithFormat:@"x%ld",(long)giftInfo.count];
|
|
|
|
self.exclusiveImageView.hidden = !_giftInfo.roomExclude;
|
|
self.giftNewImageView.hidden = !_giftInfo.hasLatest;
|
|
self.limitImageView.hidden = !_giftInfo.hasTimeLimit;
|
|
self.specialImageView.hidden = !_giftInfo.hasEffect;
|
|
|
|
if (_usingplaceType == SendGiftType_User) {
|
|
self.priceLabel.textColor = _giftInfo.isSelected ? [DJDKMIMOMColor giftPriceSelectColor] : [DJDKMIMOMColor secondTextColor];
|
|
self.giftNameLabel.textColor = _giftInfo.isSelected ? [DJDKMIMOMColor giftNameSelectColor] : [DJDKMIMOMColor mainTextColor];
|
|
self.giftNumLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
|
} else {
|
|
self.priceLabel.textColor = _giftInfo.isSelected ? [DJDKMIMOMColor giftPriceSelectColor] : [DJDKMIMOMColor giftPriceNormalColor];
|
|
self.giftNameLabel.textColor = _giftInfo.isSelected ? [DJDKMIMOMColor giftNameSelectColor] : [UIColor whiteColor];
|
|
self.giftNumLabel.textColor = [DJDKMIMOMColor giftSegmentNormalTitleColor];
|
|
}
|
|
|
|
if (giftInfo.giftType == GiftType_Noble && giftInfo.giftVipInfo) {
|
|
self.nobleIconImageView.hidden = NO;
|
|
self.nobleIconImageView.imageUrl = giftInfo.giftVipInfo.vipIcon;
|
|
self.lockImageView.hidden = self.curUserNobleLevel >= giftInfo.giftVipInfo.vipLevel;
|
|
} else {
|
|
self.nobleIconImageView.hidden = YES;
|
|
self.lockImageView.hidden = YES;
|
|
}
|
|
}
|
|
}
|
|
|
|
- (void)setUsingplaceType:(SendGiftType)usingplaceType {
|
|
_usingplaceType = usingplaceType;
|
|
}
|
|
|
|
- (UIStackView *)tagStackView {
|
|
if (!_tagStackView) {
|
|
_tagStackView = [[UIStackView alloc] init];
|
|
_tagStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
_tagStackView.distribution = UIStackViewDistributionFill;
|
|
_tagStackView.alignment = UIStackViewAlignmentCenter;
|
|
_tagStackView.spacing = 2;
|
|
}
|
|
return _tagStackView;
|
|
}
|
|
|
|
- (UIImageView *)exclusiveImageView {
|
|
if (!_exclusiveImageView) {
|
|
_exclusiveImageView = [self createImageView:@"gift_tag_exclude"];
|
|
}
|
|
return _exclusiveImageView;
|
|
}
|
|
|
|
- (UIImageView *)limitImageView {
|
|
if (!_limitImageView) {
|
|
_limitImageView = [self createImageView:@"gift_tag_time_limit"];
|
|
}
|
|
return _limitImageView;
|
|
}
|
|
|
|
- (UIImageView *)specialImageView {
|
|
if (!_specialImageView) {
|
|
_specialImageView = [self createImageView:@"gift_tag_effect"];
|
|
}
|
|
return _specialImageView;
|
|
}
|
|
- (UIImageView *)giftNewImageView {
|
|
if (!_giftNewImageView) {
|
|
_giftNewImageView = [self createImageView:@"gift_tag_latest"];
|
|
}
|
|
return _giftNewImageView;
|
|
}
|
|
|
|
- (UIStackView *)priceStackView {
|
|
if (!_priceStackView) {
|
|
_priceStackView = [[UIStackView alloc] init];
|
|
_priceStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
_priceStackView.distribution = UIStackViewDistributionEqualSpacing;
|
|
_priceStackView.alignment = UIStackViewAlignmentCenter;
|
|
_priceStackView.spacing = 2;
|
|
}
|
|
return _priceStackView;
|
|
}
|
|
|
|
- (UIImageView *)logoImageView {
|
|
if (!_logoImageView) {
|
|
_logoImageView = [self createImageView:@"gift_diamond"];
|
|
}
|
|
return _logoImageView;
|
|
}
|
|
|
|
- (UILabel *)priceLabel {
|
|
if (!_priceLabel) {
|
|
_priceLabel = [[UILabel alloc] init];
|
|
_priceLabel.font = [UIFont systemFontOfSize:9];
|
|
_priceLabel.textColor = [DJDKMIMOMColor giftPriceNormalColor];
|
|
}
|
|
return _priceLabel;
|
|
}
|
|
|
|
|
|
- (UILabel *)giftNameLabel {
|
|
if (!_giftNameLabel) {
|
|
_giftNameLabel = [[UILabel alloc] init];
|
|
_giftNameLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightSemibold];
|
|
_giftNameLabel.textAlignment = NSTextAlignmentCenter;
|
|
_giftNameLabel.textColor = [DJDKMIMOMColor mainTextColor];
|
|
}
|
|
return _giftNameLabel;
|
|
}
|
|
|
|
- (UILabel *)giftNumLabel {
|
|
if (!_giftNumLabel) {
|
|
_giftNumLabel = [[UILabel alloc] init];
|
|
_giftNumLabel.font = [UIFont systemFontOfSize:10];
|
|
}
|
|
return _giftNumLabel;
|
|
}
|
|
|
|
- (UIView *)coverView {
|
|
if (!_coverView) {
|
|
_coverView = [[UIView alloc] init];
|
|
_coverView.backgroundColor = [DJDKMIMOMColor giftSelectBgColor];
|
|
_coverView.layer.borderColor = [DJDKMIMOMColor appMainColor].CGColor;
|
|
_coverView.layer.masksToBounds =YES;
|
|
_coverView.layer.cornerRadius = 6;
|
|
_coverView.layer.borderWidth = 1;
|
|
_coverView.hidden = YES;
|
|
}
|
|
return _coverView;
|
|
}
|
|
|
|
- (NetImageView *)giftImageView {
|
|
if (!_giftImageView) {
|
|
_giftImageView = [[NetImageView alloc] init];
|
|
_giftImageView.backgroundColor = [UIColor clearColor];
|
|
_giftImageView.layer.masksToBounds = YES;
|
|
_giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
}
|
|
return _giftImageView;
|
|
}
|
|
|
|
- (NetImageView *)nobleIconImageView {
|
|
if (!_nobleIconImageView) {
|
|
_nobleIconImageView = [[NetImageView alloc] init];
|
|
_nobleIconImageView.backgroundColor = [UIColor clearColor];
|
|
_nobleIconImageView.hidden = YES;
|
|
_nobleIconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
}
|
|
return _nobleIconImageView;
|
|
}
|
|
|
|
|
|
- (UIImageView *)lockImageView {
|
|
if (!_lockImageView) {
|
|
_lockImageView = [self createImageView:@"room_gift_noble_lock"];
|
|
_lockImageView.hidden = YES;
|
|
}
|
|
return _lockImageView;
|
|
}
|
|
|
|
@end
|