mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Fix lint issues.
This commit is contained in:
@@ -10,8 +10,8 @@
|
||||
import UIKit
|
||||
|
||||
extension UIResponder {
|
||||
|
||||
private weak static var _currentFirstResponder: UIResponder? = nil
|
||||
|
||||
private weak static var _currentFirstResponder: UIResponder?
|
||||
|
||||
public static var isFirstResponderTextField: Bool {
|
||||
var isTextField = false
|
||||
@@ -27,7 +27,7 @@ extension UIResponder {
|
||||
UIApplication.shared.sendAction(#selector(findFirstResponder(sender:)), to: nil, from: nil, for: nil)
|
||||
return UIResponder._currentFirstResponder
|
||||
}
|
||||
|
||||
|
||||
public static func resignCurrentFirstResponder() {
|
||||
if let responder = currentFirstResponder {
|
||||
responder.resignFirstResponder()
|
||||
@@ -37,6 +37,6 @@ extension UIResponder {
|
||||
@objc internal func findFirstResponder(sender: AnyObject) {
|
||||
UIResponder._currentFirstResponder = self
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,32 +10,32 @@
|
||||
import UIKit
|
||||
|
||||
extension UIView {
|
||||
|
||||
|
||||
public func setFrameIfNotEqual(_ rect: CGRect) {
|
||||
if !self.frame.equalTo(rect) {
|
||||
self.frame = rect
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func addChildAndPin(_ view: UIView) {
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(view)
|
||||
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
safeAreaLayoutGuide.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
safeAreaLayoutGuide.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||
safeAreaLayoutGuide.topAnchor.constraint(equalTo: view.topAnchor),
|
||||
safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
||||
])
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public func asImage() -> UIImage {
|
||||
let renderer = UIGraphicsImageRenderer(bounds: bounds)
|
||||
return renderer.image { rendererContext in
|
||||
layer.render(in: rendererContext.cgContext)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,14 +10,14 @@ import UIKit
|
||||
import SwiftUI
|
||||
|
||||
extension UIViewController {
|
||||
|
||||
|
||||
// MARK: Autolayout
|
||||
|
||||
|
||||
public func addChildAndPinView(_ controller: UIViewController) {
|
||||
view.addChildAndPin(controller.view)
|
||||
addChild(controller)
|
||||
}
|
||||
|
||||
|
||||
public func replaceChildAndPinView(_ controller: UIViewController) {
|
||||
for subview in view.subviews {
|
||||
subview.removeFromSuperview()
|
||||
@@ -27,9 +27,9 @@ extension UIViewController {
|
||||
}
|
||||
addChildAndPinView(controller)
|
||||
}
|
||||
|
||||
|
||||
// MARK: Error Handling
|
||||
|
||||
|
||||
public func presentError(title: String, message: String, dismiss: (() -> Void)? = nil) {
|
||||
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
let dismissTitle = NSLocalizedString("OK", comment: "OK")
|
||||
@@ -39,7 +39,7 @@ extension UIViewController {
|
||||
alertController.addAction(dismissAction)
|
||||
self.present(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: SwiftUI
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
import UIKit
|
||||
|
||||
extension UIWindow {
|
||||
|
||||
|
||||
public var topViewController: UIViewController? {
|
||||
|
||||
|
||||
var top = self.rootViewController
|
||||
while true {
|
||||
if let presented = top?.presentedViewController {
|
||||
@@ -33,10 +33,10 @@ extension UIWindow {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return top
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user