From 261e2a951aa8b9d2040a5ca533fa6362a58e5b96 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 4 May 2019 16:10:58 -0500 Subject: [PATCH] Add ability to update credentials --- .../Accounts/AccountsAddViewController.swift | 6 +-- Mac/Preferences/Accounts/AccountsDetail.xib | 13 +++++ .../AccountsDetailViewController.swift | 22 +++++++- ...untsAddFeedbin.xib => AccountsFeedbin.xib} | 20 +++----- ... => AccountsFeedbinWindowController.swift} | 50 ++++++++++++------- NetNewsWire.xcodeproj/project.pbxproj | 16 +++--- 6 files changed, 84 insertions(+), 43 deletions(-) rename Mac/Preferences/Accounts/{AccountsAddFeedbin.xib => AccountsFeedbin.xib} (93%) rename Mac/Preferences/Accounts/{AccountsAddFeedbinWindowController.swift => AccountsFeedbinWindowController.swift} (63%) diff --git a/Mac/Preferences/Accounts/AccountsAddViewController.swift b/Mac/Preferences/Accounts/AccountsAddViewController.swift index 52155e07c..92c9d6ddf 100644 --- a/Mac/Preferences/Accounts/AccountsAddViewController.swift +++ b/Mac/Preferences/Accounts/AccountsAddViewController.swift @@ -83,9 +83,9 @@ extension AccountsAddViewController: NSTableViewDelegate { accountsAddLocalWindowController.runSheetOnWindow(self.view.window!) accountsAddWindowController = accountsAddLocalWindowController case 1: - let accountsAddLocalWindowController = AccountsAddFeedbinWindowController() - accountsAddLocalWindowController.runSheetOnWindow(self.view.window!) - accountsAddWindowController = accountsAddLocalWindowController + let accountsFeedbinWindowController = AccountsFeedbinWindowController() + accountsFeedbinWindowController.runSheetOnWindow(self.view.window!) + accountsAddWindowController = accountsFeedbinWindowController default: break } diff --git a/Mac/Preferences/Accounts/AccountsDetail.xib b/Mac/Preferences/Accounts/AccountsDetail.xib index ed26b3b1c..12ecf43f9 100644 --- a/Mac/Preferences/Accounts/AccountsDetail.xib +++ b/Mac/Preferences/Accounts/AccountsDetail.xib @@ -8,6 +8,7 @@ + @@ -92,10 +93,22 @@ + + + diff --git a/Mac/Preferences/Accounts/AccountsDetailViewController.swift b/Mac/Preferences/Accounts/AccountsDetailViewController.swift index a511b219a..bb481934a 100644 --- a/Mac/Preferences/Accounts/AccountsDetailViewController.swift +++ b/Mac/Preferences/Accounts/AccountsDetailViewController.swift @@ -14,8 +14,10 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate @IBOutlet weak var typeLabel: NSTextField! @IBOutlet weak var nameTextField: NSTextField! @IBOutlet weak var activeButton: NSButtonCell! + @IBOutlet weak var credentialsButton: NSButton! - private weak var account: Account? + private var accountsWindowController: NSWindowController? + private var account: Account? init(account: Account) { super.init(nibName: "AccountsDetail", bundle: nil) @@ -28,10 +30,12 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate override func viewDidLoad() { super.viewDidLoad() + nameTextField.delegate = self typeLabel.stringValue = account?.defaultName ?? "" nameTextField.stringValue = account?.name ?? "" activeButton.state = account?.isActive ?? false ? .on : .off + credentialsButton.isHidden = account?.type ?? .onMyMac == .onMyMac } func controlTextDidEndEditing(_ obj: Notification) { @@ -46,4 +50,20 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate account?.isActive = sender.state == .on ? true : false } + @IBAction func credentials(_ sender: Any) { + + guard let account = account else { return } + + switch account.type { + case .feedbin: + let accountsFeedbinWindowController = AccountsFeedbinWindowController() + accountsFeedbinWindowController.account = account + accountsFeedbinWindowController.runSheetOnWindow(self.view.window!) + accountsWindowController = accountsFeedbinWindowController + default: + break + } + + } + } diff --git a/Mac/Preferences/Accounts/AccountsAddFeedbin.xib b/Mac/Preferences/Accounts/AccountsFeedbin.xib similarity index 93% rename from Mac/Preferences/Accounts/AccountsAddFeedbin.xib rename to Mac/Preferences/Accounts/AccountsFeedbin.xib index 612bb4f48..48f9294fe 100644 --- a/Mac/Preferences/Accounts/AccountsAddFeedbin.xib +++ b/Mac/Preferences/Accounts/AccountsFeedbin.xib @@ -5,9 +5,9 @@ - + - + @@ -24,7 +24,7 @@ - + @@ -88,9 +88,6 @@ - - - @@ -117,9 +114,6 @@ NSAllRomanInputSourcesLocaleIdentifier - - - @@ -136,8 +130,8 @@