|
@@ -0,0 +1,268 @@
|
|
|
+//
|
|
|
+// LoginType1ViewController.m
|
|
|
+// 双子星云手机
|
|
|
+//
|
|
|
+// Created by xd h on 2025/1/16.
|
|
|
+//
|
|
|
+
|
|
|
+#import "LoginType1ViewController.h"
|
|
|
+
|
|
|
+@interface LoginType1ViewController ()<UITextViewDelegate,UITextFieldDelegate>
|
|
|
+@property(nonatomic,strong) UITextField *accountTF;
|
|
|
+@property(nonatomic,strong) UIButton *loginOkBut;
|
|
|
+@property(nonatomic,strong) UIButton *protocolSelectBut;//协议按钮
|
|
|
+@property(nonatomic,strong) CAGradientLayer *gradientLayer;
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation LoginType1ViewController
|
|
|
+
|
|
|
+- (void)viewDidLoad {
|
|
|
+ [super viewDidLoad];
|
|
|
+ // Do any additional setup after loading the view.
|
|
|
+
|
|
|
+ [self drawAnyView];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (void)drawAnyView{
|
|
|
+ [self.navigationBar setHidden:YES];
|
|
|
+ [self.toolBar setHidden:YES];
|
|
|
+
|
|
|
+ [self initBaseUIFun];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)initBaseUIFun
|
|
|
+{
|
|
|
+ self.view.backgroundColor = [UIColor whiteColor];
|
|
|
+
|
|
|
+ UIImageView *logoImageV = [UIImageView new];
|
|
|
+ logoImageV.image = [UIImage imageNamed:@"PrivateX_icon"];
|
|
|
+ [self.view addSubview:logoImageV];
|
|
|
+
|
|
|
+ [logoImageV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.mas_equalTo(64);
|
|
|
+ make.height.mas_equalTo(64);
|
|
|
+ make.centerX.mas_equalTo(0);
|
|
|
+ make.top.mas_equalTo(180);
|
|
|
+ }];
|
|
|
+
|
|
|
+ //背景
|
|
|
+ UIView *bgView = [UIView new];
|
|
|
+ bgView.backgroundColor = [UIColor hwColor:@"#F5F7FA"];
|
|
|
+ bgView.layer.cornerRadius = 8;
|
|
|
+ [self.view addSubview:bgView];
|
|
|
+
|
|
|
+ [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(20);
|
|
|
+ make.right.mas_equalTo(-20);
|
|
|
+ make.height.mas_equalTo(50);
|
|
|
+ make.top.equalTo(logoImageV.mas_bottom).offset(80);
|
|
|
+ }];
|
|
|
+
|
|
|
+ NSString *curTitle = NSLocalizedString(@"input_your_account",nil);
|
|
|
+ UILabel *tipLabel = [[UILabel alloc] init];
|
|
|
+ tipLabel.text = curTitle;
|
|
|
+ tipLabel.textColor = [UIColor hwColor:@"#999999"];
|
|
|
+ tipLabel.font = [UIFont systemFontOfSize:14.0];
|
|
|
+ [bgView addSubview:tipLabel];
|
|
|
+
|
|
|
+ [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(15);
|
|
|
+ make.height.mas_equalTo(30);
|
|
|
+ make.centerY.mas_equalTo(0);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIButton *scanBut = [[UIButton alloc] init];
|
|
|
+ [scanBut setImage:[UIImage imageNamed:@"login_scan"] forState:UIControlStateNormal];
|
|
|
+ [bgView addSubview:scanBut];
|
|
|
+ //scanBut.backgroundColor = [UIColor greenColor];
|
|
|
+
|
|
|
+ [scanBut mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.width.mas_equalTo(50);
|
|
|
+ make.height.mas_equalTo(50);
|
|
|
+ make.top.mas_equalTo(0);
|
|
|
+ }];
|
|
|
+
|
|
|
+ _accountTF = [[UITextField alloc] init];
|
|
|
+ _accountTF.textColor = [UIColor blackColor];
|
|
|
+ _accountTF.font = [UIFont systemFontOfSize:12];
|
|
|
+ _accountTF.delegate = self;
|
|
|
+ //_accountTF.keyboardType = UIKeyboardTypeDecimalPad;
|
|
|
+ [bgView addSubview:_accountTF];
|
|
|
+
|
|
|
+ [_accountTF mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(tipLabel.mas_right).offset(5);
|
|
|
+ make.right.equalTo(scanBut.mas_left).offset(0);
|
|
|
+ make.height.mas_equalTo(50);
|
|
|
+ make.top.mas_equalTo(0);
|
|
|
+ }];
|
|
|
+
|
|
|
+ _loginOkBut = [[UIButton alloc] init];
|
|
|
+
|
|
|
+ _gradientLayer = [CAGradientLayer layer];
|
|
|
+ _gradientLayer.frame = CGRectMake(0, 0, (SCREEN_W - 20*2), 50);
|
|
|
+ _gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:0.5].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:0.5].CGColor];
|
|
|
+ _gradientLayer.locations = @[@(0), @(1.0f)];
|
|
|
+ _gradientLayer.startPoint = CGPointMake(0, 0.5);
|
|
|
+ _gradientLayer.endPoint = CGPointMake(0.97, 0.5);
|
|
|
+ [_loginOkBut.layer addSublayer:_gradientLayer];
|
|
|
+
|
|
|
+ [_loginOkBut setTitle:NSLocalizedString(@"login_type1_but_title",nil) forState:UIControlStateNormal];
|
|
|
+ _loginOkBut.titleLabel.font = [UIFont systemFontOfSize:16.0];
|
|
|
+ [_loginOkBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
+ _loginOkBut.layer.cornerRadius = 8;
|
|
|
+ _loginOkBut.layer.masksToBounds = YES;
|
|
|
+ _loginOkBut.enabled = NO;
|
|
|
+ _loginOkBut.tag = 1;
|
|
|
+ [_loginOkBut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:_loginOkBut];
|
|
|
+
|
|
|
+
|
|
|
+ [_loginOkBut mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.mas_equalTo(50);
|
|
|
+ make.left.mas_equalTo(20);
|
|
|
+ make.right.mas_equalTo(-20);
|
|
|
+ make.top.mas_equalTo(bgView.mas_bottom).offset(42);
|
|
|
+ }];
|
|
|
+
|
|
|
+ //协议
|
|
|
+ _protocolSelectBut = [[UIButton alloc] init];
|
|
|
+ [_protocolSelectBut setImage:[UIImage imageNamed:@"common_un_check_24"] forState:UIControlStateNormal];
|
|
|
+ [_protocolSelectBut setImage:[UIImage imageNamed:@"common_did_check_24"] forState:UIControlStateSelected];
|
|
|
+ [_protocolSelectBut addTarget:self action:@selector(didClickProtocolButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:_protocolSelectBut];
|
|
|
+
|
|
|
+ [_protocolSelectBut mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(20);
|
|
|
+ make.width.mas_equalTo(30);
|
|
|
+ make.height.mas_equalTo(30);
|
|
|
+ make.top.equalTo(_loginOkBut.mas_bottom).offset(15);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UITextView *contentTV = [[UITextView alloc] init];
|
|
|
+ contentTV.backgroundColor = [UIColor whiteColor];
|
|
|
+ contentTV.textColor = [UIColor hwColor:@"#999999"];
|
|
|
+ contentTV.delegate = self;
|
|
|
+ contentTV.editable = NO; //必须禁止输入,否则点击将弹出输入键盘
|
|
|
+ contentTV.scrollEnabled = NO;
|
|
|
+ [self.view addSubview:contentTV];
|
|
|
+ //contentTV.backgroundColor = [UIColor greenColor];
|
|
|
+
|
|
|
+ [contentTV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.mas_equalTo(60);
|
|
|
+ make.left.equalTo(_protocolSelectBut.mas_right).offset(0);
|
|
|
+ make.right.mas_equalTo(-20);
|
|
|
+ make.top.equalTo(_protocolSelectBut.mas_top).offset(-2);
|
|
|
+ }];
|
|
|
+
|
|
|
+ // 创建长按手势识别器
|
|
|
+ UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress)];
|
|
|
+ // 设置长按手势的最小按压时间
|
|
|
+ longPress.minimumPressDuration = 0.5; // 2
|
|
|
+ // 将手势识别器添加到视图上
|
|
|
+ [contentTV addGestureRecognizer:longPress];
|
|
|
+
|
|
|
+ NSString *title1 = NSLocalizedString(@"login_protocol_tip_1",nil);
|
|
|
+ NSString *title2 = NSLocalizedString(@"login_protocol_tip_2",nil);
|
|
|
+ NSString *title3 = NSLocalizedString(@"login_protocol_tip_3",nil);
|
|
|
+ NSString *title4 = NSLocalizedString(@"login_protocol_tip_4",nil);
|
|
|
+ NSString *title5 = NSLocalizedString(@"login_protocol_tip_5",nil);
|
|
|
+
|
|
|
+
|
|
|
+ NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@%@%@%@%@",title1,title2,title3,title4,title5];
|
|
|
+
|
|
|
+ NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle];
|
|
|
+ NSRange redRange = NSMakeRange([fullTitle rangeOfString:title2].location, [fullTitle rangeOfString:title2].length);
|
|
|
+ UIColor *noteColor =[UIColor hwColor:@"#13B2EB" alpha:1.0];
|
|
|
+ [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
|
|
|
+
|
|
|
+ NSRange redRange4 = NSMakeRange([fullTitle rangeOfString:title4].location, [fullTitle rangeOfString:title4].length);
|
|
|
+ [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange4];
|
|
|
+
|
|
|
+ [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:NSMakeRange(0, attrStr.length)];
|
|
|
+
|
|
|
+ // 设置段落样式以实现水平中间对齐
|
|
|
+ NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
|
|
+ paragraphStyle.alignment = NSTextAlignmentLeft; // 水平中间对齐
|
|
|
+ [attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attrStr.length)];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [attrStr addAttribute:NSLinkAttributeName
|
|
|
+ value:@"didclick1://"
|
|
|
+ range:redRange];
|
|
|
+
|
|
|
+ [attrStr addAttribute:NSLinkAttributeName
|
|
|
+ value:@"didclick2://"
|
|
|
+ range:redRange4];
|
|
|
+
|
|
|
+ contentTV.attributedText = attrStr;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark ---- textView Delegate ----
|
|
|
+- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction
|
|
|
+{
|
|
|
+
|
|
|
+ if([[URL scheme] isEqualToString:@"didclick1"]){
|
|
|
+
|
|
|
+// if(_didClickButtonFun){
|
|
|
+// _didClickButtonFun(10);
|
|
|
+// }
|
|
|
+ return NO;
|
|
|
+ }
|
|
|
+
|
|
|
+ return YES;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 拦截长按事件
|
|
|
+- (void)longPress{
|
|
|
+ HLog(@"拦截长按事件")
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - UITextFieldDelegate Methods
|
|
|
+
|
|
|
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
|
|
+ // 在这里处理文本输入事件
|
|
|
+ //NSString *currentText = textField.text;
|
|
|
+ //NSString *updatedText = [currentText stringByReplacingCharactersInRange:range withString:string];
|
|
|
+
|
|
|
+ // 打印更新后的文本
|
|
|
+ //NSLog(@"Updated Text: %@", updatedText);
|
|
|
+
|
|
|
+ [self checkLoginButCanClickFun];
|
|
|
+ return YES;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 点击登录
|
|
|
+- (void)didClickButtonFun:(UIButton*)but
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 点击协议
|
|
|
+- (void)didClickProtocolButtonFun:(UIButton*)but
|
|
|
+{
|
|
|
+ _protocolSelectBut.selected = !_protocolSelectBut.selected;
|
|
|
+ [self checkLoginButCanClickFun];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 检测登录按钮是否可用
|
|
|
+- (void)checkLoginButCanClickFun
|
|
|
+{
|
|
|
+ if(_protocolSelectBut.selected && _accountTF.text.length > 0){
|
|
|
+ if (!_loginOkBut.enabled) {
|
|
|
+ _loginOkBut.enabled = YES;
|
|
|
+ _gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if(_loginOkBut.enabled){
|
|
|
+ _loginOkBut.enabled = NO;
|
|
|
+ _gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:0.5].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:0.5].CGColor];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+@end
|