diff --git a/WordPressAuthenticator.podspec b/WordPressAuthenticator.podspec index b79264692..c117a8c14 100644 --- a/WordPressAuthenticator.podspec +++ b/WordPressAuthenticator.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressAuthenticator" - s.version = "1.20.0-beta.6" + s.version = "1.20.0-beta.7" s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps." s.description = <<-DESC diff --git a/WordPressAuthenticator.xcodeproj/project.pbxproj b/WordPressAuthenticator.xcodeproj/project.pbxproj index 839dae853..1d3b9ae2e 100644 --- a/WordPressAuthenticator.xcodeproj/project.pbxproj +++ b/WordPressAuthenticator.xcodeproj/project.pbxproj @@ -124,6 +124,7 @@ CE6BCD2F24A3A235001BCDC5 /* TextLabelTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE6BCD2D24A3A235001BCDC5 /* TextLabelTableViewCell.xib */; }; CE6BCD3824A3CB5E001BCDC5 /* TextLinkButtonTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6BCD3624A3CB5E001BCDC5 /* TextLinkButtonTableViewCell.swift */; }; CE6BCD3924A3CB5E001BCDC5 /* TextLinkButtonTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE6BCD3724A3CB5E001BCDC5 /* TextLinkButtonTableViewCell.xib */; }; + CE73475624B77A3800A22660 /* SiteCredentialsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE73475524B77A3800A22660 /* SiteCredentialsViewController.swift */; }; CE9091F72499549500AB50BD /* TextFieldTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE9091F52499549500AB50BD /* TextFieldTableViewCell.swift */; }; CE9091F82499549500AB50BD /* TextFieldTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE9091F62499549500AB50BD /* TextFieldTableViewCell.xib */; }; CE9091FE249A720E00AB50BD /* UIView+AuthHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE9091FD249A720E00AB50BD /* UIView+AuthHelpers.swift */; }; @@ -294,6 +295,7 @@ CE6BCD2D24A3A235001BCDC5 /* TextLabelTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TextLabelTableViewCell.xib; sourceTree = ""; }; CE6BCD3624A3CB5E001BCDC5 /* TextLinkButtonTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLinkButtonTableViewCell.swift; sourceTree = ""; }; CE6BCD3724A3CB5E001BCDC5 /* TextLinkButtonTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TextLinkButtonTableViewCell.xib; sourceTree = ""; }; + CE73475524B77A3800A22660 /* SiteCredentialsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteCredentialsViewController.swift; sourceTree = ""; }; CE9091F52499549500AB50BD /* TextFieldTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldTableViewCell.swift; sourceTree = ""; }; CE9091F62499549500AB50BD /* TextFieldTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TextFieldTableViewCell.xib; sourceTree = ""; }; CE9091FD249A720E00AB50BD /* UIView+AuthHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+AuthHelpers.swift"; sourceTree = ""; }; @@ -711,6 +713,7 @@ children = ( CEC77C6524854F2E00FB9050 /* SiteAddressViewController.swift */, CEC77C6724854F3E00FB9050 /* SiteAddress.storyboard */, + CE73475524B77A3800A22660 /* SiteCredentialsViewController.swift */, ); path = "Site Address"; sourceTree = ""; @@ -992,6 +995,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + CE73475624B77A3800A22660 /* SiteCredentialsViewController.swift in Sources */, 982C8E7923021C20003F1BA0 /* LoginPrologueLoginMethodViewController.swift in Sources */, B5609144208A563800399AE4 /* LoginPrologueSignupMethodViewController.swift in Sources */, B56090D1208A4F5400399AE4 /* NUXViewController.swift in Sources */, diff --git a/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift b/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift index 42b47e961..3195a2d7f 100644 --- a/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift +++ b/WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift @@ -1,8 +1,8 @@ import UIKit import WordPressShared -/// Part two of the self-hosted sign in flow. A valid site address should be acquired -/// before presenting this view controller. +/// Part two of the self-hosted sign in flow. Used by WPiOS and NiOS. +/// A valid site address should be acquired before presenting this view controller. /// class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder { @IBOutlet var siteHeaderView: SiteInfoHeaderView! diff --git a/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift b/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift index 6c65d1bb9..76debf9a9 100644 --- a/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift +++ b/WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift @@ -1,8 +1,8 @@ import UIKit import WordPressShared -/// Part two of the self-hosted sign in flow. A valid site address should be acquired -/// before presenting this view controller. +/// Part two of the self-hosted sign in flow. For use by WCiOS only. +/// A valid site address should be acquired before presenting this view controller. /// class LoginUsernamePasswordViewController: LoginViewController, NUXKeyboardResponder { @IBOutlet var siteHeaderView: SiteInfoHeaderView! diff --git a/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddress.storyboard b/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddress.storyboard index 1f10afc65..3d745d870 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddress.storyboard +++ b/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddress.storyboard @@ -85,5 +85,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift index a941621b4..419e0b502 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift @@ -408,8 +408,8 @@ extension SiteAddressViewController { /// @objc func showSelfHostedUsernamePassword() { configureViewLoading(false) - guard let vc = LoginSelfHostedViewController.instantiate(from: .login) else { - DDLogError("Failed to navigate from LoginEmailViewController to LoginSelfHostedViewController") + guard let vc = SiteCredentialsViewController.instantiate(from: .siteAddress) else { + DDLogError("Failed to navigate from SiteAddressViewController to SiteCredentialsViewController") return } diff --git a/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteCredentialsViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteCredentialsViewController.swift new file mode 100644 index 000000000..805cfe100 --- /dev/null +++ b/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteCredentialsViewController.swift @@ -0,0 +1,129 @@ +import UIKit + + +/// Part two of the self-hosted sign in flow: username + password. Used by WPiOS and NiOS. +/// A valid site address should be acquired before presenting this view controller. +/// +class SiteCredentialsViewController: LoginViewController { + + /// Private properties. + /// + @IBOutlet private weak var tableView: UITableView! + @IBOutlet var bottomContentConstraint: NSLayoutConstraint? + + // Required property declaration for `NUXKeyboardResponder` but unused here. + var verticalCenterConstraint: NSLayoutConstraint? + + private var rows = [Row]() + + // MARK: - Actions + @IBAction func handleContinueButtonTapped(_ sender: NUXButton) { + + } + + override func viewDidLoad() { + super.viewDidLoad() + + localizePrimaryButton() + registerTableViewCells() + loadRows() + configureSubmitButton(animating: false) + } + + // MARK: - Overrides + + /// Style individual ViewController backgrounds, for now. + /// + override func styleBackground() { + guard let unifiedBackgroundColor = WordPressAuthenticator.shared.unifiedStyle?.viewControllerBackgroundColor else { + super.styleBackground() + return + } + + view.backgroundColor = unifiedBackgroundColor + } +} + + +// MARK: - UITableViewDataSource +extension SiteCredentialsViewController: UITableViewDataSource { + /// Returns the number of rows in a section. + /// + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return rows.count + } + + /// Configure cells delegate method. + /// + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let row = rows[indexPath.row] + let cell = tableView.dequeueReusableCell(withIdentifier: row.reuseIdentifier, for: indexPath) + configure(cell, for: row, at: indexPath) + + return cell + } +} + + +// MARK: - Private Methods +private extension SiteCredentialsViewController { + + /// Localize the "Continue" button. + /// + func localizePrimaryButton() { + let primaryTitle = WordPressAuthenticator.shared.displayStrings.continueButtonTitle + submitButton?.setTitle(primaryTitle, for: .normal) + submitButton?.setTitle(primaryTitle, for: .highlighted) + } + + /// Registers all of the available TableViewCells. + /// + func registerTableViewCells() { + let cells = [ + TextLabelTableViewCell.reuseIdentifier: TextLabelTableViewCell.loadNib() + ] + + for (reuseIdentifier, nib) in cells { + tableView.register(nib, forCellReuseIdentifier: reuseIdentifier) + } + } + + /// Describes how the tableView rows should be rendered. + /// + func loadRows() { + rows = [.instructions] + } + + /// Configure cells. + /// + func configure(_ cell: UITableViewCell, for row: Row, at indexPath: IndexPath) { + switch cell { + case let cell as TextLabelTableViewCell where row == .instructions: + configureInstructionLabel(cell) + default: + DDLogError("Error: Unidentified tableViewCell type found.") + } + } + + /// Configure the instruction cell. + /// + func configureInstructionLabel(_ cell: TextLabelTableViewCell) { + cell.configureLabel(text: "Enter your account information for pamelanguyen.com.", style: .body) + } + + + // MARK: - Private Constants + + /// Rows listed in the order they were created. + /// + enum Row { + case instructions + + var reuseIdentifier: String { + switch self { + case .instructions: + return TextLabelTableViewCell.reuseIdentifier + } + } + } +}