FormsToastKit is toast library.
import FormsToastKit
Forms.framework
Toast can be shown on every UIViewController (also UINavigationController)
Toast.new()
.with(title: "Some message"))
.show(in: controller)
or
Toast.new(of: CustomToastView.self)
.show(in: controller)
Position allows you to change toast position
enum ToastPosition {
case top
case bottom
}
Toast.new()
.with(position: .bottom))
.with(title: "Some message"))
.show(in: controller)
Style allows you to change toast presentation style
enum ToastStyleType {
case info
case success
case error
}
Toast.new()
.with(style: .info))
.with(title: "Some message"))
.show(in: controller)
or
Toast.error()
.with(title: "Some message"))
.show(in: controller)
Custom configuration
Injector.main.register(ConfigurationToastProtocol.self) { _ in
return Configuration.Toast(
backgroundColor: .init(
info: UIColor.black,
success: UIColor.green,
error: UIColor.red)
)
}
Custom toast implementation
class CustomToastView: ToastView {
override func add(to parent: UIView) { }
override func show(animated: Bool,
completion: ((Bool) -> Void)? = nil) { }
override func hide(animated: Bool,
completion: ((Bool) -> Void)? = nil) { }
}