114 lines
3.4 KiB
Objective-C
114 lines
3.4 KiB
Objective-C
//
|
|
// YMNewUserRechargeCollectionViewCell.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/7/29.
|
|
//
|
|
|
|
#import "XPNewUserRechargeCollectionViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor+FirstRecharge.h"
|
|
#import "NetImageView.h"
|
|
#import "UIImage+Utils.h"
|
|
///Model
|
|
#import "FirstRechargeRewardModel.h"
|
|
|
|
@interface XPNewUserRechargeCollectionViewCell ()
|
|
///奖励的图片
|
|
@property (nonatomic, strong) NetImageView *iconImageView;
|
|
///显示奖励图片
|
|
@property (nonatomic, strong) UILabel *titleLabel;
|
|
///显示奖励的时间
|
|
@property (nonatomic, strong) UIButton *timeButton;
|
|
@end
|
|
|
|
|
|
@implementation XPNewUserRechargeCollectionViewCell
|
|
|
|
- (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.iconImageView];
|
|
[self addSubview:self.titleLabel];
|
|
[self addSubview:self.timeButton];
|
|
}
|
|
|
|
- (void)initSubViewConstraints{
|
|
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(0);
|
|
make.centerX.mas_equalTo(self.mas_centerX);
|
|
make.width.height.mas_equalTo(60);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.height.mas_equalTo(17);
|
|
make.top.mas_equalTo(self.iconImageView.mas_bottom).mas_offset(2);
|
|
make.leading.mas_equalTo(0);
|
|
}];
|
|
|
|
[self.timeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.titleLabel.mas_bottom);
|
|
make.height.mas_equalTo(14);
|
|
make.centerX.mas_equalTo(self);
|
|
make.leading.mas_equalTo(0);
|
|
}];
|
|
|
|
}
|
|
|
|
#pragma mark - setupData
|
|
- (void)setRewardInfo:(FirstRechargeRewardModel *)rewardInfo {
|
|
_rewardInfo = rewardInfo;
|
|
self.timeButton.hidden = !(_rewardInfo.showTime > 0);
|
|
[self.timeButton setTitle:[NSString stringWithFormat:@"(%@)", _rewardInfo.showTime] forState:UIControlStateNormal];
|
|
self.titleLabel.text = _rewardInfo.showText;
|
|
self.iconImageView.imageUrl = _rewardInfo.showPir;
|
|
}
|
|
|
|
|
|
- (UIImageView *)iconImageView {
|
|
if (!_iconImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc] init];
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
config.imageType = ImageTypeUserIcon;
|
|
_iconImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_iconImageView.backgroundColor = UIColorRGBAlpha(0xFF9CC3, 0.1);
|
|
_iconImageView.layer.cornerRadius = 8;
|
|
_iconImageView.layer.masksToBounds = YES;
|
|
_iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
}
|
|
return _iconImageView;
|
|
}
|
|
|
|
- (UILabel *)titleLabel{
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
|
|
_titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
|
|
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UIButton *)timeButton{
|
|
if (!_timeButton) {
|
|
_timeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_timeButton setTitleColor:[DJDKMIMOMColor textThirdColor] forState:UIControlStateNormal];
|
|
_timeButton.titleLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
|
|
_timeButton.hidden = YES;
|
|
}
|
|
return _timeButton;
|
|
}
|
|
|
|
@end
|