From 1c6c2451ecb17168e26ecd1920c4c980fbe3ccff Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 17 Apr 2019 07:48:38 -0500 Subject: [PATCH] Fixed bug that incorrectly determining the showing edit control state. --- iOS/Master/Cell/MasterTableViewCell.swift | 10 ++++++++-- iOS/Master/Cell/MasterTableViewCellLayout.swift | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/iOS/Master/Cell/MasterTableViewCell.swift b/iOS/Master/Cell/MasterTableViewCell.swift index a71cc4b44..b2bc682eb 100644 --- a/iOS/Master/Cell/MasterTableViewCell.swift +++ b/iOS/Master/Cell/MasterTableViewCell.swift @@ -84,18 +84,24 @@ class MasterTableViewCell : UITableViewCell { }() private let unreadCountView = MasterUnreadCountView(frame: CGRect.zero) + private var showingEditControl = false required init?(coder: NSCoder) { super.init(coder: coder) commonInit() } + override func willTransition(to state: UITableViewCell.StateMask) { + super.willTransition(to: state) + showingEditControl = state == .showingEditControl + } + override func layoutSubviews() { super.layoutSubviews() - let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, isEditing: isEditing) + let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl) layoutWith(layout) } - + } private extension MasterTableViewCell { diff --git a/iOS/Master/Cell/MasterTableViewCellLayout.swift b/iOS/Master/Cell/MasterTableViewCellLayout.swift index b2cf543a2..908283847 100644 --- a/iOS/Master/Cell/MasterTableViewCellLayout.swift +++ b/iOS/Master/Cell/MasterTableViewCellLayout.swift @@ -21,13 +21,13 @@ struct MasterTableViewCellLayout { let titleRect: CGRect let unreadCountRect: CGRect - init(cellSize: CGSize, shouldShowImage: Bool, label: UILabel, unreadCountView: MasterUnreadCountView, isEditing: Bool) { + init(cellSize: CGSize, shouldShowImage: Bool, label: UILabel, unreadCountView: MasterUnreadCountView, showingEditingControl: Bool) { let bounds = CGRect(x: 0.0, y: 0.0, width: floor(cellSize.width), height: floor(cellSize.height)) var rFavicon = CGRect.zero if shouldShowImage { - let indent = isEditing ? MasterTableViewCellLayout.imageMarginLeft + 40 : MasterTableViewCellLayout.imageMarginLeft + let indent = showingEditingControl ? MasterTableViewCellLayout.imageMarginLeft + 40 : MasterTableViewCellLayout.imageMarginLeft rFavicon = CGRect(x: indent, y: 0.0, width: MasterTableViewCellLayout.imageSize.width, height: MasterTableViewCellLayout.imageSize.height) rFavicon = MasterTableViewCellLayout.centerVertically(rFavicon, bounds) }