mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-02 18:32:55 +00:00
💄 Add `MainFeedCollectionViewController` 💄 Add and hook up UICollectionView in Storyboard 🚧 Collection view loads temp cells 🚧 UICollectionView - Adds capsule shape for iPad selection - Add filter button, newItem button, settings button - Configures the collection view based on platform - implementsDidSelectItem at - Clears cell background on iPad - Adds cell textColor for iPad - Storyboard changes 🚧 Adds unread count and favicon support 🚧 Smartfeed icons now display 🚧 iPhone cells are consistent in light/dark mode 💄 Sidebar modernised Known bug: Sidebar text doesn’t adapt to dark/light mode changes on iPad 💄 Modern Sidebars Fixes some accessibilty issues and adds swipe actions. 🩹 Become firstResponder 🩹 Workaround #4691 💡 Remove print statement 💄 Fixes to storyboard - adjusts constraints on timeline header view - launch screens now adopt look of liquid glass Restore coordinator behaviour ⚡️ Tweaks to MainFeedCollectionViewController - On iPhone, returning to the feeds view deselect the current feed with an animation. - On iPhone, prefers large titles defaults to `false` - Capsule background with smaller corner radius for iPhone added for selected status. 🩹 Fixes folder height 💄 Fix unread count vertical alignment 💄 Restores header & use UICellConfigurationState 💄 Sidebar tweaks 💄 Folders now highlight on as drop target 💄 Sidebar fixes - Moves more code to cell configuation state - Allows sidebar to move to larger sizes 🩹 Fixes #4694 folder expansion using keyboard 💄 Adds new cell types for the Timeline ♻️ Remove dead code and re-orders to viewWillApp 🩹 Reordering of code from viewWA to viewDA 💄 Removes unused code, tweaks layout 💄 Multiple tweaks to sidebar and timeline 💄 Add missing constraint ♿️ Puts timeline metadata in a stackview 🎨 Adds stackview function 💄 🚑️ Moves to modern UISliders Timeline customiser now uses modern UISliders as they have tickmark functionality. `TickMarkSlider` marked as deprecated. 💄 Make All Unread cell icon tint correctly 💄 Extend edges under opaque bars on timeline 💄 Image View Controller uses modern button style 🚚 Renames `MainTimelinePseudoFeedCell` 💄 Improve feed selection animations 🩹 Use shouldSelectItem to handle selection logic 🩹 Fix fill settings for stack view 💄 Comment out usage of MainTimelineTitleView 🔧 Remove iOS cells from macOS target 💄 Give columns some flexibility 💄 Fix chevron size and alignment 💄 Don’t prefer large navigation bar titles They create a delay in animation on iPhone. 🩹 Fixes nav bar subtitle performance 🎨 Minor refactor - Switch logic in cell state - Prefer traitCollection.userInterfaceIdiom ➕ Add updated mac code for the About view 💄 NSGlassVisualEffectView for About
165 lines
5.1 KiB
Swift
165 lines
5.1 KiB
Swift
//
|
|
// PseudoFeedTableViewCell.swift
|
|
// NetNewsWire
|
|
//
|
|
// Created by Stuart Breckenridge on 19/07/2025.
|
|
// Copyright © 2025 Ranchero Software. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class MainTimelineIconFeedCell: UITableViewCell {
|
|
|
|
@IBOutlet weak var articleTitle: UILabel!
|
|
@IBOutlet weak var authorByLine: UILabel!
|
|
@IBOutlet weak var iconView: IconView!
|
|
@IBOutlet weak var indicatorView: IconView!
|
|
@IBOutlet weak var articleDate: UILabel!
|
|
@IBOutlet weak var metaDataStackView: UIStackView!
|
|
|
|
var cellData: MainTimelineCellData! {
|
|
didSet {
|
|
configure(cellData)
|
|
}
|
|
}
|
|
|
|
override func awakeFromNib() {
|
|
super.awakeFromNib()
|
|
indicatorView.alpha = 0.0
|
|
iconView.translatesAutoresizingMaskIntoConstraints = false
|
|
configureStackView()
|
|
}
|
|
|
|
private func configureStackView() {
|
|
switch traitCollection.preferredContentSizeCategory {
|
|
case .accessibilityMedium, .accessibilityLarge, .accessibilityExtraLarge, .accessibilityExtraExtraLarge, .accessibilityExtraExtraExtraLarge:
|
|
metaDataStackView.axis = .vertical
|
|
metaDataStackView.alignment = .leading
|
|
metaDataStackView.distribution = .fill
|
|
default:
|
|
metaDataStackView.axis = .horizontal
|
|
metaDataStackView.alignment = .center
|
|
metaDataStackView.distribution = .fill
|
|
}
|
|
setNeedsLayout()
|
|
}
|
|
|
|
|
|
private func configure(_ cellData: MainTimelineCellData) {
|
|
updateIndicatorView(cellData)
|
|
articleTitle.numberOfLines = cellData.numberOfLines
|
|
applyTitleTextWithAttributes(configurationState)
|
|
|
|
if cellData.showFeedName == .feed {
|
|
authorByLine.text = cellData.feedName
|
|
} else if cellData.showFeedName == .byline {
|
|
authorByLine.text = cellData.byline
|
|
} else if cellData.showFeedName == .none {
|
|
authorByLine.text = ""
|
|
}
|
|
|
|
setIconImage(cellData.iconImage, with: cellData.iconSize)
|
|
|
|
articleDate.text = cellData.dateString
|
|
}
|
|
|
|
private func setIconImage(_ iconImage: IconImage?, with size: IconSize) {
|
|
iconView.iconImage = iconImage
|
|
updateIconViewSizeConstraints(to: size.size)
|
|
}
|
|
|
|
func setIconImage(_ iconImage: IconImage?) {
|
|
iconView.iconImage = iconImage
|
|
}
|
|
|
|
private func updateIconViewSizeConstraints(to size: CGSize) {
|
|
for constraint in iconView.constraints {
|
|
constraint.isActive = false
|
|
}
|
|
|
|
NSLayoutConstraint.activate([
|
|
iconView.widthAnchor.constraint(equalToConstant: size.width),
|
|
iconView.heightAnchor.constraint(equalToConstant: size.height)
|
|
])
|
|
|
|
setNeedsLayout()
|
|
layoutIfNeeded()
|
|
}
|
|
|
|
private func updateIndicatorView(_ cellData: MainTimelineCellData) {
|
|
if cellData.read == false {
|
|
if indicatorView.alpha == 0.0 {
|
|
indicatorView.alpha = 1.0
|
|
}
|
|
UIView.animate(withDuration: 0.25) {
|
|
self.indicatorView.iconImage = AppAssets.unreadCellIndicatorImage
|
|
self.indicatorView.tintColor = AppAssets.secondaryAccentColor
|
|
}
|
|
return
|
|
} else if cellData.starred {
|
|
if indicatorView.alpha == 0.0 {
|
|
indicatorView.alpha = 1.0
|
|
}
|
|
UIView.animate(withDuration: 0.25) {
|
|
self.indicatorView.iconImage = AppAssets.starredFeedImage
|
|
self.indicatorView.tintColor = AppAssets.starColor
|
|
}
|
|
return
|
|
} else if indicatorView.alpha == 1.0 {
|
|
UIView.animate(withDuration: 0.25) {
|
|
self.indicatorView.alpha = 0.0
|
|
self.indicatorView.iconImage = nil
|
|
}
|
|
}
|
|
}
|
|
|
|
private func applyTitleTextWithAttributes(_ state: UICellConfigurationState) {
|
|
let attributedCellText = NSMutableAttributedString()
|
|
let isSelected = state.isSelected || state.isHighlighted || state.isFocused || state.isSwiped
|
|
if cellData.title != "" {
|
|
let titleAttributes: [NSAttributedString.Key: Any] = [
|
|
.font: UIFont.preferredFont(forTextStyle: .headline),
|
|
.foregroundColor: isSelected ? UIColor.white : UIColor.label
|
|
]
|
|
let titleWithNewline = cellData.title + "\n"
|
|
let titleAttributed = NSAttributedString(string: titleWithNewline, attributes: titleAttributes)
|
|
attributedCellText.append(titleAttributed)
|
|
}
|
|
if cellData.summary != "" {
|
|
let summaryAttributes: [NSAttributedString.Key: Any] = [
|
|
.font: UIFont.preferredFont(forTextStyle: .body),
|
|
.foregroundColor: isSelected ? UIColor.white : UIColor.label
|
|
]
|
|
let summaryAttributed = NSAttributedString(string: cellData.summary, attributes: summaryAttributes)
|
|
attributedCellText.append(summaryAttributed)
|
|
}
|
|
articleTitle.attributedText = attributedCellText
|
|
}
|
|
|
|
override func updateConfiguration(using state: UICellConfigurationState) {
|
|
super.updateConfiguration(using: state)
|
|
|
|
var backgroundConfig = UIBackgroundConfiguration.listCell().updated(for: state)
|
|
backgroundConfig.cornerRadius = 20
|
|
if traitCollection.userInterfaceIdiom == .pad {
|
|
backgroundConfig.edgesAddingLayoutMarginsToBackgroundInsets = [.leading, .trailing]
|
|
backgroundConfig.backgroundInsets = NSDirectionalEdgeInsets(top: 0, leading: -8, bottom: 0, trailing: -8)
|
|
}
|
|
|
|
if state.isSelected || state.isHighlighted || state.isFocused || state.isSwiped {
|
|
backgroundConfig.backgroundColor = AppAssets.primaryAccentColor
|
|
applyTitleTextWithAttributes(state)
|
|
articleDate.textColor = .lightText
|
|
authorByLine.textColor = .lightText
|
|
} else {
|
|
applyTitleTextWithAttributes(state)
|
|
articleDate.textColor = .secondaryLabel
|
|
authorByLine.textColor = .secondaryLabel
|
|
}
|
|
|
|
self.backgroundConfiguration = backgroundConfig
|
|
|
|
}
|
|
|
|
}
|