TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Mauricio Cousillas, Enrique Galindo.
By Xmartlabs SRL.
Ahoy is a swift library that helps you build awesome onboarding experiences for your users.
In order to setup your onboarding you need to define 2 components:
OnboardingViewController
. This will handle all the specific logic related to displaying the slides and managing any global control that you want to use (an skip button for example).Presenter
which should implement the protocol OnboardingPresenter
. This will handle all the specific functionality of each cell (which text goes where, the type of cells, etc.)OnboardingPresenter
protocol or subclassing from BasePresenter
.OnboardingViewController
subclass and set the presenter
property to an instance of your presenter's class. This must be done before calling super.viewDidLoad()
.After this you are ready to go! You can add any other ui components that you want via IBOutlets or directly by code.
import Ahoy
class MovieFanOnboardingController: OnboardingViewController {
override func viewDidLoad() {
presenter = MovieFanPresenter()
presenter.onOnBoardingFinished = { [weak self] in
_ = self?.navigationController?.popViewController(animated: true)
}
super.viewDidLoad()
}
}
class MovieFanPresenter: BasePresenter {
// Your presenter implementation's here
}
In order to manage user interaction, when the onboarding is finished, skipped or when a slide is being displayed. Ahoy provides a few helpers to manage this consistently:
onOnboardingSkipped
: Is called by the controller when the user taps on the skip action.onOnBoardingFinished
: Is called by the controller when the user taps on finish.visibilityChanged(for cell: UICollectionViewCell, at index: Int, amount: CGFloat)
: is called each time the visibility of a cell changes, this can be used to implement some cool animations between each cell.By default, Ahoy provides an implementation of OnboardingPresenter
, BasePresenter
which handles basic functionality and has some customization parameters:
public var cellBackgroundColor: UIColor
public var doneButtonColor: UIColor
public var doneButtonTextColor: UIColor
public var textColor: UIColor
public var swipeLabelText: String
public var titleFont: UIFont
public var bodyFont: UIFont
public var skipColor: UIColor
public var skipTitle: String
public var model: [OnboardingSlide]
public var onOnBoardingFinished: (() -> ())?
public var onOnboardingSkipped: (() -> ())?
Ahoy provides another implementation of the OnboardingViewController
that has global controls at the bottom of the screen. The BottomOnobardingController
uses BottomPresenter
as a Presenter.
Before contribute check the CONTRIBUTING file for more info.
If you use Ahoy in your app We would love to hear about it! Drop us a line on twitter.
Follow these 3 steps to run Example project: Clone Ahoy repository, open Ahoy workspace and run the Example project.
This can be found in the CHANGELOG.md file.