Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.0 #244

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

3.0.0 #244

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
42 changes: 29 additions & 13 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
{
"object": {
"pins": [
{
"package": "RxSwift",
"repositoryURL": "https://github.com/ReactiveX/RxSwift.git",
"state": {
"branch": null,
"revision": "7c17a6ccca06b5c107cfa4284e634562ddaf5951",
"version": "6.2.0"
}
"pins" : [
{
"identity" : "rxswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ReactiveX/RxSwift.git",
"state" : {
"revision" : "7c17a6ccca06b5c107cfa4284e634562ddaf5951",
"version" : "6.2.0"
}
]
},
"version": 1
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "9b1258905c21fc1b97bf03d1b4ca12c4ec4e5fda",
"version" : "1.2.0"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
}
],
"version" : 2
}
11 changes: 3 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version:5.8

import PackageDescription

let package = Package(
name: "XCoordinator",
platforms: [.iOS(.v9), .tvOS(.v9)],
platforms: [.iOS(.v11), .tvOS(.v11)],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "XCoordinator",
targets: ["XCoordinator"]),
Expand All @@ -19,13 +17,10 @@ let package = Package(
targets: ["XCoordinatorCombine"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(url: "https://github.com/ReactiveX/RxSwift.git", from: "6.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "XCoordinator",
dependencies: []),
Expand Down
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions Scripts/docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

# Preparation

set -o pipefail

# Constants

TARGET_PLATFORM="iphoneos"
TARGET_SDK="arm64-apple-ios16.4"

# Execution

swift package \
-Xswiftc "-sdk" -Xswiftc "`xcrun --sdk $TARGET_PLATFORM --show-sdk-path`" \
-Xswiftc "-target" -Xswiftc $TARGET_SDK \
--allow-writing-to-directory Documentation \
generate-documentation \
--output-path Documentation \
--transform-for-static-hosting \
--target "XCoordinator"
19 changes: 19 additions & 0 deletions Scripts/docs_preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

# Preparation

set -o pipefail

# Constants

TARGET_PLATFORM="iphoneos"
TARGET_SDK="arm64-apple-ios16.4"

# Execution

swift package \
-Xswiftc "-sdk" -Xswiftc "`xcrun --sdk $TARGET_PLATFORM --show-sdk-path`" \
-Xswiftc "-target" -Xswiftc $TARGET_SDK \
--disable-sandbox \
preview-documentation \
--product XCoordinator
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ internal class Target<GestureRecognizer: UIGestureRecognizer>: GestureRecognizer
init(recognizer gestureRecognizer: GestureRecognizer, handler: @escaping (GestureRecognizer) -> Void) {
self.handler = handler
self.gestureRecognizer = gestureRecognizer
// The method signature "handle(_ gestureRecognizer: UIGestureRecognizer)" is in conflict with validation Apple, use another name : "handleMyGesture"
gestureRecognizer.addTarget(self, action: #selector(handleGesture(of: )))
gestureRecognizer.addTarget(self, action: #selector(handleGesture))
}

// MARK: Target actions
Expand All @@ -34,4 +33,5 @@ internal class Target<GestureRecognizer: UIGestureRecognizer>: GestureRecognizer
guard let recognizer = gestureRecognizer as? GestureRecognizer else { return }
handler(recognizer)
}

}
115 changes: 0 additions & 115 deletions Sources/XCoordinator/AnyCoordinator.swift

This file was deleted.

58 changes: 0 additions & 58 deletions Sources/XCoordinator/AnyTransitionPerformer.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ open class BaseCoordinator<RouteType: Route, TransitionType: TransitionProtocol>
/// When performing a transition, children are automatically added and removed from this array
/// depending on whether they are in the view hierarchy.
///
public private(set) var children = [Presentable]()
public private(set) var children = [any Presentable]()

// MARK: Computed properties

Expand Down Expand Up @@ -68,19 +68,23 @@ open class BaseCoordinator<RouteType: Route, TransitionType: TransitionProtocol>

// MARK: Open methods

open func presented(from presentable: Presentable?) {}
public func router<R: Route>(for route: R) -> (any Router<R>)? {
self as? BaseCoordinator<R, TransitionType>
}

open func presented(from presentable: (any Presentable)?) {}

public func removeChildrenIfNeeded() {
children.removeAll { $0.canBeRemovedAsChild() }
removeParentChildren()
}

public func addChild(_ presentable: Presentable) {
public func addChild(_ presentable: any Presentable) {
children.append(presentable)
presentable.registerParent(self)
}

public func removeChild(_ presentable: Presentable) {
public func removeChild(_ presentable: any Presentable) {
children.removeAll { $0.viewController === presentable.viewController }
removeChildrenIfNeeded()
}
Expand All @@ -99,18 +103,13 @@ open class BaseCoordinator<RouteType: Route, TransitionType: TransitionProtocol>
fatalError("Please override the \(#function) method.")
}

public func registerParent(_ presentable: Presentable & AnyObject) {
public func registerParent(_ presentable: any Presentable & AnyObject) {
let previous = removeParentChildren
removeParentChildren = { [weak presentable] in
previous()
presentable?.childTransitionCompleted()
}
}

@available(iOS, unavailable, message: "Please specify the rootViewController in the initializer of your coordinator instead.")
open func generateRootViewController() -> RootViewController {
.init()
}

// MARK: Private methods

Expand All @@ -136,7 +135,7 @@ extension Presentable {

fileprivate func canBeRemovedAsChild() -> Bool {
guard !(self is UIViewController) else { return true }
guard let viewController = viewController else { return true }
guard let viewController else { return true }
return !viewController.isInViewHierarchy
&& viewController.children.allSatisfy { $0.canBeRemovedAsChild() }
}
Expand All @@ -150,7 +149,7 @@ extension UIViewController {
|| presentingViewController != nil
|| presentedViewController != nil
|| parent != nil
|| view.window != nil
|| viewIfLoaded?.window != nil
|| navigationController != nil
|| tabBarController != nil
|| splitViewController != nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ open class BasicCoordinator<RouteType: Route, TransitionType: TransitionProtocol
/// - Parameter presentable:
/// The context in which this coordinator has been shown to the user.
///
open override func presented(from presentable: Presentable?) {
open override func presented(from presentable: (any Presentable)?) {
super.presented(from: presentable)

if let initialRoute = initialRoute, initialLoadingType == .presented {
Expand Down
Loading