205 lines
6.9 KiB
Objective-C
205 lines
6.9 KiB
Objective-C
//
|
|
// LoginPhoneViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/9/8.
|
|
//
|
|
|
|
#import "LoginPhoneViewController.h"
|
|
///第三方
|
|
#import <Masonry/Masonry.h>
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
|
///Tool
|
|
#import "UIImage+Utils.h"
|
|
#import "ThemeColor.h"
|
|
#import "XPMacro.h"
|
|
///View
|
|
#import "LoginInputView.h"
|
|
///ViewController
|
|
#import "LoginVerifCodeViewController.h"
|
|
#import "LoginPasswordViewController.h"
|
|
|
|
@interface LoginPhoneViewController ()
|
|
///密码登录
|
|
@property (nonatomic,strong) UIButton *passwordLoginButton;
|
|
///标题的容器
|
|
@property (nonatomic,strong) UIStackView *titleStackView;
|
|
///标题
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
///未注册手机号自定登录
|
|
@property (nonatomic,strong) UILabel *autoLoginLabel;
|
|
///输入手机号
|
|
@property (nonatomic,strong) LoginInputView *phoneView;
|
|
///下一步
|
|
@property (nonatomic,strong) UIButton *nextButton;
|
|
///手机号
|
|
@property (nonatomic,copy) NSString *phone;
|
|
///返回按钮
|
|
@property (nonatomic,strong) UIButton *backButton;
|
|
|
|
@end
|
|
|
|
@implementation LoginPhoneViewController
|
|
- (BOOL)isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
[self initEevents];
|
|
|
|
}
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self.view addSubview:self.backButton];
|
|
[self.view addSubview:self.passwordLoginButton];
|
|
[self.view addSubview:self.titleStackView];
|
|
[self.view addSubview:self.phoneView];
|
|
[self.view addSubview:self.nextButton];
|
|
|
|
[self.titleStackView addArrangedSubview:self.titleLabel];
|
|
[self.titleStackView addArrangedSubview:self.autoLoginLabel];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
[self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.view).mas_offset(10);
|
|
make.top.mas_equalTo(statusbarHeight);
|
|
make.height.width.mas_equalTo(44);
|
|
}];
|
|
|
|
[self.passwordLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(self.view).offset(-15);
|
|
make.bottom.mas_equalTo(self.titleStackView.mas_top).offset(-30);
|
|
}];
|
|
|
|
[self.titleStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self.view);
|
|
make.top.mas_equalTo(self.view).offset(75 + kNavigationHeight);
|
|
}];
|
|
|
|
[self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.view).inset(52);
|
|
make.height.mas_equalTo(45);
|
|
make.top.mas_equalTo(self.titleStackView.mas_bottom).offset(65);
|
|
}];
|
|
|
|
[self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.height.mas_equalTo(self.phoneView);
|
|
make.top.mas_equalTo(self.phoneView.mas_bottom).offset(20);
|
|
}];
|
|
}
|
|
|
|
- (void)initEevents {
|
|
@weakify(self);
|
|
RAC(self.nextButton, enabled) = [self.phoneView.textField.rac_textSignal filter:^BOOL(NSString * _Nullable value) {
|
|
@strongify(self);
|
|
self.phone = value;
|
|
self.nextButton.enabled = (value.length == 11 || value.length == 7);
|
|
return (value.length == 11 || value.length == 7);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Event Response
|
|
- (void)nextButtonAction:(UIButton *)sender {
|
|
LoginVerifCodeViewController * codeVC = [[LoginVerifCodeViewController alloc] init];
|
|
codeVC.phone = self.phone;
|
|
codeVC.type = VerifCodeType_Regist;
|
|
[self.navigationController pushViewController:codeVC animated:YES];
|
|
}
|
|
|
|
- (void)passwordLoginButtonAction:(UIButton *)sender {
|
|
LoginPasswordViewController * passwordVC = [[LoginPasswordViewController alloc] init];
|
|
[self.navigationController pushViewController:passwordVC animated:YES];
|
|
}
|
|
|
|
- (void)backButtonAction:(UIButton *)sender {
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (UIButton *)passwordLoginButton {
|
|
if (!_passwordLoginButton) {
|
|
_passwordLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_passwordLoginButton setTitle:@"密码登录" forState:UIControlStateNormal];
|
|
[_passwordLoginButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateNormal];
|
|
_passwordLoginButton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size:15];
|
|
[_passwordLoginButton addTarget:self action:@selector(passwordLoginButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _passwordLoginButton;
|
|
}
|
|
|
|
- (UIStackView *)titleStackView {
|
|
if (!_titleStackView) {
|
|
_titleStackView = [[UIStackView alloc] init];
|
|
_titleStackView.axis = UILayoutConstraintAxisVertical;
|
|
_titleStackView.distribution = UIStackViewDistributionFillEqually;
|
|
_titleStackView.alignment = UIStackViewAlignmentCenter;
|
|
_titleStackView.spacing = 10;
|
|
}
|
|
return _titleStackView;
|
|
}
|
|
|
|
- (UILabel *)autoLoginLabel {
|
|
if (!_autoLoginLabel) {
|
|
_autoLoginLabel = [[UILabel alloc] init];
|
|
_autoLoginLabel.text = @"未注册的手机号自动登录";
|
|
_autoLoginLabel.textAlignment = NSTextAlignmentCenter;
|
|
_autoLoginLabel.font = [UIFont systemFontOfSize:11];
|
|
_autoLoginLabel.textColor = [ThemeColor secondTextColor];
|
|
}
|
|
return _autoLoginLabel;
|
|
}
|
|
|
|
- (UILabel *)titleLabel{
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.font = [UIFont boldSystemFontOfSize:18];
|
|
_titleLabel.text = @"你的手机号是多少";
|
|
_titleLabel.textColor = [ThemeColor mainTextColor];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (LoginInputView *)phoneView {
|
|
if (!_phoneView) {
|
|
_phoneView = [[LoginInputView alloc] init];
|
|
_phoneView.backgroundColor = [ThemeColor appCellBackgroundColor];
|
|
_phoneView.layer.masksToBounds = YES;
|
|
_phoneView.layer.cornerRadius = 45/2;
|
|
_phoneView.maxLength = 11;
|
|
}
|
|
return _phoneView;
|
|
}
|
|
|
|
- (UIButton *)nextButton{
|
|
if (!_nextButton) {
|
|
_nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
_nextButton.layer.masksToBounds = YES;
|
|
_nextButton.layer.cornerRadius = 45/2.f;
|
|
[_nextButton setTitle:@"下一步" forState:UIControlStateNormal];
|
|
_nextButton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
|
|
[_nextButton setTitleColor:[ThemeColor confirmButtonTextColor] forState:UIControlStateNormal];
|
|
_nextButton.enabled = NO;
|
|
UIImage *image = [UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
|
|
[_nextButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor disableButtonColor], [ThemeColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
|
|
[_nextButton setBackgroundImage:image forState:UIControlStateNormal];
|
|
[_nextButton addTarget:self action:@selector(nextButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _nextButton;
|
|
}
|
|
|
|
- (UIButton *)backButton {
|
|
if (!_backButton) {
|
|
_backButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_backButton setImage:[UIImage imageNamed:@"common_nav_back"] forState:UIControlStateNormal];
|
|
[_backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _backButton;
|
|
}
|
|
|
|
@end
|