Swiftpack.co - Package - OlegKetrar/Tools

Tools

Carthage compatible

Features

Requirements

  • Swift 4.2+
  • xCode 10.1+
  • iOS 8.0+

Installation

Carthage

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 carthage

To 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.

Usage

Reusable

NibInitable

StoryboardInitable

Button with preloader

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().

Switch

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)
}

Material-like text field

Brings new level of validation abstraction.

Styling

ValidationCondition

NotificationObserver

Convenience auto-unsubscribed observer.

KeyboardObserver

SearchController

SliderAdapter

Block-base adapter for UICollectionView.

RoutingController

Allows you to define your custom app routes and hanlde them with open(url:) method.

Presentation

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.

License

Tools is released under the MIT license. See LICENSE for details.

Github

link
Stars: 1

Dependencies

Used By

Total: 0

Releases

- 2019-08-27 17:10:43

  • fix issue with Button.shouldAffectImage

- 2019-03-26 20:43:46

  • removed AlertDispatcher dependency
  • added convenience dequeue methods to UITableView and UICollectionView
  • added support for Swift 5

- 2018-01-12 15:44:41

  • improved Presentation
  • adapted for swift 4
  • added RoutingController
  • renamed EventObsever to NotificationObserver