Remove layout caching that was causing seemly random layout issues. Issue #714

This commit is contained in:
Maurice Parker 2019-05-31 16:59:02 -05:00
parent 3593d1c5d8
commit e348a1f9ed
1 changed files with 14 additions and 21 deletions

View File

@ -17,8 +17,6 @@ class MasterTimelineTableViewCell: UITableViewCell {
private let dateView = MasterTimelineTableViewCell.singleLineUILabel()
private let feedNameView = MasterTimelineTableViewCell.singleLineUILabel()
private var layout: MasterTimelineCellLayout?
private lazy var avatarImageView: UIImageView = {
let imageView = NonIntrinsicImageView(image: AppAssets.feedImage)
imageView.contentMode = .scaleAspectFit
@ -47,29 +45,25 @@ class MasterTimelineTableViewCell: UITableViewCell {
}
override func sizeThatFits(_ size: CGSize) -> CGSize {
if layout == nil {
layout = updatedLayout()
}
return CGSize(width: bounds.width, height: layout!.height)
let layout = updatedLayout(width: size.width)
return CGSize(width: size.width, height: layout.height)
}
override func layoutSubviews() {
super.layoutSubviews()
if layout == nil {
layout = updatedLayout()
}
let layout = updatedLayout(width: bounds.width)
unreadIndicatorView.setFrameIfNotEqual(layout!.unreadIndicatorRect)
starView.setFrameIfNotEqual(layout!.starRect)
avatarImageView.setFrameIfNotEqual(layout!.avatarImageRect)
setFrame(for: titleView, rect: layout!.titleRect)
setFrame(for: summaryView, rect: layout!.summaryRect)
feedNameView.setFrameIfNotEqual(layout!.feedNameRect)
dateView.setFrameIfNotEqual(layout!.dateRect)
unreadIndicatorView.setFrameIfNotEqual(layout.unreadIndicatorRect)
starView.setFrameIfNotEqual(layout.starRect)
avatarImageView.setFrameIfNotEqual(layout.avatarImageRect)
setFrame(for: titleView, rect: layout.titleRect)
setFrame(for: summaryView, rect: layout.summaryRect)
feedNameView.setFrameIfNotEqual(layout.feedNameRect)
dateView.setFrameIfNotEqual(layout.dateRect)
separatorInset = layout!.separatorInsets
separatorInset = layout.separatorInsets
}
@ -137,11 +131,11 @@ private extension MasterTimelineTableViewCell {
accessoryView = UIImageView(image: AppAssets.chevronRightImage)
}
func updatedLayout() -> MasterTimelineCellLayout {
func updatedLayout(width: CGFloat) -> MasterTimelineCellLayout {
if UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory {
return MasterTimelineAccessibilityCellLayout(width: bounds.width, insets: safeAreaInsets, cellData: cellData)
return MasterTimelineAccessibilityCellLayout(width: width, insets: safeAreaInsets, cellData: cellData)
} else {
return MasterTimelineDefaultCellLayout(width: bounds.width, insets: safeAreaInsets, cellData: cellData)
return MasterTimelineDefaultCellLayout(width: width, insets: safeAreaInsets, cellData: cellData)
}
}
@ -234,7 +228,6 @@ private extension MasterTimelineTableViewCell {
}
func updateSubviews() {
layout = nil
updateTitleView()
updateSummaryView()
updateDateView()