CNLiveCMineInteHeaderView.m
6.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//
// CNLiveCMineInteHeaderView.m
// CNLiveCMineModule
//
// Created by open on 2021/12/27.
//
#import "CNLiveCMineInteHeaderView.h"
#import "CNLiveCMineInteHeaderSignView.h"
#import "CNLiveCMineHeader.h"
@interface CNLiveCMineInteHeaderView()
@property (nonatomic, strong) QMUIButton * detailBtn;
@property (nonatomic, strong) UILabel * inteLabel;
@property (nonatomic, strong) UIButton * pushMallBtn;
@property (nonatomic, strong) CNLiveCMineInteHeaderSignView * signView;
@property (nonatomic, strong) UILabel * titleLabel;
@property (nonatomic, strong) CNLiveCMineInteScoreModel * scoreModel; //签到数据
@property (nonatomic, strong) CNLiveCMineInteTaskListModel * taskModel;//任务列表及积分数据
@property (nonatomic, strong) CNLiveCMineInteListModel * announModel; //公告数据
@property (nonatomic, strong) CNLiveCMineInteListModel * activModel; //活动数据
@end
@implementation CNLiveCMineInteHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self addSubview:self.detailBtn];
[self addSubview:self.inteLabel];
[self addSubview:self.pushMallBtn];
[self addSubview:self.signView];
[self addSubview:self.titleLabel];
}
return self;
}
-(void)layoutSubviews
{
[super layoutSubviews];
__weak typeof(self) weakSelf = self;
[self.detailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf).offset(10);
make.left.mas_equalTo(weakSelf).offset(15);
make.width.mas_equalTo(100);
make.height.mas_equalTo(25);
}];
[self.inteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(weakSelf.detailBtn.mas_bottom).offset(5);
make.left.mas_equalTo(weakSelf).offset(15);
}];
[self.pushMallBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(weakSelf.inteLabel.mas_bottom).offset(-5);
make.right.mas_equalTo(weakSelf);
}];
[self.signView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf).offset(10);
make.right.mas_equalTo(weakSelf).offset(-10);
make.top.mas_equalTo(weakSelf.inteLabel.mas_bottom).offset(15);
make.height.mas_equalTo(180);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(weakSelf.mas_bottom).offset(-10);
make.left.mas_equalTo(weakSelf.signView.mas_left);
}];
}
-(void)pushMallAction:(UIButton *)btn
{
if (self.clickActionBlock) self.clickActionBlock(self.scoreModel, self.taskModel, self.announModel,CNLiveCMineInteHeaderClickMall);
}
-(void)pushScoreDetailAction:(UIButton *)btn
{
if (self.clickActionBlock) self.clickActionBlock(self.scoreModel, self.taskModel, self.announModel,CNLiveCMineInteHeaderClickDetail);
}
#pragma mark =
/// 对headerView的数据进行赋值
/// @param scoreModel 签到数据
/// @param taskModel 任务数据
/// @param announModel 公告数据
-(void)setupWithScoreModel:(CNLiveCMineInteScoreModel *)scoreModel
taskModel:(CNLiveCMineInteTaskListModel *)taskModel
announModel:(CNLiveCMineInteListModel *)announModel
activModel:(CNLiveCMineInteListModel *)activModel
{
_scoreModel = scoreModel;
_taskModel = taskModel;
_announModel = announModel;
_activModel = activModel;
[self.signView setupWithScoreModel:scoreModel taskModel:taskModel announModel:announModel activModel:activModel];
NSMutableAttributedString * coin_string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@积分",[taskModel.integral isNotBlank]?taskModel.integral:@"0"]];
[coin_string addAttribute:NSFontAttributeName value:UIFontCNMake(12) range:[coin_string.string rangeOfString:@"积分"]];
[coin_string addAttribute:NSFontAttributeName value:UIFontBoldCNMake(30) range:NSMakeRange(0, [coin_string.string rangeOfString:@"积分"].location)];
self.inteLabel.attributedText = coin_string;
self.titleLabel.hidden = activModel == nil;
}
#pragma mark =
-(CNLiveCMineInteHeaderSignView *)signView
{
if (!_signView) {
__weak typeof(self) weakSelf = self;
_signView = [[CNLiveCMineInteHeaderSignView alloc] init];
_signView.backgroundColor = [UIColor clearColor];
_signView.clickActionBlock = ^(CNLiveCMineInteScoreModel * _Nonnull scoreModel, CNLiveCMineInteTaskListModel * _Nonnull taskModel, CNLiveCMineInteListModel * _Nonnull announModel, CNLiveCMineInteHeaderClick headerClick) {
if (weakSelf.clickActionBlock) weakSelf.clickActionBlock(scoreModel, taskModel, announModel, headerClick);
};
}
return _signView;
}
-(UIButton *)pushMallBtn
{
if (!_pushMallBtn) {
_pushMallBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_pushMallBtn.backgroundColor = [UIColor clearColor];
[_pushMallBtn setImage:[CNLiveCMineService imageWithMineName:@"c_mine_skip_push_mall"] forState:UIControlStateNormal];
[_pushMallBtn addTarget:self action:@selector(pushMallAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _pushMallBtn;
}
-(QMUIButton *)detailBtn
{
if (!_detailBtn) {
_detailBtn = [[QMUIButton alloc] init];
[_detailBtn setTitle:@"积分明细" forState:UIControlStateNormal];
[_detailBtn setImage:[CNLiveCMineService imageWithMineName:@"c_mine_skip_inte_detail"] forState:UIControlStateNormal];
[_detailBtn setTitleColor:UIColorHex(0x481A19) forState:UIControlStateNormal];
_detailBtn.titleLabel.font = UIFontCNMake(14);
_detailBtn.backgroundColor = [UIColor clearColor];
_detailBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
_detailBtn.spacingBetweenImageAndTitle = 1;
_detailBtn.imagePosition = QMUIButtonImagePositionRight;
[_detailBtn addTarget:self action:@selector(pushScoreDetailAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _detailBtn;
}
- (UILabel *)inteLabel
{
if (!_inteLabel) {
_inteLabel = [[UILabel alloc] init];
_inteLabel.backgroundColor = [UIColor clearColor];
_inteLabel.textColor = UIColorHex(0x481A19);
}
return _inteLabel;
}
-(UILabel *)titleLabel
{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textColor = [UIColor blackColor];
_titleLabel.font = UIFontCNMake(15);
_titleLabel.font = UIFontBoldCNMake(15);
_titleLabel.text = @"积分乐园";
_titleLabel.hidden = YES;
}
return _titleLabel;
}
@end