Components
Auto-dismissing alert displayed at the bottom of the screen
A toast should be used to display a short lived alert at the bottom of the screen with a message, and optionally, a CTA.
The toast component supports dynamic type by default
public var message: String
The message text to be displayed to the user
public var linkText: String
The text on the link
style CTA button
Once constructed, a toast can be displayed with animation.
import Thumbprint/* ... */public func display(_ toastWithText text: String, linkText: String, in view: UIView, animate: Bool = true) {let toast = Toast(title: text, linkText: linkText)view.addSubview(toast)var initialYPositionConstraint: Constraint?toast.snp.makeConstraints { make inmake.left.right.equalToSuperview().inset(Space.three)initialYPositionConstraint = make.top.equalTo(tabBar.snp.bottom).constraint}view.layoutIfNeeded()initialYPositionConstraint?.deactivate()toast.snp.makeConstraints { make inmake.bottom.equalTo(tabBar.snp.top).offset(-Self.toastSpacing)}toast.alpha = 0.0UIView.animate(withDuration: animate ? 0.5 : 0) {toast.alpha = 1.0view.layoutIfNeeded()}DispatchQueue.main.asyncAfter(deadline: .now() + Self.autoDismissDelay) {UIView.animate(withDuration: Duration.six, animations: {toast.alpha = 0.0}, completion: { _ inself.remove(toast)})}}