Align separator start with the text on the timeline

This commit is contained in:
Maurice Parker 2019-04-28 16:08:02 -05:00
parent dcb65f6454
commit 2724dbf4f2
2 changed files with 18 additions and 12 deletions

View File

@ -53,8 +53,9 @@ struct MasterTimelineCellLayout {
let starRect: CGRect
let avatarImageRect: CGRect
let paddingBottom: CGFloat
let separatorInsets: UIEdgeInsets
init(width: CGFloat, height: CGFloat, feedNameRect: CGRect, dateRect: CGRect, titleRect: CGRect, numberOfLinesForTitle: Int, summaryRect: CGRect, textRect: CGRect, unreadIndicatorRect: CGRect, starRect: CGRect, avatarImageRect: CGRect, paddingBottom: CGFloat) {
init(width: CGFloat, height: CGFloat, feedNameRect: CGRect, dateRect: CGRect, titleRect: CGRect, numberOfLinesForTitle: Int, summaryRect: CGRect, textRect: CGRect, unreadIndicatorRect: CGRect, starRect: CGRect, avatarImageRect: CGRect, paddingBottom: CGFloat, separatorInsets: UIEdgeInsets) {
self.width = width - MasterTimelineCellLayout.chevronWidth
self.feedNameRect = feedNameRect
@ -67,6 +68,7 @@ struct MasterTimelineCellLayout {
self.starRect = starRect
self.avatarImageRect = avatarImageRect
self.paddingBottom = paddingBottom
self.separatorInsets = separatorInsets
if height > 0.1 {
self.height = height
@ -108,7 +110,9 @@ struct MasterTimelineCellLayout {
let paddingBottom = MasterTimelineCellLayout.cellPadding.bottom
self.init(width: width, height: height, feedNameRect: feedNameRect, dateRect: dateRect, titleRect: titleRect, numberOfLinesForTitle: numberOfLinesForTitle, summaryRect: summaryRect, textRect: textRect, unreadIndicatorRect: unreadIndicatorRect, starRect: starRect, avatarImageRect: avatarImageRect, paddingBottom: paddingBottom)
let separatorInsets = UIEdgeInsets(top: 0, left: unreadIndicatorRect.maxX + MasterTimelineCellLayout.unreadCircleMarginRight, bottom: 0, right: 0)
self.init(width: width, height: height, feedNameRect: feedNameRect, dateRect: dateRect, titleRect: titleRect, numberOfLinesForTitle: numberOfLinesForTitle, summaryRect: summaryRect, textRect: textRect, unreadIndicatorRect: unreadIndicatorRect, starRect: starRect, avatarImageRect: avatarImageRect, paddingBottom: paddingBottom, separatorInsets: separatorInsets)
}

View File

@ -51,17 +51,19 @@ class MasterTimelineTableViewCell: UITableViewCell {
super.layoutSubviews()
let layoutRects = updatedLayoutRects()
let layout = updatedLayout()
setFrame(for: titleView, rect: layoutRects.titleRect)
setFrame(for: summaryView, rect: layoutRects.summaryRect)
setFrame(for: textView, rect: layoutRects.textRect)
setFrame(for: titleView, rect: layout.titleRect)
setFrame(for: summaryView, rect: layout.summaryRect)
setFrame(for: textView, rect: layout.textRect)
dateView.setFrameIfNotEqual(layoutRects.dateRect)
unreadIndicatorView.setFrameIfNotEqual(layoutRects.unreadIndicatorRect)
feedNameView.setFrameIfNotEqual(layoutRects.feedNameRect)
avatarImageView.setFrameIfNotEqual(layoutRects.avatarImageRect)
starView.setFrameIfNotEqual(layoutRects.starRect)
dateView.setFrameIfNotEqual(layout.dateRect)
unreadIndicatorView.setFrameIfNotEqual(layout.unreadIndicatorRect)
feedNameView.setFrameIfNotEqual(layout.feedNameRect)
avatarImageView.setFrameIfNotEqual(layout.avatarImageRect)
starView.setFrameIfNotEqual(layout.starRect)
separatorInset = layout.separatorInsets
}
@ -128,7 +130,7 @@ private extension MasterTimelineTableViewCell {
accessoryView = UIImageView(image: AppAssets.chevronRightImage)
}
func updatedLayoutRects() -> MasterTimelineCellLayout {
func updatedLayout() -> MasterTimelineCellLayout {
return MasterTimelineCellLayout(width: bounds.width, height: bounds.height, cellData: cellData, hasAvatar: avatarImageView.image != nil)
}