166 lines
6.2 KiB
Objective-C
166 lines
6.2 KiB
Objective-C
//
|
|
// XPLoginAuthCodeVC.m
|
|
// YuMi
|
|
//
|
|
// Created by duoban on 2023/8/11.
|
|
//
|
|
|
|
#import "XPLoginAuthCodeVC.h"
|
|
#import "XPLoginInputView.h"
|
|
#import <ReactiveObjC.h>
|
|
#import "LoginVerifCodePresent.h"
|
|
#import "LoginFullInfoViewController.h"
|
|
@interface XPLoginAuthCodeVC ()
|
|
///背景
|
|
@property(nonatomic,strong) UIImageView *bgImageView;
|
|
|
|
/// 手机号登录
|
|
@property (nonatomic, strong) UILabel *titleLabel;
|
|
/// 手机号输入框
|
|
@property (nonatomic, strong) XPLoginInputView *codeInputView;
|
|
/// 登录按钮
|
|
@property (nonatomic, strong) UIButton *loginBtn;
|
|
@end
|
|
|
|
@implementation XPLoginAuthCodeVC
|
|
- (BOOL)isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
- (LoginVerifCodePresent *)createPresenter {
|
|
return [[LoginVerifCodePresent alloc] init];
|
|
}
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self installUI];
|
|
[self installConstraints];
|
|
[self racBind];
|
|
}
|
|
-(void)installUI{
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
[self.view addSubview:self.bgImageView];
|
|
[self.view addSubview:self.titleLabel];
|
|
|
|
|
|
}
|
|
-(void)installConstraints{
|
|
UIView *bgView = [UIView new];
|
|
bgView.backgroundColor = [UIColor whiteColor];
|
|
[self.view addSubview:bgView];
|
|
bgView.layer.cornerRadius = kGetScaleWidth(20);
|
|
bgView.layer.masksToBounds = YES;
|
|
[self.view addSubview:self.codeInputView];
|
|
[self.view addSubview:self.loginBtn];
|
|
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.top.equalTo(self.view);
|
|
make.height.mas_equalTo(kGetScaleWidth(418));
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self.view);
|
|
make.top.mas_equalTo(kGetScaleWidth(128));
|
|
make.leading.mas_equalTo(kGetScaleWidth(24));
|
|
make.height.mas_equalTo(kGetScaleWidth(40));
|
|
}];
|
|
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.bottom.equalTo(self.view);
|
|
make.top.mas_equalTo(kGetScaleWidth(192));
|
|
}];
|
|
[self.codeInputView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.equalTo(self.view);
|
|
make.width.mas_equalTo(kGetScaleWidth(303));
|
|
make.top.mas_equalTo(kGetScaleWidth(260));
|
|
make.height.mas_equalTo(kGetScaleWidth(52));
|
|
}];
|
|
[self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.codeInputView.mas_bottom).offset(kGetScaleWidth(48));
|
|
make.centerX.mas_equalTo(self.view);
|
|
make.height.mas_equalTo(kGetScaleWidth(48));
|
|
make.width.mas_equalTo(kGetScaleWidth(303));
|
|
}];
|
|
}
|
|
- (void)racBind {
|
|
|
|
RAC(self.loginBtn, enabled) = [[RACSignal combineLatest:@[self.codeInputView.inputTextField.rac_textSignal] reduce:^id _Nonnull(NSString *account){
|
|
|
|
return @(account.length > 0);
|
|
}] takeUntil:self.rac_willDeallocSignal];
|
|
}
|
|
-(void)loginBtnClicked{
|
|
[self showLoading];
|
|
[self.presenter bindAuthorizationCodeWithAuthCode:self.codeInputView.inputTextField.text];
|
|
}
|
|
#pragma mark - LoginVerifCodeProtocol
|
|
- (void)bindAuthorizationCodeSuccess{
|
|
[self hideHUD];
|
|
[self showSuccessToast:YMLocalizedString(@"XPLoginAuthCodeVC2")];
|
|
self.loginBtn.enabled = YES;
|
|
if(self.pi_isPush == YES){
|
|
LoginFullInfoViewController * FullVC = [[LoginFullInfoViewController alloc] init];
|
|
[self.navigationController pushViewController:FullVC animated:YES];
|
|
return;
|
|
}
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
if(self.delegate && [self.delegate respondsToSelector:@selector(bindCodeSuccess)]){
|
|
[self.delegate bindCodeSuccess];
|
|
}
|
|
|
|
}
|
|
-(void)bindAuthorizationCodeFail{
|
|
[self hideHUD];
|
|
self.loginBtn.enabled = YES;
|
|
}
|
|
#pragma mark - 懒加载
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.text = YMLocalizedString(@"XPLoginAuthCodeVC0");
|
|
_titleLabel.font = kFontBold(28);
|
|
_titleLabel.textColor = UIColorFromRGB(0x1F1B4F);
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
- (UIImageView *)bgImageView{
|
|
if(!_bgImageView){
|
|
_bgImageView = [[UIImageView alloc]init];
|
|
_bgImageView.image = kImage(@"login_phone_pwd_bg");
|
|
_bgImageView.contentMode = 2;
|
|
}
|
|
return _bgImageView;
|
|
}
|
|
- (XPLoginInputView *)codeInputView {
|
|
if (!_codeInputView) {
|
|
_codeInputView = [[XPLoginInputView alloc] init];
|
|
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginAuthCodeVC1")];
|
|
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
|
|
_codeInputView.inputTextField.attributedPlaceholder = placeholder;
|
|
_codeInputView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
|
|
|
|
}
|
|
return _codeInputView;
|
|
}
|
|
- (UIButton *)loginBtn {
|
|
if (!_loginBtn) {
|
|
_loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
UIImage *nextImage = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
|
|
UIImage *disableImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xD1F9FF),UIColorFromRGB(0xDEE4FF),UIColorFromRGB(0xEEDCFF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
|
|
|
|
[_loginBtn setImage:nextImage forState:UIControlStateNormal];
|
|
[_loginBtn setImage:disableImage forState:UIControlStateDisabled];
|
|
_loginBtn.layer.cornerRadius = kGetScaleWidth(48)/2;
|
|
_loginBtn.layer.masksToBounds = YES;
|
|
|
|
|
|
UILabel *titleView = [UILabel labelInitWithText:YMLocalizedString(@"XPLoginAuthCodeVC3") font:kFontMedium(16) textColor:[UIColor whiteColor]];
|
|
titleView.textAlignment = NSTextAlignmentCenter;
|
|
[_loginBtn addSubview:titleView];
|
|
[titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.loginBtn);
|
|
}];
|
|
[_loginBtn addTarget:self action:@selector(loginBtnClicked) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _loginBtn;
|
|
}
|
|
@end
|