1
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
//
|
||||
|
||||
#import "KBEmailRegistVC.h"
|
||||
#import "KBEmailLoginVC.h"
|
||||
#import <AuthenticationServices/AuthenticationServices.h>
|
||||
#import "KBLoginVM.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@interface KBEmailRegistVC () <UITextViewDelegate, UITextFieldDelegate>
|
||||
|
||||
@@ -40,13 +44,13 @@
|
||||
@property (nonatomic, strong) UIButton *submitButton; // 绿色 Login 按钮
|
||||
|
||||
// 其他登录方式
|
||||
@property (nonatomic, strong) UIButton *appleLoginButton; // Continue Through Apple
|
||||
@property (nonatomic, strong) UIControl *appleLoginButton; // Continue Through Apple(ASAuthorizationAppleIDButton)
|
||||
@property (nonatomic, strong) UIButton *emailLoginButton; // Continue Via Email
|
||||
|
||||
// 协议 & 底部文案
|
||||
@property (nonatomic, strong) UITextView *agreementTextView; // 底部协议富文本
|
||||
@property (nonatomic, strong) UILabel *accountTipLabel; // “Already Have An Account?”
|
||||
@property (nonatomic, strong) UIButton *switchAccountButton; // “Sign In”
|
||||
//@property (nonatomic, strong) UILabel *accountTipLabel; // “Already Have An Account?”
|
||||
//@property (nonatomic, strong) UIButton *switchAccountButton; // “Sign In”
|
||||
|
||||
@end
|
||||
|
||||
@@ -212,32 +216,32 @@
|
||||
// 协议文案
|
||||
[self.scrollContentView addSubview:self.agreementTextView];
|
||||
[self.agreementTextView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.emailLoginButton.mas_bottom).offset(16);
|
||||
make.bottom.equalTo(self.scrollContentView).offset(-KB_SAFE_BOTTOM - 16);
|
||||
make.left.equalTo(self.scrollContentView).offset(30);
|
||||
make.right.equalTo(self.scrollContentView).offset(-30);
|
||||
}];
|
||||
|
||||
// 底部账号切换文案
|
||||
UIView *accountLine = [UIView new];
|
||||
[self.scrollContentView addSubview:accountLine];
|
||||
[accountLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.agreementTextView.mas_bottom).offset(16);
|
||||
make.centerX.equalTo(self.scrollContentView);
|
||||
make.bottom.equalTo(self.scrollContentView).offset(-KB_SAFE_BOTTOM - 16);
|
||||
}];
|
||||
// UIView *accountLine = [UIView new];
|
||||
// [self.scrollContentView addSubview:accountLine];
|
||||
// [accountLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.top.equalTo(self.agreementTextView.mas_bottom).offset(16);
|
||||
// make.centerX.equalTo(self.scrollContentView);
|
||||
// make.bottom.equalTo(self.scrollContentView).offset(-KB_SAFE_BOTTOM - 16);
|
||||
// }];
|
||||
|
||||
[accountLine addSubview:self.accountTipLabel];
|
||||
[accountLine addSubview:self.switchAccountButton];
|
||||
|
||||
[self.accountTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.bottom.equalTo(accountLine);
|
||||
}];
|
||||
|
||||
[self.switchAccountButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.accountTipLabel.mas_right).offset(4);
|
||||
make.right.equalTo(accountLine);
|
||||
make.centerY.equalTo(self.accountTipLabel);
|
||||
}];
|
||||
// [accountLine addSubview:self.accountTipLabel];
|
||||
// [accountLine addSubview:self.switchAccountButton];
|
||||
//
|
||||
// [self.accountTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.top.left.bottom.equalTo(accountLine);
|
||||
// }];
|
||||
//
|
||||
// [self.switchAccountButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.equalTo(self.accountTipLabel.mas_right).offset(4);
|
||||
// make.right.equalTo(accountLine);
|
||||
// make.centerY.equalTo(self.accountTipLabel);
|
||||
// }];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
@@ -265,6 +269,8 @@
|
||||
- (void)onTapSwitchAccount {
|
||||
// 注册页/登录页互跳逻辑后续接入
|
||||
KBLOG(@"onTapSwitchAccount");
|
||||
KBEmailLoginVC *vc = [[KBEmailLoginVC alloc] init];
|
||||
[KB_CURRENT_NAV pushViewController:vc animated:true];
|
||||
}
|
||||
|
||||
- (void)onTapTogglePassword:(UIButton *)sender {
|
||||
@@ -279,11 +285,44 @@
|
||||
}
|
||||
|
||||
- (void)onTapAppleLogin {
|
||||
KBLOG(@"onTapAppleLogin in KBEmailRegistVC");
|
||||
// 先校验表单:邮箱、密码、重复密码均有值且两次密码一致
|
||||
NSString *email = [self.emailTextField.text ?: @"" stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
NSString *pwd = self.passwordTextField.text ?: @"";
|
||||
NSString *repeat = self.repeatPasswordTextField.text ?: @"";
|
||||
|
||||
if (email.length == 0 || pwd.length == 0 || repeat.length == 0) {
|
||||
[KBHUD showInfo:KBLocalized(@"Please complete all fields")];
|
||||
return;
|
||||
}
|
||||
if (![pwd isEqualToString:repeat]) {
|
||||
[KBHUD showInfo:KBLocalized(@"The two passwords do not match")];
|
||||
return;
|
||||
}
|
||||
|
||||
KBLOG(@"onTapAppleLogin in KBEmailRegistVC - form validated");
|
||||
|
||||
// 复用登录页的 Apple 登录逻辑
|
||||
[[KBLoginVM shared] signInWithAppleFromViewController:KB_CURRENT_NAV completion:^(BOOL success, NSError * _Nullable error) {
|
||||
if (success) {
|
||||
[KBHUD showInfo:KBLocalized(@"Signed in successfully")];
|
||||
// 登录成功后切换到主 TabBar
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
id<UIApplicationDelegate> appDelegate = UIApplication.sharedApplication.delegate;
|
||||
if ([appDelegate respondsToSelector:@selector(setupRootVC)]) {
|
||||
AppDelegate *delegate = (AppDelegate *)appDelegate;
|
||||
[delegate toMainTabbarVC];
|
||||
}
|
||||
});
|
||||
} else {
|
||||
NSString *msg = error.localizedDescription ?: KBLocalized(@"Sign-in failed");
|
||||
[KBHUD showInfo:msg];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)onTapEmailLogin {
|
||||
KBLOG(@"onTapEmailLogin in KBEmailRegistVC");
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Agreement Tap
|
||||
@@ -314,6 +353,11 @@
|
||||
if (hitTerms || hitPrivacy) {
|
||||
KBLOG(@"tap policy in KBEmailRegistVC");
|
||||
// 后续可统一跳转到协议页
|
||||
if (hitTerms == true) {
|
||||
[KBHUD showInfo:@"hitTerms"];
|
||||
}else{
|
||||
[KBHUD showInfo:@"hitPrivacy"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,7 +579,7 @@
|
||||
[_submitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
_submitButton.titleLabel.font = [KBFont medium:16];
|
||||
_submitButton.backgroundColor = [UIColor colorWithHex:KBColorValue];
|
||||
_submitButton.layer.cornerRadius = 28.0;
|
||||
_submitButton.layer.cornerRadius = 11.0;
|
||||
_submitButton.layer.masksToBounds = YES;
|
||||
[_submitButton addTarget:self
|
||||
action:@selector(onTapSubmit)
|
||||
@@ -544,22 +588,17 @@
|
||||
return _submitButton;
|
||||
}
|
||||
|
||||
- (UIButton *)appleLoginButton {
|
||||
- (UIControl *)appleLoginButton {
|
||||
if (!_appleLoginButton) {
|
||||
_appleLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_appleLoginButton setTitle:KBLocalized(@"Continue Through Apple") forState:UIControlStateNormal];
|
||||
[_appleLoginButton setTitleColor:[UIColor colorWithHex:KBBlackValue] forState:UIControlStateNormal];
|
||||
_appleLoginButton.titleLabel.font = [KBFont medium:16];
|
||||
_appleLoginButton.backgroundColor = [UIColor whiteColor];
|
||||
_appleLoginButton.layer.cornerRadius = 10.0;
|
||||
_appleLoginButton.layer.masksToBounds = YES;
|
||||
_appleLoginButton.layer.borderColor = [UIColor colorWithHex:0xE5E5E5].CGColor;
|
||||
_appleLoginButton.layer.borderWidth = 1;
|
||||
_appleLoginButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
|
||||
// 若后续有 Apple 图标资源,可在此设置 imageEdgeInsets 与图标
|
||||
[_appleLoginButton addTarget:self
|
||||
action:@selector(onTapAppleLogin)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
ASAuthorizationAppleIDButton *btn = [ASAuthorizationAppleIDButton buttonWithType:ASAuthorizationAppleIDButtonTypeSignIn
|
||||
style:ASAuthorizationAppleIDButtonStyleWhite];
|
||||
[btn addTarget:self action:@selector(onTapAppleLogin) forControlEvents:UIControlEventTouchUpInside];
|
||||
btn.cornerRadius = 10.0;
|
||||
btn.layer.borderColor = [UIColor colorWithHex:0xE5E5E5].CGColor;
|
||||
btn.layer.borderWidth = 1;
|
||||
btn.layer.cornerRadius = 10.0;
|
||||
btn.layer.masksToBounds = true;
|
||||
_appleLoginButton = btn;
|
||||
}
|
||||
return _appleLoginButton;
|
||||
}
|
||||
@@ -569,7 +608,7 @@
|
||||
_emailLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_emailLoginButton setTitle:KBLocalized(@"Continue Via Email") forState:UIControlStateNormal];
|
||||
[_emailLoginButton setTitleColor:[UIColor colorWithHex:KBBlackValue] forState:UIControlStateNormal];
|
||||
_emailLoginButton.titleLabel.font = [KBFont medium:16];
|
||||
_emailLoginButton.titleLabel.font = [KBFont medium:19];
|
||||
_emailLoginButton.backgroundColor = [UIColor whiteColor];
|
||||
_emailLoginButton.layer.cornerRadius = 10.0;
|
||||
_emailLoginButton.layer.masksToBounds = YES;
|
||||
@@ -656,27 +695,27 @@
|
||||
return _agreementTextView;
|
||||
}
|
||||
|
||||
- (UILabel *)accountTipLabel {
|
||||
if (!_accountTipLabel) {
|
||||
_accountTipLabel = [UILabel new];
|
||||
_accountTipLabel.text = KBLocalized(@"Already Have An Account?");
|
||||
_accountTipLabel.font = [KBFont regular:10];
|
||||
_accountTipLabel.textColor = [UIColor colorWithHex:KBBlackValue];
|
||||
}
|
||||
return _accountTipLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)switchAccountButton {
|
||||
if (!_switchAccountButton) {
|
||||
_switchAccountButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_switchAccountButton setTitle:KBLocalized(@"Sign In") forState:UIControlStateNormal];
|
||||
[_switchAccountButton setTitleColor:[UIColor colorWithHex:KBColorValue] forState:UIControlStateNormal];
|
||||
_switchAccountButton.titleLabel.font = [KBFont medium:10];
|
||||
[_switchAccountButton addTarget:self
|
||||
action:@selector(onTapSwitchAccount)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _switchAccountButton;
|
||||
}
|
||||
//- (UILabel *)accountTipLabel {
|
||||
// if (!_accountTipLabel) {
|
||||
// _accountTipLabel = [UILabel new];
|
||||
// _accountTipLabel.text = KBLocalized(@"Already Have An Account?");
|
||||
// _accountTipLabel.font = [KBFont regular:10];
|
||||
// _accountTipLabel.textColor = [UIColor colorWithHex:KBBlackValue];
|
||||
// }
|
||||
// return _accountTipLabel;
|
||||
//}
|
||||
//
|
||||
//- (UIButton *)switchAccountButton {
|
||||
// if (!_switchAccountButton) {
|
||||
// _switchAccountButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
// [_switchAccountButton setTitle:KBLocalized(@"Sign In") forState:UIControlStateNormal];
|
||||
// [_switchAccountButton setTitleColor:[UIColor colorWithHex:KBColorValue] forState:UIControlStateNormal];
|
||||
// _switchAccountButton.titleLabel.font = [KBFont medium:10];
|
||||
// [_switchAccountButton addTarget:self
|
||||
// action:@selector(onTapSwitchAccount)
|
||||
// forControlEvents:UIControlEventTouchUpInside];
|
||||
// }
|
||||
// return _switchAccountButton;
|
||||
//}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user