diff --git a/iOS/Account/CredentialsAccountView.swift b/iOS/Account/CredentialsAccountView.swift index e0ae144b3..0f79be8ed 100644 --- a/iOS/Account/CredentialsAccountView.swift +++ b/iOS/Account/CredentialsAccountView.swift @@ -27,6 +27,9 @@ struct CredentialsAccountView: View { @State private var errorMessage: String? @State private var isShowingSignUp = false + /// Account types that sign in with this sheet. + static let accountTypes: Set = [.feedbin, .newsBlur, .inoreader, .bazQux, .theOldReader, .freshRSS] + private static let passwordPlaceholder = NSLocalizedString("Password", comment: "Password field placeholder") init(accountType: AccountType, account: Account?, didAddAccount: (() -> Void)?) { diff --git a/iOS/Inspector/AccountInspectorViewController.swift b/iOS/Inspector/AccountInspectorViewController.swift index e23c34550..ef12eff22 100644 --- a/iOS/Inspector/AccountInspectorViewController.swift +++ b/iOS/Inspector/AccountInspectorViewController.swift @@ -67,15 +67,12 @@ final class AccountInspectorViewController: UITableViewController { } @IBAction func credentials(_ sender: Any) { - guard let account = account else { return } - switch account.type { - case .feedbin, .newsBlur, .inoreader, .bazQux, .theOldReader, .freshRSS: - let hostingController = UIHostingController(rootView: CredentialsAccountView(accountType: account.type, account: account, didAddAccount: nil)) - hostingController.modalPresentationStyle = .currentContext - present(hostingController, animated: true) - default: - break + guard let account, CredentialsAccountView.accountTypes.contains(account.type) else { + return } + let hostingController = UIHostingController(rootView: CredentialsAccountView(accountType: account.type, account: account, didAddAccount: nil)) + hostingController.modalPresentationStyle = .currentContext + present(hostingController, animated: true) } @IBAction func deleteAccount(_ sender: Any) { diff --git a/iOS/UIKit Extensions/UIViewController+Extras.swift b/iOS/UIKit Extensions/UIViewController+Extras.swift index caf3bd661..09b9b23ee 100644 --- a/iOS/UIKit Extensions/UIViewController+Extras.swift +++ b/iOS/UIKit Extensions/UIViewController+Extras.swift @@ -35,21 +35,19 @@ private extension UIViewController { let title = NSLocalizedString("Account Error", comment: "Account Error") let alertController = UIAlertController(title: title, message: error.localizedDescription, preferredStyle: .alert) - let account = AccountError.account(from: error) - if account?.type == .feedbin { - + if let account = AccountError.account(from: error), CredentialsAccountView.accountTypes.contains(account.type) { let credentialsTitle = NSLocalizedString("Update Credentials", comment: "Update Credentials") let credentialsAction = UIAlertAction(title: credentialsTitle, style: .default) { [weak self] _ in dismiss?() - let hostingController = UIHostingController(rootView: CredentialsAccountView(accountType: .feedbin, account: account, didAddAccount: nil)) + let hostingController = UIHostingController(rootView: CredentialsAccountView(accountType: account.type, account: account, didAddAccount: nil)) hostingController.modalPresentationStyle = .formSheet + hostingController.preferredContentSize = UIViewController.formSheetSize self?.present(hostingController, animated: true) } alertController.addAction(credentialsAction) alertController.preferredAction = credentialsAction - } let dismissTitle = NSLocalizedString("OK", comment: "OK button")