diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 54c31e32b..d1bd9f37b 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -22,7 +22,7 @@ public extension Notification.Name { static let AccountRefreshDidFinish = Notification.Name(rawValue: "AccountRefreshDidFinish") static let AccountRefreshProgressDidChange = Notification.Name(rawValue: "AccountRefreshProgressDidChange") static let AccountDidDownloadArticles = Notification.Name(rawValue: "AccountDidDownloadArticles") - + static let AccountStateDidChange = Notification.Name(rawValue: "AccountStateDidChange") static let StatusesDidChange = Notification.Name(rawValue: "StatusesDidChange") } @@ -71,6 +71,19 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } } public let defaultName: String + + public var isActive: Bool { + get { + return settings.isActive + } + set { + if newValue != settings.isActive { + settings.isActive = newValue + settingsDirty = true + NotificationCenter.default.post(name: .AccountStateDidChange, object: self, userInfo: nil) + } + } + } public var topLevelFeeds = Set() public var folders: Set? = Set() diff --git a/Frameworks/Account/AccountSettings.swift b/Frameworks/Account/AccountSettings.swift index 1e61aa323..2476052c2 100644 --- a/Frameworks/Account/AccountSettings.swift +++ b/Frameworks/Account/AccountSettings.swift @@ -11,4 +11,6 @@ import Foundation final class AccountSettings: Codable { var name: String? + var isActive: Bool = true + } diff --git a/Mac/Preferences/Accounts/AccountsDetail.xib b/Mac/Preferences/Accounts/AccountsDetail.xib index 4fff03c64..eda4c6b3b 100644 --- a/Mac/Preferences/Accounts/AccountsDetail.xib +++ b/Mac/Preferences/Accounts/AccountsDetail.xib @@ -7,6 +7,7 @@ + @@ -56,8 +57,20 @@ + + + diff --git a/Mac/Preferences/Accounts/AccountsDetailViewController.swift b/Mac/Preferences/Accounts/AccountsDetailViewController.swift index 24e08135c..a511b219a 100644 --- a/Mac/Preferences/Accounts/AccountsDetailViewController.swift +++ b/Mac/Preferences/Accounts/AccountsDetailViewController.swift @@ -13,6 +13,7 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate @IBOutlet weak var typeLabel: NSTextField! @IBOutlet weak var nameTextField: NSTextField! + @IBOutlet weak var activeButton: NSButtonCell! private weak var account: Account? @@ -30,6 +31,7 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate nameTextField.delegate = self typeLabel.stringValue = account?.defaultName ?? "" nameTextField.stringValue = account?.name ?? "" + activeButton.state = account?.isActive ?? false ? .on : .off } func controlTextDidEndEditing(_ obj: Notification) { @@ -40,4 +42,8 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate } } + @IBAction func active(_ sender: NSButtonCell) { + account?.isActive = sender.state == .on ? true : false + } + }