mirror of https://github.com/xaoxuu/ProHUD
update
This commit is contained in:
parent
082e976f5a
commit
1da5242844
|
@ -17,7 +17,7 @@ class ViewController: UIViewController {
|
||||||
|
|
||||||
|
|
||||||
ProHUD.configAlert { (alert) in
|
ProHUD.configAlert { (alert) in
|
||||||
alert.minimizeTimeout = 1
|
alert.minimizeTimeout = 5
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +26,23 @@ class ViewController: UIViewController {
|
||||||
|
|
||||||
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
|
|
||||||
ProHUD.show(alert: .delete, title: "确认删除", message: "此操作不可撤销").timeout(nil)
|
let a = ProHUD.show(alert: .delete, title: "确认删除", message: "此操作不可撤销")
|
||||||
|
a.addAction(style: .destructive, title: "确认", action: { [weak a] in
|
||||||
|
a?.removeAction(index: 0).removeAction(index: 0)
|
||||||
|
a?.updateContent(scene: .loading, title: "正在删除", message: "请稍后片刻")
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now()+1) {
|
||||||
|
a?.updateContent(scene: .success, title: "删除成功", message: "啊哈哈哈哈").timeout(2)
|
||||||
|
a?.addAction(style: .default, title: "我知道了", action: {
|
||||||
|
// a?.remove()
|
||||||
|
a?.removeAction(index: 0)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).addAction(style: .cancel, title: "取消", action: nil)
|
||||||
|
|
||||||
ProHUD.show(alert: .loading, title: "确认删除", message: "此操作不可撤销").timeout(nil)
|
//
|
||||||
|
// ProHUD.show(alert: .loading, title: "确认删除", message: "此操作不可撤销").timeout(nil)
|
||||||
ProHUD.show(alert: .confirm, title: "确认删除", message: "此操作不可撤销").timeout(3)
|
//
|
||||||
|
// ProHUD.show(alert: .confirm, title: "确认删除", message: "此操作不可撤销").timeout(3)
|
||||||
|
|
||||||
//
|
//
|
||||||
// a.addAction(style: .destructive, title: "删除") { [weak a] in
|
// a.addAction(style: .destructive, title: "删除") { [weak a] in
|
||||||
|
|
|
@ -60,6 +60,7 @@ public extension ProHUD.Configuration {
|
||||||
lazy var loadSubviews: (ProHUD.Alert, Alert) -> Void = {
|
lazy var loadSubviews: (ProHUD.Alert, Alert) -> Void = {
|
||||||
return { (vc, config) in
|
return { (vc, config) in
|
||||||
debugPrint(vc, "loadSubviews")
|
debugPrint(vc, "loadSubviews")
|
||||||
|
if vc.contentView.superview == nil {
|
||||||
vc.view.addSubview(vc.contentView)
|
vc.view.addSubview(vc.contentView)
|
||||||
vc.contentView.contentView.addSubview(vc.contentStack)
|
vc.contentView.contentView.addSubview(vc.contentStack)
|
||||||
|
|
||||||
|
@ -79,6 +80,7 @@ public extension ProHUD.Configuration {
|
||||||
mk.leading.equalToSuperview().offset(alertConfig.padding)
|
mk.leading.equalToSuperview().offset(alertConfig.padding)
|
||||||
mk.trailing.equalToSuperview().offset(-alertConfig.padding)
|
mk.trailing.equalToSuperview().offset(-alertConfig.padding)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -184,7 +186,15 @@ public extension ProHUD.Configuration {
|
||||||
vc.textStack.removeFromSuperview()
|
vc.textStack.removeFromSuperview()
|
||||||
}
|
}
|
||||||
if vc.actionStack.superview != nil {
|
if vc.actionStack.superview != nil {
|
||||||
|
if isFirstLayout {
|
||||||
vc.contentStack.addArrangedSubview(vc.actionStack)
|
vc.contentStack.addArrangedSubview(vc.actionStack)
|
||||||
|
} else {
|
||||||
|
vc.actionStack.transform = .init(scaleX: 1, y: 0.001)
|
||||||
|
UIView.animateForAlert {
|
||||||
|
vc.contentStack.addArrangedSubview(vc.actionStack)
|
||||||
|
vc.view.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
// 适配横竖屏和iPad
|
// 适配横竖屏和iPad
|
||||||
if isPortrait == false {
|
if isPortrait == false {
|
||||||
vc.actionStack.axis = .horizontal
|
vc.actionStack.axis = .horizontal
|
||||||
|
@ -195,18 +205,26 @@ public extension ProHUD.Configuration {
|
||||||
mk.width.greaterThanOrEqualTo(200)
|
mk.width.greaterThanOrEqualTo(200)
|
||||||
mk.leading.trailing.equalToSuperview()
|
mk.leading.trailing.equalToSuperview()
|
||||||
}
|
}
|
||||||
|
if isFirstLayout == false {
|
||||||
|
UIView.animateForAlert {
|
||||||
|
vc.actionStack.transform = .identity
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if isFirstLayout {
|
if isFirstLayout {
|
||||||
vc.view.layoutIfNeeded()
|
vc.view.layoutIfNeeded()
|
||||||
vc.imageView?.transform = .init(scaleX: 0.75, y: 0.75)
|
vc.imageView?.transform = .init(scaleX: 0.75, y: 0.75)
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
UIView.animateForAlert {
|
UIView.animateForAlert {
|
||||||
vc.imageView?.transform = .identity
|
vc.imageView?.transform = .identity
|
||||||
vc.view.layoutIfNeeded()
|
vc.view.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
UIView.animateForAlert {
|
||||||
|
vc.view.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,13 @@ public extension ProHUD {
|
||||||
if actionStack.superview == nil {
|
if actionStack.superview == nil {
|
||||||
contentStack.addArrangedSubview(actionStack)
|
contentStack.addArrangedSubview(actionStack)
|
||||||
}
|
}
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
|
button.transform = .init(scaleX: 1, y: 0.001)
|
||||||
actionStack.addArrangedSubview(button)
|
actionStack.addArrangedSubview(button)
|
||||||
|
UIView.animateForAlert {
|
||||||
|
button.transform = .identity
|
||||||
|
self.view.layoutIfNeeded()
|
||||||
|
}
|
||||||
addTouchUpAction(for: button) { [weak self] in
|
addTouchUpAction(for: button) { [weak self] in
|
||||||
action?()
|
action?()
|
||||||
if button.tag == UIAlertAction.Style.cancel.rawValue {
|
if button.tag == UIAlertAction.Style.cancel.rawValue {
|
||||||
|
@ -201,14 +207,16 @@ public extension ProHUD {
|
||||||
} else if index < self.actionStack.arrangedSubviews.count, let btn = self.actionStack.arrangedSubviews[index] as? UIButton {
|
} else if index < self.actionStack.arrangedSubviews.count, let btn = self.actionStack.arrangedSubviews[index] as? UIButton {
|
||||||
btn.removeFromSuperview()
|
btn.removeFromSuperview()
|
||||||
}
|
}
|
||||||
|
if self.actionStack.arrangedSubviews.count == 0 {
|
||||||
|
self.actionStack.removeFromSuperview()
|
||||||
|
}
|
||||||
|
willLayoutSubviews()
|
||||||
UIView.animateForAlert {
|
UIView.animateForAlert {
|
||||||
self.view.layoutIfNeeded()
|
self.view.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,7 +365,7 @@ public extension ProHUD {
|
||||||
return shared.show(toast: toast, title: title, message: message, icon: icon)
|
return shared.show(toast: toast, title: title, message: message, icon: icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
class func alert(identifier: String?) -> [Toast] {
|
class func toast(identifier: String?) -> [Toast] {
|
||||||
return shared.toasts(identifier: identifier)
|
return shared.toasts(identifier: identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue