diff --git a/Podfile.lock b/Podfile.lock index 3f1f157e9..b4a04f505 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,20 +1,5 @@ PODS: - 1PasswordExtension (1.8.5) - - AFNetworking (3.2.1): - - AFNetworking/NSURLSession (= 3.2.1) - - AFNetworking/Reachability (= 3.2.1) - - AFNetworking/Security (= 3.2.1) - - AFNetworking/Serialization (= 3.2.1) - - AFNetworking/UIKit (= 3.2.1) - - AFNetworking/NSURLSession (3.2.1): - - AFNetworking/Reachability - - AFNetworking/Security - - AFNetworking/Serialization - - AFNetworking/Reachability (3.2.1) - - AFNetworking/Security (3.2.1) - - AFNetworking/Serialization (3.2.1) - - AFNetworking/UIKit (3.2.1): - - AFNetworking/NSURLSession - Alamofire (4.7.2) - CocoaLumberjack (3.4.2): - CocoaLumberjack/Default (= 3.4.2) @@ -37,11 +22,11 @@ PODS: - GoogleToolboxForMac/Defines (= 2.1.4) - "GoogleToolboxForMac/NSString+URLArguments (= 2.1.4)" - "GoogleToolboxForMac/NSString+URLArguments (2.1.4)" - - Gridicons (0.15) + - Gridicons (0.16) - lottie-ios (2.5.0) - NSObject-SafeExpectations (0.0.3) - "NSURL+IDN (0.3)" - - OCMock (3.4.1) + - OCMock (3.4.2) - OHHTTPStubs (6.1.0): - OHHTTPStubs/Default (= 6.1.0) - OHHTTPStubs/Core (6.1.0) @@ -60,18 +45,17 @@ PODS: - Specta (1.0.7) - SVProgressHUD (2.2.5) - UIDeviceIdentifier (0.5.0) - - WordPressKit (1.0.5): - - AFNetworking (= 3.2.1) - - Alamofire (= 4.7.2) + - WordPressKit (1.1): + - Alamofire (~> 4.7) - CocoaLumberjack (= 3.4.2) - NSObject-SafeExpectations (= 0.0.3) - UIDeviceIdentifier (~> 0.4) - - WordPressShared (= 1.0.3) + - WordPressShared (~> 1.0.3) - wpxmlrpc (= 0.8.3) - - WordPressShared (1.0.3): + - WordPressShared (1.0.8): - CocoaLumberjack (~> 3.4) - FormatterKit/TimeIntervalFormatter (= 1.8.2) - - WordPressUI (1.0.2) + - WordPressUI (1.0.6) - wpxmlrpc (0.8.3) DEPENDENCIES: @@ -97,7 +81,6 @@ DEPENDENCIES: SPEC REPOS: https://github.com/cocoapods/specs.git: - 1PasswordExtension - - AFNetworking - Alamofire - CocoaLumberjack - Expecta @@ -120,25 +103,24 @@ SPEC REPOS: SPEC CHECKSUMS: 1PasswordExtension: 0e95bdea64ec8ff2f4f693be5467a09fac42a83d - AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057 Alamofire: e4fa87002c137ba2d8d634d2c51fabcda0d5c223 CocoaLumberjack: db7cc9e464771f12054c22ff6947c5a58d43a0fd Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5 FormatterKit: 4b8f29acc9b872d5d12a63efb560661e8f2e1b98 GoogleSignInRepacked: d357702618c555f38923576924661325eb1ef22b GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f - Gridicons: 0e5e76ad9fc6f7cbc3da137a9751ef516c5aef73 + Gridicons: 8cc5cb666d5ad8b8f1771d3c7a93d27ae25b7c2e lottie-ios: d699fdee68d7b63e721d949388b015fef1aaa4ac NSObject-SafeExpectations: b989b68a8a9b7b9f2b264a8b52ba9d7aab8f3129 "NSURL+IDN": 82355a0afd532fe1de08f6417c134b49b1a1c4b3 - OCMock: 2cd0716969bab32a2283ff3a46fd26a8c8b4c5e3 + OCMock: ebe9ee1dca7fbed0ff9193ac0b3e2d8862ea56f6 OHHTTPStubs: 1e21c7d2c084b8153fc53d48400d8919d2d432d0 Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66 SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6 UIDeviceIdentifier: a959a6d4f51036b4180dd31fb26483a820f1cc46 - WordPressKit: afe6d2c23db6d4f110638c25e86b029e899ffc34 - WordPressShared: b8e910d8133a54e9452ab7bd9d8e27e78dc2f5ba - WordPressUI: 70bceaff582bdd6fd8f3ed67aaa200e72fce245d + WordPressKit: a24baaa783c3a221f2d9a51c19318cbb27333373 + WordPressShared: 063e1e8b1a7aaf635abf17f091a2d235a068abdc + WordPressUI: af141587ec444f9af753a00605bd0d3f14d8d8a3 wpxmlrpc: bfc572f62ce7ee897f6f38b098d2ba08732ecef4 PODFILE CHECKSUM: adec9882e25404ab01a7a461fcdd3ddd937d5ba6 diff --git a/WordPressAuthenticator.xcodeproj/project.pbxproj b/WordPressAuthenticator.xcodeproj/project.pbxproj index 3ad75f7d3..ceb4131fa 100644 --- a/WordPressAuthenticator.xcodeproj/project.pbxproj +++ b/WordPressAuthenticator.xcodeproj/project.pbxproj @@ -22,7 +22,6 @@ B56090CB208A4F5400399AE4 /* NUXNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090BD208A4F5400399AE4 /* NUXNavigationController.swift */; }; B56090CC208A4F5400399AE4 /* NUXTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090BE208A4F5400399AE4 /* NUXTableViewController.swift */; }; B56090CD208A4F5400399AE4 /* NUXSegueHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090BF208A4F5400399AE4 /* NUXSegueHandler.swift */; }; - B56090CE208A4F5400399AE4 /* NUXSubmitButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090C0208A4F5400399AE4 /* NUXSubmitButton.swift */; }; B56090CF208A4F5400399AE4 /* NUXCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090C1208A4F5400399AE4 /* NUXCollectionViewController.swift */; }; B56090D0208A4F5400399AE4 /* NUXViewControllerBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090C2208A4F5400399AE4 /* NUXViewControllerBase.swift */; }; B56090D1208A4F5400399AE4 /* NUXViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090C3208A4F5400399AE4 /* NUXViewController.swift */; }; @@ -97,6 +96,11 @@ B5ED791D207E993E00A8FD8C /* WPAuthenticatorLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = B5ED7918207E993E00A8FD8C /* WPAuthenticatorLogging.h */; settings = {ATTRIBUTES = (Public, ); }; }; B5ED791F207E993E00A8FD8C /* CocoaLumberjack.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5ED791A207E993E00A8FD8C /* CocoaLumberjack.swift */; }; B5ED7920207E993E00A8FD8C /* WPAuthenticatorLogging.m in Sources */ = {isa = PBXBuildFile; fileRef = B5ED791B207E993E00A8FD8C /* WPAuthenticatorLogging.m */; }; + CE1B18C920EEC2C200BECC3F /* SocialService.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18C820EEC2C200BECC3F /* SocialService.swift */; }; + CE1B18CC20EEC32400BECC3F /* WordPressCredentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18CB20EEC32400BECC3F /* WordPressCredentials.swift */; }; + CE1B18CE20EEC3CB00BECC3F /* WordPressAuthenticatorDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18CD20EEC3CB00BECC3F /* WordPressAuthenticatorDelegateProtocol.swift */; }; + CE1B18D020EEC41600BECC3F /* WordPressAuthenticatorConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18CF20EEC41600BECC3F /* WordPressAuthenticatorConfiguration.swift */; }; + CE1B18D220EEC44400BECC3F /* WordPressAuthenticatorStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1B18D120EEC44400BECC3F /* WordPressAuthenticatorStyles.swift */; }; E8AF6B9EF50902F2117DFAF9 /* Pods_WordPressAuthenticatorTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A441EC80D2B8D2209C2E228 /* Pods_WordPressAuthenticatorTests.framework */; }; /* End PBXBuildFile section */ @@ -149,7 +153,6 @@ B56090BD208A4F5400399AE4 /* NUXNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXNavigationController.swift; sourceTree = ""; }; B56090BE208A4F5400399AE4 /* NUXTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXTableViewController.swift; sourceTree = ""; }; B56090BF208A4F5400399AE4 /* NUXSegueHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXSegueHandler.swift; sourceTree = ""; }; - B56090C0208A4F5400399AE4 /* NUXSubmitButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXSubmitButton.swift; sourceTree = ""; }; B56090C1208A4F5400399AE4 /* NUXCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXCollectionViewController.swift; sourceTree = ""; }; B56090C2208A4F5400399AE4 /* NUXViewControllerBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXViewControllerBase.swift; sourceTree = ""; }; B56090C3208A4F5400399AE4 /* NUXViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXViewController.swift; sourceTree = ""; }; @@ -231,6 +234,11 @@ B5ED791A207E993E00A8FD8C /* CocoaLumberjack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CocoaLumberjack.swift; sourceTree = ""; }; B5ED791B207E993E00A8FD8C /* WPAuthenticatorLogging.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WPAuthenticatorLogging.m; sourceTree = ""; }; C736FF243DE333FCAB1C2614 /* Pods_WordPressAuthenticator.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WordPressAuthenticator.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CE1B18C820EEC2C200BECC3F /* SocialService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialService.swift; sourceTree = ""; }; + CE1B18CB20EEC32400BECC3F /* WordPressCredentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressCredentials.swift; sourceTree = ""; }; + CE1B18CD20EEC3CB00BECC3F /* WordPressAuthenticatorDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorDelegateProtocol.swift; sourceTree = ""; }; + CE1B18CF20EEC41600BECC3F /* WordPressAuthenticatorConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorConfiguration.swift; sourceTree = ""; }; + CE1B18D120EEC44400BECC3F /* WordPressAuthenticatorStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorStyles.swift; sourceTree = ""; }; E9414A95E29F3297555AC92B /* Pods-WordPressAuthenticator.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.debug.xcconfig"; sourceTree = ""; }; FF475C5056EB60A277696BA9 /* Pods-WordPressAuthenticatorTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticatorTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticatorTests/Pods-WordPressAuthenticatorTests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -354,7 +362,6 @@ B56090BB208A4F5300399AE4 /* NUXLinkMailViewController.swift */, B56090BD208A4F5400399AE4 /* NUXNavigationController.swift */, B56090BF208A4F5400399AE4 /* NUXSegueHandler.swift */, - B56090C0208A4F5400399AE4 /* NUXSubmitButton.swift */, B56090BE208A4F5400399AE4 /* NUXTableViewController.swift */, B56090C3208A4F5400399AE4 /* NUXViewController.swift */, B56090C2208A4F5400399AE4 /* NUXViewControllerBase.swift */, @@ -390,7 +397,10 @@ B56090F2208A533100399AE4 /* WordPressAuthenticator+Errors.swift */, B56090F4208A533200399AE4 /* WordPressAuthenticator+Events.swift */, B56090F3208A533100399AE4 /* WordPressAuthenticator+Notifications.swift */, + CE1B18CD20EEC3CB00BECC3F /* WordPressAuthenticatorDelegateProtocol.swift */, B56090F6208A533200399AE4 /* WordPressSupportSourceTag.swift */, + CE1B18CF20EEC41600BECC3F /* WordPressAuthenticatorConfiguration.swift */, + CE1B18D120EEC44400BECC3F /* WordPressAuthenticatorStyles.swift */, ); path = Authenticator; sourceTree = ""; @@ -403,6 +413,7 @@ B5609105208A54F800399AE4 /* OnePasswordFacade.swift */, B5609104208A54F800399AE4 /* SafariCredentialsService.swift */, B56090FE208A54F700399AE4 /* SignupService.swift */, + CE1B18C820EEC2C200BECC3F /* SocialService.swift */, B56090FF208A54F800399AE4 /* WordPressComAccountService.swift */, B56090FC208A54F700399AE4 /* WordPressComBlogService.swift */, B56090FD208A54F700399AE4 /* WordPressComOAuthClientFacade.h */, @@ -468,6 +479,7 @@ B5ED78F6207E976500A8FD8C /* WordPressAuthenticator */ = { isa = PBXGroup; children = ( + CE1B18CA20EEC31000BECC3F /* Credentials */, B5609099208A4EAF00399AE4 /* Authenticator */, B560909B208A4EB000399AE4 /* Extensions */, B5ED7917207E993E00A8FD8C /* Logging */, @@ -519,6 +531,14 @@ path = Logging; sourceTree = ""; }; + CE1B18CA20EEC31000BECC3F /* Credentials */ = { + isa = PBXGroup; + children = ( + CE1B18CB20EEC32400BECC3F /* WordPressCredentials.swift */, + ); + path = Credentials; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -731,7 +751,6 @@ "${BUILT_PRODUCTS_DIR}/OHHTTPStubs/OHHTTPStubs.framework", "${BUILT_PRODUCTS_DIR}/Specta/Specta.framework", "${BUILT_PRODUCTS_DIR}/1PasswordExtension/OnePasswordExtension.framework", - "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", "${BUILT_PRODUCTS_DIR}/CocoaLumberjack/CocoaLumberjack.framework", "${BUILT_PRODUCTS_DIR}/FormatterKit/FormatterKit.framework", @@ -755,7 +774,6 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OHHTTPStubs.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Specta.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OnePasswordExtension.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CocoaLumberjack.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FormatterKit.framework", @@ -790,11 +808,13 @@ B5609140208A563800399AE4 /* LoginSocialErrorCell.swift in Sources */, B56090F7208A533200399AE4 /* WordPressAuthenticator+Errors.swift in Sources */, B56090D2208A4F5400399AE4 /* NUXButton.swift in Sources */, + CE1B18C920EEC2C200BECC3F /* SocialService.swift in Sources */, B56090D3208A4F5400399AE4 /* NUXLinkAuthViewController.swift in Sources */, B5609120208A555E00399AE4 /* SignupNavigationController.swift in Sources */, B5609143208A563800399AE4 /* LoginSocialErrorViewController.swift in Sources */, B56090F8208A533200399AE4 /* WordPressAuthenticator+Notifications.swift in Sources */, B56090EA208A51D000399AE4 /* LoginFields+Validation.swift in Sources */, + CE1B18CC20EEC32400BECC3F /* WordPressCredentials.swift in Sources */, 98AA5A5720AA1A7000A5958A /* WPHelpIndicatorView.swift in Sources */, B560913C208A563800399AE4 /* LoginProloguePromoViewController.swift in Sources */, B560910F208A54F800399AE4 /* SafariCredentialsService.swift in Sources */, @@ -816,7 +836,10 @@ B560910C208A54F800399AE4 /* WordPressComOAuthClientFacade.m in Sources */, B55272C320B2FE4100E18BC5 /* WPAuthenticatorLoggingPrivate.m in Sources */, B56090C7208A4F5400399AE4 /* NUXKeyboardResponder.swift in Sources */, + CE1B18D020EEC41600BECC3F /* WordPressAuthenticatorConfiguration.swift in Sources */, + CE1B18D220EEC44400BECC3F /* WordPressAuthenticatorStyles.swift in Sources */, B56090F0208A527000399AE4 /* FancyAlertViewController+LoginError.swift in Sources */, + CE1B18CE20EEC3CB00BECC3F /* WordPressAuthenticatorDelegateProtocol.swift in Sources */, B5609110208A54F800399AE4 /* OnePasswordFacade.swift in Sources */, B5609109208A54F800399AE4 /* SignupService.swift in Sources */, B560913D208A563800399AE4 /* LoginProloguePageViewController.swift in Sources */, @@ -840,7 +863,6 @@ B56090E4208A4F9D00399AE4 /* WPNUXMainButton.m in Sources */, B560913B208A563800399AE4 /* LoginSelfHostedViewController.swift in Sources */, B5609136208A563800399AE4 /* Login2FAViewController.swift in Sources */, - B56090CE208A4F5400399AE4 /* NUXSubmitButton.swift in Sources */, B56090E1208A4F9D00399AE4 /* WPWalkthroughTextField.m in Sources */, B56090EF208A527000399AE4 /* WPStyleGuide+Login.swift in Sources */, B56090D0208A4F5400399AE4 /* NUXViewControllerBase.swift in Sources */, diff --git a/WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift b/WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift index 2047a4f75..741827c7b 100644 --- a/WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift +++ b/WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift @@ -6,165 +6,6 @@ import WordPressShared import WordPressUI - -// MARK: - WordPress Credentials -// -public enum WordPressCredentials { - - /// WordPress.org Site Credentials. - /// - case wporg(username: String, password: String, xmlrpc: String, options: [AnyHashable: Any]) - - /// WordPress.com Site Credentials. - /// - case wpcom(username: String, authToken: String, isJetpackLogin: Bool, multifactor: Bool) -} - -// MARK: - Social Services Metadata -// -public enum SocialService { - - /// Google's Signup Linked Account - /// - case google(user: GIDGoogleUser) -} - -// MARK: - WordPressAuthenticator Delegate Protocol -// -public protocol WordPressAuthenticatorDelegate: class { - - /// Indicates if the active Authenticator can be dismissed, or not. - /// - var dismissActionEnabled: Bool { get } - - /// Indicates if the Support button action should be enabled, or not. - /// - var supportActionEnabled: Bool { get } - - /// Indicates if the Support notification indicator should be displayed. - /// - var showSupportNotificationIndicator: Bool { get } - - /// Indicates if Support is available or not. - /// - var supportEnabled: Bool { get } - - /// Signals the Host App that a new WordPress.com account has just been created. - /// - /// - Parameters: - /// - username: WordPress.com Username. - /// - authToken: WordPress.com Bearer Token. - /// - onCompletion: Closure to be executed on completion. - /// - func createdWordPressComAccount(username: String, authToken: String) - - /// Presents the Support new request, from a given ViewController, with a specified SourceTag. - /// - func presentSupportRequest(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag) - - /// Presents the Login Epilogue, in the specified NavigationController. - /// - func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: WordPressCredentials, onDismiss: @escaping () -> Void) - - /// Presents the Login Epilogue, in the specified NavigationController. - /// - func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: WordPressCredentials, service: SocialService?) - - /// Presents the Support Interface from a given ViewController, with a specified SourceTag. - /// - func presentSupport(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag) - - /// Indicates if the Login Epilogue should be displayed. - /// - /// - Parameter isJetpackLogin: Indicates if we've just logged into a WordPress.com account for Jetpack purposes!. - /// - func shouldPresentLoginEpilogue(isJetpackLogin: Bool) -> Bool - - /// Indicates if the Signup Epilogue should be displayed. - /// - func shouldPresentSignupEpilogue() -> Bool - - /// Signals the Host App that a WordPress Site (wpcom or wporg) is available with the specified credentials. - /// - /// - Parameters: - /// - credentials: WordPress Site Credentials. - /// - onCompletion: Closure to be executed on completion. - /// - func sync(credentials: WordPressCredentials, onCompletion: @escaping (Error?) -> Void) - - /// Signals the Host App that a given Analytics Event has occurred. - /// - func track(event: WPAnalyticsStat) - - /// Signals the Host App that a given Analytics Event (with the specified properties) has occurred. - /// - func track(event: WPAnalyticsStat, properties: [AnyHashable: Any]) - - /// Signals the Host App that a given Analytics Event (with an associated Error) has occurred. - /// - func track(event: WPAnalyticsStat, error: Error) -} - - -// MARK: - WordPressAuthenticator Configuration -// -public struct WordPressAuthenticatorConfiguration { - - /// WordPress.com Client ID - /// - let wpcomClientId: String - - /// WordPress.com Secret - /// - let wpcomSecret: String - - /// Client App: Used for Magic Link purposes. - /// - let wpcomScheme: String - - /// WordPress.com Terms of Service URL - /// - let wpcomTermsOfServiceURL: String - - /// GoogleLogin Client ID - /// - let googleLoginClientId: String - - /// GoogleLogin ServerClient ID - /// - let googleLoginServerClientId: String - - /// GoogleLogin Callback Scheme - /// - let googleLoginScheme: String - - /// UserAgent - /// - let userAgent: String - - /// Designated Initializer - /// - public init (wpcomClientId: String, - wpcomSecret: String, - wpcomScheme: String, - wpcomTermsOfServiceURL: String, - googleLoginClientId: String, - googleLoginServerClientId: String, - googleLoginScheme: String, - userAgent: String) { - - self.wpcomClientId = wpcomClientId - self.wpcomSecret = wpcomSecret - self.wpcomScheme = wpcomScheme - self.wpcomTermsOfServiceURL = wpcomTermsOfServiceURL - self.googleLoginClientId = googleLoginClientId - self.googleLoginServerClientId = googleLoginServerClientId - self.googleLoginScheme = googleLoginScheme - self.userAgent = userAgent - } -} - - // MARK: - WordPressAuthenticator: Public API to deal with WordPress.com and WordPress.org authentication. // @objc public class WordPressAuthenticator: NSObject { @@ -191,6 +32,10 @@ public struct WordPressAuthenticatorConfiguration { /// public let configuration: WordPressAuthenticatorConfiguration + /// Authenticator's Styles. + /// + public let style: WordPressAuthenticatorStyle + /// Notification to be posted whenever the signing flow completes. /// @objc public static let WPSigninDidFinishNotification = "WPSigninDidFinishNotification" @@ -210,18 +55,19 @@ public struct WordPressAuthenticatorConfiguration { /// Designated Initializer /// - private init(configuration: WordPressAuthenticatorConfiguration) { + private init(configuration: WordPressAuthenticatorConfiguration, style: WordPressAuthenticatorStyle) { self.configuration = configuration + self.style = style } /// Initializes the WordPressAuthenticator with the specified Configuration. /// - public static func initialize(configuration: WordPressAuthenticatorConfiguration) { + public static func initialize(configuration: WordPressAuthenticatorConfiguration, style: WordPressAuthenticatorStyle = .defaultStyle) { guard privateInstance == nil else { fatalError("WordPressAuthenticator is already initialized") } - privateInstance = WordPressAuthenticator(configuration: configuration) + privateInstance = WordPressAuthenticator(configuration: configuration, style: style) } // MARK: - Public Methods @@ -359,11 +205,12 @@ public struct WordPressAuthenticatorConfiguration { /// Returns an instance of LoginEmailViewController. This allows the host app to fine tune the way it's displayed / configure /// it's features. /// - public class func signinForWordPress() -> LoginEmailViewController { + public class func signinForWPCom() -> LoginEmailViewController { let storyboard = UIStoryboard(name: "Login", bundle: bundle) guard let controller = storyboard.instantiateViewController(withIdentifier: "emailEntry") as? LoginEmailViewController else { fatalError() } + controller.loginFields.restrictToWPCom = true return controller } diff --git a/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift new file mode 100644 index 000000000..3c499bc15 --- /dev/null +++ b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift @@ -0,0 +1,59 @@ +import GoogleSignIn + +// MARK: - WordPressAuthenticator Configuration +// +public struct WordPressAuthenticatorConfiguration { + + /// WordPress.com Client ID + /// + let wpcomClientId: String + + /// WordPress.com Secret + /// + let wpcomSecret: String + + /// Client App: Used for Magic Link purposes. + /// + let wpcomScheme: String + + /// WordPress.com Terms of Service URL + /// + let wpcomTermsOfServiceURL: String + + /// GoogleLogin Client ID + /// + let googleLoginClientId: String + + /// GoogleLogin ServerClient ID + /// + let googleLoginServerClientId: String + + /// GoogleLogin Callback Scheme + /// + let googleLoginScheme: String + + /// UserAgent + /// + let userAgent: String + + /// Designated Initializer + /// + public init (wpcomClientId: String, + wpcomSecret: String, + wpcomScheme: String, + wpcomTermsOfServiceURL: String, + googleLoginClientId: String, + googleLoginServerClientId: String, + googleLoginScheme: String, + userAgent: String) { + + self.wpcomClientId = wpcomClientId + self.wpcomSecret = wpcomSecret + self.wpcomScheme = wpcomScheme + self.wpcomTermsOfServiceURL = wpcomTermsOfServiceURL + self.googleLoginClientId = googleLoginClientId + self.googleLoginServerClientId = googleLoginServerClientId + self.googleLoginScheme = googleLoginScheme + self.userAgent = userAgent + } +} diff --git a/WordPressAuthenticator/Authenticator/WordPressAuthenticatorDelegateProtocol.swift b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorDelegateProtocol.swift new file mode 100644 index 000000000..6488b28b0 --- /dev/null +++ b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorDelegateProtocol.swift @@ -0,0 +1,77 @@ + + +// MARK: - WordPressAuthenticator Delegate Protocol +// +public protocol WordPressAuthenticatorDelegate: class { + + /// Indicates if the active Authenticator can be dismissed, or not. + /// + var dismissActionEnabled: Bool { get } + + /// Indicates if the Support button action should be enabled, or not. + /// + var supportActionEnabled: Bool { get } + + /// Indicates if the Support notification indicator should be displayed. + /// + var showSupportNotificationIndicator: Bool { get } + + /// Indicates if Support is available or not. + /// + var supportEnabled: Bool { get } + + /// Signals the Host App that a new WordPress.com account has just been created. + /// + /// - Parameters: + /// - username: WordPress.com Username. + /// - authToken: WordPress.com Bearer Token. + /// - onCompletion: Closure to be executed on completion. + /// + func createdWordPressComAccount(username: String, authToken: String) + + /// Presents the Support new request, from a given ViewController, with a specified SourceTag. + /// + func presentSupportRequest(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag) + + /// Presents the Login Epilogue, in the specified NavigationController. + /// + func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: WordPressCredentials, onDismiss: @escaping () -> Void) + + /// Presents the Login Epilogue, in the specified NavigationController. + /// + func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: WordPressCredentials, service: SocialService?) + + /// Presents the Support Interface from a given ViewController, with a specified SourceTag. + /// + func presentSupport(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag) + + /// Indicates if the Login Epilogue should be displayed. + /// + /// - Parameter isJetpackLogin: Indicates if we've just logged into a WordPress.com account for Jetpack purposes!. + /// + func shouldPresentLoginEpilogue(isJetpackLogin: Bool) -> Bool + + /// Indicates if the Signup Epilogue should be displayed. + /// + func shouldPresentSignupEpilogue() -> Bool + + /// Signals the Host App that a WordPress Site (wpcom or wporg) is available with the specified credentials. + /// + /// - Parameters: + /// - credentials: WordPress Site Credentials. + /// - onCompletion: Closure to be executed on completion. + /// + func sync(credentials: WordPressCredentials, onCompletion: @escaping (Error?) -> Void) + + /// Signals the Host App that a given Analytics Event has occurred. + /// + func track(event: WPAnalyticsStat) + + /// Signals the Host App that a given Analytics Event (with the specified properties) has occurred. + /// + func track(event: WPAnalyticsStat, properties: [AnyHashable: Any]) + + /// Signals the Host App that a given Analytics Event (with an associated Error) has occurred. + /// + func track(event: WPAnalyticsStat, error: Error) +} diff --git a/WordPressAuthenticator/Authenticator/WordPressAuthenticatorStyles.swift b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorStyles.swift new file mode 100644 index 000000000..ba073cd8f --- /dev/null +++ b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorStyles.swift @@ -0,0 +1,75 @@ + + +// MARK: - WordPress Authenticator Styles +// +public struct WordPressAuthenticatorStyle { + /// Style: Primary + Normal State + /// + public let primaryNormalBackgroundColor: UIColor + + public let primaryNormalBorderColor: UIColor + + /// Style: Primary + Highlighted State + /// + public let primaryHighlightBackgroundColor: UIColor + + public let primaryHighlightBorderColor: UIColor + + /// Style: Secondary + /// + public let secondaryNormalBackgroundColor: UIColor + + public let secondaryNormalBorderColor: UIColor + + public let secondaryHighlightBackgroundColor: UIColor + + public let secondaryHighlightBorderColor: UIColor + + /// Style: Disabled State + /// + public let disabledBackgroundColor: UIColor + + public let disabledBorderColor: UIColor + + public let primaryTitleColor: UIColor + + public let secondaryTitleColor: UIColor + + public let disabledTitleColor: UIColor + + /// Designated initializer + /// + public init(primaryNormalBackgroundColor: UIColor, primaryNormalBorderColor: UIColor, primaryHighlightBackgroundColor: UIColor, primaryHighlightBorderColor: UIColor, secondaryNormalBackgroundColor: UIColor, secondaryNormalBorderColor: UIColor, secondaryHighlightBackgroundColor: UIColor, secondaryHighlightBorderColor: UIColor, disabledBackgroundColor: UIColor, disabledBorderColor: UIColor, primaryTitleColor: UIColor, secondaryTitleColor: UIColor, disabledTitleColor: UIColor) { + self.primaryNormalBackgroundColor = primaryNormalBackgroundColor + self.primaryNormalBorderColor = primaryNormalBorderColor + self.primaryHighlightBackgroundColor = primaryHighlightBackgroundColor + self.primaryHighlightBorderColor = primaryHighlightBorderColor + self.secondaryNormalBackgroundColor = secondaryNormalBackgroundColor + self.secondaryNormalBorderColor = secondaryNormalBorderColor + self.secondaryHighlightBackgroundColor = secondaryHighlightBackgroundColor + self.secondaryHighlightBorderColor = secondaryHighlightBorderColor + self.disabledBackgroundColor = disabledBackgroundColor + self.disabledBorderColor = disabledBorderColor + self.primaryTitleColor = primaryTitleColor + self.secondaryTitleColor = secondaryTitleColor + self.disabledTitleColor = disabledTitleColor + } +} + +public extension WordPressAuthenticatorStyle { + public static var defaultStyle: WordPressAuthenticatorStyle { + return WordPressAuthenticatorStyle(primaryNormalBackgroundColor: WPStyleGuide.mediumBlue(), + primaryNormalBorderColor: WPStyleGuide.wordPressBlue(), + primaryHighlightBackgroundColor: WPStyleGuide.wordPressBlue(), + primaryHighlightBorderColor: WPStyleGuide.wordPressBlue(), + secondaryNormalBackgroundColor: UIColor.white, + secondaryNormalBorderColor: WPStyleGuide.greyLighten20(), + secondaryHighlightBackgroundColor: WPStyleGuide.greyLighten20(), + secondaryHighlightBorderColor: WPStyleGuide.greyLighten20(), + disabledBackgroundColor: UIColor.white, + disabledBorderColor: WPStyleGuide.greyLighten30(), + primaryTitleColor: UIColor.white, + secondaryTitleColor: WPStyleGuide.darkGrey(), + disabledTitleColor: WPStyleGuide.greyLighten30()) + } +} diff --git a/WordPressAuthenticator/Credentials/WordPressCredentials.swift b/WordPressAuthenticator/Credentials/WordPressCredentials.swift new file mode 100644 index 000000000..10d5d5de1 --- /dev/null +++ b/WordPressAuthenticator/Credentials/WordPressCredentials.swift @@ -0,0 +1,13 @@ + +// MARK: - WordPress Credentials +// +public enum WordPressCredentials { + + /// WordPress.org Site Credentials. + /// + case wporg(username: String, password: String, xmlrpc: String, options: [AnyHashable: Any]) + + /// WordPress.com Site Credentials. + /// + case wpcom(username: String, authToken: String, isJetpackLogin: Bool, multifactor: Bool) +} diff --git a/WordPressAuthenticator/Extensions/UIImage+Assets.swift b/WordPressAuthenticator/Extensions/UIImage+Assets.swift index ca249e453..a45945785 100644 --- a/WordPressAuthenticator/Extensions/UIImage+Assets.swift +++ b/WordPressAuthenticator/Extensions/UIImage+Assets.swift @@ -12,7 +12,6 @@ extension UIImage { return UIImage(named: "site-address", in: bundle, compatibleWith: nil)! } - /// Returns the Default Gravatar Placeholder Image. /// @objc @@ -27,41 +26,6 @@ extension UIImage { return UIImage(named: "google", in: bundle, compatibleWith: nil)! } - /// Returns the Link Image. - /// - @objc - public static var beveledBlueButtonImage: UIImage { - return UIImage(named: "beveled-blue-button", in: bundle, compatibleWith: nil)! - } - - /// Returns the Link Image. - /// - @objc - public static var belevedBlueButtonDownImage: UIImage { - return UIImage(named: "beveled-blue-button-down", in: bundle, compatibleWith: nil)! - } - - /// Returns the Link Image. - /// - @objc - public static var beveledSecondaryButtonImage: UIImage { - return UIImage(named: "beveled-secondary-button", in: bundle, compatibleWith: nil)! - } - - /// Returns the Link Image. - /// - @objc - public static var beveledSecondaryButtonDownImage: UIImage { - return UIImage(named: "beveled-secondary-button-down", in: bundle, compatibleWith: nil)! - } - - /// Returns the Link Image. - /// - @objc - public static var beveledDisabledButtonImage: UIImage { - return UIImage(named: "beveled-disabled-button", in: bundle, compatibleWith: nil)! - } - /// Returns WordPressAuthenticator's Bundle /// private static var bundle: Bundle { diff --git a/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift b/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift index 51f0d70de..80da569ca 100644 --- a/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift +++ b/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift @@ -102,8 +102,8 @@ extension WPStyleGuide { class func googleLoginButton() -> UIButton { let baseString = NSLocalizedString("{G} Log in with Google.", comment: "Label for button to log in using Google. The {G} will be replaced with the Google logo.") - let attrStrNormal = googleButtonString(baseString, linkColor: WPStyleGuide.wordPressBlue()) - let attrStrHighlight = googleButtonString(baseString, linkColor: WPStyleGuide.lightBlue()) + let attrStrNormal = googleButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.primaryNormalBorderColor) + let attrStrHighlight = googleButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.primaryHighlightBorderColor) let font = WPStyleGuide.mediumWeightFont(forStyle: .subheadline) @@ -117,8 +117,8 @@ extension WPStyleGuide { class func selfHostedLoginButton() -> UIButton { let baseString = NSLocalizedString("Log in by entering your site address.", comment: "Label for button to log in using your site address.") - let attrStrNormal = selfHostedButtonString(baseString, linkColor: WPStyleGuide.wordPressBlue()) - let attrStrHighlight = selfHostedButtonString(baseString, linkColor: WPStyleGuide.lightBlue()) + let attrStrNormal = selfHostedButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.primaryNormalBorderColor) + let attrStrHighlight = selfHostedButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.primaryHighlightBorderColor) let font = WPStyleGuide.mediumWeightFont(forStyle: .subheadline) diff --git a/WordPressAuthenticator/NUX/NUXButton.swift b/WordPressAuthenticator/NUX/NUXButton.swift index 5cce173dc..cf777ccd4 100644 --- a/WordPressAuthenticator/NUX/NUXButton.swift +++ b/WordPressAuthenticator/NUX/NUXButton.swift @@ -1,54 +1,147 @@ import UIKit import WordPressShared +import WordPressUI /// A stylized button used by Login controllers. It also can display a `UIActivityIndicatorView`. -@objc open class NUXButton: NUXSubmitButton { - // MARK: - Configuration - fileprivate let horizontalInset: CGFloat = 20 - fileprivate let verticalInset: CGFloat = 12 - fileprivate let maxFontSize: CGFloat = 22 +@objc open class NUXButton: UIButton { + @objc var isAnimating: Bool { + return activityIndicator.isAnimating + } + + @objc let activityIndicator: UIActivityIndicatorView = { + let indicator = UIActivityIndicatorView(activityIndicatorStyle: .white) + indicator.hidesWhenStopped = true + return indicator + }() + + override open func layoutSubviews() { + super.layoutSubviews() + + if activityIndicator.isAnimating { + titleLabel?.frame = CGRect.zero + + var frm = activityIndicator.frame + frm.origin.x = (frame.width - frm.width) / 2.0 + frm.origin.y = (frame.height - frm.height) / 2.0 + activityIndicator.frame = frm.integral + } + } - /// Configure the appearance of the button. + // MARK: - Instance Methods + + + /// Toggles the visibility of the activity indicator. When visible the button + /// title is hidden. + /// + /// - Parameter show: True to show the spinner. False hides it. /// - override open func configureButton() { - contentEdgeInsets = UIEdgeInsets(top: verticalInset, left: horizontalInset, bottom: verticalInset, right: horizontalInset) + open func showActivityIndicator(_ show: Bool) { + if show { + activityIndicator.startAnimating() + } else { + activityIndicator.stopAnimating() + } + setNeedsLayout() + } - titleLabel?.font = WPStyleGuide.fontForTextStyle(.headline, maximumPointSize: maxFontSize) + func didChangePreferredContentSize() { titleLabel?.adjustsFontForContentSizeCategory = true - titleLabel?.textAlignment = .center + } + + /// Indicates if the current instance should be rendered with the "Primary" Style. + /// + @IBInspectable public var isPrimary: Bool = false { + didSet { + configureBackgrounds() + configureTitleColors() + } + } + + + // MARK: - LifeCycle Methods + + open override func didMoveToWindow() { + super.didMoveToWindow() + configureAppearance() + } + + open override func awakeFromNib() { + super.awakeFromNib() + configureAppearance() + activityIndicator.activityIndicatorViewStyle = .gray + } + /// Setup: shorter reference for style + /// + private let style = WordPressAuthenticator.shared.style + + /// Setup: Everything = [Insets, Backgrounds, titleColor(s), titleLabel] + /// + private func configureAppearance() { + configureInsets() + configureBackgrounds() + configureTitleColors() + configureTitleLabel() + } + + /// Setup: NUXButton's Default Settings + /// + private func configureInsets() { + contentEdgeInsets = UIImage.DefaultRenderMetrics.contentInsets + } + + /// Setup: BackgroundImage + /// + private func configureBackgrounds() { let normalImage: UIImage - let highlightImage: UIImage - let titleColorNormal: UIColor + let highlightedImage: UIImage + let disabledImage = UIImage.renderBackgroundImage(fill: style.disabledBackgroundColor, border: style.disabledBorderColor) if isPrimary { - normalImage = .beveledBlueButtonImage - highlightImage = .belevedBlueButtonDownImage - - titleColorNormal = UIColor.white + normalImage = UIImage.renderBackgroundImage(fill: style.primaryNormalBackgroundColor, border: style.primaryNormalBorderColor) + highlightedImage = UIImage.renderBackgroundImage(fill: style.primaryHighlightBackgroundColor, border: style.primaryHighlightBorderColor) } else { - normalImage = .beveledSecondaryButtonImage - highlightImage = .beveledSecondaryButtonDownImage - - titleColorNormal = WPStyleGuide.darkGrey() + normalImage = UIImage.renderBackgroundImage(fill: style.secondaryNormalBackgroundColor, border: style.secondaryNormalBorderColor) + highlightedImage = UIImage.renderBackgroundImage(fill: style.secondaryHighlightBackgroundColor, border: style.secondaryHighlightBorderColor) } - let disabledImage = UIImage.beveledDisabledButtonImage - let titleColorDisabled = WPStyleGuide.greyLighten30() - setBackgroundImage(normalImage, for: .normal) - setBackgroundImage(highlightImage, for: .highlighted) + setBackgroundImage(highlightedImage, for: .highlighted) setBackgroundImage(disabledImage, for: .disabled) + addSubview(activityIndicator) + } + + /// Setup: TitleColor + /// + private func configureTitleColors() { + let titleColorNormal = isPrimary ? style.primaryTitleColor : style.secondaryTitleColor + setTitleColor(titleColorNormal, for: .normal) setTitleColor(titleColorNormal, for: .highlighted) - setTitleColor(titleColorDisabled, for: .disabled) + setTitleColor(style.disabledTitleColor, for: .disabled) + } - activityIndicator.activityIndicatorViewStyle = .gray + /// Setup: TitleLabel + /// + private func configureTitleLabel() { + titleLabel?.font = WPFontManager.systemSemiBoldFont(ofSize: 17.0) + titleLabel?.adjustsFontForContentSizeCategory = true + titleLabel?.textAlignment = .center + } +} - addSubview(activityIndicator) +// MARK: - +// +extension NUXButton { + override open func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + if previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory { + didChangePreferredContentSize() + } } - override open func configureBorderColor() { + private struct Metrics { + static let maxFontSize = CGFloat(22) } } diff --git a/WordPressAuthenticator/NUX/NUXLinkMailViewController.swift b/WordPressAuthenticator/NUX/NUXLinkMailViewController.swift index f96b3a07f..526767557 100644 --- a/WordPressAuthenticator/NUX/NUXLinkMailViewController.swift +++ b/WordPressAuthenticator/NUX/NUXLinkMailViewController.swift @@ -8,7 +8,7 @@ import WordPressShared /// class NUXLinkMailViewController: LoginViewController { @IBOutlet var label: UILabel? - @IBOutlet var openMailButton: NUXSubmitButton? + @IBOutlet var openMailButton: NUXButton? @IBOutlet var usePasswordButton: UIButton? var emailMagicLinkSource: EmailMagicLinkSource? override var sourceTag: WordPressSupportSourceTag { diff --git a/WordPressAuthenticator/NUX/NUXSubmitButton.swift b/WordPressAuthenticator/NUX/NUXSubmitButton.swift deleted file mode 100644 index b15f9866e..000000000 --- a/WordPressAuthenticator/NUX/NUXSubmitButton.swift +++ /dev/null @@ -1,154 +0,0 @@ -import UIKit -import WordPressShared - -let NUXSubmitButtonDisabledAlpha = CGFloat(0.25) - -/// A protocol for an element that can display a UIActivityIndicatorView -@objc -public protocol ActivityIndicatorButton { - func showActivityIndicator(_ show: Bool) -} - -/// A stylized button used by NUX controllers. The button presents white text -/// surrounded by a white border. It also can display a `UIActivityIndicatorView`. -/// -@objc -open class NUXSubmitButton: UIButton, ActivityIndicatorButton { - @IBInspectable open var isPrimary: Bool = false { - didSet { - configureButton() - } - } - @objc let cornerRadius = CGFloat(5.0) - - @objc var isAnimating: Bool { - get { - return activityIndicator.isAnimating - } - } - - @objc let activityIndicator: UIActivityIndicatorView = { - let indicator = UIActivityIndicatorView(activityIndicatorStyle: .white) - indicator.hidesWhenStopped = true - return indicator - }() - - - override open var isEnabled: Bool { - didSet { - configureBorderColor() - } - } - - - override open var isHighlighted: Bool { - didSet { - configureBorderColor() - } - } - - - // MARK: - LifeCycle Methods - - override open func awakeFromNib() { - super.awakeFromNib() - configureButton() - } - - - override open func layoutSubviews() { - super.layoutSubviews() - - if activityIndicator.isAnimating { - titleLabel?.frame = CGRect.zero - - var frm = activityIndicator.frame - frm.origin.x = (frame.width - frm.width) / 2.0 - frm.origin.y = (frame.height - frm.height) / 2.0 - activityIndicator.frame = frm - } - } - - - // MARK: - Configuration - - - /// Configure the appearance of the configure button. - /// - @objc func configureButton() { - contentEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15) - - layer.cornerRadius = cornerRadius - layer.borderWidth = 1 - layer.borderColor = UIColor.white.cgColor - clipsToBounds = true - - titleLabel?.font = WPFontManager.systemSemiBoldFont(ofSize: 17.0) - - let capInsets = UIEdgeInsets(top: cornerRadius, left: cornerRadius, bottom: cornerRadius, right: cornerRadius) - var backgroundColor = UIColor.clear - var titleColorNormal = UIColor.white - var titleColorHighlighted = WPStyleGuide.lightBlue() - var titleColorDisabled = UIColor(white: 1.0, alpha: NUXSubmitButtonDisabledAlpha) - if isPrimary { - backgroundColor = UIColor.white - titleColorNormal = WPStyleGuide.wordPressBlue() - titleColorHighlighted = WPStyleGuide.darkBlue() - titleColorDisabled = titleColorNormal.withAlphaComponent(NUXSubmitButtonDisabledAlpha) - } - let normalImage = UIImage(color: backgroundColor, havingSize: CGSize(width: 44, height: 44)) - setBackgroundImage(normalImage?.resizableImage(withCapInsets: capInsets), for: .normal) - setBackgroundImage(normalImage?.resizableImage(withCapInsets: capInsets), for: .highlighted) - - setTitleColor(titleColorNormal, for: .normal) - setTitleColor(titleColorHighlighted, for: .highlighted) - setTitleColor(titleColorDisabled, for: .disabled) - - addSubview(activityIndicator) - } - - - /// Configures the border color. - /// - @objc func configureBorderColor() { - var color: UIColor - if isEnabled { - color = isHighlighted ? WPStyleGuide.lightBlue() : UIColor.white - } else { - color = UIColor(white: 1.0, alpha: NUXSubmitButtonDisabledAlpha) - } - layer.borderColor = color.cgColor - } - - - // MARK: - Instance Methods - - - /// Toggles the visibility of the activity indicator. When visible the button - /// title is hidden. - /// - /// - Parameter show: True to show the spinner. False hides it. - /// - open func showActivityIndicator(_ show: Bool) { - if show { - activityIndicator.startAnimating() - } else { - activityIndicator.stopAnimating() - } - configureBorderColor() - setNeedsLayout() - } - - func didChangePreferredContentSize() { - titleLabel?.adjustsFontForContentSizeCategory = true - } -} - -extension NUXSubmitButton { - override open func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { - super.traitCollectionDidChange(previousTraitCollection) - if previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory { - didChangePreferredContentSize() - } - } -} diff --git a/WordPressAuthenticator/NUX/NUXViewController.swift b/WordPressAuthenticator/NUX/NUXViewController.swift index 27abfd9ab..a68c690f3 100644 --- a/WordPressAuthenticator/NUX/NUXViewController.swift +++ b/WordPressAuthenticator/NUX/NUXViewController.swift @@ -50,7 +50,7 @@ open class NUXViewController: UIViewController, NUXViewControllerBase, UIViewCon } // properties specific to NUXViewController - @IBOutlet var submitButton: NUXSubmitButton? + @IBOutlet var submitButton: NUXButton? @IBOutlet var errorLabel: UILabel? func configureSubmitButton(animating: Bool) { diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/Contents.json b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/Contents.json deleted file mode 100644 index 2fa60354a..000000000 --- a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/Contents.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "images" : [ - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 20, - "top" : 18, - "right" : 18, - "left" : 18 - } - }, - "idiom" : "universal", - "filename" : "beveled-blue-button-down.png", - "scale" : "1x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 20, - "top" : 18, - "right" : 18, - "left" : 18 - } - }, - "idiom" : "universal", - "filename" : "beveled-blue-button-down@2x.png", - "scale" : "2x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 30, - "top" : 24, - "right" : 24, - "left" : 24 - } - }, - "idiom" : "universal", - "filename" : "beveled-blue-button-down@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/beveled-blue-button-down.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/beveled-blue-button-down.png deleted file mode 100644 index 7aff33a29..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/beveled-blue-button-down.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/beveled-blue-button-down@2x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/beveled-blue-button-down@2x.png deleted file mode 100644 index a5ff4ffab..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/beveled-blue-button-down@2x.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/beveled-blue-button-down@3x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/beveled-blue-button-down@3x.png deleted file mode 100644 index e215f85db..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button-down.imageset/beveled-blue-button-down@3x.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/Contents.json b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/Contents.json deleted file mode 100644 index f2d004d01..000000000 --- a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/Contents.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "images" : [ - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 20, - "top" : 18, - "right" : 18, - "left" : 18 - } - }, - "idiom" : "universal", - "filename" : "beveled-blue-button.png", - "scale" : "1x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 20, - "top" : 18, - "right" : 18, - "left" : 18 - } - }, - "idiom" : "universal", - "filename" : "beveled-blue-button@2x.png", - "scale" : "2x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 30, - "top" : 24, - "right" : 24, - "left" : 24 - } - }, - "idiom" : "universal", - "filename" : "beveled-blue-button@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/beveled-blue-button.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/beveled-blue-button.png deleted file mode 100644 index b3c01266d..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/beveled-blue-button.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/beveled-blue-button@2x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/beveled-blue-button@2x.png deleted file mode 100644 index bba07e1c9..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/beveled-blue-button@2x.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/beveled-blue-button@3x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/beveled-blue-button@3x.png deleted file mode 100644 index cc5e50be2..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-blue-button.imageset/beveled-blue-button@3x.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/Contents.json b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/Contents.json deleted file mode 100644 index 36f066395..000000000 --- a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/Contents.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "images" : [ - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 10, - "top" : 9, - "right" : 9, - "left" : 9 - } - }, - "idiom" : "universal", - "filename" : "beveled-disabled-button.png", - "scale" : "1x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 20, - "top" : 18, - "right" : 18, - "left" : 18 - } - }, - "idiom" : "universal", - "filename" : "beveled-disabled-button@2x.png", - "scale" : "2x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 30, - "top" : 24, - "right" : 24, - "left" : 24 - } - }, - "idiom" : "universal", - "filename" : "beveled-disabled-button@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/beveled-disabled-button.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/beveled-disabled-button.png deleted file mode 100644 index 71ec5dbce..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/beveled-disabled-button.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/beveled-disabled-button@2x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/beveled-disabled-button@2x.png deleted file mode 100644 index 73798f399..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/beveled-disabled-button@2x.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/beveled-disabled-button@3x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/beveled-disabled-button@3x.png deleted file mode 100644 index fbd65edbd..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-disabled-button.imageset/beveled-disabled-button@3x.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/Contents.json b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/Contents.json deleted file mode 100644 index 793102711..000000000 --- a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/Contents.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "images" : [ - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 10, - "top" : 9, - "right" : 9, - "left" : 9 - } - }, - "idiom" : "universal", - "filename" : "beveled-secondary-button-down.png", - "scale" : "1x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 20, - "top" : 18, - "right" : 18, - "left" : 18 - } - }, - "idiom" : "universal", - "filename" : "beveled-secondary-button-down@2x.png", - "scale" : "2x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 30, - "top" : 24, - "right" : 24, - "left" : 24 - } - }, - "idiom" : "universal", - "filename" : "beveled-secondary-button-down@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/beveled-secondary-button-down.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/beveled-secondary-button-down.png deleted file mode 100644 index 335246516..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/beveled-secondary-button-down.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/beveled-secondary-button-down@2x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/beveled-secondary-button-down@2x.png deleted file mode 100644 index b6f06c154..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/beveled-secondary-button-down@2x.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/beveled-secondary-button-down@3x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/beveled-secondary-button-down@3x.png deleted file mode 100644 index 481d5837e..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button-down.imageset/beveled-secondary-button-down@3x.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/Contents.json b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/Contents.json deleted file mode 100644 index 41572b805..000000000 --- a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/Contents.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "images" : [ - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 10, - "top" : 9, - "right" : 9, - "left" : 9 - } - }, - "idiom" : "universal", - "filename" : "beveled-secondary-button.png", - "scale" : "1x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 20, - "top" : 18, - "right" : 18, - "left" : 18 - } - }, - "idiom" : "universal", - "filename" : "beveled-secondary-button@2x.png", - "scale" : "2x" - }, - { - "resizing" : { - "mode" : "9-part", - "center" : { - "mode" : "stretch", - "width" : 1, - "height" : 1 - }, - "cap-insets" : { - "bottom" : 30, - "top" : 24, - "right" : 24, - "left" : 24 - } - }, - "idiom" : "universal", - "filename" : "beveled-secondary-button@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/beveled-secondary-button.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/beveled-secondary-button.png deleted file mode 100644 index 9a1059818..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/beveled-secondary-button.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/beveled-secondary-button@2x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/beveled-secondary-button@2x.png deleted file mode 100644 index c8b665ca0..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/beveled-secondary-button@2x.png and /dev/null differ diff --git a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/beveled-secondary-button@3x.png b/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/beveled-secondary-button@3x.png deleted file mode 100644 index 12c15e210..000000000 Binary files a/WordPressAuthenticator/Resources/Assets.xcassets/beveled-secondary-button.imageset/beveled-secondary-button@3x.png and /dev/null differ diff --git a/WordPressAuthenticator/Services/SocialService.swift b/WordPressAuthenticator/Services/SocialService.swift new file mode 100644 index 000000000..ff9c1ebde --- /dev/null +++ b/WordPressAuthenticator/Services/SocialService.swift @@ -0,0 +1,10 @@ +import GoogleSignIn + +// MARK: - Social Services Metadata +// +public enum SocialService { + + /// Google's Signup Linked Account + /// + case google(user: GIDGoogleUser) +} diff --git a/WordPressAuthenticator/Signin/Login.storyboard b/WordPressAuthenticator/Signin/Login.storyboard index a032d6a6b..cb0152b34 100644 --- a/WordPressAuthenticator/Signin/Login.storyboard +++ b/WordPressAuthenticator/Signin/Login.storyboard @@ -976,9 +976,7 @@