diff --git a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift index 2153f13d3..d28ff36e7 100644 --- a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift +++ b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift @@ -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) + ]) + + } } } diff --git a/Mac/Preferences/ExtensionPoints/ExtensionPointPreferencesViewController.swift b/Mac/Preferences/ExtensionPoints/ExtensionPointPreferencesViewController.swift index d07249fba..8250a185a 100644 --- a/Mac/Preferences/ExtensionPoints/ExtensionPointPreferencesViewController.swift +++ b/Mac/Preferences/ExtensionPoints/ExtensionPointPreferencesViewController.swift @@ -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) {