JLChen
2021-05-18 a869383e163a18cdedcf587383c1eca043129754
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//
//  Copyright © 2016年 dahua. All rights reserved.
//
 
#import "LCAddBoxGudieView.h"
#import <LCBaseModule/UIColor+LeChange.h>
#import <LCBaseModule/UIFont+Dahua.h>
#import <LCBaseModule/NSString+Dahua.h>
 
#define TitleLabel_Top 80
#define TitleLabel_Left 30
#define TitleLabel_Height 20
 
@interface LCAddBoxGudieView ()
 
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UILabel *subtitleOneLabel;
@property (nonatomic,strong) UILabel *subtitleTwoLabel;
 
@property (nonatomic,strong) UIButton *checkButton;
@property (nonatomic,strong) UIButton *commitButton;
 
@property (nonatomic,strong) void(^commitButtonClickBlock)(BOOL isShowAgain);
 
@property (nonatomic,strong) UIImageView *bgView;
@end
 
@implementation LCAddBoxGudieView
 
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self setup];
    }
    
    return self;
}
 
-(instancetype)initWithFrame:(CGRect)frame withClickButton:(void(^)(BOOL isShowAgain))clickBtnblock
{
    if (self = [super initWithFrame:frame])
    {
        [self setup];
        
        self.commitButtonClickBlock = clickBtnblock;
    }
    
    return self;
}
 
/**
 *  配置内部控件
 */
-(void)setup
{
    self.backgroundColor = [UIColor dhcolor_c51];
    
    [self addSubview:self.bgView];
    
    [self addSubview:self.titleLabel];
    
    [self addSubview:self.subtitleOneLabel];
    
    [self addSubview:self.subtitleTwoLabel];
    
    [self addSubview:self.commitButton];
    
    [self addSubview:self.checkButton];
    
    UIView *blackColorView = [[UIView alloc] initWithFrame:self.bgView.frame];
    [blackColorView setBackgroundColor:[UIColor dhcolor_c51]];
    [self addSubview:blackColorView];
    [self insertSubview:blackColorView aboveSubview:self.bgView];
}
 
#pragma mark IBAction
- (void)onClickCheckButton:(UIButton*)sender
{
    // 点击不在提示
    sender.selected = !sender.selected;
    if (sender.selected)
    {
        [sender setImage:[UIImage imageNamed:@"adddevice_box_checkbox_checked"] forState:UIControlStateNormal];
    }
    else
    {
        [sender setImage:[UIImage imageNamed:@"adddevice_box_checkbox"] forState:UIControlStateNormal];
    }
}
 
-(void)onClickAddBoxCommit:(UIButton*)sender
{
    if (self.commitButtonClickBlock)
    {
        self.commitButtonClickBlock(!self.checkButton.selected);
    }
    [self removeFromSuperview];
}
 
#pragma mark Propertys
 
-(UIImageView *)bgView
{
    if (!_bgView)
    {
        //背景视图,显示相机最后捕获的画面
        _bgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 64, self.bounds.size.width, self.bounds.size.height - 64)];
    }
    
    return _bgView;
}
 
-(UILabel *)titleLabel
{
    if (!_titleLabel)
    {
        //标题label
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 80, CGRectGetWidth(self.bounds), 20)];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = [UIColor dhcolor_c43];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = [UIFont dhFont_t3];
        _titleLabel.text = @"Device_AddDevice_Confirm_Box_Working".lc_T;
    }
    
    return _titleLabel;
}
 
-(UILabel *)subtitleOneLabel
{
    if (!_subtitleOneLabel)
    {
        //子标题label
        _subtitleOneLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, CGRectGetHeight(self.bounds)*0.25, CGRectGetWidth(self.bounds)-30, 20)];
        _subtitleOneLabel.backgroundColor = [UIColor clearColor];
        _subtitleOneLabel.textColor = [UIColor dhcolor_c43];
        _subtitleOneLabel.textAlignment = NSTextAlignmentLeft;
        _subtitleOneLabel.font = [UIFont dhFont_t3];
        _subtitleOneLabel.text = @"Device_AddDevice_Plug_Power_Box_White_Light".lc_T;
    }
    
    return _subtitleOneLabel;
}
 
-(UILabel *)subtitleTwoLabel
{
    if (!_subtitleTwoLabel)
    {
        //子标题label
        _subtitleTwoLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, CGRectGetHeight(self.bounds)*0.32, CGRectGetWidth(self.bounds)-30, 20)];
        _subtitleTwoLabel.backgroundColor = [UIColor clearColor];
        _subtitleTwoLabel.textColor = [UIColor dhcolor_c43];
        _subtitleTwoLabel.textAlignment = NSTextAlignmentLeft;
        _subtitleTwoLabel.font = [UIFont dhFont_t3];
        _subtitleTwoLabel.text = @"Device_AddDevice_Connect_Available_Network".lc_T;
    }
    
    return _subtitleTwoLabel;
}
 
-(UIButton *)checkButton
{
    if (!_checkButton)
    {
        //复选框按钮
        _checkButton = [[UIButton alloc]initWithFrame:CGRectMake(15, CGRectGetHeight(self.bounds)-185-30, 140, 30)];
        _checkButton.isAccessibilityElement = YES;
        _checkButton.accessibilityIdentifier = @"selectButtonInShowAddHostDeviceHelp";
        [_checkButton setImage:[UIImage imageNamed:@"adddevice_box_checkbox"] forState:UIControlStateNormal];
        _checkButton.selected = NO;
        [_checkButton setTitle:@"Device_AddDevice_No_Reminder".lc_T forState:UIControlStateNormal];
        [_checkButton addTarget:self action:@selector(onClickCheckButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _checkButton;
}
 
-(UIButton *)commitButton
{
    if (!_commitButton)
    {
        //确定按钮
        _commitButton = [[UIButton alloc]initWithFrame:CGRectMake(15, CGRectGetHeight(self.bounds)-165,  CGRectGetWidth(self.bounds)-30, 45)];
        _commitButton.isAccessibilityElement = YES;
        _commitButton.accessibilityIdentifier = @"commitButtonInShowAddHostDeviceHelp";
        _commitButton.layer.masksToBounds = YES;
        _commitButton.layer.borderWidth = 0.5;
        _commitButton.layer.cornerRadius = 0;
        _commitButton.layer.borderColor = [UIColor dhcolor_c43].CGColor;
        [_commitButton setTitle:@"Device_AddDevice_Has_Confirm_Add".lc_T forState:UIControlStateNormal];
        [_commitButton addTarget:self action:@selector(onClickAddBoxCommit:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _commitButton;
}
@end