Skip to content

Commit

Permalink
fix existential any
Browse files Browse the repository at this point in the history
  • Loading branch information
kitwtnb committed Jul 15, 2024
1 parent 29185a4 commit a862b4d
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 37 deletions.
6 changes: 3 additions & 3 deletions Sources/Behavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -123,7 +123,7 @@ class BehaviorAdapter {
}

extension FloatingPanelController {
var _behavior: FloatingPanelBehavior {
var _behavior: any FloatingPanelBehavior {
get { floatingPanel.behaviorAdapter.behavior }
set { floatingPanel.behaviorAdapter.behavior = newValue}
}
Expand Down
18 changes: 9 additions & 9 deletions Sources/Controller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
}
Expand All @@ -1268,15 +1268,15 @@ 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
}

/// A proxy object to intercept the default behavior of the gesture recognizer.
///
/// `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
}
Expand Down
16 changes: 8 additions & 8 deletions Sources/Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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),
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand All @@ -300,7 +300,7 @@ class LayoutAdapter {
}
}

init(vc: FloatingPanelController, layout: FloatingPanelLayout) {
init(vc: FloatingPanelController, layout: any FloatingPanelLayout) {
self.vc = vc
self.layout = layout
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -854,7 +854,7 @@ extension LayoutAdapter {
}

extension FloatingPanelController {
var _layout: FloatingPanelLayout {
var _layout: any FloatingPanelLayout {
get {
floatingPanel.layoutAdapter.layout
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/LayoutAnchoring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Sources/LayoutProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Position.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions Sources/Transitioning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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()}
Expand All @@ -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() }
Expand All @@ -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()}
Expand All @@ -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() }
Expand All @@ -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()
}
}
Expand Down

0 comments on commit a862b4d

Please sign in to comment.