diff --git a/Sources/Behavior.swift b/Sources/Behavior.swift index 339f6395..d0716b89 100644 --- a/Sources/Behavior.swift +++ b/Sources/Behavior.swift @@ -86,9 +86,9 @@ open class FloatingPanelDefaultBehavior: FloatingPanelBehavior { class BehaviorAdapter { unowned let vc: FloatingPanelController - fileprivate var behavior: FloatingPanelBehavior + fileprivate var behavior: any FloatingPanelBehavior - init(vc: FloatingPanelController, behavior: FloatingPanelBehavior) { + init(vc: FloatingPanelController, behavior: any FloatingPanelBehavior) { self.vc = vc self.behavior = behavior } @@ -123,7 +123,7 @@ class BehaviorAdapter { } extension FloatingPanelController { - var _behavior: FloatingPanelBehavior { + var _behavior: any FloatingPanelBehavior { get { floatingPanel.behaviorAdapter.behavior } set { floatingPanel.behaviorAdapter.behavior = newValue} } diff --git a/Sources/Controller.swift b/Sources/Controller.swift index ca29df14..ee4c91b3 100644 --- a/Sources/Controller.swift +++ b/Sources/Controller.swift @@ -9,11 +9,11 @@ import os.log @objc public protocol FloatingPanelControllerDelegate { /// Returns a FloatingPanelLayout object. If you use the default one, you can use a `FloatingPanelBottomLayout` object. @objc(floatingPanel:layoutForTraitCollection:) optional - func floatingPanel(_ fpc: FloatingPanelController, layoutFor newCollection: UITraitCollection) -> FloatingPanelLayout + func floatingPanel(_ fpc: FloatingPanelController, layoutFor newCollection: UITraitCollection) -> any FloatingPanelLayout /// Returns a FloatingPanelLayout object. If you use the default one, you can use a `FloatingPanelBottomLayout` object. @objc(floatingPanel:layoutForSize:) optional - func floatingPanel(_ fpc: FloatingPanelController, layoutFor size: CGSize) -> FloatingPanelLayout + func floatingPanel(_ fpc: FloatingPanelController, layoutFor size: CGSize) -> any FloatingPanelLayout /// Returns a UIViewPropertyAnimator object to add/present the panel to a position. /// @@ -150,7 +150,7 @@ open class FloatingPanelController: UIViewController { /// The delegate of a panel controller object. @objc - public weak var delegate: FloatingPanelControllerDelegate?{ + public weak var delegate: (any FloatingPanelControllerDelegate)?{ didSet{ didUpdateDelegate() } @@ -198,7 +198,7 @@ open class FloatingPanelController: UIViewController { /// You need to call ``invalidateLayout()`` if you want to apply a new layout object into the panel /// immediately. @objc - public var layout: FloatingPanelLayout { + public var layout: any FloatingPanelLayout { get { _layout } set { _layout = newValue @@ -211,7 +211,7 @@ open class FloatingPanelController: UIViewController { /// The behavior object that the controller manages @objc - public var behavior: FloatingPanelBehavior { + public var behavior: any FloatingPanelBehavior { get { _behavior } set { _behavior = newValue @@ -282,7 +282,7 @@ open class FloatingPanelController: UIViewController { /// Initialize a newly created panel controller. @objc - public init(delegate: FloatingPanelControllerDelegate? = nil) { + public init(delegate: (any FloatingPanelControllerDelegate)? = nil) { super.init(nibName: nil, bundle: nil) self.delegate = delegate setUp() @@ -294,7 +294,7 @@ open class FloatingPanelController: UIViewController { modalPresentationStyle = .custom transitioningDelegate = modalTransition - let initialLayout: FloatingPanelLayout + let initialLayout: any FloatingPanelLayout if let layout = delegate?.floatingPanel?(self, layoutFor: traitCollection) { initialLayout = layout } else { @@ -344,7 +344,7 @@ open class FloatingPanelController: UIViewController { floatingPanel.adjustScrollContentInsetIfNeeded() } - open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + open override func viewWillTransition(to size: CGSize, with coordinator: any UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) if self.view.bounds.size == size { @@ -363,7 +363,7 @@ open class FloatingPanelController: UIViewController { } } - open override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) { + open override func willTransition(to newCollection: UITraitCollection, with coordinator: any UIViewControllerTransitionCoordinator) { super.willTransition(to: newCollection, with: coordinator) if shouldUpdateLayout(from: traitCollection, to: newCollection) == false { diff --git a/Sources/Core.swift b/Sources/Core.swift index 9188a7d2..8d77318e 100644 --- a/Sources/Core.swift +++ b/Sources/Core.swift @@ -79,7 +79,7 @@ class Core: NSObject, UIGestureRecognizerDelegate { // MARK: - Interface - init(_ vc: FloatingPanelController, layout: FloatingPanelLayout, behavior: FloatingPanelBehavior) { + init(_ vc: FloatingPanelController, layout: any FloatingPanelLayout, behavior: any FloatingPanelBehavior) { ownerVC = vc surfaceView = SurfaceView() @@ -1247,7 +1247,7 @@ public final class FloatingPanelPanGestureRecognizer: UIPanGestureRecognizer { /// /// - Note: The delegate is used by FloatingPanel itself. If you set your own delegate object, an /// exception is raised. If you want to handle the methods of UIGestureRecognizerDelegate, you can use `delegateProxy`. - public override weak var delegate: UIGestureRecognizerDelegate? { + public override weak var delegate: (any UIGestureRecognizerDelegate)? { get { return super.delegate } @@ -1268,7 +1268,7 @@ public final class FloatingPanelPanGestureRecognizer: UIPanGestureRecognizer { /// The default object implementing a set methods of the delegate of the gesture recognizer. /// /// Use this property with ``delegateProxy`` when you need to use the default gesture behaviors in a proxy implementation. - public var delegateOrigin: UIGestureRecognizerDelegate { + public var delegateOrigin: any UIGestureRecognizerDelegate { return floatingPanel } @@ -1276,7 +1276,7 @@ public final class FloatingPanelPanGestureRecognizer: UIPanGestureRecognizer { /// /// `UIGestureRecognizerDelegate` methods implementing by this object are called instead of the default delegate, /// ``delegateOrigin``. - public weak var delegateProxy: UIGestureRecognizerDelegate? { + public weak var delegateProxy: (any UIGestureRecognizerDelegate)? { didSet { self.delegate = floatingPanel?.panGestureDelegateRouter // Update the cached IMP } diff --git a/Sources/Layout.swift b/Sources/Layout.swift index 2118e4c6..21f181e7 100644 --- a/Sources/Layout.swift +++ b/Sources/Layout.swift @@ -12,7 +12,7 @@ import os.log @objc var initialState: FloatingPanelState { get } /// Returns the layout anchors to specify the snapping locations for each state. - @objc var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] { get } + @objc var anchors: [FloatingPanelState: any FloatingPanelLayoutAnchoring] { get } /// Returns layout constraints to determine the cross dimension of a panel. @objc optional func prepareLayout(surfaceView: UIView, in view: UIView) -> [NSLayoutConstraint] @@ -31,7 +31,7 @@ open class FloatingPanelBottomLayout: NSObject, FloatingPanelLayout { return .half } - open var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] { + open var anchors: [FloatingPanelState: any FloatingPanelLayoutAnchoring] { return [ .full: FloatingPanelLayoutAnchor(absoluteInset: 18.0, edge: .top, referenceGuide: .safeArea), .half: FloatingPanelLayoutAnchor(fractionalInset: 0.5, edge: .bottom, referenceGuide: .safeArea), @@ -64,7 +64,7 @@ class LayoutAdapter { private unowned var vc: FloatingPanelController private let defaultLayout = FloatingPanelBottomLayout() - fileprivate var layout: FloatingPanelLayout { + fileprivate var layout: any FloatingPanelLayout { didSet { surfaceView.position = position } @@ -287,7 +287,7 @@ class LayoutAdapter { return offset.rounded(by: surfaceView.fp_displayScale) } - private var hiddenAnchor: FloatingPanelLayoutAnchoring { + private var hiddenAnchor: any FloatingPanelLayoutAnchoring { switch position { case .top: return FloatingPanelLayoutAnchor(absoluteInset: -100, edge: .top, referenceGuide: .superview) @@ -300,7 +300,7 @@ class LayoutAdapter { } } - init(vc: FloatingPanelController, layout: FloatingPanelLayout) { + init(vc: FloatingPanelController, layout: any FloatingPanelLayout) { self.vc = vc self.layout = layout } @@ -404,7 +404,7 @@ class LayoutAdapter { } } - private func referenceEdge(of anchor: FloatingPanelLayoutAnchoring) -> FloatingPanelReferenceEdge { + private func referenceEdge(of anchor: any FloatingPanelLayoutAnchoring) -> FloatingPanelReferenceEdge { switch anchor { case is FloatingPanelIntrinsicLayoutAnchor, is FloatingPanelAdaptiveLayoutAnchor: @@ -546,7 +546,7 @@ class LayoutAdapter { NSLayoutConstraint.deactivate(constraint: interactionConstraint) interactionConstraint = nil - let layoutGuideProvider: LayoutGuideProvider + let layoutGuideProvider: any LayoutGuideProvider switch anchor.referenceGuide { case .safeArea: layoutGuideProvider = vc.view.safeAreaLayoutGuide @@ -854,7 +854,7 @@ extension LayoutAdapter { } extension FloatingPanelController { - var _layout: FloatingPanelLayout { + var _layout: any FloatingPanelLayout { get { floatingPanel.layoutAdapter.layout } diff --git a/Sources/LayoutAnchoring.swift b/Sources/LayoutAnchoring.swift index 17e1aa5d..23afc88e 100644 --- a/Sources/LayoutAnchoring.swift +++ b/Sources/LayoutAnchoring.swift @@ -65,7 +65,7 @@ public extension FloatingPanelLayoutAnchor { } } - private func layoutConstraints(_ layoutGuide: LayoutGuideProvider, for edgeAnchor: NSLayoutYAxisAnchor) -> [NSLayoutConstraint] { + private func layoutConstraints(_ layoutGuide: some LayoutGuideProvider, for edgeAnchor: NSLayoutYAxisAnchor) -> [NSLayoutConstraint] { switch referenceEdge { case .top: if isAbsolute { @@ -84,7 +84,7 @@ public extension FloatingPanelLayoutAnchor { } } - private func layoutConstraints(_ layoutGuide: LayoutGuideProvider, for edgeAnchor: NSLayoutXAxisAnchor) -> [NSLayoutConstraint] { + private func layoutConstraints(_ layoutGuide: some LayoutGuideProvider, for edgeAnchor: NSLayoutXAxisAnchor) -> [NSLayoutConstraint] { switch referenceEdge { case .left: if isAbsolute { diff --git a/Sources/LayoutProperties.swift b/Sources/LayoutProperties.swift index c33b410b..adcafc0e 100644 --- a/Sources/LayoutProperties.swift +++ b/Sources/LayoutProperties.swift @@ -34,7 +34,7 @@ extension FloatingPanelReferenceEdge { } extension FloatingPanelLayoutReferenceGuide { - func layoutGuide(vc: UIViewController) -> LayoutGuideProvider { + func layoutGuide(vc: UIViewController) -> any LayoutGuideProvider { switch self { case .safeArea: return vc.view.safeAreaLayoutGuide @@ -52,7 +52,7 @@ extension FloatingPanelLayoutReferenceGuide { } extension FloatingPanelLayoutContentBoundingGuide { - func layoutGuide(_ fpc: FloatingPanelController) -> LayoutGuideProvider? { + func layoutGuide(_ fpc: FloatingPanelController) -> (any LayoutGuideProvider)? { switch self { case .superview: return fpc.view diff --git a/Sources/Position.swift b/Sources/Position.swift index 973bc55f..d0e31902 100644 --- a/Sources/Position.swift +++ b/Sources/Position.swift @@ -25,7 +25,7 @@ extension FloatingPanelPosition { } } - func mainDimensionAnchor(_ layoutGuide: LayoutGuideProvider) -> NSLayoutDimension { + func mainDimensionAnchor(_ layoutGuide: some LayoutGuideProvider) -> NSLayoutDimension { switch self { case .top, .bottom: return layoutGuide.heightAnchor case .left, .right: return layoutGuide.widthAnchor diff --git a/Sources/Transitioning.swift b/Sources/Transitioning.swift index 88ab2348..d83d77ae 100644 --- a/Sources/Transitioning.swift +++ b/Sources/Transitioning.swift @@ -5,11 +5,11 @@ import UIKit class ModalTransition: NSObject, UIViewControllerTransitioningDelegate { func animationController(forPresented presented: UIViewController, presenting: UIViewController, - source: UIViewController) -> UIViewControllerAnimatedTransitioning? { + source: UIViewController) -> (any UIViewControllerAnimatedTransitioning)? { return ModalPresentTransition() } - func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + func animationController(forDismissed dismissed: UIViewController) -> (any UIViewControllerAnimatedTransitioning)? { return ModalDismissTransition() } @@ -81,7 +81,7 @@ class PresentationController: UIPresentationController { } class ModalPresentTransition: NSObject, UIViewControllerAnimatedTransitioning { - func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { + func transitionDuration(using transitionContext: (any UIViewControllerContextTransitioning)?) -> TimeInterval { guard let fpc = transitionContext?.viewController(forKey: .to) as? FloatingPanelController else { fatalError()} @@ -90,7 +90,7 @@ class ModalPresentTransition: NSObject, UIViewControllerAnimatedTransitioning { return TimeInterval(animator.duration) } - func interruptibleAnimator(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating { + func interruptibleAnimator(using transitionContext: any UIViewControllerContextTransitioning) -> any UIViewImplicitlyAnimating { guard let fpc = transitionContext.viewController(forKey: .to) as? FloatingPanelController else { fatalError() } @@ -110,13 +110,13 @@ class ModalPresentTransition: NSObject, UIViewControllerAnimatedTransitioning { return transitionAnimator } - func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { + func animateTransition(using transitionContext: any UIViewControllerContextTransitioning) { self.interruptibleAnimator(using: transitionContext).startAnimation() } } class ModalDismissTransition: NSObject, UIViewControllerAnimatedTransitioning { - func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { + func transitionDuration(using transitionContext: (any UIViewControllerContextTransitioning)?) -> TimeInterval { guard let fpc = transitionContext?.viewController(forKey: .from) as? FloatingPanelController else { fatalError()} @@ -125,7 +125,7 @@ class ModalDismissTransition: NSObject, UIViewControllerAnimatedTransitioning { return TimeInterval(animator.duration) } - func interruptibleAnimator(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating { + func interruptibleAnimator(using transitionContext: any UIViewControllerContextTransitioning) -> any UIViewImplicitlyAnimating { guard let fpc = transitionContext.viewController(forKey: .from) as? FloatingPanelController else { fatalError() } @@ -142,7 +142,7 @@ class ModalDismissTransition: NSObject, UIViewControllerAnimatedTransitioning { return fpc.transitionAnimator! } - func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { + func animateTransition(using transitionContext: any UIViewControllerContextTransitioning) { self.interruptibleAnimator(using: transitionContext).startAnimation() } }