Explainer text for accounts and extensions

Explainer text will display when no account/extension is selected.
This commit is contained in:
Stuart Breckenridge 2020-11-02 11:08:54 +08:00
parent e9989052e5
commit 3b5dfb38ec
2 changed files with 46 additions and 1 deletions

View File

@ -226,7 +226,7 @@ private extension AccountsPreferencesViewController {
func showController(_ controller: NSViewController) {
hideController()
addChild(controller)
controller.view.translatesAutoresizingMaskIntoConstraints = false
detailView.addSubview(controller.view)
@ -239,6 +239,21 @@ 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.addFullSizeConstraints(forSubview: textHostingController.view)
}
}
}

View File

@ -179,6 +179,21 @@ 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.addFullSizeConstraints(forSubview: textHostingController.view)
}
}
func showController(_ controller: NSViewController) {
@ -195,6 +210,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) {