|
|
@@ -0,0 +1,213 @@
|
|
|
+//
|
|
|
+// QRCodeInputSecretKeyView.m
|
|
|
+// 双子星云手机
|
|
|
+//
|
|
|
+// Created by xd h on 2025/11/3.
|
|
|
+//
|
|
|
+
|
|
|
+#import "QRCodeInputSecretKeyView.h"
|
|
|
+
|
|
|
+@interface QRCodeInputSecretKeyView ()<UITextViewDelegate>
|
|
|
+{
|
|
|
+ UITextView *inputView;
|
|
|
+ UILabel *inputTipLab;
|
|
|
+}
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation QRCodeInputSecretKeyView
|
|
|
+
|
|
|
+-(instancetype)initWithFrame:(CGRect)frame{
|
|
|
+ if(self = [super initWithFrame:frame])
|
|
|
+ {
|
|
|
+ [self createSubviews];
|
|
|
+
|
|
|
+ }
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+-(void)createSubviews
|
|
|
+{
|
|
|
+ UIView *backGround = [[UIView alloc]init];
|
|
|
+ backGround.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF" alpha:0.3];
|
|
|
+ [self addSubview:backGround];
|
|
|
+
|
|
|
+
|
|
|
+ [backGround mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(0);
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.top.mas_equalTo(0);
|
|
|
+ make.bottom.mas_equalTo(0);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIView *whiteBackGround = [[UIView alloc]init];
|
|
|
+ whiteBackGround.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF" alpha:1.0];
|
|
|
+ whiteBackGround.layer.cornerRadius = 8;
|
|
|
+ [self addSubview:whiteBackGround];
|
|
|
+
|
|
|
+ [whiteBackGround mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(40);
|
|
|
+ make.right.mas_equalTo(-40);
|
|
|
+ make.centerY.mas_equalTo(-60);
|
|
|
+ make.height.mas_equalTo(235);
|
|
|
+ }];
|
|
|
+
|
|
|
+ //设备密钥
|
|
|
+ NSString *curTitle = NSLocalizedString(@"qrcode_secret_key_tip",nil);
|
|
|
+ UILabel *titleLab = [[UILabel alloc]init];
|
|
|
+ titleLab.text = curTitle;
|
|
|
+ titleLab.textColor = [UIColor hwColor:@"#333333" alpha:1.0];
|
|
|
+ titleLab.font = [UIFont systemFontOfSize:18];
|
|
|
+ titleLab.textAlignment = NSTextAlignmentCenter;
|
|
|
+ [whiteBackGround addSubview:titleLab];
|
|
|
+ [titleLab sizeToFit];
|
|
|
+ [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(0);
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.top.mas_equalTo(20);
|
|
|
+ make.height.mas_equalTo(30);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ //输入框 背景
|
|
|
+ UIView *inputBackGround = [[UIView alloc]init];
|
|
|
+ inputBackGround.backgroundColor = [UIColor colorWithHexString:@"#EEEEEE" alpha:1.0];
|
|
|
+ inputBackGround.layer.cornerRadius = 4;
|
|
|
+ [whiteBackGround addSubview:inputBackGround];
|
|
|
+
|
|
|
+ [inputBackGround mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.mas_equalTo(-15);
|
|
|
+ make.left.mas_equalTo(15);
|
|
|
+ make.top.equalTo(titleLab.mas_bottom).offset(20);
|
|
|
+ make.height.mas_equalTo(80);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ //请输入密钥
|
|
|
+ NSString *curinputTip = NSLocalizedString(@"qrcode_secret_key_input_tip",nil);
|
|
|
+ inputTipLab = [[UILabel alloc]init];
|
|
|
+ inputTipLab.text = curinputTip;
|
|
|
+ inputTipLab.textColor = [UIColor hwColor:@"#999999" alpha:1.0];
|
|
|
+ inputTipLab.font = [UIFont systemFontOfSize:16];
|
|
|
+
|
|
|
+
|
|
|
+ //输入框
|
|
|
+ inputView = [[UITextView alloc] init];
|
|
|
+ inputView.backgroundColor = [UIColor clearColor];
|
|
|
+ //inputView.layer.cornerRadius = 8;
|
|
|
+ inputView.textColor = [UIColor blackColor];
|
|
|
+ //inputView.textAlignment = NSTextAlignmentCenter;
|
|
|
+ inputView.font = [UIFont systemFontOfSize:16.0];
|
|
|
+ //inputView.placeholder = curinputTip;
|
|
|
+ inputView.delegate = self;
|
|
|
+ //inputView.keyboardType = UIKeyboardTypeNumberPad;
|
|
|
+ [inputBackGround addSubview:inputView];
|
|
|
+ [inputView setTintColor:[UIColor hwColor:@"#FF9500" alpha:1.0]];
|
|
|
+
|
|
|
+ //inputView.text = @"0xa8d3cbfb5a7142630a928249616f7d13a71663cac05265849d8c45cbabd5a275";
|
|
|
+
|
|
|
+ [inputView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.mas_equalTo(-10);
|
|
|
+ make.left.mas_equalTo(10);
|
|
|
+ make.top.mas_equalTo(5);
|
|
|
+ make.bottom.mas_equalTo(-5);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ [inputView addSubview:inputTipLab];
|
|
|
+ [inputTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(0);
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.centerY.mas_equalTo(0);
|
|
|
+ make.height.mas_equalTo(20);
|
|
|
+ }];
|
|
|
+
|
|
|
+ //取消按钮
|
|
|
+ UIButton* _leftCancleButton = [[UIButton alloc] init];
|
|
|
+ [_leftCancleButton setTitleColor:[UIColor hwColor:@"#0A132B" alpha:1.0] forState:UIControlStateNormal];
|
|
|
+ _leftCancleButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
|
|
|
+ //_leftCancleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
|
|
+ [_leftCancleButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ _leftCancleButton.tag = 1;
|
|
|
+ _leftCancleButton.backgroundColor = [UIColor hwColor:@"#EEEEEE"];
|
|
|
+ _leftCancleButton.layer.cornerRadius = 8;
|
|
|
+ [_leftCancleButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
|
|
|
+ [whiteBackGround addSubview:_leftCancleButton];
|
|
|
+
|
|
|
+ [_leftCancleButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(inputBackGround.mas_left).offset(0);
|
|
|
+ make.right.equalTo(inputBackGround.mas_centerX).offset(-10);
|
|
|
+ make.height.mas_equalTo(40);
|
|
|
+ make.bottom.mas_equalTo(-30);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ //校验按钮
|
|
|
+ UIButton *_rightSelectAllButton = [[UIButton alloc] init];
|
|
|
+ [_rightSelectAllButton setTitleColor:[UIColor hwColor:@"#000000" alpha:1.0] forState:UIControlStateNormal];
|
|
|
+ _rightSelectAllButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
|
|
|
+ //_leftCancleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
|
|
+ [_rightSelectAllButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ _rightSelectAllButton.tag = 2;
|
|
|
+ _rightSelectAllButton.backgroundColor = [UIColor hwColor:@"#FFD315"];
|
|
|
+ _rightSelectAllButton.layer.cornerRadius = 8;
|
|
|
+ [_rightSelectAllButton setTitle:NSLocalizedString(@"qrcode_secret_key_check_tip",nil) forState:UIControlStateNormal];
|
|
|
+ [whiteBackGround addSubview:_rightSelectAllButton];
|
|
|
+
|
|
|
+ [_rightSelectAllButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.equalTo(inputBackGround.mas_right).offset(0);
|
|
|
+ make.left.equalTo(inputBackGround.mas_centerX).offset(10);
|
|
|
+ make.height.mas_equalTo(40);
|
|
|
+ make.bottom.mas_equalTo(-30);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+//- (void)textViewDidChange:(UITextView *)textView {
|
|
|
+// if (textView.text.length > 0) {
|
|
|
+// NSLog(@"有输入内容: %@", textView.text);
|
|
|
+// // 执行有内容时的操作
|
|
|
+// inputTipLab.hidden = YES;
|
|
|
+// } else {
|
|
|
+// NSLog(@"没有输入内容");
|
|
|
+// // 执行无内容时的操作
|
|
|
+// inputTipLab.hidden = NO;
|
|
|
+// }
|
|
|
+//}
|
|
|
+
|
|
|
+- (void)textViewDidBeginEditing:(UITextView *)textView
|
|
|
+{
|
|
|
+ inputTipLab.hidden = YES;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)textViewDidEndEditing:(UITextView *)textView
|
|
|
+{
|
|
|
+ if (textView.text.length > 0) {
|
|
|
+ NSLog(@"有输入内容: %@", textView.text);
|
|
|
+ // 执行有内容时的操作
|
|
|
+ inputTipLab.hidden = YES;
|
|
|
+ } else {
|
|
|
+ NSLog(@"没有输入内容");
|
|
|
+ // 执行无内容时的操作
|
|
|
+ inputTipLab.hidden = NO;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 按钮点击时间
|
|
|
+- (void)didClickButtonFun:(UIButton*)but
|
|
|
+{
|
|
|
+ NSInteger tag = but.tag;
|
|
|
+
|
|
|
+ if (tag == 1) {
|
|
|
+ if (_didClickCancelButton) {
|
|
|
+ _didClickCancelButton();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (tag == 2) {
|
|
|
+ NSString *codeStr = [inputView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
|
|
+ if (codeStr.length > 0) {
|
|
|
+ if (_didClickOKButton) {
|
|
|
+ _didClickOKButton(codeStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+@end
|