mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-28 16:26:04 +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
125 lines
3.1 KiB
Swift
125 lines
3.1 KiB
Swift
//
|
|
// IconView.swift
|
|
// NetNewsWire-iOS
|
|
//
|
|
// Created by Maurice Parker on 9/17/19.
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
@IBDesignable
|
|
final class IconView: UIView {
|
|
|
|
var iconImage: IconImage? = nil {
|
|
didSet {
|
|
guard iconImage !== oldValue else {
|
|
return
|
|
}
|
|
imageView.image = iconImage?.image
|
|
if traitCollection.userInterfaceStyle == .dark {
|
|
let isDark = iconImage?.isDark ?? false
|
|
isDiscernable = !isDark
|
|
}
|
|
else {
|
|
let isBright = iconImage?.isBright ?? false
|
|
isDiscernable = !isBright
|
|
}
|
|
setNeedsLayout()
|
|
}
|
|
}
|
|
|
|
private var isDiscernable = true
|
|
|
|
private let imageView: UIImageView = {
|
|
let imageView = NonIntrinsicImageView(image: AppAssets.faviconTemplateImage)
|
|
imageView.contentMode = .scaleAspectFit
|
|
imageView.clipsToBounds = true
|
|
imageView.layer.cornerRadius = 2.0
|
|
imageView.layer.cornerCurve = .continuous
|
|
return imageView
|
|
}()
|
|
|
|
private var isVerticalBackgroundExposed: Bool {
|
|
return imageView.frame.size.height < bounds.size.height
|
|
}
|
|
|
|
private var isSymbolImage: Bool {
|
|
return iconImage?.isSymbol ?? false
|
|
}
|
|
|
|
private var isBackgroundSuppressed: Bool {
|
|
return iconImage?.isBackgroundSuppressed ?? false
|
|
}
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
commonInit()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
super.init(coder: coder)
|
|
commonInit()
|
|
}
|
|
|
|
convenience init() {
|
|
self.init(frame: .zero)
|
|
}
|
|
|
|
override func didMoveToSuperview() {
|
|
setNeedsLayout()
|
|
}
|
|
|
|
override func layoutSubviews() {
|
|
imageView.setFrameIfNotEqual(rectForImageView())
|
|
updateBackgroundColor()
|
|
}
|
|
}
|
|
|
|
private extension IconView {
|
|
|
|
func commonInit() {
|
|
layer.cornerRadius = MainTimelineDefaultCellLayout.iconCornerRadius
|
|
clipsToBounds = true
|
|
addSubview(imageView)
|
|
}
|
|
|
|
func rectForImageView() -> CGRect {
|
|
guard let image = iconImage?.image else {
|
|
return CGRect.zero
|
|
}
|
|
|
|
let imageSize = image.size
|
|
let viewSize = bounds.size
|
|
if imageSize.height == imageSize.width {
|
|
if imageSize.height >= viewSize.height * 0.75 {
|
|
// Close enough to viewSize to scale up the image.
|
|
return CGRect(x: 0.0, y: 0.0, width: viewSize.width, height: viewSize.height)
|
|
}
|
|
let offset = floor((viewSize.height - imageSize.height) / 2.0)
|
|
return CGRect(x: offset, y: offset, width: imageSize.width, height: imageSize.height)
|
|
}
|
|
else if imageSize.height > imageSize.width {
|
|
let factor = viewSize.height / imageSize.height
|
|
let width = imageSize.width * factor
|
|
let originX = floor((viewSize.width - width) / 2.0)
|
|
return CGRect(x: originX, y: 0.0, width: width, height: viewSize.height)
|
|
}
|
|
|
|
// Wider than tall: imageSize.width > imageSize.height
|
|
let factor = viewSize.width / imageSize.width
|
|
let height = imageSize.height * factor
|
|
let originY = floor((viewSize.height - height) / 2.0)
|
|
return CGRect(x: 0.0, y: originY, width: viewSize.width, height: height)
|
|
}
|
|
|
|
private func updateBackgroundColor() {
|
|
if !isBackgroundSuppressed && ((iconImage != nil && isVerticalBackgroundExposed) || !isDiscernable) {
|
|
backgroundColor = AppAssets.iconBackgroundColor
|
|
} else {
|
|
backgroundColor = nil
|
|
}
|
|
}
|
|
}
|
|
|