Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 77f8a04

Browse files
authored
Merge pull request #125 from wordpress-mobile/issues/12398-signup-siwa-button
[SIWA] Add Continue with Apple to Sign Up
2 parents f8124a7 + 34122fa commit 77f8a04

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

WordPressAuthenticator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressAuthenticator"
3-
s.version = "1.8.0-beta.13"
3+
s.version = "1.8.0-beta.14"
44
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."
55

66
s.description = <<-DESC

WordPressAuthenticator/Signin/LoginEmailViewController.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder {
453453
vc.googleTapped = { [weak self] in
454454
self?.performSegue(withIdentifier: NUXViewController.SegueIdentifier.showGoogle.rawValue, sender: self)
455455
}
456+
vc.appleTapped = { [weak self] in
457+
self?.appleTapped()
458+
}
456459
vc.modalPresentationStyle = .custom
457460
}
458461
}
@@ -540,6 +543,13 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder {
540543
}
541544
}
542545
}
546+
547+
private func appleTapped() {
548+
#if XCODE11
549+
AppleAuthenticator.sharedInstance.delegate = self
550+
AppleAuthenticator.sharedInstance.showFrom(viewController: self)
551+
#endif
552+
}
543553
}
544554

545555
// LoginFacadeDelegate methods for Google Google Sign In
@@ -626,3 +636,12 @@ extension LoginEmailViewController: LoginSocialErrorViewControllerDelegate {
626636
/// This is needed to set self as uiDelegate, even though none of the methods are called
627637
extension LoginEmailViewController: GIDSignInUIDelegate {
628638
}
639+
640+
#if XCODE11
641+
extension LoginEmailViewController: AppleAuthenticatorDelegate {
642+
func showWPComLogin(loginFields: LoginFields) {
643+
self.loginFields = loginFields
644+
performSegue(withIdentifier: .showWPComLogin, sender: self)
645+
}
646+
}
647+
#endif

WordPressAuthenticator/Signin/LoginPrologueSignupMethodViewController.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class LoginPrologueSignupMethodViewController: NUXViewController {
1212

1313
open var emailTapped: (() -> Void)?
1414
open var googleTapped: (() -> Void)?
15+
open var appleTapped: (() -> Void)?
1516

1617
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
1718
super.prepare(for: segue, sender: sender)
@@ -68,11 +69,27 @@ class LoginPrologueSignupMethodViewController: NUXViewController {
6869
self?.present(safariViewController, animated: true, completion: nil)
6970
}
7071
buttonViewController.stackView?.insertArrangedSubview(termsButton, at: 0)
72+
73+
if WordPressAuthenticator.shared.configuration.enableSignInWithApple {
74+
#if XCODE11
75+
if #available(iOS 13.0, *) {
76+
let appleButton = WPStyleGuide.appleLoginButton()
77+
appleButton.addTarget(self, action: #selector(handleAppleButtonTapped), for: .touchDown)
78+
buttonViewController.stackView?.insertArrangedSubview(appleButton, at: 1)
79+
}
80+
#endif
81+
}
82+
7183
buttonViewController.backgroundColor = WordPressAuthenticator.shared.style.viewControllerBackgroundColor
7284
}
7385

7486
@IBAction func dismissTapped() {
7587
WordPressAuthenticator.track(.signupCancelled)
7688
dismiss(animated: true)
7789
}
90+
91+
@objc func handleAppleButtonTapped() {
92+
dismiss(animated: true)
93+
appleTapped?()
94+
}
7895
}

WordPressAuthenticator/Signin/LoginPrologueViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class LoginPrologueViewController: LoginViewController {
5151
vc.googleTapped = { [weak self] in
5252
self?.performSegue(withIdentifier: .showGoogle, sender: self)
5353
}
54+
vc.appleTapped = { [weak self] in
55+
self?.appleTapped()
56+
}
5457
vc.modalPresentationStyle = .custom
5558
}
5659

0 commit comments

Comments
 (0)