Skip to content

ekoll/UIKit-Unwinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UIKit-Unwinder

A little bit late invention to do unwind operations for UIKit developers that does not use storyboards. With this library, now you are able to unwind operations even with programmatic UI development approach(with UIKit).

Supported Containers

  • UINavigationController
  • UITabbarController
  • UIPageViewController
  • UISplitViewController
  • Your Custom Containers

Integration

Currently It is just usable via SPM. There is no future plan for add support for other package managers

https://github.com/ekoll/UIKit-Unwinder

Usage

In your target view controller create an unwind point method. Your unwind method must be @objc method.

class MyCustomViewController: UIViewController {
    // Content of your ViewController...

    @objc func unwindToMe() {
        // Your unwind logic
    }
}

and call Unwinder from your unwind source

Unwinder.unwind(from: myCurrentViewController, target: #selector(MyCustomViewController.unwindToMe))

Passing parameter

You can also pass one parameter via this unwind operation

Just add your parameter to your unwind point method

    @objc func unwindToMe(_ parameter: Any) {
        // You may need binding here
        guard let parameter = parameter as? MyCustomType else { return }
        // Your unwind logic
    }

and send corresponding value for your parameter

Unwinder.unwind(
    from: myCurrentViewController,
    target: #selector(MyCustomViewController.unwindToMe),
    parameter: MyCustomType()
)

Usage for custom containers

If you use a custom container mechanism to present your ViewControllers inside (like UINavigationController or UITabbarController) you must implement these two methods to manage unwind operation in your container

childForUnwind(selector:)

You should finds the target ViewController of unwind operation in its child ViewController(s) and return. Maybe your container can be the target, so it can return itself when needed

executeUnwind(forChild)

You should manage transition operation from current presenting ViewController to target ViewController in here. All the transitions between these screens in your container is managed here

About

Unwind without needing storyboards

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages