This commit is contained in:
xaoxuu 2019-08-13 09:14:30 +08:00
parent 29fa9f13c0
commit 4217c5a98c
4 changed files with 30 additions and 12 deletions

View File

@ -89,7 +89,8 @@ class TestToastVC: BaseListVC {
} }
} else if row == 7 { } else if row == 7 {
Toast.find("aaa", last: { (t) in Toast.find("aaa", last: { (t) in
t.update { (vm) in t.pulse()
t.update() { (vm) in
vm.title = "已经存在了" vm.title = "已经存在了"
} }
}) { }) {

View File

@ -56,7 +56,7 @@ public extension ProHUD {
public var vm = ViewModel() public var vm = ViewModel()
// MARK: // MARK:
internal var isLoadFinished = false private var isLoadFinished = false
/// ///
/// - Parameter scene: /// - Parameter scene:
@ -180,7 +180,7 @@ public extension Alert {
return Alert(scene: scene, title: title, message: message, actions: actions).push() return Alert(scene: scene, title: title, message: message, actions: actions).push()
} }
/// ///
/// - Parameter identifier: /// - Parameter identifier:
class func find(_ identifier: String?) -> [Alert] { class func find(_ identifier: String?) -> [Alert] {
var aa = [Alert]() var aa = [Alert]()

View File

@ -49,7 +49,7 @@ public extension ProHUD {
public var isFullScreen = false public var isFullScreen = false
/// ///
private var displaying = false private var isDisplaying = false
/// ///
public var backgroundColor: UIColor? = UIColor(white: 0, alpha: 0.4) public var backgroundColor: UIColor? = UIColor(white: 0, alpha: 0.4)
@ -57,7 +57,7 @@ public extension ProHUD {
public var vm = ViewModel() public var vm = ViewModel()
// MARK: // MARK:
internal var isLoadFinished = false private var isLoadFinished = false
/// ///
/// - Parameter title: /// - Parameter title:
@ -106,10 +106,10 @@ public extension Guard {
view.snp.makeConstraints { (mk) in view.snp.makeConstraints { (mk) in
mk.edges.equalToSuperview() mk.edges.equalToSuperview()
} }
if displaying == false { if isDisplaying == false {
privTranslateOut() privTranslateOut()
} }
displaying = true isDisplaying = true
UIView.animateForGuard { UIView.animateForGuard {
self.privTranslateIn() self.privTranslateIn()
} }
@ -124,16 +124,16 @@ public extension Guard {
/// ///
func pop() { func pop() {
if displaying { if isDisplaying {
debug("pop") debug("pop")
willDisappearCallback?() willDisappearCallback?()
displaying = false isDisplaying = false
view.isUserInteractionEnabled = false view.isUserInteractionEnabled = false
self.removeFromParent() self.removeFromParent()
UIView.animateForGuard(animations: { UIView.animateForGuard(animations: {
self.privTranslateOut() self.privTranslateOut()
}) { (done) in }) { (done) in
if self.displaying == false { if self.isDisplaying == false {
self.view.removeFromSuperview() self.view.removeFromSuperview()
} }
} }
@ -162,7 +162,7 @@ public extension Guard {
return Guard(actions: actions).push(to: viewController) return Guard(actions: actions).push(to: viewController)
} }
/// ///
/// - Parameter identifier: /// - Parameter identifier:
class func find(_ identifier: String?, from viewController: UIViewController? = nil) -> [Guard] { class func find(_ identifier: String?, from viewController: UIViewController? = nil) -> [Guard] {
var gg = [Guard]() var gg = [Guard]()

View File

@ -173,6 +173,8 @@ public extension Toast {
vm.tapCallback = callback vm.tapCallback = callback
} }
///
/// - Parameter rotate:
func animate(rotate: Bool) { func animate(rotate: Bool) {
if rotate { if rotate {
DispatchQueue.main.async { DispatchQueue.main.async {
@ -187,6 +189,21 @@ public extension Toast {
} }
} }
///
func pulse() {
DispatchQueue.main.async {
UIView.animate(withDuration: 0.2, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: [.allowUserInteraction, .curveEaseOut], animations: {
self.window?.transform = .init(scaleX: 1.04, y: 1.04)
}) { (done) in
UIView.animate(withDuration: 1, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 1, options: [.allowUserInteraction, .curveEaseIn], animations: {
self.window?.transform = .identity
}) { (done) in
}
}
}
}
} }
@ -202,7 +219,7 @@ public extension Toast {
return Toast(scene: scene, title: title, message: message, duration: duration, actions: actions).push() return Toast(scene: scene, title: title, message: message, duration: duration, actions: actions).push()
} }
/// toast ///
/// - Parameter identifier: /// - Parameter identifier:
class func find(_ identifier: String?) -> [Toast] { class func find(_ identifier: String?) -> [Toast] {
var tt = [Toast]() var tt = [Toast]()