mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge pull request #2547 from stuartbreckenridge/explainer-text
Explainer text for accounts and extensions
This commit is contained in:
@@ -226,12 +226,11 @@ private extension AccountsPreferencesViewController {
|
||||
|
||||
func showController(_ controller: NSViewController) {
|
||||
hideController()
|
||||
|
||||
|
||||
addChild(controller)
|
||||
controller.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
detailView.addSubview(controller.view)
|
||||
detailView.addFullSizeConstraints(forSubview: controller.view)
|
||||
|
||||
}
|
||||
|
||||
func hideController() {
|
||||
@@ -239,6 +238,26 @@ private extension AccountsPreferencesViewController {
|
||||
children.removeAll()
|
||||
controller.view.removeFromSuperview()
|
||||
}
|
||||
|
||||
if tableView.selectedRow == -1 {
|
||||
var helpText = ""
|
||||
if sortedAccounts.count == 0 {
|
||||
helpText = NSLocalizedString("Add an account by clicking the + button.", comment: "Add Account Explainer")
|
||||
} else {
|
||||
helpText = NSLocalizedString("Select an account or add a new account by clicking the + button.", comment: "Add Account Explainer")
|
||||
}
|
||||
|
||||
let textHostingController = NSHostingController(rootView: Text(helpText).multilineTextAlignment(.center))
|
||||
addChild(textHostingController)
|
||||
textHostingController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
detailView.addSubview(textHostingController.view)
|
||||
detailView.addConstraints([
|
||||
NSLayoutConstraint(item: textHostingController.view, attribute: .top, relatedBy: .equal, toItem: detailView, attribute: .top, multiplier: 1, constant: 1),
|
||||
NSLayoutConstraint(item: textHostingController.view, attribute: .bottom, relatedBy: .equal, toItem: detailView, attribute: .bottom, multiplier: 1, constant: -deleteButton.frame.height),
|
||||
NSLayoutConstraint(item: textHostingController.view, attribute: .width, relatedBy: .equal, toItem: detailView, attribute: .width, multiplier: 1, constant: 1)
|
||||
])
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -179,6 +179,25 @@ private extension ExtensionPointPreferencesViewController {
|
||||
func showDefaultView() {
|
||||
activeExtensionPoints = Array(ExtensionPointManager.shared.activeExtensionPoints.values).sorted(by: { $0.title < $1.title })
|
||||
tableView.reloadData()
|
||||
|
||||
if tableView.selectedRow == -1 {
|
||||
var helpText = ""
|
||||
if activeExtensionPoints.count == 0 {
|
||||
helpText = NSLocalizedString("Add an extension point by clicking the + button.", comment: "Extension Explainer")
|
||||
} else {
|
||||
helpText = NSLocalizedString("Select an extension point or add a new extension point by clicking the + button.", comment: "Extension Explainer")
|
||||
}
|
||||
|
||||
let textHostingController = NSHostingController(rootView: Text(helpText).multilineTextAlignment(.center))
|
||||
addChild(textHostingController)
|
||||
textHostingController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
detailView.addSubview(textHostingController.view)
|
||||
detailView.addConstraints([
|
||||
NSLayoutConstraint(item: textHostingController.view, attribute: .top, relatedBy: .equal, toItem: detailView, attribute: .top, multiplier: 1, constant: 1),
|
||||
NSLayoutConstraint(item: textHostingController.view, attribute: .bottom, relatedBy: .equal, toItem: detailView, attribute: .bottom, multiplier: 1, constant: -deleteButton.frame.height),
|
||||
NSLayoutConstraint(item: textHostingController.view, attribute: .width, relatedBy: .equal, toItem: detailView, attribute: .width, multiplier: 1, constant: 1)
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
func showController(_ controller: NSViewController) {
|
||||
@@ -195,6 +214,21 @@ private extension ExtensionPointPreferencesViewController {
|
||||
children.removeAll()
|
||||
controller.view.removeFromSuperview()
|
||||
}
|
||||
|
||||
if tableView.selectedRow == -1 {
|
||||
var helpText = ""
|
||||
if activeExtensionPoints.count == 0 {
|
||||
helpText = NSLocalizedString("Add an extension point by clicking the + button.", comment: "Extension Explainer")
|
||||
} else {
|
||||
helpText = NSLocalizedString("Select an extension point or add a new extension point by clicking the + button.", comment: "Extension Explainer")
|
||||
}
|
||||
|
||||
let textHostingController = NSHostingController(rootView: Text(helpText).multilineTextAlignment(.center))
|
||||
addChild(textHostingController)
|
||||
textHostingController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
detailView.addSubview(textHostingController.view)
|
||||
detailView.addFullSizeConstraints(forSubview: textHostingController.view)
|
||||
}
|
||||
}
|
||||
|
||||
func enableOauth1(_ provider: OAuth1SwiftProvider.Type, extensionPointType: ExtensionPoint.Type) {
|
||||
|
||||
Reference in New Issue
Block a user