From 59a30fdd3428649533ac8836265041a046f51eb8 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 19 Apr 2019 07:37:47 -0500 Subject: [PATCH 01/12] Change iOS webview baseURL handling to match macOS version. --- .../Article Rendering/ArticleRenderer.swift | 3 ++ iOS/Detail/DetailViewController.swift | 30 +------------------ 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/Shared/Article Rendering/ArticleRenderer.swift b/Shared/Article Rendering/ArticleRenderer.swift index 4dfe61757..7643b1091 100644 --- a/Shared/Article Rendering/ArticleRenderer.swift +++ b/Shared/Article Rendering/ArticleRenderer.swift @@ -365,6 +365,9 @@ private extension ArticleRenderer { func renderHTML(withBody body: String) -> String { var s = "\n" + if let baseURL = baseURL { + s += ("") + } s += "\n" s += title.htmlBySurroundingWithTag("title") s += styleString().htmlBySurroundingWithTag("style") diff --git a/iOS/Detail/DetailViewController.swift b/iOS/Detail/DetailViewController.swift index 338f67998..0b9f81269 100644 --- a/iOS/Detail/DetailViewController.swift +++ b/iOS/Detail/DetailViewController.swift @@ -64,7 +64,7 @@ class DetailViewController: UIViewController { } let style = ArticleStylesManager.shared.currentStyle let html = ArticleRenderer.articleHTML(article: article, style: style) - webView.loadHTMLString(html, baseURL: article.baseURL) + webView.loadHTMLString(html, baseURL: nil) } @objc func statusesDidChange(_ note: Notification) { @@ -155,33 +155,5 @@ extension DetailViewController: WKNavigationDelegate { } } -} - -private extension Article { - - var baseURL: URL? { - var s = url - if s == nil { - s = feed?.homePageURL - } - if s == nil { - s = feed?.url - } - - guard let urlString = s else { - return nil - } - var urlComponents = URLComponents(string: urlString) - if urlComponents == nil { - return nil - } - - // Can’t use url-with-fragment as base URL. The webview won’t load. See scripting.com/rss.xml for example. - urlComponents!.fragment = nil - guard let url = urlComponents!.url, url.scheme == "http" || url.scheme == "https" else { - return nil - } - return url - } } From ca6f8dcb46ca4dac7ab74e2471fa2bafa1b417c3 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 19 Apr 2019 07:49:35 -0500 Subject: [PATCH 02/12] Fix missing or incorrect file documentation headers. --- iOS/Extensions/String-Extensions.swift | 2 +- iOS/Extensions/UIImage-Extensions.swift | 8 +++++++- iOS/Extensions/UISplitViewController-Extensions.swift | 8 +++++++- iOS/Extensions/UIStoryboard-Extensions.swift | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/iOS/Extensions/String-Extensions.swift b/iOS/Extensions/String-Extensions.swift index d546ce63f..c56dda628 100644 --- a/iOS/Extensions/String-Extensions.swift +++ b/iOS/Extensions/String-Extensions.swift @@ -1,5 +1,5 @@ // -// String+.swift +// String-Extensions.swift // NetNewsWire // // Created by Maurice Parker on 4/8/19. diff --git a/iOS/Extensions/UIImage-Extensions.swift b/iOS/Extensions/UIImage-Extensions.swift index 79aff8d1f..e9e071c40 100644 --- a/iOS/Extensions/UIImage-Extensions.swift +++ b/iOS/Extensions/UIImage-Extensions.swift @@ -1,4 +1,10 @@ -//Copyright © 2019 Vincode, Inc. All rights reserved. +// +// UIImage-Extensions.swift +// NetNewsWire +// +// Created by Maurice Parker on 4/18/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// import UIKit diff --git a/iOS/Extensions/UISplitViewController-Extensions.swift b/iOS/Extensions/UISplitViewController-Extensions.swift index 617b417eb..98fa33c5d 100644 --- a/iOS/Extensions/UISplitViewController-Extensions.swift +++ b/iOS/Extensions/UISplitViewController-Extensions.swift @@ -1,4 +1,10 @@ -//Copyright © 2019 Ranchero Software. All rights reserved. +// +// UISplitViewController-Extensions.swift +// NetNewsWire +// +// Created by Maurice Parker on 4/18/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// import UIKit diff --git a/iOS/Extensions/UIStoryboard-Extensions.swift b/iOS/Extensions/UIStoryboard-Extensions.swift index 66bfc485a..540b96e22 100644 --- a/iOS/Extensions/UIStoryboard-Extensions.swift +++ b/iOS/Extensions/UIStoryboard-Extensions.swift @@ -1,5 +1,5 @@ // -// UIStoryboard+.swift +// UIStoryboard-Extensions.swift // NetNewsWire // // Created by Maurice Parker on 4/8/19. From 057fcc3a606c51d2107418cb4893144914a955ba Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 19 Apr 2019 20:03:02 -0500 Subject: [PATCH 03/12] Implement moving in and out of folders. --- iOS/Master/MasterViewController.swift | 100 +++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/iOS/Master/MasterViewController.swift b/iOS/Master/MasterViewController.swift index cb855e307..4019595b4 100644 --- a/iOS/Master/MasterViewController.swift +++ b/iOS/Master/MasterViewController.swift @@ -268,6 +268,91 @@ class MasterViewController: UITableViewController, UndoableCommandRunner { self.navigationController?.pushViewController(timeline, animated: true) } + + override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { + guard let node = nodeFor(indexPath) else { + return false + } + return node.representedObject is Feed + } + + override func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -> IndexPath { + + // Adjust the index path so that it will never be in the smart feeds area + let destIndexPath: IndexPath = { + if proposedDestinationIndexPath.section == 0 { + return IndexPath(row: 0, section: 1) + } + return proposedDestinationIndexPath + }() + + guard let draggedNode = nodeFor(sourceIndexPath), let destNode = nodeFor(destIndexPath), let parentNode = destNode.parent else { + assertionFailure("This should never happen") + return sourceIndexPath + } + + // If this is a folder and isn't expanded or doesn't have any entries, let the users drop on it + if destNode.representedObject is Folder && (destNode.numberOfChildNodes == 0 || !expandedNodes.contains(destNode)) { + let movementAdjustment = sourceIndexPath > proposedDestinationIndexPath ? 1 : 0 + return IndexPath(row: destIndexPath.row + movementAdjustment, section: destIndexPath.section) + } + + // If we are dragging around in the same container, just return the original source + if parentNode.childNodes.contains(draggedNode) { + return sourceIndexPath + } + + // Suggest to the user the best place to drop the feed + // Revisit if the tree controller can ever be sorted in some other way. + let nodes = parentNode.childNodes + [draggedNode] + var sortedNodes = nodes.sortedAlphabeticallyWithFoldersAtEnd() + let index = sortedNodes.firstIndex(of: draggedNode)! + + if index == 0 { + if parentNode.representedObject is Account { + return IndexPath(row: 0, section: destIndexPath.section) + } else { + return indexPathFor(parentNode)! + } + } else { + sortedNodes.remove(at: sortedNodes.firstIndex(of: draggedNode)!) + let movementAdjustment = sourceIndexPath < proposedDestinationIndexPath ? 1 : 0 + return indexPathFor(sortedNodes[index - movementAdjustment])! + } + + } + + override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { + + let movementAdjustment = sourceIndexPath > destinationIndexPath ? 1 : 0 + let adjustedDestIndexPath = IndexPath(row: destinationIndexPath.row - movementAdjustment, section: destinationIndexPath.section) + + guard let sourceNode = nodeFor(sourceIndexPath), + let destNode = nodeFor(adjustedDestIndexPath), + let feed = sourceNode.representedObject as? Feed else { + return + } + + let destParentNode: Node? = { + if destNode.representedObject is Folder { + return destNode + } else { + if destNode.parent?.representedObject is Folder { + return destNode.parent! + } else { + return nil + } + } + }() + + let account = accountForNode(destNode) + let sourceContainer = sourceNode.parent?.representedObject as? Container + let destinationFolder = destParentNode?.representedObject as? Folder + sourceContainer?.deleteFeed(feed) + account?.addFeed(feed, to: destinationFolder) + account?.structureDidChange() + + } // MARK: Actions @@ -570,7 +655,20 @@ private extension MasterViewController { callback(cell as! MasterTableViewCell, node) } } - + + private func accountForNode(_ node: Node) -> Account? { + if let account = node.representedObject as? Account { + return account + } + if let folder = node.representedObject as? Folder { + return folder.account + } + if let feed = node.representedObject as? Feed { + return feed.account + } + return nil + } + func rebuildShadowTable() { for i in 0.. Date: Sat, 20 Apr 2019 08:46:58 -0500 Subject: [PATCH 04/12] Make drop code work for special case of where the destination row is 0. --- iOS/Master/MasterViewController.swift | 28 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/iOS/Master/MasterViewController.swift b/iOS/Master/MasterViewController.swift index 4019595b4..7265ac476 100644 --- a/iOS/Master/MasterViewController.swift +++ b/iOS/Master/MasterViewController.swift @@ -324,20 +324,27 @@ class MasterViewController: UITableViewController, UndoableCommandRunner { override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { - let movementAdjustment = sourceIndexPath > destinationIndexPath ? 1 : 0 - let adjustedDestIndexPath = IndexPath(row: destinationIndexPath.row - movementAdjustment, section: destinationIndexPath.section) - - guard let sourceNode = nodeFor(sourceIndexPath), - let destNode = nodeFor(adjustedDestIndexPath), - let feed = sourceNode.representedObject as? Feed else { - return + guard let sourceNode = nodeFor(sourceIndexPath), let feed = sourceNode.representedObject as? Feed else { + return } - + + // Based on the drop we have to determine a node to start looking for a parent container. + let destNode: Node = { + if destinationIndexPath.row == 0 { + return treeController.rootNode.childAtIndex(destinationIndexPath.section)! + } else { + let movementAdjustment = sourceIndexPath > destinationIndexPath ? 1 : 0 + let adjustedDestIndexPath = IndexPath(row: destinationIndexPath.row - movementAdjustment, section: destinationIndexPath.section) + return nodeFor(adjustedDestIndexPath)! + } + }() + + // Now we start looking for the parent container let destParentNode: Node? = { - if destNode.representedObject is Folder { + if destNode.representedObject is Container { return destNode } else { - if destNode.parent?.representedObject is Folder { + if destNode.parent?.representedObject is Container { return destNode.parent! } else { return nil @@ -345,6 +352,7 @@ class MasterViewController: UITableViewController, UndoableCommandRunner { } }() + // Move the Feed let account = accountForNode(destNode) let sourceContainer = sourceNode.parent?.representedObject as? Container let destinationFolder = destParentNode?.representedObject as? Folder From 99e50038066659b432147d41878d20c501fb68f5 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 20 Apr 2019 09:07:54 -0500 Subject: [PATCH 05/12] Fix crashing bug where last entry in folder wasn't correctly calculating its suggested IndexPath. --- iOS/Master/MasterViewController.swift | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/iOS/Master/MasterViewController.swift b/iOS/Master/MasterViewController.swift index 7265ac476..dcd36b864 100644 --- a/iOS/Master/MasterViewController.swift +++ b/iOS/Master/MasterViewController.swift @@ -293,7 +293,7 @@ class MasterViewController: UITableViewController, UndoableCommandRunner { // If this is a folder and isn't expanded or doesn't have any entries, let the users drop on it if destNode.representedObject is Folder && (destNode.numberOfChildNodes == 0 || !expandedNodes.contains(destNode)) { - let movementAdjustment = sourceIndexPath > proposedDestinationIndexPath ? 1 : 0 + let movementAdjustment = sourceIndexPath > destIndexPath ? 1 : 0 return IndexPath(row: destIndexPath.row + movementAdjustment, section: destIndexPath.section) } @@ -309,15 +309,26 @@ class MasterViewController: UITableViewController, UndoableCommandRunner { let index = sortedNodes.firstIndex(of: draggedNode)! if index == 0 { + if parentNode.representedObject is Account { return IndexPath(row: 0, section: destIndexPath.section) } else { return indexPathFor(parentNode)! } + } else { - sortedNodes.remove(at: sortedNodes.firstIndex(of: draggedNode)!) - let movementAdjustment = sourceIndexPath < proposedDestinationIndexPath ? 1 : 0 - return indexPathFor(sortedNodes[index - movementAdjustment])! + + sortedNodes.remove(at: index) + + let movementAdjustment = sourceIndexPath < destIndexPath ? 1 : 0 + let adjustedIndex = index - movementAdjustment + if adjustedIndex >= sortedNodes.count { + let lastSortedIndexPath = indexPathFor(sortedNodes[sortedNodes.count - 1])! + return IndexPath(row: lastSortedIndexPath.row + 1, section: lastSortedIndexPath.section) + } else { + return indexPathFor(sortedNodes[adjustedIndex])! + } + } } From 936e727842825cefadf0432e2ded7d6ece344c03 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 20 Apr 2019 09:44:11 -0500 Subject: [PATCH 06/12] updated RSCore --- submodules/RSCore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/RSCore b/submodules/RSCore index 7c3e722bf..42de80e9f 160000 --- a/submodules/RSCore +++ b/submodules/RSCore @@ -1 +1 @@ -Subproject commit 7c3e722bfac7939cf11e2fe6f579faaa4203c248 +Subproject commit 42de80e9f4114163b9af344ac4e538005611e33e From f2191f1dcce88866f125346ac270c76f02d82cdf Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 20 Apr 2019 09:50:44 -0500 Subject: [PATCH 07/12] Update to use the UIView extension in RSCore --- iOS/Master/Cell/MasterTableViewCell.swift | 16 ++++------------ .../Cell/MasterTableViewSectionHeader.swift | 4 ++-- .../Cell/MasterTimelineTableViewCell.swift | 12 ++++++------ submodules/RSCore | 2 +- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/iOS/Master/Cell/MasterTableViewCell.swift b/iOS/Master/Cell/MasterTableViewCell.swift index 4ab775021..d81cea3fb 100644 --- a/iOS/Master/Cell/MasterTableViewCell.swift +++ b/iOS/Master/Cell/MasterTableViewCell.swift @@ -167,18 +167,10 @@ private extension MasterTableViewCell { } func layoutWith(_ layout: MasterTableViewCellLayout) { - faviconImageView.rs_setFrameIfNotEqual(layout.faviconRect) - titleView.rs_setFrameIfNotEqual(layout.titleRect) - unreadCountView.rs_setFrameIfNotEqual(layout.unreadCountRect) - disclosureButton?.rs_setFrameIfNotEqual(layout.disclosureButtonRect) + faviconImageView.setFrameIfNotEqual(layout.faviconRect) + titleView.setFrameIfNotEqual(layout.titleRect) + unreadCountView.setFrameIfNotEqual(layout.unreadCountRect) + disclosureButton?.setFrameIfNotEqual(layout.disclosureButtonRect) } } - -extension UIView { - func rs_setFrameIfNotEqual(_ rect: CGRect) { - if !self.frame.equalTo(rect) { - self.frame = rect - } - } -} diff --git a/iOS/Master/Cell/MasterTableViewSectionHeader.swift b/iOS/Master/Cell/MasterTableViewSectionHeader.swift index df91732be..beaa98398 100644 --- a/iOS/Master/Cell/MasterTableViewSectionHeader.swift +++ b/iOS/Master/Cell/MasterTableViewSectionHeader.swift @@ -91,8 +91,8 @@ private extension MasterTableViewSectionHeader { } func layoutWith(_ layout: MasterTableViewCellLayout) { - titleView.rs_setFrameIfNotEqual(layout.titleRect) - unreadCountView.rs_setFrameIfNotEqual(layout.unreadCountRect) + titleView.setFrameIfNotEqual(layout.titleRect) + unreadCountView.setFrameIfNotEqual(layout.unreadCountRect) } } diff --git a/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift b/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift index 41cc9631f..ab536d22b 100644 --- a/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift +++ b/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift @@ -59,11 +59,11 @@ class MasterTimelineTableViewCell: UITableViewCell { setFrame(for: summaryView, rect: layoutRects.summaryRect) setFrame(for: textView, rect: layoutRects.textRect) - dateView.rs_setFrameIfNotEqual(layoutRects.dateRect) - unreadIndicatorView.rs_setFrameIfNotEqual(layoutRects.unreadIndicatorRect) - feedNameView.rs_setFrameIfNotEqual(layoutRects.feedNameRect) - avatarImageView.rs_setFrameIfNotEqual(layoutRects.avatarImageRect) - starView.rs_setFrameIfNotEqual(layoutRects.starRect) + dateView.setFrameIfNotEqual(layoutRects.dateRect) + unreadIndicatorView.setFrameIfNotEqual(layoutRects.unreadIndicatorRect) + feedNameView.setFrameIfNotEqual(layoutRects.feedNameRect) + avatarImageView.setFrameIfNotEqual(layoutRects.avatarImageRect) + starView.setFrameIfNotEqual(layoutRects.starRect) } @@ -94,7 +94,7 @@ private extension MasterTimelineTableViewCell { hideView(label) } else { showView(label) - label.rs_setFrameIfNotEqual(rect) + label.setFrameIfNotEqual(rect) } } diff --git a/submodules/RSCore b/submodules/RSCore index 42de80e9f..ac59e3481 160000 --- a/submodules/RSCore +++ b/submodules/RSCore @@ -1 +1 @@ -Subproject commit 42de80e9f4114163b9af344ac4e538005611e33e +Subproject commit ac59e34818d4a0c2d3e510f0dad4adf33cf43ce7 From a4b30793a8638827e2154c54583154732d701f00 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 20 Apr 2019 10:58:16 -0500 Subject: [PATCH 08/12] Fix editing and reorder cell rendering issues. --- iOS/Master/Cell/MasterTableViewCell.swift | 4 ++-- .../Cell/MasterTableViewCellLayout.swift | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/iOS/Master/Cell/MasterTableViewCell.swift b/iOS/Master/Cell/MasterTableViewCell.swift index d81cea3fb..2ec5a9aa8 100644 --- a/iOS/Master/Cell/MasterTableViewCell.swift +++ b/iOS/Master/Cell/MasterTableViewCell.swift @@ -115,12 +115,12 @@ class MasterTableViewCell : UITableViewCell { override func willTransition(to state: UITableViewCell.StateMask) { super.willTransition(to: state) - showingEditControl = state == .showingEditControl + showingEditControl = state.contains(.showingEditControl) } override func layoutSubviews() { super.layoutSubviews() - let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indent, shouldShowDisclosure: true) + let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indent, shouldShowDisclosure: !showsReorderControl) layoutWith(layout) } diff --git a/iOS/Master/Cell/MasterTableViewCellLayout.swift b/iOS/Master/Cell/MasterTableViewCellLayout.swift index f22621742..675170f7d 100644 --- a/iOS/Master/Cell/MasterTableViewCellLayout.swift +++ b/iOS/Master/Cell/MasterTableViewCellLayout.swift @@ -11,6 +11,8 @@ import RSCore struct MasterTableViewCellLayout { + private static let indent = CGFloat(integerLiteral: 20) + private static let editingControlIndent = CGFloat(integerLiteral: 40) private static let imageSize = CGSize(width: 16, height: 16) private static let marginLeft = CGFloat(integerLiteral: 8) private static let imageMarginRight = CGFloat(integerLiteral: 8) @@ -25,14 +27,20 @@ struct MasterTableViewCellLayout { init(cellSize: CGSize, shouldShowImage: Bool, label: UILabel, unreadCountView: MasterUnreadCountView, showingEditingControl: Bool, indent: Bool, shouldShowDisclosure: Bool) { - let bounds = CGRect(x: 0.0, y: 0.0, width: floor(cellSize.width), height: floor(cellSize.height)) - + var initialIndent = MasterTableViewCellLayout.marginLeft + if indent { + initialIndent += MasterTableViewCellLayout.indent + } + if showingEditingControl { + initialIndent += MasterTableViewCellLayout.editingControlIndent + } + + let bounds = CGRect(x: initialIndent, y: 0.0, width: floor(cellSize.width - initialIndent), height: floor(cellSize.height)) + // Favicon var rFavicon = CGRect.zero if shouldShowImage { - var indentX = showingEditingControl ? MasterTableViewCellLayout.marginLeft + 40 : MasterTableViewCellLayout.marginLeft - indentX = indent ? indentX + 20 : indentX - rFavicon = CGRect(x: indentX, y: 0.0, width: MasterTableViewCellLayout.imageSize.width, height: MasterTableViewCellLayout.imageSize.height) + rFavicon = CGRect(x: bounds.origin.x, y: 0.0, width: MasterTableViewCellLayout.imageSize.width, height: MasterTableViewCellLayout.imageSize.height) rFavicon = MasterTableViewCellLayout.centerVertically(rFavicon, bounds) } self.faviconRect = rFavicon @@ -44,7 +52,7 @@ struct MasterTableViewCellLayout { if shouldShowImage { rLabel.origin.x = rFavicon.maxX + MasterTableViewCellLayout.imageMarginRight } else { - rLabel.origin.x = indent ? MasterTableViewCellLayout.marginLeft + 10 : MasterTableViewCellLayout.marginLeft + rLabel.origin.x = bounds.minX } rLabel = MasterTableViewCellLayout.centerVertically(rLabel, bounds) From f01517d1845deae4d5e830d48d51c15a9afc2148 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 20 Apr 2019 11:11:09 -0500 Subject: [PATCH 09/12] Remove indent attribute as we should have been using indentionLevel. --- iOS/Master/Cell/MasterTableViewCell.swift | 10 +--------- iOS/Master/MasterViewController.swift | 4 +++- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/iOS/Master/Cell/MasterTableViewCell.swift b/iOS/Master/Cell/MasterTableViewCell.swift index 2ec5a9aa8..b8b95acd5 100644 --- a/iOS/Master/Cell/MasterTableViewCell.swift +++ b/iOS/Master/Cell/MasterTableViewCell.swift @@ -32,14 +32,6 @@ class MasterTableViewCell : UITableViewCell { } } - var indent = false { - didSet { - if indent != oldValue { - setNeedsLayout() - } - } - } - var disclosureExpanded = false { didSet { updateDisclosureImage() @@ -120,7 +112,7 @@ class MasterTableViewCell : UITableViewCell { override func layoutSubviews() { super.layoutSubviews() - let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indent, shouldShowDisclosure: !showsReorderControl) + let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: !showsReorderControl) layoutWith(layout) } diff --git a/iOS/Master/MasterViewController.swift b/iOS/Master/MasterViewController.swift index dcd36b864..579805247 100644 --- a/iOS/Master/MasterViewController.swift +++ b/iOS/Master/MasterViewController.swift @@ -487,7 +487,9 @@ class MasterViewController: UITableViewController, UndoableCommandRunner { func configure(_ cell: MasterTableViewCell, _ node: Node) { cell.delegate = self - cell.indent = node.parent?.representedObject is Folder + if node.parent?.representedObject is Folder { + cell.indentationLevel = 1 + } cell.disclosureExpanded = expandedNodes.contains(node) cell.allowDisclosureSelection = node.canHaveChildNodes From a9ef76d8fc11a736b1997656c176ec8db025971c Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 20 Apr 2019 11:13:02 -0500 Subject: [PATCH 10/12] Tweak indent level to something less dramatic. --- iOS/Master/Cell/MasterTableViewCellLayout.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/Master/Cell/MasterTableViewCellLayout.swift b/iOS/Master/Cell/MasterTableViewCellLayout.swift index 675170f7d..e0039fd44 100644 --- a/iOS/Master/Cell/MasterTableViewCellLayout.swift +++ b/iOS/Master/Cell/MasterTableViewCellLayout.swift @@ -11,7 +11,7 @@ import RSCore struct MasterTableViewCellLayout { - private static let indent = CGFloat(integerLiteral: 20) + private static let indent = CGFloat(integerLiteral: 14) private static let editingControlIndent = CGFloat(integerLiteral: 40) private static let imageSize = CGSize(width: 16, height: 16) private static let marginLeft = CGFloat(integerLiteral: 8) From e31be75d95f29306473cc232e425f3fa1a965e7d Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 20 Apr 2019 11:25:02 -0500 Subject: [PATCH 11/12] Fixed rendering on phones with the notch by taking into consideration cell safe area insets. --- iOS/Master/Cell/MasterTableViewCell.swift | 2 +- iOS/Master/Cell/MasterTableViewCellLayout.swift | 6 +++--- iOS/Master/Cell/MasterTableViewSectionHeader.swift | 2 +- iOS/Master/MasterViewController.swift | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/iOS/Master/Cell/MasterTableViewCell.swift b/iOS/Master/Cell/MasterTableViewCell.swift index b8b95acd5..8cea92c37 100644 --- a/iOS/Master/Cell/MasterTableViewCell.swift +++ b/iOS/Master/Cell/MasterTableViewCell.swift @@ -112,7 +112,7 @@ class MasterTableViewCell : UITableViewCell { override func layoutSubviews() { super.layoutSubviews() - let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: !showsReorderControl) + let layout = MasterTableViewCellLayout(cellSize: bounds.size, insets: safeAreaInsets, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: !showsReorderControl) layoutWith(layout) } diff --git a/iOS/Master/Cell/MasterTableViewCellLayout.swift b/iOS/Master/Cell/MasterTableViewCellLayout.swift index e0039fd44..cc692740c 100644 --- a/iOS/Master/Cell/MasterTableViewCellLayout.swift +++ b/iOS/Master/Cell/MasterTableViewCellLayout.swift @@ -25,9 +25,9 @@ struct MasterTableViewCellLayout { let unreadCountRect: CGRect let disclosureButtonRect: CGRect - init(cellSize: CGSize, shouldShowImage: Bool, label: UILabel, unreadCountView: MasterUnreadCountView, showingEditingControl: Bool, indent: Bool, shouldShowDisclosure: Bool) { + init(cellSize: CGSize, insets: UIEdgeInsets, shouldShowImage: Bool, label: UILabel, unreadCountView: MasterUnreadCountView, showingEditingControl: Bool, indent: Bool, shouldShowDisclosure: Bool) { - var initialIndent = MasterTableViewCellLayout.marginLeft + var initialIndent = MasterTableViewCellLayout.marginLeft + insets.left if indent { initialIndent += MasterTableViewCellLayout.indent } @@ -35,7 +35,7 @@ struct MasterTableViewCellLayout { initialIndent += MasterTableViewCellLayout.editingControlIndent } - let bounds = CGRect(x: initialIndent, y: 0.0, width: floor(cellSize.width - initialIndent), height: floor(cellSize.height)) + let bounds = CGRect(x: initialIndent, y: 0.0, width: floor(cellSize.width - initialIndent - insets.right), height: floor(cellSize.height)) // Favicon var rFavicon = CGRect.zero diff --git a/iOS/Master/Cell/MasterTableViewSectionHeader.swift b/iOS/Master/Cell/MasterTableViewSectionHeader.swift index beaa98398..a2b468fab 100644 --- a/iOS/Master/Cell/MasterTableViewSectionHeader.swift +++ b/iOS/Master/Cell/MasterTableViewSectionHeader.swift @@ -71,7 +71,7 @@ class MasterTableViewSectionHeader: UITableViewHeaderFooterView { override func layoutSubviews() { super.layoutSubviews() - let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: false, label: titleView, unreadCountView: unreadCountView, showingEditingControl: false, indent: true, shouldShowDisclosure: false) + let layout = MasterTableViewCellLayout(cellSize: bounds.size, insets: safeAreaInsets, shouldShowImage: false, label: titleView, unreadCountView: unreadCountView, showingEditingControl: false, indent: true, shouldShowDisclosure: false) layoutWith(layout) } diff --git a/iOS/Master/MasterViewController.swift b/iOS/Master/MasterViewController.swift index 579805247..a77dc206f 100644 --- a/iOS/Master/MasterViewController.swift +++ b/iOS/Master/MasterViewController.swift @@ -489,6 +489,8 @@ class MasterViewController: UITableViewController, UndoableCommandRunner { cell.delegate = self if node.parent?.representedObject is Folder { cell.indentationLevel = 1 + } else { + cell.indentationLevel = 0 } cell.disclosureExpanded = expandedNodes.contains(node) cell.allowDisclosureSelection = node.canHaveChildNodes From 691038298192c89c8e3145c9af1c898b8a92fd74 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 20 Apr 2019 11:43:05 -0500 Subject: [PATCH 12/12] Change how section header background color is set to clear up console warning. --- iOS/Master/Cell/MasterTableViewSectionHeader.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iOS/Master/Cell/MasterTableViewSectionHeader.swift b/iOS/Master/Cell/MasterTableViewSectionHeader.swift index a2b468fab..ed3d6ae94 100644 --- a/iOS/Master/Cell/MasterTableViewSectionHeader.swift +++ b/iOS/Master/Cell/MasterTableViewSectionHeader.swift @@ -80,7 +80,9 @@ class MasterTableViewSectionHeader: UITableViewHeaderFooterView { private extension MasterTableViewSectionHeader { func commonInit() { - backgroundColor = AppAssets.tableSectionHeaderColor + let view = UIView() + view.backgroundColor = AppAssets.tableSectionHeaderColor + backgroundView = view addSubviewAtInit(unreadCountView) addSubviewAtInit(titleView) }