ToastView UIKit - admiral-team/admiralui-ios GitHub Wiki

Class

A view for presenting important information above all views.


Declaration

open class ToastView: UIView, AnyAppThemable

Overview

A view notify the user of a changing information. It has image or circle timer view, text, link button for get more information and close button for remove notification from screen.

Toast view can be of two types.

The first type is default type for presenting on top screen and after some time view will close. This type serves for presenting important information. For example it can be message about error connection or message from friend.

The second type is action type for presenting on bottom screen and toast view contain timer for presenting when view will close. It type allow cancel action while view don't close.

Live example

Configure a Toast View

Configuration with default type

let view = ToastView()
view.title = "At breakpoint boundaries, mini units divide the screen into a fixed master grid."
view.linkText = "Link text"
view.type = .error
view.imageType = .error
view.linkAction = {}
view.closeAction = {}

Configuration with action type

Principle difference with default type is setting property timerDuration.

let view = ToastView()
view.title = "Text"
view.type = .default
view.closeAction = {}
view.closeTitle = "Cancel"
view.timerDuration = 5

Presenting Toast view

For presenting your toast view use class BannerNotification. You can use many way for presenting. We recommend use logic switch presenter, for simple using you can call method defaultSwitchBanner() from class BannerNotification. This logic serves for presenting views and dynamic animation of changing toast views.

For staring create property in your controller.

let switchPresenter = BannerNotification.defaultSwitchBanner()

For presenting view you must call method show from object of BannerNotification. This method has property config. Property config serves for configuration presentation toast view, time duration presenting toast and direction presenting.

var config = BannerNotification.Config.default
config.displayingTime = 2.0

let view = ToastView()
switchPresenter.show(banner: view, config: config)
config.direction = .down

Contribution

You can help us to find bugs or ask us to add features.

  • To start issue please use ready-made templates.
  • To make changes to the repository, you need to create a fork of the project, make changes to the code and create a pull request in our project. You can read more about this in the Github documentation.