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 {
Toast.find("aaa", last: { (t) in
t.update { (vm) in
t.pulse()
t.update() { (vm) in
vm.title = "已经存在了"
}
}) {

View File

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

View File

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

View File

@ -173,6 +173,8 @@ public extension Toast {
vm.tapCallback = callback
}
///
/// - Parameter rotate:
func animate(rotate: Bool) {
if rotate {
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()
}
/// toast
///
/// - Parameter identifier:
class func find(_ identifier: String?) -> [Toast] {
var tt = [Toast]()