ReusableNibInitableStoryboardInitable
NotificationObserver- convenience auto-unsubscribed observer.Section<Into, Item>HasApplyprotocol- RoutingController
- various
Stringextensions
KeyboardObserverSliderAdapter- declarative block-basedUICollectionViewadapterSearchController- declarative block-basedUISearchControllerabstraction- Button -
UIButtonwith with preloader, prevents multiple execution - Switch -
UISwitchwith control of value changing - Presentation - abstraction around presenting/dismissing of
UIViewControllers UIColorextensions- AutoLayout extensions
- Swift 5.2+
- xCode 11.7+
- iOS 9.0+
.package(url: "https://github.com/OlegKetrar/Tools", .exact("0.6")),Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthageTo integrate Tools into your Xcode project using Carthage, specify it in your Cartfile:
github "OlegKetrar/Tools" == 0.6
Run carthage update to build the framework and drag the built Tools.framework into your Xcode project.
Used disabled state to show preloader on button. Disallow all touchs and hides title and attributedTitle
while preloader is active. By setting flag shouldAffectImage to false you can show image while if preloader is active.
By default true.
let actionButton = Button(frame: .zero)
...
// you can define preloader color.
// other poperties you can change in the usual way.
actionButton.preloaderColor = .white
// you always need to call `finish` closure and call it only on main queue.
actionButton.start(activity: { (finish) in
doSomethingAsyncronousWithCallback {
// finish work and stop `preloader` on button
DispatchQueue.main.async { finish() }
}
})Also you can explicitly control preloader with startPreloader() and stopPreloader().
Adds control to value changing.
let someSwitch = Switch(frame: .zero)
// setup autolayout
// ask you every time somebody toggle switch.
someSwitch.onShouldChangeValue { (proposedValue) in
// return `true` to change to `proposedValue` or `false` to not.
return canEnableSmth(proposedValue)
}Allows you to define your custom app routes and hanlde them with open(url:) method.
Abstraction around present/push and dismiss/pop.
Presentation represents just a method for showing view controller. Has three built in methods:
// create presentation for presenting controllers over someMyVC
let modalyOverMyVC = Presentation.present(over: someMyVC)
// create presentation for pushing into someMyNC
let pushIntoMyNC = Presentation.push(into: someMyVC)
// create presentation for presenting over current topmost controller
let modallyOverTopVC = Presentation.presentOverTop()Then you can use it for displaying specific view controller:
somePresentation.show(someViewControllerToShow, animated: true, completion: {
// do smth
})And then unwind it:
somePresentation.hide(animated: true, completion: {
// do smth
})You need to hide concrete Presentation which you already show.
Presentation does not retain navigation controller or presented view controller presenting view controller.
Tools is released under the MIT license. See LICENSE for details.