From adf2d75f9546ebce9db67eaab284b3ff91f31b61 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 22 Apr 2020 05:04:39 -0500 Subject: [PATCH] Added Twitter add UI rules --- Mac/Base.lproj/AddTwitterFeedSheet.xib | 159 +++++++++--------- .../AddTwitterFeedWindowController.swift | 77 +++++++-- 2 files changed, 149 insertions(+), 87 deletions(-) diff --git a/Mac/Base.lproj/AddTwitterFeedSheet.xib b/Mac/Base.lproj/AddTwitterFeedSheet.xib index c4c8cb500..9e04ecb71 100644 --- a/Mac/Base.lproj/AddTwitterFeedSheet.xib +++ b/Mac/Base.lproj/AddTwitterFeedSheet.xib @@ -7,6 +7,7 @@ + @@ -22,50 +23,12 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -104,64 +101,74 @@ DQ - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + @@ -171,22 +178,22 @@ DQ - - + - + + - + diff --git a/Mac/MainWindow/AddFeed/AddTwitterFeedWindowController.swift b/Mac/MainWindow/AddFeed/AddTwitterFeedWindowController.swift index 943b46eba..9ab8f8cc0 100644 --- a/Mac/MainWindow/AddFeed/AddTwitterFeedWindowController.swift +++ b/Mac/MainWindow/AddFeed/AddTwitterFeedWindowController.swift @@ -15,10 +15,13 @@ import Account class AddTwitterFeedWindowController : NSWindowController, AddFeedWindowController { - @IBOutlet weak var accountPopupButton: NSPopUpButton! @IBOutlet weak var typePopupButton: NSPopUpButton! @IBOutlet weak var typeDescriptionLabel: NSTextField! + + @IBOutlet weak var accountLabel: NSTextField! + @IBOutlet weak var accountPopupButton: NSPopUpButton! @IBOutlet weak var screenSearchTextField: NSTextField! + @IBOutlet var nameTextField: NSTextField! @IBOutlet var addButton: NSButton! @IBOutlet var folderPopupButton: NSPopUpButton! @@ -54,9 +57,6 @@ class AddTwitterFeedWindowController : NSWindowController, AddFeedWindowControll override func windowDidLoad() { - typeDescriptionLabel.stringValue = "Tweets from everyone you follow" - screenSearchTextField.isHidden = true - folderPopupButton.menu = FolderTreeMenu.createFolderPopupMenu(with: folderTreeController.rootNode) if let container = AddWebFeedDefaultContainer.defaultContainer { @@ -74,7 +74,12 @@ class AddTwitterFeedWindowController : NSWindowController, AddFeedWindowControll // MARK: Actions - @IBAction func cancel(_ sender: Any?) { + @IBAction func selectedType(_ sender: Any) { + screenSearchTextField.stringValue = "" + updateUI() + } + + @IBAction func cancel(_ sender: Any?) { cancelSheet() } @@ -88,13 +93,11 @@ class AddTwitterFeedWindowController : NSWindowController, AddFeedWindowControll delegate?.addFeedWindowController(self, userEnteredURL: url, userEnteredTitle: userEnteredTitle, container: container) } - // MARK: NSTextFieldDelegate +} - @objc func controlTextDidEndEditing(_ obj: Notification) { - updateUI() - } +extension AddTwitterFeedWindowController: NSTextFieldDelegate { - @objc func controlTextDidChange(_ obj: Notification) { + func controlTextDidChange(_ obj: Notification) { updateUI() } @@ -103,7 +106,59 @@ class AddTwitterFeedWindowController : NSWindowController, AddFeedWindowControll private extension AddTwitterFeedWindowController { private func updateUI() { -// addButton.isEnabled = urlTextField.stringValue.mayBeURL + + switch typePopupButton.selectedItem?.tag ?? 0 { + case 0: + + accountLabel.isHidden = false + accountPopupButton.isHidden = false + typeDescriptionLabel.stringValue = NSLocalizedString("Tweets from everyone you follow", comment: "Home Timeline") + screenSearchTextField.isHidden = true + addButton.isEnabled = true + + case 1: + + accountLabel.isHidden = false + accountPopupButton.isHidden = false + typeDescriptionLabel.stringValue = NSLocalizedString("Tweets mentioning you", comment: "Mentions") + screenSearchTextField.isHidden = true + addButton.isEnabled = true + + case 2: + + accountLabel.isHidden = true + accountPopupButton.isHidden = true + + var screenName = screenSearchTextField.stringValue + if !screenName.isEmpty && !screenName.starts(with: "@") { + screenName = "@\(screenName)" + typeDescriptionLabel.stringValue = NSLocalizedString("Tweets from \(screenName)", comment: "Home Timeline") + } else { + typeDescriptionLabel.stringValue = "" + } + + screenSearchTextField.placeholderString = NSLocalizedString("@name", comment: "@name") + screenSearchTextField.isHidden = false + addButton.isEnabled = !screenSearchTextField.stringValue.isEmpty + + default: + + accountLabel.isHidden = true + accountPopupButton.isHidden = true + + if !screenSearchTextField.stringValue.isEmpty { + typeDescriptionLabel.stringValue = NSLocalizedString("Tweets that contain \(screenSearchTextField.stringValue)", comment: "Home Timeline") + } else { + typeDescriptionLabel.stringValue = "" + } + + screenSearchTextField.placeholderString = nil + screenSearchTextField.isHidden = false + addButton.isEnabled = !screenSearchTextField.stringValue.isEmpty + + } + + addButton.isEnabled = !screenSearchTextField.stringValue.isEmpty } func cancelSheet() {