Files
NetNewsWire/iOS/MainFeed/Collection View Cells/MainFeedCollectionViewFolderCell.swift
T
Stuart Breckenridge 04f659f704 💄 Liquid Glass Redesign for NetNewsWire
💄 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
2025-07-23 21:58:47 +08:00

136 lines
3.5 KiB
Swift

//
// MainFeedCollectionViewFolderCell.swift
// NetNewsWire-iOS
//
// Created by Stuart Breckenridge on 14/07/2025.
// Copyright © 2025 Ranchero Software. All rights reserved.
//
import UIKit
protocol MainFeedCollectionViewFolderCellDelegate: AnyObject {
func mainFeedCollectionFolderViewCellDisclosureDidToggle(_ sender: MainFeedCollectionViewFolderCell, expanding: Bool)
}
class MainFeedCollectionViewFolderCell: UICollectionViewCell {
@IBOutlet weak var folderTitle: UILabel!
@IBOutlet weak var faviconView: IconView!
@IBOutlet weak var unreadCountLabel: UILabel!
@IBOutlet weak var disclosureButton: UIButton!
var delegate: MainFeedCollectionViewFolderCellDelegate?
private var _unreadCount: Int = 0
var unreadCount: Int {
get {
return _unreadCount
}
set {
_unreadCount = newValue
if newValue == 0 {
unreadCountLabel.isHidden = true
} else {
unreadCountLabel.isHidden = false
}
unreadCountLabel.text = newValue.formatted()
}
}
var iconImage: IconImage? {
didSet {
faviconView.iconImage = iconImage
if let preferredColor = iconImage?.preferredColor {
faviconView.tintColor = UIColor(cgColor: preferredColor)
} else {
faviconView.tintColor = AppAssets.secondaryAccentColor
}
}
}
var disclosureExpanded = true {
didSet {
updateExpandedState(animate: true)
updateUnreadCount()
}
}
override func awakeFromNib() {
super.awakeFromNib()
disclosureButton.addInteraction(UIPointerInteraction())
}
func updateExpandedState(animate: Bool) {
let angle: CGFloat = disclosureExpanded ? 0 : -.pi / 2
let transform = CGAffineTransform(rotationAngle: angle)
let animations = {
self.disclosureButton.transform = transform
}
if animate {
UIView.animate(withDuration: 0.3, animations: animations)
} else {
animations()
}
}
func updateUnreadCount() {
if !disclosureExpanded && unreadCount > 0 {
UIView.animate(withDuration: 0.3) {
self.unreadCountLabel.alpha = 1
}
} else {
UIView.animate(withDuration: 0.3) {
self.unreadCountLabel.alpha = 0
}
}
}
@IBAction
func toggleDisclosure() {
setDisclosure(isExpanded: !disclosureExpanded, animated: true)
delegate?.mainFeedCollectionFolderViewCellDisclosureDidToggle(self, expanding: disclosureExpanded)
}
func setDisclosure(isExpanded: Bool, animated: Bool) {
disclosureExpanded = isExpanded
}
override var accessibilityLabel: String? {
set {}
get {
if unreadCount > 0 {
let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility")
return "\(String(describing: folderTitle.text)) \(unreadCount) \(unreadLabel)"
} else {
return (String(describing: folderTitle.text))
}
}
}
override func updateConfiguration(using state: UICellConfigurationState) {
var backgroundConfig = UIBackgroundConfiguration.listCell().updated(for: state)
switch (state.isHighlighted || state.isSelected || state.isFocused, traitCollection.userInterfaceIdiom) {
case (true, .pad):
backgroundConfig.backgroundColor = .tertiarySystemFill
folderTitle.textColor = AppAssets.primaryAccentColor
case (true, .phone):
backgroundConfig.backgroundColor = AppAssets.primaryAccentColor
folderTitle.textColor = .white
unreadCountLabel.textColor = .lightText
faviconView.tintColor = .white
default:
folderTitle.textColor = .label
faviconView.tintColor = AppAssets.primaryAccentColor
}
if state.cellDropState == .targeted {
backgroundConfig.backgroundColor = .tertiarySystemFill
}
self.backgroundConfiguration = backgroundConfig
}
}