mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Never show more than one toast view
This commit is contained in:
parent
75ead2ac09
commit
06a8bffa66
1 changed files with 13 additions and 0 deletions
|
@ -67,6 +67,8 @@ class ToastView: UIView {
|
|||
@objc
|
||||
class ToastController: NSObject, ToastViewDelegate {
|
||||
|
||||
static var currentToastController: ToastController?
|
||||
|
||||
private let toastView: ToastView
|
||||
private var isDismissing: Bool
|
||||
|
||||
|
@ -98,6 +100,12 @@ class ToastController: NSObject, ToastViewDelegate {
|
|||
toastView.autoPinEdge(.bottom, to: .bottom, of: view, withOffset: -inset)
|
||||
toastView.autoPinWidthToSuperview(withMargin: 24)
|
||||
|
||||
if let currentToastController = type(of: self).currentToastController {
|
||||
currentToastController.dismissToastView()
|
||||
type(of: self).currentToastController = nil
|
||||
}
|
||||
type(of: self).currentToastController = self
|
||||
|
||||
UIView.animate(withDuration: 0.1) {
|
||||
self.toastView.alpha = 1
|
||||
}
|
||||
|
@ -131,6 +139,11 @@ class ToastController: NSObject, ToastViewDelegate {
|
|||
return
|
||||
}
|
||||
isDismissing = true
|
||||
|
||||
if type(of: self).currentToastController == self {
|
||||
type(of: self).currentToastController = nil
|
||||
}
|
||||
|
||||
UIView.animate(withDuration: 0.1,
|
||||
animations: {
|
||||
self.toastView.alpha = 0
|
||||
|
|
Loading…
Reference in a new issue