From a4b30793a8638827e2154c54583154732d701f00 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 20 Apr 2019 10:58:16 -0500 Subject: [PATCH] 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)