Fix lint issues.

This commit is contained in:
Brent Simmons
2025-01-22 22:18:09 -08:00
parent 40ada2ba5a
commit bbef99f2d3
92 changed files with 1651 additions and 1694 deletions

View File

@@ -32,7 +32,7 @@ class FeedbinAccountViewController: UITableViewController {
activityIndicator.isHidden = true
emailTextField.delegate = self
passwordTextField.delegate = self
if let account = account, let credentials = try? account.retrieveCredentials(type: .basic) {
actionButton.setTitle(NSLocalizedString("Update Credentials", comment: "Update Credentials"), for: .normal)
actionButton.isEnabled = true
@@ -47,7 +47,7 @@ class FeedbinAccountViewController: UITableViewController {
tableView.register(ImageHeaderView.self, forHeaderFooterViewReuseIdentifier: "SectionHeader")
}
private func setupFooter() {
footerLabel.text = NSLocalizedString("Sign in to your Feedbin account and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDont have a Feedbin account?", comment: "Feedbin")
}
@@ -55,7 +55,7 @@ class FeedbinAccountViewController: UITableViewController {
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return section == 0 ? ImageHeaderView.rowHeight : super.tableView(tableView, heightForHeaderInSection: section)
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
@@ -69,7 +69,7 @@ class FeedbinAccountViewController: UITableViewController {
@IBAction func cancel(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
@IBAction func showHidePassword(_ sender: Any) {
if passwordTextField.isSecureTextEntry {
passwordTextField.isSecureTextEntry = false
@@ -79,21 +79,21 @@ class FeedbinAccountViewController: UITableViewController {
showHideButton.setTitle("Show", for: .normal)
}
}
@IBAction func action(_ sender: Any) {
guard let email = emailTextField.text, let password = passwordTextField.text else {
showError(NSLocalizedString("Username & password required.", comment: "Credentials Error"))
return
}
// When you fill in the email address via auto-complete it adds extra whitespace
let trimmedEmail = email.trimmingCharacters(in: .whitespaces)
guard account != nil || !AccountManager.shared.duplicateServiceAccount(type: .feedbin, username: trimmedEmail) else {
showError(NSLocalizedString("There is already a Feedbin account with that username created.", comment: "Duplicate Error"))
return
}
resignFirstResponder()
toggleActivityIndicatorAnimation(visible: true)
setNavigationEnabled(to: false)
@@ -102,22 +102,22 @@ class FeedbinAccountViewController: UITableViewController {
Account.validateCredentials(type: .feedbin, credentials: credentials) { result in
self.toggleActivityIndicatorAnimation(visible: false)
self.setNavigationEnabled(to: true)
switch result {
case .success(let credentials):
if let credentials = credentials {
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: .feedbin)
}
do {
do {
try self.account?.removeCredentials(type: .basic)
} catch {}
try self.account?.storeCredentials(credentials)
self.account?.refreshAll() { result in
self.account?.refreshAll { result in
switch result {
case .success:
break
@@ -125,7 +125,7 @@ class FeedbinAccountViewController: UITableViewController {
self.presentError(error)
}
}
self.dismiss(animated: true, completion: nil)
self.delegate?.dismiss()
} catch {
@@ -137,32 +137,31 @@ class FeedbinAccountViewController: UITableViewController {
case .failure:
self.showError(NSLocalizedString("Network error. Try again later.", comment: "Credentials Error"))
}
}
}
@IBAction func signUpWithProvider(_ sender: Any) {
let url = URL(string: "https://feedbin.com/signup")!
let safari = SFSafariViewController(url: url)
safari.modalPresentationStyle = .currentContext
self.present(safari, animated: true, completion: nil)
}
@objc func textDidChange(_ note: Notification) {
actionButton.isEnabled = !(emailTextField.text?.isEmpty ?? false) && !(passwordTextField.text?.isEmpty ?? false)
actionButton.isEnabled = !(emailTextField.text?.isEmpty ?? false) && !(passwordTextField.text?.isEmpty ?? false)
}
private func showError(_ message: String) {
presentError(title: NSLocalizedString("Error", comment: "Credentials Error"), message: message)
}
private func setNavigationEnabled(to value:Bool){
private func setNavigationEnabled(to value: Bool) {
cancelBarButtonItem.isEnabled = value
actionButton.isEnabled = value
}
private func toggleActivityIndicatorAnimation(visible value: Bool){
private func toggleActivityIndicatorAnimation(visible value: Bool) {
activityIndicator.isHidden = !value
if value {
activityIndicator.startAnimating()
@@ -170,11 +169,11 @@ class FeedbinAccountViewController: UITableViewController {
activityIndicator.stopAnimating()
}
}
}
extension FeedbinAccountViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField == emailTextField {
passwordTextField.becomeFirstResponder()
@@ -184,5 +183,5 @@ extension FeedbinAccountViewController: UITextFieldDelegate {
}
return true
}
}