diff --git a/iOS/IconView.swift b/iOS/IconView.swift index 90c61b150..db3f5e8c9 100644 --- a/iOS/IconView.swift +++ b/iOS/IconView.swift @@ -77,7 +77,7 @@ final class IconView: UIView { private extension IconView { func commonInit() { - layer.cornerRadius = MasterTimelineDefaultCellLayout.iconCornerRadius + layer.cornerRadius = TimelineDefaultCellLayout.iconCornerRadius clipsToBounds = true addSubview(imageView) } diff --git a/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift b/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift index 277518725..12043cc8c 100644 --- a/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift +++ b/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift @@ -157,24 +157,24 @@ private extension MasterTimelineTableViewCell { if UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory { return TimelineAccessibilityCellLayout(width: width, insets: safeAreaInsets, cellData: cellData) } else { - return MasterTimelineDefaultCellLayout(width: width, insets: safeAreaInsets, cellData: cellData) + return TimelineDefaultCellLayout(width: width, insets: safeAreaInsets, cellData: cellData) } } func updateTitleView() { - titleView.font = MasterTimelineDefaultCellLayout.titleFont + titleView.font = TimelineDefaultCellLayout.titleFont titleView.textColor = labelColor updateTextFieldAttributedText(titleView, cellData?.attributedTitle) } func updateSummaryView() { - summaryView.font = MasterTimelineDefaultCellLayout.summaryFont + summaryView.font = TimelineDefaultCellLayout.summaryFont summaryView.textColor = labelColor updateTextFieldText(summaryView, cellData?.summary) } func updateDateView() { - dateView.font = MasterTimelineDefaultCellLayout.dateFont + dateView.font = TimelineDefaultCellLayout.dateFont dateView.textColor = secondaryLabelColor updateTextFieldText(dateView, cellData.dateString) } @@ -204,12 +204,12 @@ private extension MasterTimelineTableViewCell { switch cellData.showFeedName { case .feed: showView(feedNameView) - feedNameView.font = MasterTimelineDefaultCellLayout.feedNameFont + feedNameView.font = TimelineDefaultCellLayout.feedNameFont feedNameView.textColor = secondaryLabelColor updateTextFieldText(feedNameView, cellData.feedName) case .byline: showView(feedNameView) - feedNameView.font = MasterTimelineDefaultCellLayout.feedNameFont + feedNameView.font = TimelineDefaultCellLayout.feedNameFont feedNameView.textColor = secondaryLabelColor updateTextFieldText(feedNameView, cellData.byline) case .none: diff --git a/iOS/MasterTimeline/Cell/TimelineAccessibilityCellLayout.swift b/iOS/MasterTimeline/Cell/TimelineAccessibilityCellLayout.swift index 387428338..923ec2311 100644 --- a/iOS/MasterTimeline/Cell/TimelineAccessibilityCellLayout.swift +++ b/iOS/MasterTimeline/Cell/TimelineAccessibilityCellLayout.swift @@ -23,15 +23,15 @@ struct TimelineAccessibilityCellLayout: TimelineCellLayout { init(width: CGFloat, insets: UIEdgeInsets, cellData: MasterTimelineCellData) { var currentPoint = CGPoint.zero - currentPoint.x = MasterTimelineDefaultCellLayout.cellPadding.left + insets.left + MasterTimelineDefaultCellLayout.unreadCircleMarginLeft - currentPoint.y = MasterTimelineDefaultCellLayout.cellPadding.top + currentPoint.x = TimelineDefaultCellLayout.cellPadding.left + insets.left + TimelineDefaultCellLayout.unreadCircleMarginLeft + currentPoint.y = TimelineDefaultCellLayout.cellPadding.top // Unread Indicator and Star self.unreadIndicatorRect = TimelineAccessibilityCellLayout.rectForUnreadIndicator(currentPoint) self.starRect = TimelineAccessibilityCellLayout.rectForStar(currentPoint) // Start the point at the beginning position of the main block - currentPoint.x += MasterTimelineDefaultCellLayout.unreadCircleDimension + MasterTimelineDefaultCellLayout.unreadCircleMarginRight + currentPoint.x += TimelineDefaultCellLayout.unreadCircleDimension + TimelineDefaultCellLayout.unreadCircleMarginRight // Icon Image if cellData.showIcon { @@ -41,7 +41,7 @@ struct TimelineAccessibilityCellLayout: TimelineCellLayout { self.iconImageRect = CGRect.zero } - let textAreaWidth = width - (currentPoint.x + MasterTimelineDefaultCellLayout.cellPadding.right + insets.right) + let textAreaWidth = width - (currentPoint.x + TimelineDefaultCellLayout.cellPadding.right + insets.right) // Title Text Block let (titleRect, numberOfLinesForTitle) = TimelineAccessibilityCellLayout.rectForTitle(cellData, currentPoint, textAreaWidth) @@ -49,7 +49,7 @@ struct TimelineAccessibilityCellLayout: TimelineCellLayout { // Summary Text Block if self.titleRect != CGRect.zero { - currentPoint.y = self.titleRect.maxY + MasterTimelineDefaultCellLayout.titleBottomMargin + currentPoint.y = self.titleRect.maxY + TimelineDefaultCellLayout.titleBottomMargin } self.summaryRect = TimelineAccessibilityCellLayout.rectForSummary(cellData, currentPoint, textAreaWidth, numberOfLinesForTitle) @@ -65,7 +65,7 @@ struct TimelineAccessibilityCellLayout: TimelineCellLayout { // Feed Name and Pub Date self.dateRect = TimelineAccessibilityCellLayout.rectForDate(cellData, currentPoint, textAreaWidth) - self.height = self.dateRect.maxY + MasterTimelineDefaultCellLayout.cellPadding.bottom + self.height = self.dateRect.maxY + TimelineDefaultCellLayout.cellPadding.bottom } @@ -79,7 +79,7 @@ private extension TimelineAccessibilityCellLayout { var r = CGRect.zero - let size = SingleLineUILabelSizer.size(for: cellData.dateString, font: MasterTimelineDefaultCellLayout.dateFont) + let size = SingleLineUILabelSizer.size(for: cellData.dateString, font: TimelineDefaultCellLayout.dateFont) r.size = size r.origin = point diff --git a/iOS/MasterTimeline/Cell/TimelineCellLayout.swift b/iOS/MasterTimeline/Cell/TimelineCellLayout.swift index 38718757e..d92818d43 100644 --- a/iOS/MasterTimeline/Cell/TimelineCellLayout.swift +++ b/iOS/MasterTimeline/Cell/TimelineCellLayout.swift @@ -25,7 +25,7 @@ extension TimelineCellLayout { static func rectForUnreadIndicator(_ point: CGPoint) -> CGRect { var r = CGRect.zero - r.size = CGSize(width: MasterTimelineDefaultCellLayout.unreadCircleDimension, height: MasterTimelineDefaultCellLayout.unreadCircleDimension) + r.size = CGSize(width: TimelineDefaultCellLayout.unreadCircleDimension, height: TimelineDefaultCellLayout.unreadCircleDimension) r.origin.x = point.x r.origin.y = point.y + 5 return r @@ -34,9 +34,9 @@ extension TimelineCellLayout { static func rectForStar(_ point: CGPoint) -> CGRect { var r = CGRect.zero - r.size.width = MasterTimelineDefaultCellLayout.starDimension - r.size.height = MasterTimelineDefaultCellLayout.starDimension - r.origin.x = floor(point.x - ((MasterTimelineDefaultCellLayout.starDimension - MasterTimelineDefaultCellLayout.unreadCircleDimension) / 2.0)) + r.size.width = TimelineDefaultCellLayout.starDimension + r.size.height = TimelineDefaultCellLayout.starDimension + r.origin.x = floor(point.x - ((TimelineDefaultCellLayout.starDimension - TimelineDefaultCellLayout.unreadCircleDimension) / 2.0)) r.origin.y = point.y + 3 return r } @@ -58,7 +58,7 @@ extension TimelineCellLayout { r.origin = point - let sizeInfo = MultilineUILabelSizer.size(for: cellData.title, font: MasterTimelineDefaultCellLayout.titleFont, numberOfLines: cellData.numberOfLines, width: Int(textAreaWidth)) + let sizeInfo = MultilineUILabelSizer.size(for: cellData.title, font: TimelineDefaultCellLayout.titleFont, numberOfLines: cellData.numberOfLines, width: Int(textAreaWidth)) r.size.width = textAreaWidth r.size.height = sizeInfo.size.height @@ -81,7 +81,7 @@ extension TimelineCellLayout { r.origin = point - let sizeInfo = MultilineUILabelSizer.size(for: cellData.summary, font: MasterTimelineDefaultCellLayout.summaryFont, numberOfLines: linesLeft, width: Int(textAreaWidth)) + let sizeInfo = MultilineUILabelSizer.size(for: cellData.summary, font: TimelineDefaultCellLayout.summaryFont, numberOfLines: linesLeft, width: Int(textAreaWidth)) r.size.width = textAreaWidth r.size.height = sizeInfo.size.height @@ -99,7 +99,7 @@ extension TimelineCellLayout { r.origin = point let feedName = cellData.showFeedName == .feed ? cellData.feedName : cellData.byline - let size = SingleLineUILabelSizer.size(for: feedName, font: MasterTimelineDefaultCellLayout.feedNameFont) + let size = SingleLineUILabelSizer.size(for: feedName, font: TimelineDefaultCellLayout.feedNameFont) r.size = size if r.size.width > textAreaWidth { diff --git a/iOS/MasterTimeline/Cell/MasterTimelineDefaultCellLayout.swift b/iOS/MasterTimeline/Cell/TimelineDefaultCellLayout.swift similarity index 53% rename from iOS/MasterTimeline/Cell/MasterTimelineDefaultCellLayout.swift rename to iOS/MasterTimeline/Cell/TimelineDefaultCellLayout.swift index 9367d6caa..4e80c5545 100644 --- a/iOS/MasterTimeline/Cell/MasterTimelineDefaultCellLayout.swift +++ b/iOS/MasterTimeline/Cell/TimelineDefaultCellLayout.swift @@ -1,5 +1,5 @@ // -// MasterTimelineDefaultCellLayout.swift +// TimelineDefaultCellLayout.swift // NetNewsWire // // Created by Brent Simmons on 2/6/16. @@ -9,17 +9,17 @@ import UIKit import RSCore -struct MasterTimelineDefaultCellLayout: TimelineCellLayout { +struct TimelineDefaultCellLayout: TimelineCellLayout { static let cellPadding = UIEdgeInsets(top: 12, left: 8, bottom: 12, right: 20) static let unreadCircleMarginLeft = CGFloat(integerLiteral: 0) static let unreadCircleDimension = CGFloat(integerLiteral: 12) - static let unreadCircleSize = CGSize(width: MasterTimelineDefaultCellLayout.unreadCircleDimension, height: MasterTimelineDefaultCellLayout.unreadCircleDimension) + static let unreadCircleSize = CGSize(width: TimelineDefaultCellLayout.unreadCircleDimension, height: TimelineDefaultCellLayout.unreadCircleDimension) static let unreadCircleMarginRight = CGFloat(integerLiteral: 8) static let starDimension = CGFloat(integerLiteral: 16) - static let starSize = CGSize(width: MasterTimelineDefaultCellLayout.starDimension, height: MasterTimelineDefaultCellLayout.starDimension) + static let starSize = CGSize(width: TimelineDefaultCellLayout.starDimension, height: TimelineDefaultCellLayout.starDimension) static let iconMarginRight = CGFloat(integerLiteral: 8) static let iconCornerRadius = CGFloat(integerLiteral: 4) @@ -55,52 +55,52 @@ struct MasterTimelineDefaultCellLayout: TimelineCellLayout { init(width: CGFloat, insets: UIEdgeInsets, cellData: MasterTimelineCellData) { var currentPoint = CGPoint.zero - currentPoint.x = MasterTimelineDefaultCellLayout.cellPadding.left + insets.left + MasterTimelineDefaultCellLayout.unreadCircleMarginLeft - currentPoint.y = MasterTimelineDefaultCellLayout.cellPadding.top + currentPoint.x = TimelineDefaultCellLayout.cellPadding.left + insets.left + TimelineDefaultCellLayout.unreadCircleMarginLeft + currentPoint.y = TimelineDefaultCellLayout.cellPadding.top // Unread Indicator and Star - self.unreadIndicatorRect = MasterTimelineDefaultCellLayout.rectForUnreadIndicator(currentPoint) - self.starRect = MasterTimelineDefaultCellLayout.rectForStar(currentPoint) + self.unreadIndicatorRect = TimelineDefaultCellLayout.rectForUnreadIndicator(currentPoint) + self.starRect = TimelineDefaultCellLayout.rectForStar(currentPoint) // Start the point at the beginning position of the main block - currentPoint.x += MasterTimelineDefaultCellLayout.unreadCircleDimension + MasterTimelineDefaultCellLayout.unreadCircleMarginRight + currentPoint.x += TimelineDefaultCellLayout.unreadCircleDimension + TimelineDefaultCellLayout.unreadCircleMarginRight // Icon Image if cellData.showIcon { - self.iconImageRect = MasterTimelineDefaultCellLayout.rectForIconView(currentPoint, iconSize: cellData.iconSize) - currentPoint.x = self.iconImageRect.maxX + MasterTimelineDefaultCellLayout.iconMarginRight + self.iconImageRect = TimelineDefaultCellLayout.rectForIconView(currentPoint, iconSize: cellData.iconSize) + currentPoint.x = self.iconImageRect.maxX + TimelineDefaultCellLayout.iconMarginRight } else { self.iconImageRect = CGRect.zero } - let textAreaWidth = width - (currentPoint.x + MasterTimelineDefaultCellLayout.cellPadding.right + insets.right) + let textAreaWidth = width - (currentPoint.x + TimelineDefaultCellLayout.cellPadding.right + insets.right) // Title Text Block - let (titleRect, numberOfLinesForTitle) = MasterTimelineDefaultCellLayout.rectForTitle(cellData, currentPoint, textAreaWidth) + let (titleRect, numberOfLinesForTitle) = TimelineDefaultCellLayout.rectForTitle(cellData, currentPoint, textAreaWidth) self.titleRect = titleRect // Summary Text Block if self.titleRect != CGRect.zero { - currentPoint.y = self.titleRect.maxY + MasterTimelineDefaultCellLayout.titleBottomMargin + currentPoint.y = self.titleRect.maxY + TimelineDefaultCellLayout.titleBottomMargin } - self.summaryRect = MasterTimelineDefaultCellLayout.rectForSummary(cellData, currentPoint, textAreaWidth, numberOfLinesForTitle) + self.summaryRect = TimelineDefaultCellLayout.rectForSummary(cellData, currentPoint, textAreaWidth, numberOfLinesForTitle) var y = [self.titleRect, self.summaryRect].maxY() if y == 0 { y = iconImageRect.origin.y + iconImageRect.height // Necessary calculation of either feed name or date since we are working with dynamic font-sizes - let tmp = MasterTimelineDefaultCellLayout.rectForDate(cellData, currentPoint, textAreaWidth) + let tmp = TimelineDefaultCellLayout.rectForDate(cellData, currentPoint, textAreaWidth) y -= tmp.height } currentPoint.y = y // Feed Name and Pub Date - self.dateRect = MasterTimelineDefaultCellLayout.rectForDate(cellData, currentPoint, textAreaWidth) + self.dateRect = TimelineDefaultCellLayout.rectForDate(cellData, currentPoint, textAreaWidth) - let feedNameWidth = textAreaWidth - (MasterTimelineDefaultCellLayout.feedRightMargin + self.dateRect.size.width) - self.feedNameRect = MasterTimelineDefaultCellLayout.rectForFeedName(cellData, currentPoint, feedNameWidth) + let feedNameWidth = textAreaWidth - (TimelineDefaultCellLayout.feedRightMargin + self.dateRect.size.width) + self.feedNameRect = TimelineDefaultCellLayout.rectForFeedName(cellData, currentPoint, feedNameWidth) - self.height = [self.iconImageRect, self.feedNameRect].maxY() + MasterTimelineDefaultCellLayout.cellPadding.bottom + self.height = [self.iconImageRect, self.feedNameRect].maxY() + TimelineDefaultCellLayout.cellPadding.bottom } @@ -108,13 +108,13 @@ struct MasterTimelineDefaultCellLayout: TimelineCellLayout { // MARK: - Calculate Rects -extension MasterTimelineDefaultCellLayout { +extension TimelineDefaultCellLayout { static func rectForDate(_ cellData: MasterTimelineCellData, _ point: CGPoint, _ textAreaWidth: CGFloat) -> CGRect { var r = CGRect.zero - let size = SingleLineUILabelSizer.size(for: cellData.dateString, font: MasterTimelineDefaultCellLayout.dateFont) + let size = SingleLineUILabelSizer.size(for: cellData.dateString, font: TimelineDefaultCellLayout.dateFont) r.size = size r.origin.x = (point.x + textAreaWidth) - size.width r.origin.y = point.y diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index ad099afdf..a27da6d3c 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -552,7 +552,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner let layout = TimelineAccessibilityCellLayout(width: tableView.bounds.width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) tableView.estimatedRowHeight = layout.height } else { - let layout = MasterTimelineDefaultCellLayout(width: tableView.bounds.width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) + let layout = TimelineDefaultCellLayout(width: tableView.bounds.width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) tableView.estimatedRowHeight = layout.height } diff --git a/iOS/Settings/TimelinePreviewTableViewController.swift b/iOS/Settings/TimelinePreviewTableViewController.swift index 4422abbfb..7ac3152b0 100644 --- a/iOS/Settings/TimelinePreviewTableViewController.swift +++ b/iOS/Settings/TimelinePreviewTableViewController.swift @@ -26,7 +26,7 @@ class TimelinePreviewTableViewController: UIViewController, UITableViewDelegate, let layout = TimelineAccessibilityCellLayout(width: width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) return layout.height } else { - let layout = MasterTimelineDefaultCellLayout(width: width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) + let layout = TimelineDefaultCellLayout(width: width, insets: tableView.safeAreaInsets, cellData: prototypeCellData) return layout.height } }