diff --git a/iOS/Settings/DetailAccountViewController.swift b/iOS/Settings/DetailAccountViewController.swift index 9e516bda3..40dd698ee 100644 --- a/iOS/Settings/DetailAccountViewController.swift +++ b/iOS/Settings/DetailAccountViewController.swift @@ -32,6 +32,40 @@ class DetailAccountViewController: UITableViewController { account?.isActive = activeSwitch.isOn } + @IBAction func credentials(_ sender: Any) { + guard let account = account else { return } + switch account.type { + case .feedbin: + let navController = UIStoryboard.settings.instantiateViewController(withIdentifier: "FeedbinAccountNavigationViewController") as! UINavigationController + let addViewController = navController.topViewController as! FeedbinAccountViewController + addViewController.account = account + navController.modalPresentationStyle = .currentContext + present(navController, animated: true) + default: + break + } + } + + @IBAction func deleteAccount(_ sender: Any) { + let title = NSLocalizedString("Delete Account", comment: "Delete Account") + let message = NSLocalizedString("Are you sure you want to delete this account? This can not be undone.", comment: "Delete Account") + let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) + + let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel") + let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel) + alertController.addAction(cancelAction) + + let markTitle = NSLocalizedString("Delete", comment: "Delete") + let markAction = UIAlertAction(title: markTitle, style: .default) { [weak self] (action) in + guard let account = self?.account else { return } + AccountManager.shared.deleteAccount(account) + self?.navigationController?.popViewController(animated: true) + } + alertController.addAction(markAction) + + present(alertController, animated: true) + } + } extension DetailAccountViewController { @@ -68,64 +102,11 @@ extension DetailAccountViewController { } override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if let account = account, account.type == .onMyMac { - if indexPath.section == 1 { - deleteAccount() - } - } else { - switch indexPath.section { - case 1: - credentials() - case 2: - deleteAccount() - default: - break - } - } - tableView.selectRow(at: nil, animated: true, scrollPosition: .none) } } -private extension DetailAccountViewController { - - func credentials() { - guard let account = account else { return } - switch account.type { - case .feedbin: - let navController = UIStoryboard.settings.instantiateViewController(withIdentifier: "FeedbinAccountNavigationViewController") as! UINavigationController - let addViewController = navController.topViewController as! FeedbinAccountViewController - addViewController.account = account - navController.modalPresentationStyle = .currentContext - present(navController, animated: true) - default: - break - } - } - - func deleteAccount() { - let title = NSLocalizedString("Delete Account", comment: "Delete Account") - let message = NSLocalizedString("Are you sure you want to delete this account? This can not be undone.", comment: "Delete Account") - let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) - - let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel") - let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel) - alertController.addAction(cancelAction) - - let markTitle = NSLocalizedString("Delete", comment: "Delete") - let markAction = UIAlertAction(title: markTitle, style: .default) { [weak self] (action) in - guard let account = self?.account else { return } - AccountManager.shared.deleteAccount(account) - self?.navigationController?.popViewController(animated: true) - } - alertController.addAction(markAction) - - present(alertController, animated: true) - } - -} - extension DetailAccountViewController: UITextFieldDelegate { func textFieldShouldReturn(_ textField: UITextField) -> Bool { diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard index 538fbcf4a..2bf1f6875 100644 --- a/iOS/Settings/Settings.storyboard +++ b/iOS/Settings/Settings.storyboard @@ -68,7 +68,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -173,7 +173,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -296,7 +296,7 @@ - + @@ -418,15 +418,23 @@ - - - + + + + @@ -441,16 +449,25 @@ - - - + + + + @@ -631,7 +648,7 @@ - + @@ -639,7 +656,10 @@ - - + + + + @@ -741,7 +763,7 @@ - + @@ -749,7 +771,10 @@ - - + + + +