This commit is contained in:
xaoxuu 2019-08-06 20:09:16 +08:00
parent d182b5fede
commit 0da83c80b5
8 changed files with 49 additions and 28 deletions

View File

@ -165,7 +165,15 @@ fileprivate var privReloadData: (ProHUD.Alert) -> Void = {
}
vc.imageView = icon
}
if vc.model.scene == .loading {
let ani = CABasicAnimation(keyPath: "transform.rotation.z")
ani.toValue = M_PI*2.0
ani.duration = 2
ani.repeatCount = 10000
vc.imageView?.layer.add(ani, forKey: "rotationAnimation")
} else {
vc.imageView?.layer.removeAllAnimations()
}
// text
if vc.model.title?.count ?? 0 > 0 || vc.model.message?.count ?? 0 > 0 {
vc.contentStack.addArrangedSubview(vc.textStack)
@ -263,6 +271,15 @@ fileprivate var privReloadData: (ProHUD.Alert) -> Void = {
vc.view.layoutIfNeeded()
}
}
switch vc.model.scene {
case .loading:
vc.model.duration = nil
default:
vc.model.duration = 2
}
if vc.actionStack.arrangedSubviews.count > 0 {
vc.model.duration = nil
}
}
}()

View File

@ -64,12 +64,6 @@ public extension ProHUD {
model.title = title
model.message = message
model.icon = icon
switch scene {
case .loading:
model.duration = nil
default:
model.duration = 2
}
willLayoutSubviews()
@ -166,7 +160,7 @@ public extension ProHUD.Alert {
model.scene = scene
model.title = title
model.message = message
cfg.alert.reloadData(self)
willLayoutSubviews()
return self
}
@ -175,6 +169,7 @@ public extension ProHUD.Alert {
@discardableResult func update(icon: UIImage?) -> ProHUD.Alert {
model.icon = icon
cfg.alert.reloadData(self)
imageView?.layer.removeAllAnimations()
return self
}
@ -230,6 +225,7 @@ public extension ProHUD {
///
/// - Parameter alert:
@discardableResult func push(_ alert: Alert) -> Alert {
if alerts.contains(alert) == false {
let window = getAlertWindow(alert)
window.makeKeyAndVisible()
window.resignKey()
@ -242,6 +238,7 @@ public extension ProHUD {
window.backgroundColor = window.backgroundColor?.withAlphaComponent(0.6)
}
alerts.append(alert)
}
updateAlertsLayout()
// setup duration
if let _ = alert.model.duration, alert.model.durationBlock == nil {
@ -436,9 +433,11 @@ fileprivate extension ProHUD {
if alerts.count > 1 {
for (i, a) in alerts.enumerated() {
if a == alert {
if i < alerts.count {
alerts.remove(at: i)
}
}
}
updateAlertsLayout()
} else if alerts.count == 1 {
alerts.removeAll()

View File

@ -17,7 +17,7 @@ public class HUDController: UIViewController {
internal var disappearCallback: (() -> Void)?
///
internal var buttonEvents = [UIButton:() -> Void]()
fileprivate var buttonEvents = [UIButton:() -> Void]()
init() {
super.init(nibName: nil, bundle: nil)

View File

@ -33,8 +33,11 @@ public extension ProHUD {
if #available(iOS 13.0, *) {
super.init(effect: UIBlurEffect(style: .systemMaterial))
} else {
} else if #available(iOS 11.0, *) {
super.init(effect: UIBlurEffect(style: .extraLight))
} else {
super.init(effect: .none)
backgroundColor = .white
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -123,5 +123,13 @@ fileprivate var privReloadData: (ProHUD.Toast) -> Void = {
}
vc.view.layoutIfNeeded()
switch vc.model.scene {
case .loading:
vc.model.duration = nil
default:
vc.model.duration = 3
}
}
}()

View File

@ -71,12 +71,6 @@ public extension ProHUD {
model.title = title
model.message = message
model.icon = icon
switch scene {
case .loading:
model.duration = nil
default:
model.duration = 2
}
//
cfg.toast.loadSubviews(self)