Refreshes Feeds screen

This commit is contained in:
Stuart Breckenridge
2022-01-23 21:01:55 +08:00
parent 98cdb86e66
commit f66146e9bc
3 changed files with 40 additions and 11 deletions

View File

@@ -45,6 +45,14 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
}
}
var itemIsInFolder = false {
didSet {
if itemIsInFolder != oldValue {
setNeedsLayout()
}
}
}
var isSeparatorShown = true {
didSet {
if isSeparatorShown != oldValue {
@@ -88,7 +96,7 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
label.allowsDefaultTighteningForTruncation = false
label.adjustsFontForContentSizeCategory = true
label.lineBreakMode = .byTruncatingTail
label.font = .preferredFont(forTextStyle: .body).bold()
label.font = .preferredFont(forTextStyle: .body)
return label
}()
@@ -136,14 +144,19 @@ class MasterFeedTableViewCell : VibrantTableViewCell {
}
override func sizeThatFits(_ size: CGSize) -> CGSize {
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, label: titleView, unreadCountView: unreadCountView, showingEditingControl: isShowingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: isDisclosureAvailable)
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, label: titleView, unreadCountView: unreadCountView, showingEditingControl: isShowingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: isDisclosureAvailable, itemIsInFolder: itemIsInFolder)
return CGSize(width: bounds.width, height: layout.height)
}
override func layoutSubviews() {
super.layoutSubviews()
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, label: titleView, unreadCountView: unreadCountView, showingEditingControl: isShowingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: isDisclosureAvailable)
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, label: titleView, unreadCountView: unreadCountView, showingEditingControl: isShowingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: isDisclosureAvailable, itemIsInFolder: itemIsInFolder)
layoutWith(layout)
if isDisclosureAvailable {
titleView.font = .preferredFont(forTextStyle: .body).bold()
} else {
titleView.font = .preferredFont(forTextStyle: .body)
}
}
@objc func buttonPressed(_ sender: UIButton) {

View File

@@ -11,13 +11,13 @@ import RSCore
struct MasterFeedTableViewCellLayout {
private static let indentWidth = CGFloat(integerLiteral: 42)
private static let indentWidth = CGFloat(integerLiteral: 15)
private static let editingControlIndent = CGFloat(integerLiteral: 40)
private static let imageSize = CGSize(width: 24, height: 24)
private static let imageMarginRight = CGFloat(integerLiteral: 11)
private static let labelMarginRight = CGFloat(integerLiteral: 8)
private static let unreadCountMarginRight = CGFloat(integerLiteral: 16)
private static let disclosureButtonSize = CGSize(width: 44, height: 44)
private static let disclosureButtonSize = CGSize(width: 55, height: 44)
private static let verticalPadding = CGFloat(integerLiteral: 11)
private static let minRowHeight = CGFloat(integerLiteral: 44)
@@ -32,7 +32,7 @@ struct MasterFeedTableViewCellLayout {
let height: CGFloat
init(cellWidth: CGFloat, insets: UIEdgeInsets, label: UILabel, unreadCountView: MasterFeedUnreadCountView, showingEditingControl: Bool, indent: Bool, shouldShowDisclosure: Bool) {
init(cellWidth: CGFloat, insets: UIEdgeInsets, label: UILabel, unreadCountView: MasterFeedUnreadCountView, showingEditingControl: Bool, indent: Bool, shouldShowDisclosure: Bool, itemIsInFolder: Bool) {
var initialIndent = insets.left
if indent {
@@ -54,7 +54,12 @@ struct MasterFeedTableViewCellLayout {
let y = UIFontMetrics.default.scaledValue(for: MasterFeedTableViewCellLayout.verticalPadding) +
label.font.lineHeight / 2.0 -
MasterFeedTableViewCellLayout.imageSize.height / 2.0
rFavicon = CGRect(x: x, y: y, width: MasterFeedTableViewCellLayout.imageSize.width, height: MasterFeedTableViewCellLayout.imageSize.height)
if itemIsInFolder {
rFavicon = CGRect(x: x + MasterFeedTableViewCellLayout.disclosureButtonSize.width - (MasterFeedTableViewCellLayout.imageSize.width / 2), y: y, width: MasterFeedTableViewCellLayout.imageSize.width, height: MasterFeedTableViewCellLayout.imageSize.height)
} else {
rFavicon = CGRect(x: x, y: y, width: MasterFeedTableViewCellLayout.imageSize.width, height: MasterFeedTableViewCellLayout.imageSize.height)
}
}
// Unread Count
@@ -68,9 +73,9 @@ struct MasterFeedTableViewCellLayout {
}
// Title
var rLabelx = insets.left + MasterFeedTableViewCellLayout.disclosureButtonSize.width
if !shouldShowDisclosure {
rLabelx = rLabelx + MasterFeedTableViewCellLayout.imageSize.width + MasterFeedTableViewCellLayout.imageMarginRight
var rLabelx = MasterFeedTableViewCellLayout.disclosureButtonSize.width
if itemIsInFolder {
rLabelx += MasterFeedTableViewCellLayout.disclosureButtonSize.width - (rFavicon.width / 2)
}
let rLabely = UIFontMetrics.default.scaledValue(for: MasterFeedTableViewCellLayout.verticalPadding)
@@ -127,6 +132,7 @@ struct MasterFeedTableViewCellLayout {
let separatorInset = MasterFeedTableViewCellLayout.disclosureButtonSize.width
separatorRect = CGRect(x: separatorInset, y: cellHeight - 0.5, width: cellWidth - separatorInset, height: 0.5)
// Assign the properties
self.height = cellHeight
self.faviconRect = rFavicon

View File

@@ -739,7 +739,7 @@ private extension MasterFeedViewController {
let unreadCountView = MasterFeedUnreadCountView()
unreadCountView.unreadCount = 10
let layout = MasterFeedTableViewCellLayout(cellWidth: tableView.bounds.size.width, insets: tableView.safeAreaInsets, label: titleLabel, unreadCountView: unreadCountView, showingEditingControl: false, indent: false, shouldShowDisclosure: false)
let layout = MasterFeedTableViewCellLayout(cellWidth: tableView.bounds.size.width, insets: tableView.safeAreaInsets, label: titleLabel, unreadCountView: unreadCountView, showingEditingControl: false, indent: false, shouldShowDisclosure: false, itemIsInFolder: false)
tableView.estimatedRowHeight = layout.height
}
@@ -763,6 +763,16 @@ private extension MasterFeedViewController {
if let feed = node.representedObject as? Feed {
cell.name = feed.nameForDisplay
cell.unreadCount = feed.unreadCount
cell.itemIsInFolder = false
if let account = feed.account, let folders = account.folders {
for folder in folders {
if folder.objectIsChild(node.representedObject) {
cell.itemIsInFolder = true
break
}
}
}
}
configureIcon(cell, indexPath)