Add Extension/Account Tweaks

• Tidies up extension language
• Adds images to account / extension panels
• Click on images will display add account / add extension sheets
This commit is contained in:
Stuart Breckenridge 2020-11-04 10:35:53 +08:00
parent e12bd28ff4
commit 840668452c
7 changed files with 136 additions and 18 deletions

View File

@ -45,10 +45,7 @@ final class AccountsPreferencesViewController: NSViewController {
rTable.size.width = tableView.superview!.frame.size.width
tableView.frame = rTable
// Set initial row selection
if sortedAccounts.count > 0 {
tableView.selectRow(0)
}
hideController()
}
@IBAction func addAccount(_ sender: Any) {
@ -247,7 +244,8 @@ private extension AccountsPreferencesViewController {
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))
let textHostingController = NSHostingController(rootView:
AddAccountHelpView(delegate: addAccountDelegate, helpText: helpText))
addChild(textHostingController)
textHostingController.view.translatesAutoresizingMaskIntoConstraints = false
detailView.addSubview(textHostingController.view)

View File

@ -0,0 +1,48 @@
//
// AddAccountHelpView.swift
// NetNewsWire
//
// Created by Stuart Breckenridge on 4/11/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import SwiftUI
import Account
struct AddAccountHelpView: View {
let accountTypes: [AccountType] = AddAccountSections.allOrdered.sectionContent
var delegate: AccountsPreferencesAddAccountDelegate?
var helpText: String
@State private var hoveringId: String? = nil
var body: some View {
VStack {
HStack {
ForEach(accountTypes, id: \.self) { account in
account.image()
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.onTapGesture {
delegate?.presentSheetForAccount(account)
hoveringId = nil
}
.onHover(perform: { hovering in
if hovering {
hoveringId = account.localizedAccountName()
} else {
hoveringId = nil
}
})
.scaleEffect(hoveringId == account.localizedAccountName() ? 1.2 : 1)
.shadow(radius: hoveringId == account.localizedAccountName() ? 0.8 : 0)
}
}
Text(helpText)
.multilineTextAlignment(.center)
.padding(.top, 8)
}
}
}

View File

@ -9,11 +9,12 @@
import SwiftUI
import Account
private enum AddAccountSections: Int, CaseIterable {
enum AddAccountSections: Int, CaseIterable {
case local = 0
case icloud
case web
case selfhosted
case allOrdered
var sectionHeader: String {
switch self {
@ -25,6 +26,8 @@ private enum AddAccountSections: Int, CaseIterable {
return NSLocalizedString("Web", comment: "Web Account")
case .selfhosted:
return NSLocalizedString("Self-hosted", comment: "Self hosted Account")
case .allOrdered:
return ""
}
}
@ -38,6 +41,8 @@ private enum AddAccountSections: Int, CaseIterable {
return NSLocalizedString("Web accounts sync your subscriptions across all your devices.", comment: "Web Account")
case .selfhosted:
return NSLocalizedString("Self-hosted accounts sync your subscriptions across all your devices.", comment: "Self hosted Account")
case .allOrdered:
return ""
}
}
@ -51,6 +56,11 @@ private enum AddAccountSections: Int, CaseIterable {
return [.bazQux, .feedbin, .feedly, .feedWrangler, .inoreader, .newsBlur, .theOldReader]
case .selfhosted:
return [.freshRSS]
case .allOrdered:
return AddAccountSections.local.sectionContent +
AddAccountSections.icloud.sectionContent +
AddAccountSections.web.sectionContent +
AddAccountSections.selfhosted.sectionContent
}
}
}

View File

@ -0,0 +1,48 @@
//
// EnableExtensionPointHelpView.swift
// NetNewsWire
//
// Created by Stuart Breckenridge on 4/11/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import AppKit
import SwiftUI
import RSCore
struct EnableExtensionPointHelpView: View {
let imageLiterals = ["extensionPointMarsEdit", "extensionPointMicroblog", "extensionPointReddit", "extensionPointTwitter"]
var helpText: String
weak var preferencesController: ExtensionPointPreferencesViewController?
@State private var hoveringId: String?
var body: some View {
VStack {
HStack {
ForEach(imageLiterals, id: \.self) { name in
Image(name)
.resizable()
.frame(width: 20, height: 20, alignment: .center)
.onTapGesture {
preferencesController?.enableExtensionPoints(self)
hoveringId = nil
}
.onHover(perform: { hovering in
if hovering {
hoveringId = name
} else {
hoveringId = nil
}
})
.scaleEffect(hoveringId == name ? 1.2 : 1)
.shadow(radius: hoveringId == name ? 0.8 : 0)
}
}
Text(helpText)
.multilineTextAlignment(.center)
.padding(.top, 8)
}
}
}

View File

@ -107,7 +107,7 @@ struct EnableExtensionPointView: View {
.pickerStyle(RadioGroupPickerStyle())
.offset(x: 7.5, y: 0)
Text("An extension point that makes websites appear to provide RSS feeds for their content.")
Text("An extension that makes websites appear to provide RSS feeds for their content.")
.foregroundColor(.gray)
.font(.caption)
.padding(.horizontal)
@ -144,7 +144,7 @@ struct EnableExtensionPointView: View {
.pickerStyle(RadioGroupPickerStyle())
.offset(x: 7.5, y: 0)
Text("An extension point that enables a share menu item that passes article data to a third-party application.")
Text("An extension that enables a share menu item that passes article data to a third-party application.")
.foregroundColor(.gray)
.font(.caption)
.padding(.horizontal)
@ -170,3 +170,6 @@ struct EnableExtensionPointView: View {
fatalError()
}
}

View File

@ -41,10 +41,7 @@ final class ExtensionPointPreferencesViewController: NSViewController {
showDefaultView()
// Set initial row selection
if activeExtensionPoints.count > 0 {
tableView.selectRow(0)
}
}
@IBAction func enableExtensionPoints(_ sender: Any) {
@ -183,9 +180,9 @@ private extension ExtensionPointPreferencesViewController {
if tableView.selectedRow == -1 {
var helpText = ""
if activeExtensionPoints.count == 0 {
helpText = NSLocalizedString("Add an extension point by clicking the + button.", comment: "Extension Explainer")
helpText = NSLocalizedString("Add an extension 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")
helpText = NSLocalizedString("Select an extension or add a new extension point by clicking the + button.", comment: "Extension Explainer")
}
if let controller = children.first {
@ -193,7 +190,7 @@ private extension ExtensionPointPreferencesViewController {
controller.view.removeFromSuperview()
}
let textHostingController = NSHostingController(rootView: Text(helpText).multilineTextAlignment(.center))
let textHostingController = NSHostingController(rootView: EnableExtensionPointHelpView(helpText: helpText, preferencesController: self))
addChild(textHostingController)
textHostingController.view.translatesAutoresizingMaskIntoConstraints = false
detailView.addSubview(textHostingController.view)
@ -223,12 +220,12 @@ private extension ExtensionPointPreferencesViewController {
if tableView.selectedRow == -1 {
var helpText = ""
if activeExtensionPoints.count == 0 {
helpText = NSLocalizedString("Add an extension point by clicking the + button.", comment: "Extension Explainer")
helpText = NSLocalizedString("Add an extension 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")
helpText = NSLocalizedString("Select an extension or add a new extension point by clicking the + button.", comment: "Extension Explainer")
}
let textHostingController = NSHostingController(rootView: Text(helpText).multilineTextAlignment(.center))
let textHostingController = NSHostingController(rootView: EnableExtensionPointHelpView(helpText: helpText, preferencesController: self))
addChild(textHostingController)
textHostingController.view.translatesAutoresizingMaskIntoConstraints = false
detailView.addSubview(textHostingController.view)
@ -297,3 +294,5 @@ private extension ExtensionPointPreferencesViewController {
}
}

View File

@ -9,6 +9,10 @@
/* Begin PBXBuildFile section */
1704053424E5985A00A00787 /* SceneNavigationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1704053324E5985A00A00787 /* SceneNavigationModel.swift */; };
1704053524E5985A00A00787 /* SceneNavigationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1704053324E5985A00A00787 /* SceneNavigationModel.swift */; };
1710B9132552354E00679C0D /* AddAccountHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1710B9122552354E00679C0D /* AddAccountHelpView.swift */; };
1710B9142552354E00679C0D /* AddAccountHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1710B9122552354E00679C0D /* AddAccountHelpView.swift */; };
1710B929255246F900679C0D /* EnableExtensionPointHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1710B928255246F900679C0D /* EnableExtensionPointHelpView.swift */; };
1710B92A255246F900679C0D /* EnableExtensionPointHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1710B928255246F900679C0D /* EnableExtensionPointHelpView.swift */; };
1717535624BADF33004498C6 /* GeneralPreferencesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1717535524BADF33004498C6 /* GeneralPreferencesModel.swift */; };
171BCB8C24CB08A3006E22D9 /* FixAccountCredentialView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 171BCB8B24CB08A3006E22D9 /* FixAccountCredentialView.swift */; };
171BCB8D24CB08A3006E22D9 /* FixAccountCredentialView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 171BCB8B24CB08A3006E22D9 /* FixAccountCredentialView.swift */; };
@ -1434,6 +1438,8 @@
/* Begin PBXFileReference section */
1704053324E5985A00A00787 /* SceneNavigationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneNavigationModel.swift; sourceTree = "<group>"; };
1710B9122552354E00679C0D /* AddAccountHelpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountHelpView.swift; sourceTree = "<group>"; };
1710B928255246F900679C0D /* EnableExtensionPointHelpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnableExtensionPointHelpView.swift; sourceTree = "<group>"; };
1717535524BADF33004498C6 /* GeneralPreferencesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralPreferencesModel.swift; sourceTree = "<group>"; };
171BCB8B24CB08A3006E22D9 /* FixAccountCredentialView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FixAccountCredentialView.swift; sourceTree = "<group>"; };
172199C824AB228900A31D04 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
@ -2304,6 +2310,7 @@
isa = PBXGroup;
children = (
5183CFAE254C78C8006B83A5 /* EnableExtensionPointView.swift */,
1710B928255246F900679C0D /* EnableExtensionPointHelpView.swift */,
515A516D243E7F950089E588 /* ExtensionPointDetail.xib */,
515A5170243E802B0089E588 /* ExtensionPointDetailViewController.swift */,
515A5147243E64BA0089E588 /* ExtensionPointEnableWindowController.swift */,
@ -3328,6 +3335,7 @@
isa = PBXGroup;
children = (
178A9F9C2549449F00AB7E9D /* AddAccountsView.swift */,
1710B9122552354E00679C0D /* AddAccountHelpView.swift */,
84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */,
84C9FC7422629E1200D921D6 /* AccountsDetail.xib */,
5144EA2E2279FAB600D19003 /* AccountsDetailViewController.swift */,
@ -4794,6 +4802,7 @@
65ED3FBD235DEF6C0081F399 /* AppDefaults.swift in Sources */,
65ED3FBE235DEF6C0081F399 /* Account+Scriptability.swift in Sources */,
65ED3FBF235DEF6C0081F399 /* NothingInspectorViewController.swift in Sources */,
1710B92A255246F900679C0D /* EnableExtensionPointHelpView.swift in Sources */,
65ED3FC0235DEF6C0081F399 /* AppNotifications.swift in Sources */,
65ED3FC1235DEF6C0081F399 /* TimelineKeyboardDelegate.swift in Sources */,
65ED3FC2235DEF6C0081F399 /* Browser.swift in Sources */,
@ -4863,6 +4872,7 @@
65ED3FF7235DEF6C0081F399 /* SearchFeedDelegate.swift in Sources */,
65ED3FF8235DEF6C0081F399 /* ErrorHandler.swift in Sources */,
65ED3FF9235DEF6C0081F399 /* ActivityManager.swift in Sources */,
1710B9142552354E00679C0D /* AddAccountHelpView.swift in Sources */,
65ED3FFA235DEF6C0081F399 /* WebFeedInspectorViewController.swift in Sources */,
65ED3FFB235DEF6C0081F399 /* AccountsReaderAPIWindowController.swift in Sources */,
65ED3FFC235DEF6C0081F399 /* AccountsAddLocalWindowController.swift in Sources */,
@ -5179,6 +5189,7 @@
D5907D7F2004AC00005947E5 /* NSApplication+Scriptability.swift in Sources */,
8405DD9C22153BD7008CE1BF /* NSView-Extensions.swift in Sources */,
849A979F1ED9F130007D329B /* SidebarCell.swift in Sources */,
1710B929255246F900679C0D /* EnableExtensionPointHelpView.swift in Sources */,
515A50E6243D07A90089E588 /* ExtensionPointManager.swift in Sources */,
51E595A5228CC36500FCC42B /* ArticleStatusSyncTimer.swift in Sources */,
515A5177243E90200089E588 /* ExtensionPointIdentifer.swift in Sources */,
@ -5234,6 +5245,7 @@
511B9806237DCAC90028BCAA /* UserInfoKey.swift in Sources */,
84C9FC7722629E1200D921D6 /* AdvancedPreferencesViewController.swift in Sources */,
849EE72120391F560082A1EA /* SharingServicePickerDelegate.swift in Sources */,
1710B9132552354E00679C0D /* AddAccountHelpView.swift in Sources */,
5108F6B62375E612001ABC45 /* CacheCleaner.swift in Sources */,
849A97981ED9EFAA007D329B /* Node-Extensions.swift in Sources */,
849EE70F203919360082A1EA /* AppAssets.swift in Sources */,