From 4ad7cd7bdda912968737f37bbdd056eceea51772 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 8 Dec 2019 10:39:13 -0700 Subject: [PATCH] Fix vibrancy for new add web feed folder picker. Issue #1384 --- NetNewsWire.xcodeproj/project.pbxproj | 8 ++++ iOS/Add/Add.storyboard | 5 +- iOS/Add/AddWebFeedFolderTableViewCell.swift | 12 ++++- .../AddWebFeedSelectFolderTableViewCell.swift | 22 +++++++++ .../AddWebFeedSelectFolderTableViewCell.xib | 48 +++++++++++++++++++ iOS/Add/AddWebFeedViewController.swift | 19 ++++++-- 6 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 iOS/Add/AddWebFeedSelectFolderTableViewCell.swift create mode 100644 iOS/Add/AddWebFeedSelectFolderTableViewCell.xib diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 52fd04c74..56fc5acb6 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -228,6 +228,8 @@ 51D5948722668EFA00DFC836 /* MarkStatusCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84702AA31FA27AC0006B8943 /* MarkStatusCommand.swift */; }; 51D6A5BC23199C85001C27D8 /* MasterTimelineDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D6A5BB23199C85001C27D8 /* MasterTimelineDataSource.swift */; }; 51D87EE12311D34700E63F03 /* ActivityType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D87EE02311D34700E63F03 /* ActivityType.swift */; }; + 51E36E71239D6610006F47A5 /* AddWebFeedSelectFolderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E36E70239D6610006F47A5 /* AddWebFeedSelectFolderTableViewCell.swift */; }; + 51E36E8C239D6765006F47A5 /* AddWebFeedSelectFolderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 51E36E8B239D6765006F47A5 /* AddWebFeedSelectFolderTableViewCell.xib */; }; 51E3EB33229AB02C00645299 /* ErrorHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E3EB32229AB02C00645299 /* ErrorHandler.swift */; }; 51E3EB3D229AB08300645299 /* ErrorHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E3EB3C229AB08300645299 /* ErrorHandler.swift */; }; 51E43962238037C400015C31 /* AddWebFeedFolderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E43961238037C400015C31 /* AddWebFeedFolderViewController.swift */; }; @@ -1349,6 +1351,8 @@ 51CE1C0A23622006005548FC /* RefreshProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshProgressView.swift; sourceTree = ""; }; 51D6A5BB23199C85001C27D8 /* MasterTimelineDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTimelineDataSource.swift; sourceTree = ""; }; 51D87EE02311D34700E63F03 /* ActivityType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityType.swift; sourceTree = ""; }; + 51E36E70239D6610006F47A5 /* AddWebFeedSelectFolderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWebFeedSelectFolderTableViewCell.swift; sourceTree = ""; }; + 51E36E8B239D6765006F47A5 /* AddWebFeedSelectFolderTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AddWebFeedSelectFolderTableViewCell.xib; sourceTree = ""; }; 51E3EB32229AB02C00645299 /* ErrorHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorHandler.swift; sourceTree = ""; }; 51E3EB3C229AB08300645299 /* ErrorHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorHandler.swift; sourceTree = ""; }; 51E43961238037C400015C31 /* AddWebFeedFolderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWebFeedFolderViewController.swift; sourceTree = ""; }; @@ -1969,6 +1973,8 @@ 51C4528B2265095F00C03939 /* AddFolderViewController.swift */, 51C452842265093600C03939 /* AddWebFeedViewController.swift */, 51E43961238037C400015C31 /* AddWebFeedFolderViewController.swift */, + 51E36E70239D6610006F47A5 /* AddWebFeedSelectFolderTableViewCell.swift */, + 51E36E8B239D6765006F47A5 /* AddWebFeedSelectFolderTableViewCell.xib */, 51E4397F23805EBC00015C31 /* AddWebFeedFolderTableViewCell.swift */, ); path = Add; @@ -3453,6 +3459,7 @@ 51CE1C0923621EDA005548FC /* RefreshProgressView.xib in Resources */, 84C9FC9D2262A1A900D921D6 /* Assets.xcassets in Resources */, 514219582353C28900E07E2C /* main_ios.js in Resources */, + 51E36E8C239D6765006F47A5 /* AddWebFeedSelectFolderTableViewCell.xib in Resources */, 51C452B82265178500C03939 /* styleSheet.css in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -3814,6 +3821,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 51E36E71239D6610006F47A5 /* AddWebFeedSelectFolderTableViewCell.swift in Sources */, 840D617F2029031C009BC708 /* AppDelegate.swift in Sources */, 51236339236915B100951F16 /* RoundedProgressView.swift in Sources */, 512E08E72268801200BDCFDD /* WebFeedTreeControllerDelegate.swift in Sources */, diff --git a/iOS/Add/Add.storyboard b/iOS/Add/Add.storyboard index b489e9d72..d59f560c7 100644 --- a/iOS/Add/Add.storyboard +++ b/iOS/Add/Add.storyboard @@ -18,7 +18,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -108,7 +108,6 @@ - diff --git a/iOS/Add/AddWebFeedFolderTableViewCell.swift b/iOS/Add/AddWebFeedFolderTableViewCell.swift index c8c849956..4023057f1 100644 --- a/iOS/Add/AddWebFeedFolderTableViewCell.swift +++ b/iOS/Add/AddWebFeedFolderTableViewCell.swift @@ -8,9 +8,19 @@ import UIKit -class AddWebFeedFolderTableViewCell: UITableViewCell { +class AddWebFeedFolderTableViewCell: VibrantTableViewCell { @IBOutlet weak var icon: UIImageView! @IBOutlet weak var label: UILabel! + override func updateVibrancy(animated: Bool) { + super.updateVibrancy(animated: animated) + + let iconTintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor + UIView.animate(withDuration: duration(animated: animated)) { + self.icon.tintColor = iconTintColor + } + updateLabelVibrancy(label, color: labelColor, animated: animated) + } + } diff --git a/iOS/Add/AddWebFeedSelectFolderTableViewCell.swift b/iOS/Add/AddWebFeedSelectFolderTableViewCell.swift new file mode 100644 index 000000000..287d25807 --- /dev/null +++ b/iOS/Add/AddWebFeedSelectFolderTableViewCell.swift @@ -0,0 +1,22 @@ +// +// AddWebFeedSelectFolderTableViewCell.swift +// NetNewsWire-iOS +// +// Created by Maurice Parker on 12/8/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import UIKit + +class AddWebFeedSelectFolderTableViewCell: VibrantTableViewCell { + + @IBOutlet weak var folderLabel: UILabel! + @IBOutlet weak var detailLabel: UILabel! + + override func updateVibrancy(animated: Bool) { + super.updateVibrancy(animated: animated) + updateLabelVibrancy(folderLabel, color: labelColor, animated: animated) + updateLabelVibrancy(detailLabel, color: labelColor, animated: animated) + } + +} diff --git a/iOS/Add/AddWebFeedSelectFolderTableViewCell.xib b/iOS/Add/AddWebFeedSelectFolderTableViewCell.xib new file mode 100644 index 000000000..b257cc618 --- /dev/null +++ b/iOS/Add/AddWebFeedSelectFolderTableViewCell.xib @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/Add/AddWebFeedViewController.swift b/iOS/Add/AddWebFeedViewController.swift index e663cc9d2..e2f8a883f 100644 --- a/iOS/Add/AddWebFeedViewController.swift +++ b/iOS/Add/AddWebFeedViewController.swift @@ -16,8 +16,8 @@ class AddWebFeedViewController: UITableViewController, AddContainerViewControlle @IBOutlet private weak var urlTextField: UITextField! @IBOutlet private weak var nameTextField: UITextField! - @IBOutlet private weak var folderLabel: UILabel! + private var folderLabel = "" private var userCancelled = false weak var delegate: AddContainerViewControllerChildDelegate? @@ -59,6 +59,8 @@ class AddWebFeedViewController: UITableViewController, AddContainerViewControlle // I couldn't figure out the gap at the top of the UITableView, so I took a hammer to it. tableView.contentInset = UIEdgeInsets(top: -28, left: 0, bottom: 0, right: 0) + tableView.register(UINib(nibName: "AddWebFeedSelectFolderTableViewCell", bundle: nil), forCellReuseIdentifier: "AddWebFeedSelectFolderTableViewCell") + NotificationCenter.default.addObserver(self, selector: #selector(textDidChange(_:)), name: UITextField.textDidChangeNotification, object: urlTextField) } @@ -119,6 +121,16 @@ class AddWebFeedViewController: UITableViewController, AddContainerViewControlle delegate?.readyToAdd(state: urlTextField.text?.rs_stringMayBeURL() ?? false) } + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.row == 2 { + let cell = tableView.dequeueReusableCell(withIdentifier: "AddWebFeedSelectFolderTableViewCell", for: indexPath) as? AddWebFeedSelectFolderTableViewCell + cell!.detailLabel.text = folderLabel + return cell! + } else { + return super.tableView(tableView, cellForRowAt: indexPath) + } + } + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if indexPath.row == 2 { let navController = UIStoryboard.add.instantiateViewController(withIdentifier: "AddWebFeedFolderNavViewController") as! UINavigationController @@ -159,10 +171,11 @@ private extension AddWebFeedViewController { func updateFolderLabel() { if let containerName = (container as? DisplayNameProvider)?.nameForDisplay { if container is Folder { - folderLabel.text = "\(container?.account?.nameForDisplay ?? "") / \(containerName)" + folderLabel = "\(container?.account?.nameForDisplay ?? "") / \(containerName)" } else { - folderLabel.text = containerName + folderLabel = containerName } + tableView.reloadData() } } }