Clean whitespace-only lines.

This commit is contained in:
Brent Simmons committed 2025-11-05 11:22:10 -08:00
1 parent 9827300a9a
commit 9efde554d4
452 files changed
+5354 -5354

No files matched your search

+4 -4
View File
@@ -10,16 +10,16 @@ import Foundation
/// Used to select which animations should be performed
public struct Animations: OptionSet {
/// Selections and deselections will be animated.
public static let select = Animations(rawValue: 1)
/// Scrolling will be animated
public static let scroll = Animations(rawValue: 2)
/// Pushing and popping navigation view controllers will be animated
public static let navigation = Animations(rawValue: 4)
public let rawValue: Int
public init(rawValue: Int) {
self.rawValue = rawValue
+3 -3
View File
@@ -9,12 +9,12 @@
import UIKit
extension Array where Element == CGRect {
func maxY() -> CGFloat {
var y: CGFloat = 0.0
self.forEach { y = Swift.max(y, $0.maxY) }
return y
}
}
+4 -4
View File
@@ -9,17 +9,17 @@
import Foundation
extension Bundle {
var appName: String {
return infoDictionary?["CFBundleName"] as! String
}
var versionNumber: String {
return infoDictionary?["CFBundleShortVersionString"] as! String
}
var buildNumber: String {
return infoDictionary?["CFBundleVersion"] as! String
}
}
@@ -9,11 +9,11 @@
import UIKit
final class CroppingPreviewParameters: UIPreviewParameters {
override init() {
super.init()
}
init(view: UIView) {
super.init()
let newBounds = CGRect(x: 1, y: 1, width: view.bounds.width - 2, height: view.bounds.height - 2)
+4 -4
View File
@@ -11,19 +11,19 @@ import UIKit
final class ImageHeaderView: UITableViewHeaderFooterView {
static let rowHeight = CGFloat(integerLiteral: 88)
var imageView = UIImageView()
override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
commonInit()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
commonInit()
}
func commonInit() {
imageView.tintColor = UIColor.label
imageView.contentMode = .scaleAspectFit
@@ -12,10 +12,10 @@ final class ModalNavigationController: UINavigationController {
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// This hack is to resolve https://github.com/brentsimmons/NetNewsWire/issues/1301
let frame = navigationBar.frame
navigationBar.frame = CGRect(x: frame.minX, y: frame.minY, width: frame.size.width, height: 64.0)
}
}
+1 -1
View File
@@ -14,5 +14,5 @@ final class NonIntrinsicLabel: UILabel {
override var intrinsicContentSize: CGSize {
return CGSize(width: UIView.noIntrinsicMetric, height: UIView.noIntrinsicMetric)
}
}
@@ -10,7 +10,7 @@
import UIKit
final class PoppableGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate {
weak var navigationController: UINavigationController?
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
@@ -20,12 +20,12 @@ final class PoppableGestureRecognizerDelegate: NSObject, UIGestureRecognizerDele
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
if otherGestureRecognizer is UIPanGestureRecognizer {
return true
}
return false
}
}
+3 -3
View File
@@ -9,17 +9,17 @@
import UIKit
extension String {
func height(withConstrainedWidth width: CGFloat, font: UIFont) -> CGFloat {
let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude)
let boundingBox = self.boundingRect(with: constraintRect, options: [.usesLineFragmentOrigin, .usesFontLeading], attributes: [NSAttributedString.Key.font: font], context: nil)
return ceil(boundingBox.height)
}
func width(withConstrainedHeight height: CGFloat, font: UIFont) -> CGFloat {
let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height)
let boundingBox = self.boundingRect(with: constraintRect, options: [.usesLineFragmentOrigin, .usesFontLeading], attributes: [NSAttributedString.Key.font: font], context: nil)
return ceil(boundingBox.width)
}
}
+13 -13
View File
@@ -13,7 +13,7 @@ final class TickMarkSlider: UISlider {
private var enableFeedback = false
private let feedbackGenerator = UISelectionFeedbackGenerator()
private var roundedValue: Float?
override var value: Float {
didSet {
@@ -24,17 +24,17 @@ final class TickMarkSlider: UISlider {
}
}
}
func addTickMarks() {
enableFeedback = true
let numberOfGaps = Int(maximumValue) - Int(minimumValue)
var gapLayoutGuides = [UILayoutGuide]()
for i in 0...numberOfGaps {
let tick = UIView()
tick.translatesAutoresizingMaskIntoConstraints = false
tick.backgroundColor = AppAssets.tickMarkColor
@@ -47,11 +47,11 @@ final class TickMarkSlider: UISlider {
if i == 0 {
tick.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
}
if let lastGapLayoutGuild = gapLayoutGuides.last {
lastGapLayoutGuild.trailingAnchor.constraint(equalTo: tick.leadingAnchor).isActive = true
}
if i != numberOfGaps {
let gapLayoutGuild = UILayoutGuide()
gapLayoutGuides.append(gapLayoutGuild)
@@ -60,17 +60,17 @@ final class TickMarkSlider: UISlider {
} else {
tick.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
}
}
if let firstGapLayoutGuild = gapLayoutGuides.first {
for i in 1..<gapLayoutGuides.count {
gapLayoutGuides[i].widthAnchor.constraint(equalTo: firstGapLayoutGuild.widthAnchor).isActive = true
}
}
}
override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
let result = super.continueTracking(touch, with: event)
value = value.rounded()
@@ -80,5 +80,5 @@ final class TickMarkSlider: UISlider {
override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
value = value.rounded()
}
}
@@ -12,7 +12,7 @@ extension UIActivityViewController {
convenience init(url: URL, title: String?, applicationActivities: [UIActivity]?) {
let itemSource = ArticleActivityItemSource(url: url, subject: title)
let titleSource = TitleActivityItemSource(title: title)
self.init(activityItems: [titleSource, itemSource], applicationActivities: applicationActivities)
}
}
@@ -9,7 +9,7 @@
import UIKit
public extension UIBarButtonItem {
@IBInspectable var accEnabled: Bool {
get {
return isAccessibilityElement
@@ -18,7 +18,7 @@ public extension UIBarButtonItem {
isAccessibilityElement = newValue
}
}
@IBInspectable var accLabelText: String? {
get {
return accessibilityLabel
@@ -27,5 +27,5 @@ public extension UIBarButtonItem {
accessibilityLabel = newValue
}
}
}
@@ -20,7 +20,7 @@ extension UICollectionView {
indexPath.row < dataSource.collectionView(self, numberOfItemsInSection: indexPath.section) else {
return
}
selectItem(at: indexPath, animated: animations.contains(.select), scrollPosition: [])
if !indexPathsForVisibleItems.contains(indexPath) {
+4 -4
View File
@@ -9,7 +9,7 @@
import UIKit
extension UIFont {
func withTraits(traits:UIFontDescriptor.SymbolicTraits) -> UIFont {
if let descriptor = fontDescriptor.withSymbolicTraits(traits) {
return UIFont(descriptor: descriptor, size: 0) //size 0 means keep the size as it is
@@ -17,13 +17,13 @@ extension UIFont {
return self
}
}
func bold() -> UIFont {
return withTraits(traits: .traitBold)
}
func italic() -> UIFont {
return withTraits(traits: .traitItalic)
}
}
@@ -9,7 +9,7 @@
import UIKit
extension UIPageViewController {
var scrollViewInsidePageControl: UIScrollView? {
for view in view.subviews {
if let scrollView = view as? UIScrollView {
@@ -18,5 +18,5 @@ extension UIPageViewController {
}
return nil
}
}
@@ -9,39 +9,39 @@
import UIKit
extension UIStoryboard {
static let preferredContentSizeForFormSheetDisplay = CGSize(width: 460.0, height: 400.0)
static var main: UIStoryboard {
return UIStoryboard(name: "Main", bundle: nil)
}
static var add: UIStoryboard {
return UIStoryboard(name: "Add", bundle: nil)
}
static var settings: UIStoryboard {
return UIStoryboard(name: "Settings", bundle: nil)
}
static var inspector: UIStoryboard {
return UIStoryboard(name: "Inspector", bundle: nil)
}
static var account: UIStoryboard {
return UIStoryboard(name: "Account", bundle: nil)
}
func instantiateController<T>(ofType type: T.Type = T.self) -> T where T: UIViewController {
let storyboardId = String(describing: type)
guard let viewController = instantiateViewController(withIdentifier: storyboardId) as? T else {
print("Unable to load view with Scene Identifier: \(storyboardId)")
fatalError()
}
return viewController
}
}
@@ -9,7 +9,7 @@
import UIKit
extension UITableView {
/**
Selects a row and scrolls it to the middle if it is not visible
*/
@@ -20,7 +20,7 @@ extension UITableView {
indexPath.row < dataSource.tableView(self, numberOfRowsInSection: indexPath.section) else {
return
}
selectRow(at: indexPath, animated: animations.contains(.select), scrollPosition: .none)
if let visibleIndexPaths = indexPathsForRows(in: safeAreaLayoutGuide.layoutFrame) {
@@ -29,12 +29,12 @@ extension UITableView {
}
}
}
func cellCompletelyVisible(_ indexPath: IndexPath) -> Bool {
let rect = rectForRow(at: indexPath)
return safeAreaLayoutGuide.layoutFrame.contains(rect)
}
public func middleVisibleRow() -> IndexPath? {
if let visibleIndexPaths = indexPathsForRows(in: safeAreaLayoutGuide.layoutFrame), visibleIndexPaths.count > 2 {
return visibleIndexPaths[visibleIndexPaths.count / 2]
@@ -11,7 +11,7 @@ import RSCore
import Account
extension UIViewController {
func presentError(_ error: Error, dismiss: (() -> Void)? = nil) {
if let accountError = error as? AccountError, accountError.isCredentialsError {
presentAccountError(accountError, dismiss: dismiss)
@@ -41,7 +41,7 @@ extension UIViewController {
let localizedError = NSLocalizedString("This theme cannot be used because of data corruption in the Info.plist. %@.", comment: "Decoding key missing")
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, debugDescription) as String
presentError(title: errorTitle, message: informativeText, dismiss: dismiss)
default:
informativeText = error.localizedDescription
presentError(title: errorTitle, message: informativeText, dismiss: dismiss)
@@ -61,44 +61,44 @@ extension UIViewController {
}
private extension UIViewController {
func presentAccountError(_ error: AccountError, dismiss: (() -> Void)? = nil) {
let title = NSLocalizedString("Account Error", comment: "Account Error")
let alertController = UIAlertController(title: title, message: error.localizedDescription, preferredStyle: .alert)
if error.account?.type == .feedbin {
let credentialsTitle = NSLocalizedString("Update Credentials", comment: "Update Credentials")
let credentialsAction = UIAlertAction(title: credentialsTitle, style: .default) { [weak self] _ in
dismiss?()
let navController = UIStoryboard.account.instantiateViewController(withIdentifier: "FeedbinAccountNavigationViewController") as! UINavigationController
navController.modalPresentationStyle = .formSheet
let addViewController = navController.topViewController as! FeedbinAccountViewController
addViewController.account = error.account
self?.present(navController, animated: true)
}
alertController.addAction(credentialsAction)
alertController.preferredAction = credentialsAction
}
let dismissTitle = NSLocalizedString("OK", comment: "OK")
let dismissAction = UIAlertAction(title: dismissTitle, style: .default) { _ in
dismiss?()
}
alertController.addAction(dismissAction)
self.present(alertController, animated: true, completion: nil)
}
func presentErrorWithRecovery(error: RecoverableError & LocalizedError, dismiss: (() -> Void)? = nil) {
let title = error.errorDescription ?? NSLocalizedString("Error", comment: "Error")
let message = [error.failureReason, error.recoverySuggestion].compactMap { $0 }.joined(separator: " ")
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
// Add recovery options as buttons
for (index, option) in error.recoveryOptions.enumerated() {
let action = UIAlertAction(title: option, style: index == 0 ? .default : .cancel) { _ in
@@ -106,13 +106,13 @@ private extension UIViewController {
_ = error.attemptRecovery(optionIndex: index)
}
alertController.addAction(action)
// Make the first option the preferred action
if index == 0 {
alertController.preferredAction = action
}
}
self.present(alertController, animated: true, completion: nil)
}
+3 -3
View File
@@ -9,7 +9,7 @@
import UIKit
final class VibrantButton: UIButton {
@IBInspectable var backgroundHighlightColor: UIColor = AppAssets.secondaryAccentColor
override init(frame: CGRect) {
@@ -20,7 +20,7 @@ final class VibrantButton: UIButton {
super.init(coder: coder)
commonInit()
}
private func commonInit() {
setTitleColor(AppAssets.vibrantTextColor, for: .highlighted)
let disabledColor = AppAssets.secondaryAccentColor.withAlphaComponent(0.5)
@@ -47,5 +47,5 @@ final class VibrantButton: UIButton {
isHighlighted = false
super.touchesCancelled(touches, with: event)
}
}
+3 -3
View File
@@ -9,17 +9,17 @@
import UIKit
final class VibrantLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
commonInit()
}
private func commonInit() {
highlightedTextColor = AppAssets.vibrantTextColor
}
+16 -16
View File
@@ -9,27 +9,27 @@
import UIKit
class VibrantTableViewCell: UITableViewCell {
static let duration: TimeInterval = 0.6
var labelColor: UIColor {
return isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label
}
var secondaryLabelColor: UIColor {
return isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.secondaryLabel
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
commonInit()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
commonInit()
}
private func commonInit() {
applyThemeProperties()
}
@@ -43,7 +43,7 @@ class VibrantTableViewCell: UITableViewCell {
super.setSelected(selected, animated: animated)
updateVibrancy(animated: animated)
}
/// Subclass overrides should call super
func applyThemeProperties() {
let selectedBackgroundView = UIView(frame: .zero)
@@ -56,7 +56,7 @@ class VibrantTableViewCell: UITableViewCell {
updateLabelVibrancy(textLabel, color: labelColor, animated: animated)
updateLabelVibrancy(detailTextLabel, color: labelColor, animated: animated)
}
func updateLabelVibrancy(_ label: UILabel?, color: UIColor, animated: Bool) {
guard let label = label else { return }
if animated {
@@ -67,33 +67,33 @@ class VibrantTableViewCell: UITableViewCell {
label.textColor = color
}
}
}
class VibrantBasicTableViewCell: VibrantTableViewCell {
@IBOutlet private var label: UILabel!
@IBOutlet private var detail: UILabel!
@IBOutlet private var icon: UIImageView!
@IBInspectable var imageNormal: UIImage?
@IBInspectable var imageSelected: UIImage?
var iconTint: UIColor {
return isHighlighted || isSelected ? labelColor : AppAssets.primaryAccentColor
}
var iconImage: UIImage? {
return isHighlighted || isSelected ? imageSelected : imageNormal
}
override func updateVibrancy(animated: Bool) {
super.updateVibrancy(animated: animated)
updateIconVibrancy(icon, color: iconTint, image: iconImage, animated: animated)
updateLabelVibrancy(label, color: labelColor, animated: animated)
updateLabelVibrancy(detail, color: secondaryLabelColor, animated: animated)
}
private func updateIconVibrancy(_ icon: UIImageView?, color: UIColor, image: UIImage?, animated: Bool) {
guard let icon = icon else { return }
if animated {
@@ -106,5 +106,5 @@ class VibrantBasicTableViewCell: VibrantTableViewCell {
icon.image = image
}
}
}