From 430a4a37bfaa9a5366b53969d82177fc9f89fb93 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 23 Oct 2019 10:35:53 -0500 Subject: [PATCH] Add icon next to accounts in the Settings listing. Issue #1160 --- NetNewsWire.xcodeproj/project.pbxproj | 20 ++++++-- iOS/AppAssets.swift | 26 ++++++++++ .../SettingsAccountTableViewCell.swift | 30 ++++++++++++ iOS/Settings/SettingsAccountTableViewCell.xib | 47 +++++++++++++++++++ iOS/Settings/SettingsViewController.swift | 16 ++++--- 5 files changed, 129 insertions(+), 10 deletions(-) create mode 100644 iOS/Settings/SettingsAccountTableViewCell.swift create mode 100644 iOS/Settings/SettingsAccountTableViewCell.xib diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index dcbae23cd..1a326e674 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -81,6 +81,9 @@ 515D4FC123257A3200EE1167 /* FolderTreeControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97A11ED9F180007D329B /* FolderTreeControllerDelegate.swift */; }; 515D4FCA23257CB500EE1167 /* Node-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97971ED9EFAA007D329B /* Node-Extensions.swift */; }; 515D4FCC2325815A00EE1167 /* SafariExt.js in Resources */ = {isa = PBXBuildFile; fileRef = 515D4FCB2325815A00EE1167 /* SafariExt.js */; }; + 516A093723609A3600EAE89B /* SettingsAccountTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 516A091D23609A3600EAE89B /* SettingsAccountTableViewCell.xib */; }; + 516A09392360A2AE00EAE89B /* SettingsAccountTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 516A09382360A2AE00EAE89B /* SettingsAccountTableViewCell.swift */; }; + 516A093B2360A4A000EAE89B /* SettingsTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 516A093A2360A4A000EAE89B /* SettingsTableViewCell.xib */; }; 51707439232AA97100A461A3 /* ShareFolderPickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51707438232AA97100A461A3 /* ShareFolderPickerController.swift */; }; 5170743A232AABFC00A461A3 /* FlattenedAccountFolderPickerData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51C452812265093600C03939 /* FlattenedAccountFolderPickerData.swift */; }; 517630042336215100E15FFF /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 517630032336215100E15FFF /* main.js */; }; @@ -106,7 +109,6 @@ 519D740623243CC0008BB345 /* RefreshInterval-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519D740523243CC0008BB345 /* RefreshInterval-Extensions.swift */; }; 519E743D22C663F900A78E47 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519E743422C663F900A78E47 /* SceneDelegate.swift */; }; 51A16997235E10D700EB091F /* RefreshIntervalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51A1698D235E10D600EB091F /* RefreshIntervalViewController.swift */; }; - 51A16998235E10D700EB091F /* SettingsTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 51A1698E235E10D600EB091F /* SettingsTableViewCell.xib */; }; 51A16999235E10D700EB091F /* AddLocalAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51A1698F235E10D600EB091F /* AddLocalAccountViewController.swift */; }; 51A1699A235E10D700EB091F /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 51A16990235E10D600EB091F /* Settings.storyboard */; }; 51A1699B235E10D700EB091F /* DetailAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51A16991235E10D600EB091F /* DetailAccountViewController.swift */; }; @@ -1237,6 +1239,9 @@ 515D4FCB2325815A00EE1167 /* SafariExt.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = SafariExt.js; sourceTree = ""; }; 515D4FCD2325909200EE1167 /* NetNewsWire_iOS_ShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NetNewsWire_iOS_ShareExtension.entitlements; sourceTree = ""; }; 515D4FCE2325B3D000EE1167 /* NetNewsWire_iOSshareextension_target.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = NetNewsWire_iOSshareextension_target.xcconfig; sourceTree = ""; }; + 516A091D23609A3600EAE89B /* SettingsAccountTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsAccountTableViewCell.xib; sourceTree = ""; }; + 516A09382360A2AE00EAE89B /* SettingsAccountTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAccountTableViewCell.swift; sourceTree = ""; }; + 516A093A2360A4A000EAE89B /* SettingsTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsTableViewCell.xib; sourceTree = ""; }; 51707438232AA97100A461A3 /* ShareFolderPickerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareFolderPickerController.swift; sourceTree = ""; }; 517630032336215100E15FFF /* main.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = main.js; sourceTree = ""; }; 517630222336657E00E15FFF /* ArticleViewControllerWebViewProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleViewControllerWebViewProvider.swift; sourceTree = ""; }; @@ -1258,7 +1263,6 @@ 519D740523243CC0008BB345 /* RefreshInterval-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RefreshInterval-Extensions.swift"; sourceTree = ""; }; 519E743422C663F900A78E47 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 51A1698D235E10D600EB091F /* RefreshIntervalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshIntervalViewController.swift; sourceTree = ""; }; - 51A1698E235E10D600EB091F /* SettingsTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsTableViewCell.xib; sourceTree = ""; }; 51A1698F235E10D600EB091F /* AddLocalAccountViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddLocalAccountViewController.swift; sourceTree = ""; }; 51A16990235E10D600EB091F /* Settings.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = ""; }; 51A16991235E10D600EB091F /* DetailAccountViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailAccountViewController.swift; sourceTree = ""; }; @@ -1775,7 +1779,9 @@ 51A16991235E10D600EB091F /* DetailAccountViewController.swift */, 51A16996235E10D700EB091F /* FeedbinAccountViewController.swift */, 51A1698D235E10D600EB091F /* RefreshIntervalViewController.swift */, - 51A1698E235E10D600EB091F /* SettingsTableViewCell.xib */, + 516A09382360A2AE00EAE89B /* SettingsAccountTableViewCell.swift */, + 516A091D23609A3600EAE89B /* SettingsAccountTableViewCell.xib */, + 516A093A2360A4A000EAE89B /* SettingsTableViewCell.xib */, 51A16993235E10D600EB091F /* SettingsViewController.swift */, ); path = Settings; @@ -2914,6 +2920,10 @@ DevelopmentTeam = SHJK2V3AJG; ProvisioningStyle = Automatic; }; + 65ED4090235DEF770081F399 = { + DevelopmentTeam = SHJK2V3AJG; + ProvisioningStyle = Automatic; + }; 840D617B2029031C009BC708 = { CreatedOnToolsVersion = 9.3; DevelopmentTeam = SHJK2V3AJG; @@ -3361,13 +3371,14 @@ 51C452862265093600C03939 /* Add.storyboard in Resources */, 511D43EF231FBDE900FB1562 /* LaunchScreenPad.storyboard in Resources */, 511D43D2231FA62C00FB1562 /* GlobalKeyboardShortcuts.plist in Resources */, - 51A16998235E10D700EB091F /* SettingsTableViewCell.xib in Resources */, 84C9FCA12262A1B300D921D6 /* Main.storyboard in Resources */, 51BB7C312335ACDE008E8144 /* page.html in Resources */, + 516A093723609A3600EAE89B /* SettingsAccountTableViewCell.xib in Resources */, 51F85BF32272531500C787DC /* Dedication.rtf in Resources */, 84C9FCA42262A1B800D921D6 /* LaunchScreenPhone.storyboard in Resources */, 51F85BEB22724CB600C787DC /* About.rtf in Resources */, 51F85BED227251DF00C787DC /* Acknowledgments.rtf in Resources */, + 516A093B2360A4A000EAE89B /* SettingsTableViewCell.xib in Resources */, 511D43D1231FA62800FB1562 /* SidebarKeyboardShortcuts.plist in Resources */, 51C452AB22650DC600C03939 /* template.html in Resources */, 51F85BF12272524100C787DC /* Credits.rtf in Resources */, @@ -3866,6 +3877,7 @@ 51D87EE12311D34700E63F03 /* ActivityType.swift in Sources */, 51C452772265091600C03939 /* MultilineUILabelSizer.swift in Sources */, 51C452A522650A2D00C03939 /* SmallIconProvider.swift in Sources */, + 516A09392360A2AE00EAE89B /* SettingsAccountTableViewCell.swift in Sources */, 51D5948722668EFA00DFC836 /* MarkStatusCommand.swift in Sources */, 51A1699C235E10D700EB091F /* AddAccountViewController.swift in Sources */, 51A16999235E10D700EB091F /* AddLocalAccountViewController.swift in Sources */, diff --git a/iOS/AppAssets.swift b/iOS/AppAssets.swift index 55f66027a..dcb1c9227 100644 --- a/iOS/AppAssets.swift +++ b/iOS/AppAssets.swift @@ -7,9 +7,22 @@ // import UIKit import RSCore +import Account struct AppAssets { + static var accountLocalImage: UIImage = { + return UIImage(named: "accountLocal")! + }() + + static var accountFeedbinImage: UIImage = { + return UIImage(named: "accountFeedbin")! + }() + + static var accountFreshRSSImage: UIImage = { + return UIImage(named: "accountFreshRSS")! + }() + static var articleExtractorError: UIImage = { return UIImage(named: "articleExtractorError")! }() @@ -161,4 +174,17 @@ struct AppAssets { return UIColor(named: "vibrantTextColor")! }() + static func image(for accountType: AccountType) -> UIImage? { + switch accountType { + case .onMyMac: + return AppAssets.accountLocalImage + case .feedbin: + return AppAssets.accountFeedbinImage + case .freshRSS: + return AppAssets.accountFreshRSSImage + default: + return nil + } + } + } diff --git a/iOS/Settings/SettingsAccountTableViewCell.swift b/iOS/Settings/SettingsAccountTableViewCell.swift new file mode 100644 index 000000000..cc45c59b0 --- /dev/null +++ b/iOS/Settings/SettingsAccountTableViewCell.swift @@ -0,0 +1,30 @@ +// +// SettingsAccountTableViewCell.swift +// NetNewsWire-iOS +// +// Created by Maurice Parker on 10/23/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import UIKit + +class SettingsAccountTableViewCell: VibrantTableViewCell { + + @IBOutlet weak var accountImage: UIImageView! + @IBOutlet weak var accountNameLabel: UILabel! + + override func setHighlighted(_ highlighted: Bool, animated: Bool) { + super.setHighlighted(highlighted, animated: animated) + let tintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label + accountImage?.tintColor = tintColor + accountNameLabel?.highlightedTextColor = tintColor + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + let tintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label + accountImage?.tintColor = tintColor + accountNameLabel?.highlightedTextColor = tintColor + } + +} diff --git a/iOS/Settings/SettingsAccountTableViewCell.xib b/iOS/Settings/SettingsAccountTableViewCell.xib new file mode 100644 index 000000000..1b4d94da3 --- /dev/null +++ b/iOS/Settings/SettingsAccountTableViewCell.xib @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/Settings/SettingsViewController.swift b/iOS/Settings/SettingsViewController.swift index b88d37246..56fe7f11f 100644 --- a/iOS/Settings/SettingsViewController.swift +++ b/iOS/Settings/SettingsViewController.swift @@ -33,8 +33,9 @@ class SettingsViewController: UITableViewController { NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidAddAccount, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidDeleteAccount, object: nil) + tableView.register(UINib(nibName: "SettingsAccountTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsAccountTableViewCell") tableView.register(UINib(nibName: "SettingsTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsTableViewCell") - + } override func viewWillAppear(_ animated: Bool) { @@ -94,15 +95,18 @@ class SettingsViewController: UITableViewController { let cell: UITableViewCell switch indexPath.section { case 1: - - cell = tableView.dequeueReusableCell(withIdentifier: "SettingsTableViewCell", for: indexPath) - cell.textLabel?.adjustsFontForContentSizeCategory = true - + let sortedAccounts = AccountManager.shared.sortedAccounts if indexPath.row == sortedAccounts.count { + cell = tableView.dequeueReusableCell(withIdentifier: "SettingsTableViewCell", for: indexPath) + cell.textLabel?.adjustsFontForContentSizeCategory = true cell.textLabel?.text = NSLocalizedString("Add Account", comment: "Accounts") } else { - cell.textLabel?.text = sortedAccounts[indexPath.row].nameForDisplay + let acctCell = tableView.dequeueReusableCell(withIdentifier: "SettingsAccountTableViewCell", for: indexPath) as! SettingsAccountTableViewCell + let account = sortedAccounts[indexPath.row] + acctCell.accountImage?.image = AppAssets.image(for: account.type) + acctCell.accountNameLabel?.text = account.nameForDisplay + cell = acctCell } default: