This repository was archived by the owner on Feb 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
UL&S: Navigate to a blank SiteCredentialsViewController #324
Merged
mindgraffiti
merged 27 commits into
develop
from
feature/322-site-address-username-password
Jul 9, 2020
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
17dde4c
Update to recommended Xcode project settings for pods
mindgraffiti 5c5d149
Explain which host app uses this view controller
mindgraffiti a70991f
Continue documentation
mindgraffiti ee7391b
Try to explain why there are two very similar VCs
mindgraffiti 09dfd79
Merge branch 'develop' into feature/322-site-adress-username-password
mindgraffiti 6a00d08
Bump podspec to 1.20.0-beta.5
mindgraffiti cceaac5
Add a blank SiteCredentialsViewController file to the project
mindgraffiti 5653da3
Inherit from LoginViewController
mindgraffiti 7843a3a
Navigate to the next step in the new SiteAddress flow
mindgraffiti cdcf13b
Add nib to storyboard
mindgraffiti b3afaea
Add outlets and enum to SiteCredentialsViewController
mindgraffiti 6ce6e36
Add methods to configure the primary button ("Continue" button)
mindgraffiti 2c3a13e
Register the table cells
mindgraffiti 2a941be
Load the rows
mindgraffiti 74dea92
Add table data for the row count
mindgraffiti 87f3834
Configure an example instruction cell
mindgraffiti 487aad1
Update the example sentence
mindgraffiti 6bbb8f8
Merge branch 'develop' into feature/322-site-address-username-password
mindgraffiti d8a05d9
Missing indentation
mindgraffiti 5b1598f
Merge branch 'develop' into feature/322-site-address-username-password
mindgraffiti 0c44c2c
Bump podspec to 1.20.0-beta.6
mindgraffiti 380bf2e
Revert "Update to recommended Xcode project settings for pods"
mindgraffiti c438d51
Missed a period
mindgraffiti 6e35f2f
Use the correct name in the error message
mindgraffiti ed8577a
Add the override for the unifiedBackgroundColor
mindgraffiti 15f49e0
Merge branch 'develop' into feature/322-site-address-username-password
mindgraffiti 04374b3
Bump podspec version to 1.20.0-beta.7
mindgraffiti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
WordPressAuthenticator/Signin/LoginSelfHostedViewController.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
WordPressAuthenticator/Signin/LoginUsernamePasswordViewController.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
...sAuthenticator/Unified Auth/View Related/Site Address/SiteCredentialsViewController.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a thought: unless you are going to have a considerable number of different cases, maybe you could just refer to the constant (
TextLabelTableViewCell.reuseIdentifier) since it's already accessible from the same scope?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are going to be 5 cases in total, so this enum will expand quite a bit in the next PR. I put the instruction row in so that it proves the table is displaying correctly and populating data.