Remove folder icons and feed indenting. Issue #1063
This commit is contained in:
parent
9c8f5b7d65
commit
c33cd8f988
@ -48,18 +48,16 @@ struct AppAssets {
|
||||
return UIImage(systemName: "circle")!
|
||||
}()
|
||||
|
||||
static var chevronDisclosureColor: UIColor = {
|
||||
return UIColor(named: "chevronDisclosureColor")!
|
||||
static var sectionChevronDisclosureColor: UIColor = {
|
||||
return UIColor(named: "sectionChevronDisclosureColor")!
|
||||
}()
|
||||
|
||||
static var chevronDownImage: UIImage = {
|
||||
let image = UIImage(systemName: "chevron.down")!
|
||||
return image.withTintColor(AppAssets.chevronDisclosureColor, renderingMode: .alwaysOriginal)
|
||||
return UIImage(systemName: "chevron.down")!
|
||||
}()
|
||||
|
||||
static var chevronRightImage: UIImage = {
|
||||
let image = UIImage(systemName: "chevron.right")!
|
||||
return image.withTintColor(AppAssets.chevronDisclosureColor, renderingMode: .alwaysOriginal)
|
||||
return UIImage(systemName: "chevron.right")!
|
||||
}()
|
||||
|
||||
static var copyImage: UIImage = {
|
||||
|
@ -40,21 +40,7 @@ class MasterFeedTableViewCell : NNWTableViewCell {
|
||||
|
||||
var faviconImage: UIImage? {
|
||||
didSet {
|
||||
if let image = faviconImage {
|
||||
faviconImageView.image = shouldShowImage ? image : nil
|
||||
}
|
||||
else {
|
||||
faviconImageView.image = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var shouldShowImage = false {
|
||||
didSet {
|
||||
if shouldShowImage != oldValue {
|
||||
setNeedsLayout()
|
||||
}
|
||||
faviconImageView.image = shouldShowImage ? faviconImage : nil
|
||||
faviconImageView.image = faviconImage
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +87,7 @@ class MasterFeedTableViewCell : NNWTableViewCell {
|
||||
|
||||
private var unreadCountView = MasterFeedUnreadCountView(frame: CGRect.zero)
|
||||
private var showingEditControl = false
|
||||
private var disclosureButton: UIButton?
|
||||
var disclosureButton: UIButton?
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
@ -133,15 +119,13 @@ class MasterFeedTableViewCell : NNWTableViewCell {
|
||||
}
|
||||
|
||||
override func sizeThatFits(_ size: CGSize) -> CGSize {
|
||||
let shouldShowDisclosure = !(showingEditControl && showsReorderControl)
|
||||
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: shouldShowDisclosure)
|
||||
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: isDisclosureAvailable)
|
||||
return CGSize(width: bounds.width, height: layout.height)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
let shouldShowDisclosure = !(showingEditControl && showsReorderControl)
|
||||
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: shouldShowDisclosure)
|
||||
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indentationLevel == 1, shouldShowDisclosure: isDisclosureAvailable)
|
||||
layoutWith(layout)
|
||||
}
|
||||
|
||||
@ -164,14 +148,10 @@ private extension MasterFeedTableViewCell {
|
||||
}
|
||||
|
||||
func addDisclosureView() {
|
||||
|
||||
disclosureButton = NonIntrinsicButton(type: .roundedRect)
|
||||
disclosureButton!.tintColor = AppAssets.chevronDisclosureColor
|
||||
disclosureButton!.addTarget(self, action: #selector(buttonPressed(_:)), for: UIControl.Event.touchUpInside)
|
||||
|
||||
updateDisclosureImage()
|
||||
addSubviewAtInit(disclosureButton!)
|
||||
|
||||
}
|
||||
|
||||
func updateDisclosureImage() {
|
||||
|
@ -30,7 +30,7 @@ struct MasterFeedTableViewCellLayout {
|
||||
|
||||
let height: CGFloat
|
||||
|
||||
init(cellWidth: CGFloat, insets: UIEdgeInsets, shouldShowImage: Bool, 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) {
|
||||
|
||||
var initialIndent = insets.left
|
||||
if indent {
|
||||
@ -51,8 +51,8 @@ struct MasterFeedTableViewCellLayout {
|
||||
|
||||
// Favicon
|
||||
var rFavicon = CGRect.zero
|
||||
if shouldShowImage {
|
||||
let x = bounds.origin.x + MasterFeedTableViewCellLayout.disclosureButtonSize.width
|
||||
if !shouldShowDisclosure {
|
||||
let x = bounds.origin.x + ((MasterFeedTableViewCellLayout.disclosureButtonSize.width - MasterFeedTableViewCellLayout.imageSize.width) / 2)
|
||||
let y = UIFontMetrics.default.scaledValue(for: CGFloat(integerLiteral: 4))
|
||||
rFavicon = CGRect(x: x, y: y, width: MasterFeedTableViewCellLayout.imageSize.width, height: MasterFeedTableViewCellLayout.imageSize.height)
|
||||
}
|
||||
@ -77,12 +77,8 @@ struct MasterFeedTableViewCellLayout {
|
||||
let labelWidth = bounds.width - (rFavicon.width + MasterFeedTableViewCellLayout.imageMarginRight + MasterFeedTableViewCellLayout.unreadCountMarginLeft + rUnread.width + MasterFeedTableViewCellLayout.disclosureButtonSize.width + MasterFeedTableViewCellLayout.unreadCountMarginRight)
|
||||
let labelSizeInfo = MultilineUILabelSizer.size(for: label.text ?? "", font: label.font, numberOfLines: 0, width: Int(floor(labelWidth)))
|
||||
|
||||
var rLabel = CGRect(x: 0.0, y: 0.0, width: labelSizeInfo.size.width, height: labelSizeInfo.size.height)
|
||||
if shouldShowImage {
|
||||
rLabel.origin.x = rFavicon.maxX + MasterFeedTableViewCellLayout.imageMarginRight
|
||||
} else {
|
||||
rLabel.origin.x = bounds.minX + MasterFeedTableViewCellLayout.disclosureButtonSize.width
|
||||
}
|
||||
let rLabelx = bounds.minX + MasterFeedTableViewCellLayout.disclosureButtonSize.width
|
||||
var rLabel = CGRect(x: rLabelx, y: 0.0, width: labelSizeInfo.size.width, height: labelSizeInfo.size.height)
|
||||
|
||||
// Determine cell height
|
||||
var cellHeight = [rFavicon, rLabel, rUnread, rDisclosure].maxY()
|
||||
@ -93,7 +89,7 @@ struct MasterFeedTableViewCellLayout {
|
||||
// Center in Cell
|
||||
let newBounds = CGRect(x: bounds.origin.x, y: bounds.origin.y, width: bounds.width, height: cellHeight)
|
||||
|
||||
if shouldShowImage && labelSizeInfo.numberOfLinesUsed == 1 {
|
||||
if !shouldShowDisclosure && labelSizeInfo.numberOfLinesUsed == 1 {
|
||||
rFavicon = MasterFeedTableViewCellLayout.centerVertically(rFavicon, newBounds)
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ class MasterFeedTableViewSectionHeader: UITableViewHeaderFooterView {
|
||||
// cell below.
|
||||
unreadCountView.unreadCount = 888
|
||||
|
||||
let layout = MasterFeedTableViewCellLayout(cellWidth: size.width, insets: safeAreaInsets, shouldShowImage: false, label: titleView, unreadCountView: unreadCountView, showingEditingControl: false, indent: false, shouldShowDisclosure: true)
|
||||
let layout = MasterFeedTableViewCellLayout(cellWidth: size.width, insets: safeAreaInsets, label: titleView, unreadCountView: unreadCountView, showingEditingControl: false, indent: false, shouldShowDisclosure: true)
|
||||
|
||||
return CGSize(width: bounds.width, height: layout.height)
|
||||
|
||||
@ -112,7 +112,7 @@ class MasterFeedTableViewSectionHeader: UITableViewHeaderFooterView {
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, shouldShowImage: false, label: titleView, unreadCountView: unreadCountView, showingEditingControl: false, indent: false, shouldShowDisclosure: true)
|
||||
let layout = MasterFeedTableViewCellLayout(cellWidth: bounds.size.width, insets: safeAreaInsets, label: titleView, unreadCountView: unreadCountView, showingEditingControl: false, indent: false, shouldShowDisclosure: true)
|
||||
layoutWith(layout)
|
||||
}
|
||||
|
||||
@ -131,6 +131,7 @@ private extension MasterFeedTableViewSectionHeader {
|
||||
}
|
||||
|
||||
func updateDisclosureImage() {
|
||||
disclosureView.tintColor = AppAssets.sectionChevronDisclosureColor
|
||||
if disclosureExpanded {
|
||||
disclosureView.image = AppAssets.chevronDownImage
|
||||
} else {
|
||||
|
@ -606,7 +606,6 @@ private extension MasterFeedViewController {
|
||||
cell.name = nameFor(node)
|
||||
cell.unreadCount = coordinator.unreadCountFor(node)
|
||||
configureFavicon(cell, node)
|
||||
cell.shouldShowImage = node.representedObject is SmallIconProvider
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user