What's New

2019-08-27T17:10:43Z
  • fix issue with Button.shouldAffectImage

Tools

Carthage compatible

Features

Requirements

  • Swift 3.1+
  • xCode 8.0+
  • 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.3.1

Run carthage update to build the framework and drag the built Tools.framework into your Xcode project.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ brew update
$ brew install cocoapods

or

$ gem install cocoapods

To integrate Tools into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
pod 'Tools', :git => 'https://github.com/OlegKetrar/Tools.git', :tag => '0.3.1'
end

Then, run the following command:

$ pod install

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.

Description

  • Swift Tools 3.1.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Dec 20 2024 16:58:19 GMT-1000 (Hawaii-Aleutian Standard Time)