From 0da83c80b58a84905724dc462cb1e816612f29e7 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Tue, 6 Aug 2019 20:09:16 +0800 Subject: [PATCH] update --- ProHUD/Alert/AlertConfig.swift | 19 ++++++++- ProHUD/Alert/AlertController.swift | 37 +++++++++--------- ProHUD/HUDController.swift | 2 +- ProHUD/HUDView.swift | 5 ++- .../ProHUDLoading@2x.png | Bin 3223 -> 2538 bytes .../ProHUDLoading@3x.png | Bin 4487 -> 3399 bytes ProHUD/Toast/ToastConfig.swift | 8 ++++ ProHUD/Toast/ToastController.swift | 6 --- 8 files changed, 49 insertions(+), 28 deletions(-) diff --git a/ProHUD/Alert/AlertConfig.swift b/ProHUD/Alert/AlertConfig.swift index 80dd8f5..9a0e624 100644 --- a/ProHUD/Alert/AlertConfig.swift +++ b/ProHUD/Alert/AlertConfig.swift @@ -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 + } } }() diff --git a/ProHUD/Alert/AlertController.swift b/ProHUD/Alert/AlertController.swift index 9077194..369ec18 100644 --- a/ProHUD/Alert/AlertController.swift +++ b/ProHUD/Alert/AlertController.swift @@ -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,18 +225,20 @@ public extension ProHUD { /// 推入屏幕 /// - Parameter alert: 实例 @discardableResult func push(_ alert: Alert) -> Alert { - let window = getAlertWindow(alert) - window.makeKeyAndVisible() - window.resignKey() - window.addSubview(alert.view) - alert.view.transform = .init(scaleX: 1.2, y: 1.2) - alert.view.alpha = 0 - UIView.animateForAlertBuildIn { - alert.view.transform = .identity - alert.view.alpha = 1 - window.backgroundColor = window.backgroundColor?.withAlphaComponent(0.6) + if alerts.contains(alert) == false { + let window = getAlertWindow(alert) + window.makeKeyAndVisible() + window.resignKey() + window.addSubview(alert.view) + alert.view.transform = .init(scaleX: 1.2, y: 1.2) + alert.view.alpha = 0 + UIView.animateForAlertBuildIn { + alert.view.transform = .identity + alert.view.alpha = 1 + window.backgroundColor = window.backgroundColor?.withAlphaComponent(0.6) + } + alerts.append(alert) } - alerts.append(alert) updateAlertsLayout() // setup duration if let _ = alert.model.duration, alert.model.durationBlock == nil { @@ -436,7 +433,9 @@ fileprivate extension ProHUD { if alerts.count > 1 { for (i, a) in alerts.enumerated() { if a == alert { - alerts.remove(at: i) + if i < alerts.count { + alerts.remove(at: i) + } } } updateAlertsLayout() diff --git a/ProHUD/HUDController.swift b/ProHUD/HUDController.swift index cb858b1..c79d081 100644 --- a/ProHUD/HUDController.swift +++ b/ProHUD/HUDController.swift @@ -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) diff --git a/ProHUD/HUDView.swift b/ProHUD/HUDView.swift index dfc2676..f9aed8d 100644 --- a/ProHUD/HUDView.swift +++ b/ProHUD/HUDView.swift @@ -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 } } diff --git a/ProHUD/ProHUD.xcassets/ProHUDLoading.imageset/ProHUDLoading@2x.png b/ProHUD/ProHUD.xcassets/ProHUDLoading.imageset/ProHUDLoading@2x.png index 6357f41fef458d242c64f6cef60aeaa0f1215012..2f37d0169c458b17a7313dd929d5d3423a165afa 100644 GIT binary patch delta 1461 zcmZwGYdF&j90%}i)-;itWXoKVS?)wQs^yx^Z5dl6a&H=)l{?d4nrc}to0w>usN)=2 zD@&4?TtlgzlVeUrr9-(bEm^soUYzGSm*@Q6e4p?4_2*ZH`k*DoLxDAHf`@BRI(X(# zC{2&NNtEbab^b>OKQ`hDY%4`gBZyHnSrOEE9_g{2H{{KlvBt09Lu&yyHI3ozM&ZKR zdRA0aC-tlFoVK}r*~nbok>W_6EGaZ=P==+o_wXC6r{?Qrc1a7eq|})mwlFq0T8gxR zu}@Ku=|b%~=Y4?S%%x~OvcZ+5aIgA!(+;VmBZ!R9Hrjid;gAjtG&_^>7~Pxmn0SamA~9wE7u&M&PaeIy2sM0cko|baZ{J7`@Rs))$=yr~ zYQunrqxXDX?=1q43kLU_i!n#i!%;hx4`OA;%*r>Ci(bvYet{~C4U+Ktafu}vlV^CYC=y4EqJ z_R5~IwR9~f%_Wdz>)D88H75|geicI3wfS4oUzq-3N{`Y8UgVC(Y0%MW8(QFRGWIsjE8l1@UOX}=F6Ey*88S;X`OwX zy%VNNtJ`~4OJhRjm7hj)@=b|}r=R%zegZyVuJaT-J{<(Vqo#D3J_=4ItE6k6Y$Xc1Lejra;;GmHBGHd;rV?aIy!XKrSXViG&E`AHY6@h4SAeS&F zCVc~+dP@c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H)6GZ#%9~_6A|CN(4+_jZ{$6X!t=bGgJPaYi5h}$SPah7LON72Jci@y^+rDLcv@;OP>?U4lKFhg1ViEVzZC#4at7` z@i67#BNl*R92~D{G|pSb8Ax3&?A zI#_D&4UJhnkN$d3)qF!w+Ccw@`AXJ(qb)FnA?}jjv z8k&5^2-!vAPC3x)yq5`zPCg2VJvraU!qZp1$^3jMK+wPkoDl%aXS~yf7J8cg)Pch! zdFQYJZ7JExaD}MoDW3I7w>}q0mAj+67bM)6e^2Xy(6}5-C3a&40W}TGr3c zh>F?N_ie%4kGw3LQqNlK{LHpvmdl+uOv!busFsB`k|ZVwVtX?F4$hadDHhOwKj-US z33qwB^>O()lcF)^U^{A8^9^9AP&u(*dz64)T~|*Z@lXQ!6Jt;{n}?q^zRLYk-aflc z8bEk}bZR9opGeK!IUOtV^$5z6SB6Ms;nvLT5sY-6Wa+l-?|0KSzQ3Y9G4$ZWqKBIn z%u4onv0EzU61ya-z|%fhC(^8_Td%xFBfW}xtG%|}_5JK<=EZhnf;0T5%nhl&t3N#z zere_mM2p_k{znq;n#LBy9oksYEAOVkS`>c|&Id`riJ|`&W(l-2& Void = { } vc.view.layoutIfNeeded() + switch vc.model.scene { + case .loading: + vc.model.duration = nil + default: + vc.model.duration = 3 + } + } + }() diff --git a/ProHUD/Toast/ToastController.swift b/ProHUD/Toast/ToastController.swift index b9b86f8..2143e45 100644 --- a/ProHUD/Toast/ToastController.swift +++ b/ProHUD/Toast/ToastController.swift @@ -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)