Skip to content

Commit

Permalink
Updated documentation. Reformatted the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Kazaev committed Dec 21, 2022
1 parent fbf1718 commit 7ef173d
Show file tree
Hide file tree
Showing 393 changed files with 2,505 additions and 2,257 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- RouteComposer (2.10.0)
- RouteComposer (2.10.2)
- SwiftFormat/CLI (0.43.5)

DEPENDENCIES:
Expand All @@ -15,7 +15,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
RouteComposer: 124c6765ec7013509f7d3d9b58854a77d9d61a65
RouteComposer: 37f0a7dfe42fd1200a857cd6bf8582f0b6113e4e
SwiftFormat: 352ea545e3e13cfd7a449e621c1f3c2e244d4906

PODFILE CHECKSUM: fc9566202a2f646e3cbb198c10cf157d9dd60f4f
Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/RouteComposer.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2,804 changes: 1,524 additions & 1,280 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ struct AnalyticsRouterDecorator: Router {
self.router = router
}

func navigate<ViewController: UIViewController, Context>(to step: DestinationStep<ViewController, Context>,
with context: Context,
animated: Bool = true,
completion: ((RoutingResult) -> Void)? = nil) throws {
func navigate<Context>(to step: DestinationStep<some UIViewController, Context>,
with context: Context,
animated: Bool = true,
completion: ((RoutingResult) -> Void)? = nil) throws {
var sourceScreen: ExampleScreenTypes?

if let topmostViewController = UIApplication.shared.windows.first?.topmostViewController,
Expand All @@ -36,7 +36,7 @@ struct AnalyticsRouterDecorator: Router {
}

try router.navigate(to: step, with: context, animated: animated) { result in
if let sourceScreen = sourceScreen {
if let sourceScreen {
print("Source: \(sourceScreen)")
if let topmostViewController = UIApplication.shared.windows.first?.topmostViewController,
let analyticsViewController = try? UIViewController.findViewController(in: topmostViewController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BlurredBackgroundTransitionAnimator: NSObject, UIViewControllerAnimatedTra
private func blurEffectView(_ style: UIBlurEffect.Style = .light, frame: CGRect? = nil, backgroundColor: UIColor?) -> UIVisualEffectView {
let blurEffect = UIBlurEffect(style: style)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
if let frame = frame {
if let frame {
blurEffectView.frame = frame
}
blurEffectView.backgroundColor = backgroundColor
Expand Down
8 changes: 4 additions & 4 deletions Example/RouteComposer/Configuration/FailingRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ struct FailingRouter<R>: Router where R: Router {
self.failOnError = failOnError
}

func navigate<ViewController: UIViewController, Context>(to step: DestinationStep<ViewController, Context>,
with context: Context,
animated: Bool,
completion: ((RoutingResult) -> Void)?) throws {
func navigate<Context>(to step: DestinationStep<some UIViewController, Context>,
with context: Context,
animated: Bool,
completion: ((RoutingResult) -> Void)?) throws {
do {
try router.navigate(to: step, with: context, animated: animated, completion: { result in
if let error = try? result.getError() {
Expand Down
2 changes: 1 addition & 1 deletion Example/RouteComposer/Extensions/Router+Destination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import UIKit
/// Simple extension to support `Destination` instance directly by the `Router`.
extension Router {

func navigate<ViewController: UIViewController, Context>(to step: DestinationStep<ViewController, Context>, with context: Context) throws {
func navigate<Context>(to step: DestinationStep<some UIViewController, Context>, with context: Context) throws {
try navigate(to: step, with: context, animated: true, completion: nil)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class CustomContainerController: UIViewController {
currentViewController?.view.removeFromSuperview()
currentViewController?.didMove(toParent: nil)

guard let rootViewController = rootViewController else {
guard let rootViewController else {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class ImageDetailsViewController: UIViewController {
}

private func reloadData() {
guard isViewLoaded, let imageID = imageID else {
guard isViewLoaded, let imageID else {
return
}
view.accessibilityIdentifier = "image\(imageID)ViewController"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CityTableContextTask: ContextTask {
// `CitiesTableViewController` can perfectly work with the `Context` object of type `Int?`, but to demonstrate the possibility of context conversion,
// we say that the actual context is `String?`. But it is done for demonstration and testing purposes only.
func perform(on viewController: CitiesTableViewController, with cityIdAsString: String?) throws {
guard let cityIdAsString = cityIdAsString else {
guard let cityIdAsString else {
viewController.cityId = nil
return
}
Expand All @@ -39,7 +39,7 @@ class CitiesTableViewController: UITableViewController, ExampleAnalyticsSupport

var cityId: Int? {
didSet {
guard let cityId = cityId else {
guard let cityId else {
return
}
let indexPath = IndexPath(row: cityId - 1, section: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CityDetailViewController: UIViewController, ExampleAnalyticsSupport {
title = "\(city.city)"

detailsTextView.text = city.city + "\n\n" + city.description
if let cityId = cityId {
if let cityId {
view.accessibilityIdentifier = "cityDetailsViewController+\(cityId)"
} else {
view.accessibilityIdentifier = "cityDetailsViewController"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ColorViewController: UIViewController, DismissibleWithRuntimeStorage, Exam

var colorHex: ColorDisplayModel? {
didSet {
if let colorHex = colorHex, isViewLoaded {
if let colorHex, isViewLoaded {
self.view.backgroundColor = UIColor(hexString: colorHex)
}
}
Expand All @@ -68,7 +68,7 @@ class ColorViewController: UIViewController, DismissibleWithRuntimeStorage, Exam
super.viewDidLoad()
view.accessibilityIdentifier = "colorViewController"
title = "Color"
if let colorHex = colorHex {
if let colorHex {
view.backgroundColor = UIColor(hexString: colorHex)
} else {
view.backgroundColor = UIColor.white
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct CustomContainerControllerAdapter: ConcreteContainerAdapter {
}

public func makeVisible(_ viewController: UIViewController, animated: Bool, completion: @escaping (_: RoutingResult) -> Void) {
guard let customContainerController = customContainerController else {
guard let customContainerController else {
completion(.failure(RoutingError.compositionFailed(.init("CustomContainerController has been deallocated"))))
return
}
Expand All @@ -101,7 +101,7 @@ struct CustomContainerControllerAdapter: ConcreteContainerAdapter {
}

public func setContainedViewControllers(_ containedViewControllers: [UIViewController], animated: Bool, completion: @escaping (_: RoutingResult) -> Void) {
guard let customContainerController = customContainerController else {
guard let customContainerController else {
completion(.failure(RoutingError.compositionFailed(.init("CustomContainerController has been deallocated"))))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ProductViewController: UIViewController, ExampleAnalyticsSupport, ContextA
}

productIdLabel.text = productId
if let productId = productId {
if let productId {
view.accessibilityIdentifier = "productViewController+\(productId)"
title = "Product \(productId)"
} else {
Expand All @@ -95,7 +95,7 @@ class ProductViewController: UIViewController, ExampleAnalyticsSupport, ContextA
}

@IBAction func goToProductFromCircleTapped() {
guard let productId = productId,
guard let productId,
var productIdAsInt = Int(productId) else {
return
}
Expand Down
24 changes: 12 additions & 12 deletions Example/Tests/ExtrasTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ class ExtrasTest: XCTestCase {

func testSingleNavigationRouterThrowingException() {
class FaultyTestRouter: Router {
func navigate<ViewController: UIViewController, Context>(to step: DestinationStep<ViewController, Context>,
with context: Context,
animated: Bool,
completion: ((RoutingResult) -> Void)?) throws {
func navigate<Context>(to step: DestinationStep<some UIViewController, Context>,
with context: Context,
animated: Bool,
completion: ((RoutingResult) -> Void)?) throws {
throw RoutingError.generic(.init("Test"))
}
}
Expand Down Expand Up @@ -257,21 +257,21 @@ class ExtrasTest: XCTestCase {

func testRouterNavigationToDestination() {
class TestRouter: Router {
func navigate<ViewController: UIViewController, Context>(to step: DestinationStep<ViewController, Context>,
with context: Context,
animated: Bool,
completion: ((RoutingResult) -> Void)?) throws {
func navigate<Context>(to step: DestinationStep<some UIViewController, Context>,
with context: Context,
animated: Bool,
completion: ((RoutingResult) -> Void)?) throws {
XCTAssertTrue(animated)
XCTAssertNotNil(completion)
completion?(.success)
}
}

class FaultyTestRouter: Router {
func navigate<ViewController: UIViewController, Context>(to step: DestinationStep<ViewController, Context>,
with context: Context,
animated: Bool,
completion: ((RoutingResult) -> Void)?) throws {
func navigate<Context>(to step: DestinationStep<some UIViewController, Context>,
with context: Context,
animated: Bool,
completion: ((RoutingResult) -> Void)?) throws {
XCTAssertFalse(animated)
XCTAssertNotNil(completion)
throw RoutingError.generic(.init("Test"))
Expand Down
2 changes: 1 addition & 1 deletion RouteComposer.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RouteComposer'
s.version = '2.10.1'
s.version = '2.10.2'
s.summary = 'Protocol oriented library that helps to handle view controllers composition, navigation and deep linking tasks.'
s.swift_version = '5.7'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public enum TabBarControllerActions {

private func setup(viewController: UIViewController,
at childViewControllers: inout [UIViewController], tabIndex: Int?) {
if let tabIndex = tabIndex, tabIndex < childViewControllers.count {
if let tabIndex, tabIndex < childViewControllers.count {
if replacing {
childViewControllers[tabIndex] = viewController
} else {
Expand Down
14 changes: 7 additions & 7 deletions RouteComposer/Classes/Actions/UIViewController+Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,24 @@ public enum ViewControllerActions {
"already presenting a view controller."))))
return
}
if let presentationStyle = presentationStyle {
if let presentationStyle {
viewController.modalPresentationStyle = presentationStyle
}
if let transitionStyle = transitionStyle {
if let transitionStyle {
viewController.modalTransitionStyle = transitionStyle
}
if let transitioningDelegate = transitioningDelegate {
if let transitioningDelegate {
viewController.transitioningDelegate = transitioningDelegate
}
if let preferredContentSize = preferredContentSize {
if let preferredContentSize {
viewController.preferredContentSize = preferredContentSize
}
if let popoverPresentationController = viewController.popoverPresentationController,
let popoverControllerConfigurationBlock = popoverControllerConfigurationBlock {
let popoverControllerConfigurationBlock {
popoverControllerConfigurationBlock(popoverPresentationController)
}
if #available(iOS 13, *),
let isModalInPresentation = isModalInPresentation {
let isModalInPresentation {
viewController.isModalInPresentation = isModalInPresentation
}

Expand Down Expand Up @@ -231,7 +231,7 @@ public enum ViewControllerActions {
return
}

guard animated, let animationOptions = animationOptions, duration > 0 else {
guard animated, let animationOptions, duration > 0 else {
window.rootViewController = viewController
window.makeKeyAndVisible()
completion(.success)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct NavigationControllerAdapter<VC: UINavigationController>: ConcreteC
}

public func makeVisible(_ viewController: UIViewController, animated: Bool, completion: @escaping (_: RoutingResult) -> Void) {
guard let navigationController = navigationController else {
guard let navigationController else {
completion(.failure(RoutingError.compositionFailed(.init("\(String(describing: VC.self)) has been deallocated"))))
return
}
Expand Down Expand Up @@ -67,7 +67,7 @@ public struct NavigationControllerAdapter<VC: UINavigationController>: ConcreteC
}

public func setContainedViewControllers(_ containedViewControllers: [UIViewController], animated: Bool, completion: @escaping (_: RoutingResult) -> Void) {
guard let navigationController = navigationController else {
guard let navigationController else {
completion(.failure(RoutingError.compositionFailed(.init("\(String(describing: VC.self)) has been deallocated"))))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct SplitControllerAdapter<VC: UISplitViewController>: ConcreteContain
/// **Quote:** When designing your split view interface, it is best to install primary and secondary view controllers that do not change.
/// A common technique is to install navigation controllers in both positions and then push and pop new content as needed.
public func setContainedViewControllers(_ containedViewControllers: [UIViewController], animated: Bool, completion: @escaping (_: RoutingResult) -> Void) {
guard let splitViewController = splitViewController else {
guard let splitViewController else {
completion(.failure(RoutingError.compositionFailed(.init("\(String(describing: VC.self)) has been deallocated"))))
return
}
Expand Down
4 changes: 2 additions & 2 deletions RouteComposer/Classes/Adapters/TabBarControllerAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public struct TabBarControllerAdapter<VC: UITabBarController>: ConcreteContainer
}

public func makeVisible(_ viewController: UIViewController, animated: Bool, completion: @escaping (_: RoutingResult) -> Void) {
guard let tabBarController = tabBarController else {
guard let tabBarController else {
completion(.failure(RoutingError.compositionFailed(.init("\(String(describing: VC.self)) has been deallocated"))))
return
}
Expand All @@ -59,7 +59,7 @@ public struct TabBarControllerAdapter<VC: UITabBarController>: ConcreteContainer
}

public func setContainedViewControllers(_ containedViewControllers: [UIViewController], animated: Bool, completion: @escaping (_: RoutingResult) -> Void) {
guard let tabBarController = tabBarController else {
guard let tabBarController else {
completion(.failure(RoutingError.compositionFailed(.init("\(String(describing: VC.self)) has been deallocated"))))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct ActionConnectingAssembly<VC: UIViewController, C> {
///
/// - Parameter action: `Action` instance to be used with a step.
/// - Returns: `ChainAssembly` to continue building the chain.
public func using<A: Action>(_ action: A) -> StepChainAssembly<VC, C> {
public func using(_ action: some Action) -> StepChainAssembly<VC, C> {
var previousSteps = previousSteps
if let routingStep = stepToFullFill.routingStep(with: action) {
previousSteps.append(routingStep)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import UIKit
public class IntermediateDestinationStep {

// Hides action integration from library user.
func routingStep<A: Action>(with action: A) -> RoutingStep? {
func routingStep(with action: some Action) -> RoutingStep? {
nil
}

// Hides action integration from library user.
func embeddableRoutingStep<A: ContainerAction>(with action: A) -> RoutingStep? {
func embeddableRoutingStep(with action: some ContainerAction) -> RoutingStep? {
nil
}

Expand Down
Loading

0 comments on commit 7ef173d

Please sign in to comment.