//
|
// 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
|