2022-11-16 17:04:34 +08:00
|
|
|
//
|
|
|
|
// XPHomeSearchAwardView.m
|
|
|
|
// xplan-ios
|
|
|
|
//
|
|
|
|
// Created by GreenLand on 2022/11/16.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "XPHomeSearchAwardView.h"
|
|
|
|
#import "Masonry/Masonry.h"
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
#import "XPMacro.h"
|
|
|
|
#import "NetImageView.h"
|
|
|
|
#import "TTPopup.h"
|
|
|
|
|
|
|
|
@interface XPHomeSearchAwardView()
|
|
|
|
|
|
|
|
///奖励标题
|
|
|
|
@property (nonatomic, strong) UILabel *awardTitle;
|
|
|
|
///关闭
|
|
|
|
@property (nonatomic, strong) UIButton *closeBtn;
|
|
|
|
///奖励icon
|
|
|
|
@property (nonatomic, strong) NetImageView *awardImageView;
|
|
|
|
///礼物名称
|
|
|
|
@property (nonatomic, strong) UILabel *giftTitle;
|
|
|
|
///描述
|
|
|
|
@property (nonatomic, strong) UILabel *giftDes;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation XPHomeSearchAwardView
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
|
|
{
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
if (self) {
|
|
|
|
[self initView];
|
|
|
|
[self initContraints];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)initView {
|
|
|
|
self.backgroundColor = [UIColor whiteColor];
|
2022-12-01 11:20:56 +08:00
|
|
|
self.layer.cornerRadius = 20;
|
|
|
|
self.layer.masksToBounds = YES;
|
2022-11-16 17:04:34 +08:00
|
|
|
[self addSubview:self.awardTitle];
|
|
|
|
[self addSubview:self.closeBtn];
|
|
|
|
[self addSubview:self.awardImageView];
|
|
|
|
[self addSubview:self.giftTitle];
|
|
|
|
[self addSubview:self.giftDes];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)initContraints {
|
|
|
|
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.size.mas_equalTo(CGSizeMake(300, 220));
|
|
|
|
}];
|
|
|
|
[self.awardTitle mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(16);
|
|
|
|
make.height.mas_equalTo(22);
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
make.right.mas_equalTo(self.closeBtn.mas_left).mas_offset(-5);
|
|
|
|
}];
|
|
|
|
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(13);
|
|
|
|
make.right.mas_equalTo(-15);
|
|
|
|
make.width.height.mas_equalTo(20);
|
|
|
|
}];
|
|
|
|
[self.awardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(self.awardTitle.mas_bottom).mas_offset(17);
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
make.size.mas_equalTo(CGSizeMake(112, 90));
|
|
|
|
}];
|
|
|
|
[self.giftTitle mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(self.awardImageView.mas_bottom).mas_offset(11);
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
make.height.mas_equalTo(20);
|
|
|
|
make.left.mas_equalTo(8);
|
|
|
|
}];
|
|
|
|
[self.giftDes mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(self.giftTitle.mas_bottom).mas_offset(4);
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
make.height.mas_equalTo(17);
|
|
|
|
make.left.mas_equalTo(8);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)onCloseBtnClick:(UIButton *)sender {
|
|
|
|
[TTPopup dismiss];
|
|
|
|
}
|
|
|
|
|
2022-12-01 11:20:56 +08:00
|
|
|
- (void)setData:(HomeSearchHijackAwardModel *)data {
|
|
|
|
self.awardImageView.imageUrl = data.awardUrl;
|
|
|
|
self.giftTitle.text = data.awardName;
|
|
|
|
}
|
|
|
|
|
2022-11-16 17:04:34 +08:00
|
|
|
#pragma mark - getter
|
|
|
|
- (UILabel *)awardTitle {
|
|
|
|
if (!_awardTitle) {
|
|
|
|
UILabel *label = [[UILabel alloc] init];
|
|
|
|
label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
|
|
label.textColor = [ThemeColor mainTextColor];
|
2022-12-01 11:20:56 +08:00
|
|
|
label.text = @"不错哟~你获得了神秘奖励";
|
|
|
|
label.textAlignment = NSTextAlignmentCenter;
|
2022-11-16 17:04:34 +08:00
|
|
|
_awardTitle = label;
|
|
|
|
}
|
|
|
|
return _awardTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIButton *)closeBtn {
|
|
|
|
if (!_closeBtn) {
|
|
|
|
_closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
2022-12-01 11:20:56 +08:00
|
|
|
[_closeBtn setImage:[UIImage imageNamed:@"room_little_game_close"] forState:UIControlStateNormal];
|
2022-11-16 17:04:34 +08:00
|
|
|
[_closeBtn addTarget:self action:@selector(onCloseBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
}
|
|
|
|
return _closeBtn;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NetImageView *)awardImageView {
|
|
|
|
if (!_awardImageView) {
|
|
|
|
NetImageConfig *config = [[NetImageConfig alloc] init];
|
|
|
|
config.placeHolder = [UIImageConstant defaultEmptyAvatarPlaceholder];
|
|
|
|
_awardImageView = [[NetImageView alloc] initWithConfig:config];
|
2022-12-01 11:20:56 +08:00
|
|
|
_awardImageView.contentMode = UIViewContentModeScaleAspectFit;
|
2022-11-16 17:04:34 +08:00
|
|
|
_awardImageView.layer.masksToBounds = YES;
|
|
|
|
_awardImageView.layer.cornerRadius = 8;
|
|
|
|
}
|
|
|
|
return _awardImageView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UILabel *)giftTitle {
|
|
|
|
if (!_giftTitle) {
|
|
|
|
UILabel *label = [[UILabel alloc] init];
|
|
|
|
label.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
|
|
|
|
label.textColor = [ThemeColor mainTextColor];
|
2022-12-01 11:20:56 +08:00
|
|
|
label.textAlignment = NSTextAlignmentCenter;
|
2022-11-16 17:04:34 +08:00
|
|
|
_giftTitle = label;
|
|
|
|
}
|
|
|
|
return _giftTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UILabel *)giftDes {
|
|
|
|
if (!_giftDes) {
|
|
|
|
UILabel *label = [[UILabel alloc] init];
|
|
|
|
label.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
|
|
|
|
label.textColor = [ThemeColor secondTextColor];
|
|
|
|
label.text = @"奖励已自动发放";
|
2022-12-01 11:20:56 +08:00
|
|
|
label.textAlignment = NSTextAlignmentCenter;
|
2022-11-16 17:04:34 +08:00
|
|
|
_giftDes = label;
|
|
|
|
}
|
|
|
|
return _giftDes;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|