萤石云 iOSSDK,移植跨平台相关工程
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
//
//  HDLFVCreateTemPassView.m
//  Ezviz
//
//  Created by 陈启扬 on 2022/4/22.
//  Copyright © 2022 hdl. All rights reserved.
//
 
#import "HDLFVCreateTemPassView.h"
@interface HDLFVCreateTemPassView ()
@property (nonatomic, strong)UILabel *tipL;//提示Lable
@property (nonatomic, strong)UILabel *QRCodetipL;//二维码提示Lable
@property (nonatomic, strong)UIView *expireV;//无效View
@property (nonatomic, strong)UILabel *expireL;//无效Lable
 
@property (nonatomic, strong)UIScrollView *scrollV;//滚动view
 
@end
@implementation HDLFVCreateTemPassView
 
-(instancetype)init{
    self = [super init];
    if (self) {
//        _isShow=YES;
//        _tempPassword=@"";
        [self initUI];
    }
    
    return  self;
}
 
-(void)initUI{
    //滚动view
    _scrollV=[[UIScrollView alloc] init];
    if (@available(iOS 11.0, *)) {
        _scrollV.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    [self addSubview:_scrollV];
    [_scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.right.left.bottom.equalTo(self);
    }];
    _scrollV.contentSize=CGSizeMake(APP_SCREEN_WIDTH, 665);
 
 
 
    //提示lable
    _tipL=[[UILabel alloc] init];
    [_scrollV addSubview:_tipL];
    [_tipL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_scrollV).offset(20);
        make.left.equalTo(self).offset(20);
        make.right.equalTo(self).offset(-20);
        make.height.mas_equalTo(40);
    }];
    _tipL.adjustsFontSizeToFitWidth=YES;
    _tipL.numberOfLines=2;
    _tipL.textColor=HDLFV_COLOR_TEXT_LIGHT_GRAY;
    _tipL.font=HDLFV_Get_FontRegularWithSize(HDLFV_FontSize_12);
    _tipL.text=HDLFVLocalizedString(@"*After you initiate the visitor certificate, you can  unlock the door by password or swipe the code  freely within the validity period you set. Please share the certificate carefully.");
    
    //访客手机
    _phoneInputV=[[HDLTopTitleInputView alloc] init];
    [_scrollV addSubview:_phoneInputV];
    [_phoneInputV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_tipL.mas_bottom).offset(30);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(80);
    }];
    _phoneInputV.inputTextF.keyboardType=UIKeyboardTypeNumberPad;
    _phoneInputV.placeHolder=HDLFVLocalizedString(@"Input phone number of the visitor");
    _phoneInputV.title=HDLFVLocalizedString(@"Visitor Phone Number");
    
 
    //动态密码
    _temPassInputV=[[HDLTopTitleInputView alloc] init];
    [_scrollV addSubview:_temPassInputV];
    [_temPassInputV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_phoneInputV.mas_bottom);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(80);
    }];
    _temPassInputV.inputTextF.keyboardType=UIKeyboardTypeNumberPad;
    _temPassInputV.placeHolder=HDLFVLocalizedString(@"Input 6-digits temporary password");
    _temPassInputV.title=HDLFVLocalizedString(@"Temporary password");
    _temPassInputV.btnTitle=HDLFVLocalizedString(@"Random Generation");
    
    
//    //使用次数
//    _useTimesInputV=[[HDLTopTitleInputView alloc] init];
//    [_scrollV addSubview:_useTimesInputV];
//    [_useTimesInputV mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(_temPassInputV.mas_bottom);
//        make.left.right.equalTo(self);
//        make.height.mas_equalTo(80);
//    }];
//    _useTimesInputV.inputTextF.keyboardType=UIKeyboardTypeNumberPad;
//    _useTimesInputV.inputTextF.text=@"1";
//    _useTimesInputV.placeHolder=HDLFVLocalizedString(@"Input usage times");
//    _useTimesInputV.title=HDLFVLocalizedString(@"Usage Times");
    
    //生效时间
    _validTimeV=[[HDLFVNormalCellView alloc] init];
    [_scrollV addSubview:_validTimeV];
    [_validTimeV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_temPassInputV.mas_bottom).offset(8);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(50);
    }];
    _validTimeV.title=HDLFVLocalizedString(@"Effective Time");
    
    //失效时间
    _expireTimeV=[[HDLFVNormalCellView alloc] init];
    [_scrollV addSubview:_expireTimeV];
    [_expireTimeV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_validTimeV.mas_bottom);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(50);
    }];
    _expireTimeV.title=HDLFVLocalizedString(@"Expiration Time");
    
    //二维码
    _QRCodeImageV=[[UIImageView alloc] init];
    [_scrollV addSubview:_QRCodeImageV];
    [_QRCodeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_expireTimeV.mas_bottom).offset(33);
        make.centerX.equalTo(self.mas_centerX);
        make.height.width.mas_equalTo(142);
    }];
    _QRCodeImageV.userInteractionEnabled = YES;
    
    //添加点击事件
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickQRCode)];
    UILongPressGestureRecognizer *longTap=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longTapQRCode:)];
    [_QRCodeImageV addGestureRecognizer:tap];
    [_QRCodeImageV addGestureRecognizer:longTap];
    [_QRCodeImageV setHidden:YES];
 
    //无效view
    _expireV=[[UIView alloc] init];
    [_scrollV addSubview:_expireV];
    [_expireV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_expireTimeV.mas_bottom).offset(33);
        make.centerX.equalTo(self.mas_centerX);
        make.height.width.mas_equalTo(142);
    }];
    _expireV.backgroundColor=[UIColor blackColor];
    _expireV.alpha=0.6;
    [_expireV setHidden:YES];
    
    //无效Lable
    _expireL=[[UILabel alloc] init];
    [_scrollV addSubview:_expireL];
    _expireL.textAlignment=NSTextAlignmentCenter;
    _expireL.textColor=[UIColor whiteColor];
    [_expireL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_expireTimeV.mas_bottom).offset(33);
        make.centerX.equalTo(self.mas_centerX);
        make.height.width.mas_equalTo(142);
        
    }];
    _expireL.font=HDLFV_Get_FontRegularWithSize(HDLFV_FontSize_12);
    _expireL.text=HDLFVLocalizedString(@"QR code is invalid");
    [_expireL setHidden:YES];
 
    //提示lable
    _QRCodetipL=[[UILabel alloc] init];
    [_scrollV addSubview:_QRCodetipL];
    [_QRCodetipL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_QRCodeImageV.mas_bottom).offset(20);
        make.left.equalTo(self).offset(10);
        make.right.equalTo(self).offset(-10);
        make.height.mas_equalTo(20);
    }];
    _QRCodetipL.adjustsFontSizeToFitWidth=YES;
    _QRCodetipL.textAlignment=NSTextAlignmentCenter;
    _QRCodetipL.textColor=HDLFV_COLOR_TEXT_TITLE_GRAY;
    _QRCodetipL.font=HDLFV_Get_FontRegularWithSize(HDLFV_FontSize_12);
    _QRCodetipL.text=HDLFVLocalizedString(@"Long press the QR code to save the QR code to the album");
    [_QRCodetipL setHidden:YES];
    
    
}
 
//点击了二维码
-(void)clickQRCode{
    
    self.clickQRCodeBlock(_QRCodeImageV.image);
}
 
//长按二维码
-(void)longTapQRCode:(UIGestureRecognizer*)recognizer{
    if (recognizer.state==UIGestureRecognizerStateBegan) {
        HDLFVLog(@"长按了二维码");
        self.longTapQRCodeBlock(_QRCodeImageV.image);
    }
 
}
 
/*展示二维码
 
 */
-(void)showQRCode:(BOOL)show{
    [_QRCodetipL setHidden:!show];
    [_QRCodeImageV setHidden:!show];
 
}
 
-(void)setIsInvalid:(BOOL)isInvalid{
    _isInvalid=isInvalid;
    if (isInvalid) {//如果为无效
        [_expireL setHidden:NO];
        [_expireV setHidden:NO];
        [_QRCodetipL setHidden:YES];
        _temPassInputV.inputTextF.text=HDLFVLocalizedString(@"Temporary password is invalid");
    }
}
 
-(void)setTemPassType:(HDLFVTemPassType)temPassType{
    _temPassType=temPassType;
    if (temPassType==HDLFVTemPassType_Generate) {
        [_phoneInputV.inputTextF setEnabled:YES];
        [_temPassInputV.inputTextF setEnabled:YES];
        _temPassInputV.btnTitle=HDLFVLocalizedString(@"Random Generation");
//        [_useTimesInputV.inputTextF setEnabled:YES];
        [_expireTimeV.button setEnabled:YES];
        [_validTimeV.button setEnabled:YES];
        [self showQRCode:NO];
    }else{
        [_phoneInputV.inputTextF setEnabled:NO];
        [_temPassInputV.inputTextF setEnabled:NO];
        _temPassInputV.btnTitle=@"";
//        [_useTimesInputV.inputTextF setEnabled:NO];
        [_expireTimeV.button setEnabled:NO];
        [_validTimeV.button setEnabled:NO];
        [self showQRCode:YES];
 
    }
}
@end