diff --git a/CHANGELOG.md b/CHANGELOG.md index 319839a..8fc6b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## [14.1.0](https://github.com/relatedcode/ProgressHUD/releases/tag/14.1.0) + +Released on 2023-10-15. + +#### Changed + +- Renamed the `AnimatedIcon` enum to `LiveIcon`. +- The general `show` method has been split into multiple specialized methods: `animate`, `progress`, `liveIcon`, `image`, `symbol`. +- Updated the Static Image SF Symbol weight configuration to utilize a bold setting. +- Conducted minor code improvements for better maintainability and performance. + ## [14.0.0](https://github.com/relatedcode/ProgressHUD/releases/tag/14.0.0) Released on 2023-10-14. diff --git a/ProgressHUD.podspec b/ProgressHUD.podspec index d9dd599..975d667 100644 --- a/ProgressHUD.podspec +++ b/ProgressHUD.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'ProgressHUD' - s.version = '14.0.0' + s.version = '14.1.0' s.license = 'MIT' s.summary = 'A lightweight and easy-to-use Progress HUD for iOS.' diff --git a/ProgressHUD/Sources/Animations/ProgressHUD+SFSymbolBounce.swift b/ProgressHUD/Sources/Animations/ProgressHUD+SFSymbolBounce.swift index e26d511..4c4cfba 100644 --- a/ProgressHUD/Sources/Animations/ProgressHUD+SFSymbolBounce.swift +++ b/ProgressHUD/Sources/Animations/ProgressHUD+SFSymbolBounce.swift @@ -19,10 +19,10 @@ extension ProgressHUD { let height = view.frame.height let image = UIImage(systemName: animationSymbol) ?? UIImage(systemName: "questionmark") + let config = UIImage.SymbolConfiguration(weight: .bold) let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: width, height: height)) - let configuration = UIImage.SymbolConfiguration(weight: .bold) - imageView.image = image?.applyingSymbolConfiguration(configuration) + imageView.image = image?.applyingSymbolConfiguration(config) imageView.tintColor = colorAnimation imageView.contentMode = .scaleAspectFit diff --git a/ProgressHUD/Sources/ProgressHUD+Enums.swift b/ProgressHUD/Sources/ProgressHUD+Enums.swift index 0eefe80..4b3fffe 100644 --- a/ProgressHUD/Sources/ProgressHUD+Enums.swift +++ b/ProgressHUD/Sources/ProgressHUD+Enums.swift @@ -37,8 +37,8 @@ public enum AnimationType: CaseIterable { case triangleDotShift } -// MARK: - AnimatedIcon -public enum AnimatedIcon { +// MARK: - LiveIcon +public enum LiveIcon { case succeed case failed case added diff --git a/ProgressHUD/Sources/ProgressHUD+AnimatedIcon.swift b/ProgressHUD/Sources/ProgressHUD+LiveIcon.swift similarity index 94% rename from ProgressHUD/Sources/ProgressHUD+AnimatedIcon.swift rename to ProgressHUD/Sources/ProgressHUD+LiveIcon.swift index e722033..8b0ba3d 100644 --- a/ProgressHUD/Sources/ProgressHUD+AnimatedIcon.swift +++ b/ProgressHUD/Sources/ProgressHUD+LiveIcon.swift @@ -11,10 +11,10 @@ import UIKit -// MARK: - Succeed +// MARK: - Live Icon Succeed extension ProgressHUD { - func animatedIconSucceed(_ view: UIView) { + func liveIconSucceed(_ view: UIView) { let length = view.frame.width let delay = (alpha == 0) ? 0.25 : 0.0 @@ -45,10 +45,10 @@ extension ProgressHUD { } } -// MARK: - Failed +// MARK: - Live Icon Failed extension ProgressHUD { - func animatedIconFailed(_ view: UIView) { + func liveIconFailed(_ view: UIView) { let length = view.frame.width let delay = (alpha == 0) ? 0.25 : 0.0 @@ -88,10 +88,10 @@ extension ProgressHUD { } } -// MARK: - Added +// MARK: - Live Icon Added extension ProgressHUD { - func animatedIconAdded(_ view: UIView) { + func liveIconAdded(_ view: UIView) { let length = view.frame.width let delay = (alpha == 0) ? 0.25 : 0.0 diff --git a/ProgressHUD/Sources/ProgressHUD+Public.swift b/ProgressHUD/Sources/ProgressHUD+Public.swift index a183275..0dace93 100644 --- a/ProgressHUD/Sources/ProgressHUD+Public.swift +++ b/ProgressHUD/Sources/ProgressHUD+Public.swift @@ -109,7 +109,7 @@ public extension ProgressHUD { } } -// MARK: - HUD General +// MARK: - HUD Removal public extension ProgressHUD { class func dismiss() { @@ -123,44 +123,54 @@ public extension ProgressHUD { shared.removeHUD() } } +} - class func show(_ text: String? = nil, interaction: Bool = true) { +// MARK: - Progress +public extension ProgressHUD { + + class func progress(_ value: CGFloat, interaction: Bool = false) { DispatchQueue.main.async { - shared.setup(text: text, interaction: interaction) + shared.progress(text: nil, value: value, interaction: interaction) + } + } + + class func progress(_ text: String?, _ value: CGFloat, interaction: Bool = false) { + DispatchQueue.main.async { + shared.progress(text: text, value: value, interaction: interaction) } } } -// MARK: - Animated Icon +// MARK: - Live Icon public extension ProgressHUD { - class func show(_ text: String? = nil, icon: AnimatedIcon, interaction: Bool = true, delay: TimeInterval? = nil) { + class func liveIcon(_ text: String? = nil, icon: LiveIcon, interaction: Bool = true, delay: TimeInterval? = nil) { DispatchQueue.main.async { - shared.setup(text: text, animatedIcon: icon, interaction: interaction, delay: delay) + shared.liveIcon(text: text, icon: icon, interaction: interaction, delay: delay) } } - class func showSucceed(_ text: String? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { + class func succeed(_ text: String? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { DispatchQueue.main.async { - shared.setup(text: text, animatedIcon: .succeed, interaction: interaction, delay: delay) + shared.liveIcon(text: text, icon: .succeed, interaction: interaction, delay: delay) } } - class func showFailed(_ text: String? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { + class func failed(_ text: String? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { DispatchQueue.main.async { - shared.setup(text: text, animatedIcon: .failed, interaction: interaction, delay: delay) + shared.liveIcon(text: text, icon: .failed, interaction: interaction, delay: delay) } } - class func showFailed(_ error: Error?, interaction: Bool = true, delay: TimeInterval? = nil) { + class func failed(_ error: Error?, interaction: Bool = true, delay: TimeInterval? = nil) { DispatchQueue.main.async { - shared.setup(text: error?.localizedDescription, animatedIcon: .failed, interaction: interaction, delay: delay) + shared.liveIcon(text: error?.localizedDescription, icon: .failed, interaction: interaction, delay: delay) } } - class func showAdded(_ text: String? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { + class func added(_ text: String? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { DispatchQueue.main.async { - shared.setup(text: text, animatedIcon: .added, interaction: interaction, delay: delay) + shared.liveIcon(text: text, icon: .added, interaction: interaction, delay: delay) } } } @@ -168,45 +178,62 @@ public extension ProgressHUD { // MARK: - Static Image public extension ProgressHUD { - class func show(_ text: String? = nil, symbol: String, interaction: Bool = true, delay: TimeInterval? = nil) { + class func image(_ text: String? = nil, image: UIImage?, interaction: Bool = true, delay: TimeInterval? = nil) { DispatchQueue.main.async { - let image = UIImage(systemName: symbol) ?? UIImage(systemName: "questionmark") - let colored = image?.withTintColor(shared.colorAnimation, renderingMode: .alwaysOriginal) - shared.setup(text: text, staticImage: colored, interaction: interaction, delay: delay) + shared.staticImage(text: text, image: image, interaction: interaction, delay: delay) } } - class func showSuccess(_ text: String? = nil, image: UIImage? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { + class func symbol(_ text: String? = nil, name: String, interaction: Bool = true, delay: TimeInterval? = nil) { DispatchQueue.main.async { - shared.setup(text: text, staticImage: image ?? shared.imageSuccess, interaction: interaction, delay: delay) + let image = UIImage(systemName: name) ?? UIImage(systemName: "questionmark") + let config = UIImage.SymbolConfiguration(weight: .bold) + let modified = image?.applyingSymbolConfiguration(config) + let colored = modified?.withTintColor(colorAnimation, renderingMode: .alwaysOriginal) + shared.staticImage(text: text, image: colored, interaction: interaction, delay: delay) } } - class func showError(_ text: String? = nil, image: UIImage? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { + class func success(_ text: String? = nil, image: UIImage? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { DispatchQueue.main.async { - shared.setup(text: text, staticImage: image ?? shared.imageError, interaction: interaction, delay: delay) + shared.staticImage(text: text, image: image ?? imageSuccess, interaction: interaction, delay: delay) } } - class func showError(_ error: Error?, image: UIImage? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { + class func error(_ text: String? = nil, image: UIImage? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { DispatchQueue.main.async { - shared.setup(text: error?.localizedDescription, staticImage: image ?? shared.imageError, interaction: interaction, delay: delay) + shared.staticImage(text: text, image: image ?? imageError, interaction: interaction, delay: delay) + } + } + + class func error(_ error: Error?, image: UIImage? = nil, interaction: Bool = true, delay: TimeInterval? = nil) { + DispatchQueue.main.async { + shared.staticImage(text: error?.localizedDescription, image: image ?? imageError, interaction: interaction, delay: delay) } } } -// MARK: - Progress +// MARK: - Animation public extension ProgressHUD { - class func showProgress(_ progress: CGFloat, interaction: Bool = false) { + class func animate(_ text: String? = nil, interaction: Bool = true) { + DispatchQueue.main.async { + shared.animate(text: text, interaction: interaction) + } + } + + class func animate(_ text: String? = nil, _ type: AnimationType, interaction: Bool = true) { DispatchQueue.main.async { - shared.setup(text: nil, progress: progress, interaction: interaction) + animationType = type + shared.animate(text: text, interaction: interaction) } } - class func showProgress(_ text: String?, _ progress: CGFloat, interaction: Bool = false) { + class func animate(_ text: String? = nil, symbol: String, interaction: Bool = true) { DispatchQueue.main.async { - shared.setup(text: text, progress: progress, interaction: interaction) + animationType = .sfSymbolBounce + animationSymbol = symbol + shared.animate(text: text, interaction: interaction) } } } @@ -214,13 +241,13 @@ public extension ProgressHUD { // MARK: - Banner public extension ProgressHUD { - class func showBanner(_ title: String?, _ message: String?, delay: TimeInterval = 3.0) { + class func banner(_ title: String?, _ message: String?, delay: TimeInterval = 3.0) { DispatchQueue.main.async { shared.showBanner(title: title, message: message, delay: delay) } } - class func hideBanner() { + class func bannerHide() { DispatchQueue.main.async { shared.hideBanner() } diff --git a/ProgressHUD/Sources/ProgressHUD.swift b/ProgressHUD/Sources/ProgressHUD.swift index af60eb1..7bb7e11 100644 --- a/ProgressHUD/Sources/ProgressHUD.swift +++ b/ProgressHUD/Sources/ProgressHUD.swift @@ -42,7 +42,7 @@ public class ProgressHUD: UIView { var labelStatus: UILabel? var viewProgress: ProgressView? - var viewAnimatedIcon: UIView? + var viewLiveIcon: UIView? var viewStaticImage: UIImageView? var viewAnimation: UIView? @@ -85,10 +85,10 @@ public class ProgressHUD: UIView { } } -// MARK: - Setup +// MARK: - Progress extension ProgressHUD { - func setup(text: String?, progress: CGFloat? = nil, animatedIcon: AnimatedIcon? = nil, staticImage: UIImage? = nil, interaction: Bool, delay: TimeInterval? = nil) { + func progress(text: String?, value: CGFloat, interaction: Bool) { removeDelayTimer() @@ -97,34 +97,86 @@ extension ProgressHUD { setupToolbar() setupStatus(text) - var animation = false - - if let progress { - removeAnimatedIcon() - removeStaticImage() - removeAnimationView() - setupProgressView(progress) - } else if let animatedIcon { - removeProgressView() - removeStaticImage() - removeAnimationView() - setupAnimatedIcon(animatedIcon) - setupDelayTimer(text, delay) - } else if let staticImage { - removeProgressView() - removeAnimatedIcon() - removeAnimationView() - setupStaticImage(staticImage) - setupDelayTimer(text, delay) - } else { - removeProgressView() - removeAnimatedIcon() - removeStaticImage() - setupAnimationView() - animation = true - } + removeLiveIcon() + removeStaticImage() + removeAnimationView() + setupProgressView(value) - setupSizes(text, animation) + setupSizes(text, false) + setupNotifications() + setupPosition() + displayHUD() + } +} + +// MARK: - Live Icon +extension ProgressHUD { + + func liveIcon(text: String?, icon: LiveIcon, interaction: Bool, delay: TimeInterval?) { + + removeDelayTimer() + + setupWindow() + setupBackground(interaction) + setupToolbar() + setupStatus(text) + + removeStaticImage() + removeProgressView() + removeAnimationView() + setupLiveIcon(icon) + setupDelayTimer(text, delay) + + setupSizes(text, false) + setupNotifications() + setupPosition() + displayHUD() + } +} + +// MARK: - Static Image +extension ProgressHUD { + + func staticImage(text: String?, image: UIImage?, interaction: Bool, delay: TimeInterval?) { + + removeDelayTimer() + + setupWindow() + setupBackground(interaction) + setupToolbar() + setupStatus(text) + + removeLiveIcon() + removeProgressView() + removeAnimationView() + setupStaticImage(image) + setupDelayTimer(text, delay) + + setupSizes(text, false) + setupNotifications() + setupPosition() + displayHUD() + } +} + +// MARK: - Animation +extension ProgressHUD { + + func animate(text: String?, interaction: Bool) { + + removeDelayTimer() + + setupWindow() + setupBackground(interaction) + setupToolbar() + setupStatus(text) + + removeLiveIcon() + removeStaticImage() + removeProgressView() + setupAnimationView() + + setupSizes(text, true) setupNotifications() setupPosition() displayHUD() @@ -255,7 +307,7 @@ extension ProgressHUD { viewProgress = nil } - private func setupProgressView(_ progress: CGFloat) { + private func setupProgressView(_ value: CGFloat) { if (viewProgress == nil) { viewProgress = ProgressView(colorProgress) viewProgress?.frame = CGRect(x: 0, y: 0, width: mediaSize, height: mediaSize) @@ -267,36 +319,36 @@ extension ProgressHUD { toolbarHUD?.addSubview(viewProgress) } - viewProgress.setProgress(progress) + viewProgress.setProgress(value) } } -// MARK: - Animated Icon +// MARK: - Live Icon extension ProgressHUD { - private func removeAnimatedIcon() { - viewAnimatedIcon?.removeFromSuperview() - viewAnimatedIcon = nil + private func removeLiveIcon() { + viewLiveIcon?.removeFromSuperview() + viewLiveIcon = nil } - private func setupAnimatedIcon(_ animatedIcon: AnimatedIcon) { - if (viewAnimatedIcon == nil) { - viewAnimatedIcon = UIView(frame: CGRect(x: 0, y: 0, width: mediaSize, height: mediaSize)) + private func setupLiveIcon(_ icon: LiveIcon) { + if (viewLiveIcon == nil) { + viewLiveIcon = UIView(frame: CGRect(x: 0, y: 0, width: mediaSize, height: mediaSize)) } - guard let viewAnimatedIcon = viewAnimatedIcon else { return } + guard let viewLiveIcon = viewLiveIcon else { return } - if (viewAnimatedIcon.superview == nil) { - toolbarHUD?.addSubview(viewAnimatedIcon) + if (viewLiveIcon.superview == nil) { + toolbarHUD?.addSubview(viewLiveIcon) } - viewAnimatedIcon.layer.sublayers?.forEach { + viewLiveIcon.layer.sublayers?.forEach { $0.removeFromSuperlayer() } - if (animatedIcon == .succeed) { animatedIconSucceed(viewAnimatedIcon) } - if (animatedIcon == .failed) { animatedIconFailed(viewAnimatedIcon) } - if (animatedIcon == .added) { animatedIconAdded(viewAnimatedIcon) } + if (icon == .succeed) { liveIconSucceed(viewLiveIcon) } + if (icon == .failed) { liveIconFailed(viewLiveIcon) } + if (icon == .added) { liveIconAdded(viewLiveIcon) } } } @@ -308,7 +360,7 @@ extension ProgressHUD { viewStaticImage = nil } - private func setupStaticImage(_ staticImage: UIImage) { + private func setupStaticImage(_ image: UIImage?) { if (viewStaticImage == nil) { viewStaticImage = UIImageView(frame: CGRect(x: 0, y: 0, width: mediaSize, height: mediaSize)) } @@ -319,7 +371,7 @@ extension ProgressHUD { toolbarHUD?.addSubview(viewStaticImage) } - viewStaticImage.image = staticImage + viewStaticImage.image = image viewStaticImage.contentMode = .scaleAspectFit } } @@ -431,7 +483,7 @@ extension ProgressHUD { toolbarHUD?.bounds = CGRect(x: 0, y: 0, width: ceil(width), height: ceil(height)) viewProgress?.center = center - viewAnimatedIcon?.center = center + viewLiveIcon?.center = center viewStaticImage?.center = center viewAnimation?.center = center @@ -538,10 +590,10 @@ extension ProgressHUD { removeDelayTimer() removeNotifications() - removeAnimationView() + removeLiveIcon() removeStaticImage() - removeAnimatedIcon() removeProgressView() + removeAnimationView() removeStatus() removeToolbar() diff --git a/ProgressHUD/Sources/ProgressView.swift b/ProgressHUD/Sources/ProgressView.swift index f3d04b5..35a6135 100644 --- a/ProgressHUD/Sources/ProgressView.swift +++ b/ProgressHUD/Sources/ProgressView.swift @@ -75,9 +75,9 @@ class ProgressView: UIView { addSubview(labelPercentage) } - func setProgress(_ value: CGFloat, duration: TimeInterval = 0.2) { + func setProgress(_ value: CGFloat) { let animation = CABasicAnimation(keyPath: "strokeEnd") - animation.duration = duration + animation.duration = 0.2 animation.fromValue = progress animation.toValue = value animation.fillMode = .both diff --git a/ProgressHUD/app.xcodeproj/project.pbxproj b/ProgressHUD/app.xcodeproj/project.pbxproj index 8abbf75..8a0ce97 100644 --- a/ProgressHUD/app.xcodeproj/project.pbxproj +++ b/ProgressHUD/app.xcodeproj/project.pbxproj @@ -11,7 +11,7 @@ 295B8483248C1C5B003E8AE6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 295B8481248C1C5B003E8AE6 /* ViewController.swift */; }; 299876DB248FCB290025E297 /* ProgressHUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 299876DA248FCB290025E297 /* ProgressHUD.swift */; }; 29A3BDAC2AC6A0810034CAF3 /* ProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A3BDAA2AC6A0810034CAF3 /* ProgressView.swift */; }; - 29A3BDAF2AC6A5EF0034CAF3 /* ProgressHUD+AnimatedIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A3BDAE2AC6A5EF0034CAF3 /* ProgressHUD+AnimatedIcon.swift */; }; + 29A3BDAF2AC6A5EF0034CAF3 /* ProgressHUD+LiveIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A3BDAE2AC6A5EF0034CAF3 /* ProgressHUD+LiveIcon.swift */; }; 29A3BDB12AC6A7500034CAF3 /* ProgressHUD+Banner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A3BDB02AC6A7500034CAF3 /* ProgressHUD+Banner.swift */; }; 29A3BDB32AC6ACA90034CAF3 /* ProgressHUD+Enums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A3BDB22AC6ACA90034CAF3 /* ProgressHUD+Enums.swift */; }; 29A3BDB52AC6AF780034CAF3 /* ProgressHUD+Public.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A3BDB42AC6AF780034CAF3 /* ProgressHUD+Public.swift */; }; @@ -47,7 +47,7 @@ 295B8481248C1C5B003E8AE6 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 299876DA248FCB290025E297 /* ProgressHUD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressHUD.swift; sourceTree = ""; }; 29A3BDAA2AC6A0810034CAF3 /* ProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressView.swift; sourceTree = ""; }; - 29A3BDAE2AC6A5EF0034CAF3 /* ProgressHUD+AnimatedIcon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+AnimatedIcon.swift"; sourceTree = ""; }; + 29A3BDAE2AC6A5EF0034CAF3 /* ProgressHUD+LiveIcon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+LiveIcon.swift"; sourceTree = ""; }; 29A3BDB02AC6A7500034CAF3 /* ProgressHUD+Banner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+Banner.swift"; sourceTree = ""; }; 29A3BDB22AC6ACA90034CAF3 /* ProgressHUD+Enums.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+Enums.swift"; sourceTree = ""; }; 29A3BDB42AC6AF780034CAF3 /* ProgressHUD+Public.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ProgressHUD+Public.swift"; sourceTree = ""; }; @@ -124,9 +124,9 @@ children = ( 29783DC82AD7F7AC0017A142 /* Animations */, 299876DA248FCB290025E297 /* ProgressHUD.swift */, - 29A3BDAE2AC6A5EF0034CAF3 /* ProgressHUD+AnimatedIcon.swift */, 29A3BDB02AC6A7500034CAF3 /* ProgressHUD+Banner.swift */, 29A3BDB22AC6ACA90034CAF3 /* ProgressHUD+Enums.swift */, + 29A3BDAE2AC6A5EF0034CAF3 /* ProgressHUD+LiveIcon.swift */, 29A3BDB42AC6AF780034CAF3 /* ProgressHUD+Public.swift */, 29A3BDAA2AC6A0810034CAF3 /* ProgressView.swift */, ); @@ -276,7 +276,7 @@ 29FD93DB2AD9781A0054B585 /* ProgressHUD+CircleRippleSingle.swift in Sources */, 29FD93D92AD9781A0054B585 /* ProgressHUD+HorizontalDotScaling.swift in Sources */, 29FD93CF2AD9781A0054B585 /* ProgressHUD+CirclePulseMultiple.swift in Sources */, - 29A3BDAF2AC6A5EF0034CAF3 /* ProgressHUD+AnimatedIcon.swift in Sources */, + 29A3BDAF2AC6A5EF0034CAF3 /* ProgressHUD+LiveIcon.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -425,7 +425,7 @@ INFOPLIST_FILE = app/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited)"; - MARKETING_VERSION = 14.0.0; + MARKETING_VERSION = 14.1.0; PRODUCT_BUNDLE_IDENTIFIER = com.relatedcode.progresshud; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -456,7 +456,7 @@ INFOPLIST_FILE = app/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited)"; - MARKETING_VERSION = 14.0.0; + MARKETING_VERSION = 14.1.0; PRODUCT_BUNDLE_IDENTIFIER = com.relatedcode.progresshud; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/ProgressHUD/app/ViewController.swift b/ProgressHUD/app/ViewController.swift index 4f9340f..2e35031 100644 --- a/ProgressHUD/app/ViewController.swift +++ b/ProgressHUD/app/ViewController.swift @@ -114,31 +114,31 @@ class ViewController: UITableViewController { // MARK: - Progress Methods extension ViewController { - func actionProgressStart(_ status: String? = nil) { + func progressStart(_ status: String? = nil) { counter = 0 - ProgressHUD.showProgress(status, counter/100) + ProgressHUD.progress(status, counter/100) timer = Timer.scheduledTimer(withTimeInterval: 0.025, repeats: true) { [weak self] _ in guard let self = self else { return } - self.actionProgress(status) + self.progressStep(status) } } - func actionProgress(_ status: String?) { + func progressStep(_ status: String?) { counter += 1 - ProgressHUD.showProgress(status, counter/100) + ProgressHUD.progress(status, counter/100) if (counter >= 100) { - actionProgressStop(status) + progressStop(status) } } - func actionProgressStop(_ status: String?) { + func progressStop(_ status: String?) { timer?.invalidate() timer = nil DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { - ProgressHUD.showSucceed(status, interaction: false, delay: 0.75) + ProgressHUD.succeed(status, interaction: false, delay: 0.75) } } } @@ -197,8 +197,8 @@ extension ViewController { if (section == 3) { return "Animation" } if (section == 4) { return "Progress" } if (section == 5) { return "Progress" } - if (section == 6) { return "Action - Static" } - if (section == 7) { return "Action - Animated" } + if (section == 6) { return "Static Image" } + if (section == 7) { return "Live Icon" } return nil } } @@ -210,8 +210,8 @@ extension ViewController { tableView.deselectRow(at: indexPath, animated: true) if (indexPath.section == 0) { - if (indexPath.row == 0) { ProgressHUD.showBanner("Banner title", toggleText()) } - if (indexPath.row == 1) { ProgressHUD.hideBanner() } + if (indexPath.row == 0) { ProgressHUD.banner("Banner title", toggleText()) } + if (indexPath.row == 1) { ProgressHUD.bannerHide() } } if (indexPath.section == 1) { @@ -222,48 +222,48 @@ extension ViewController { if (indexPath.section == 2) { let animation = animations[indexPath.row] - ProgressHUD.animationType = animation - if (animation == .sfSymbolBounce) { - ProgressHUD.animationSymbol = symbol() + if (animation != .sfSymbolBounce) { + ProgressHUD.animate(status, animation) + } else { + ProgressHUD.animate(status, symbol: symbol()) } - ProgressHUD.show(status) } if (indexPath.section == 3) { - if (indexPath.row == 0) { ProgressHUD.show(); status = nil } - if (indexPath.row == 1) { ProgressHUD.show(textShort); status = textShort } - if (indexPath.row == 2) { ProgressHUD.show(textLong); status = textLong } + if (indexPath.row == 0) { ProgressHUD.animate(); status = nil } + if (indexPath.row == 1) { ProgressHUD.animate(textShort); status = textShort } + if (indexPath.row == 2) { ProgressHUD.animate(textLong); status = textLong } } if (indexPath.section == 4) { - if (indexPath.row == 0) { actionProgressStart() } - if (indexPath.row == 1) { actionProgressStart(textShort) } - if (indexPath.row == 2) { actionProgressStart(textLong) } + if (indexPath.row == 0) { progressStart() } + if (indexPath.row == 1) { progressStart(textShort) } + if (indexPath.row == 2) { progressStart(textLong) } } if (indexPath.section == 5) { - if (indexPath.row == 0) { ProgressHUD.showProgress(0.1, interaction: true) } - if (indexPath.row == 1) { ProgressHUD.showProgress(0.4, interaction: true) } - if (indexPath.row == 2) { ProgressHUD.showProgress(0.6, interaction: true) } - if (indexPath.row == 3) { ProgressHUD.showProgress(0.9, interaction: true) } + if (indexPath.row == 0) { ProgressHUD.progress(0.1, interaction: true) } + if (indexPath.row == 1) { ProgressHUD.progress(0.4, interaction: true) } + if (indexPath.row == 2) { ProgressHUD.progress(0.6, interaction: true) } + if (indexPath.row == 3) { ProgressHUD.progress(0.9, interaction: true) } } if (indexPath.section == 6) { - if (indexPath.row == 0) { ProgressHUD.show(symbol: symbol()) } - if (indexPath.row == 1) { ProgressHUD.show(textAdded, symbol: symbol()) } - if (indexPath.row == 2) { ProgressHUD.showSuccess() } - if (indexPath.row == 3) { ProgressHUD.showSuccess(textSuccess) } - if (indexPath.row == 4) { ProgressHUD.showError() } - if (indexPath.row == 5) { ProgressHUD.showError(textError) } + if (indexPath.row == 0) { ProgressHUD.symbol(name: symbol()) } + if (indexPath.row == 1) { ProgressHUD.symbol(textAdded, name: symbol()) } + if (indexPath.row == 2) { ProgressHUD.success() } + if (indexPath.row == 3) { ProgressHUD.success(textSuccess) } + if (indexPath.row == 4) { ProgressHUD.error() } + if (indexPath.row == 5) { ProgressHUD.error(textError) } } if (indexPath.section == 7) { - if (indexPath.row == 0) { ProgressHUD.showSucceed() } - if (indexPath.row == 1) { ProgressHUD.showSucceed(textSucceed) } - if (indexPath.row == 2) { ProgressHUD.showFailed() } - if (indexPath.row == 3) { ProgressHUD.showFailed(textFailed) } - if (indexPath.row == 4) { ProgressHUD.showAdded() } - if (indexPath.row == 5) { ProgressHUD.showAdded(textAdded) } + if (indexPath.row == 0) { ProgressHUD.succeed() } + if (indexPath.row == 1) { ProgressHUD.succeed(textSucceed) } + if (indexPath.row == 2) { ProgressHUD.failed() } + if (indexPath.row == 3) { ProgressHUD.failed(textFailed) } + if (indexPath.row == 4) { ProgressHUD.added() } + if (indexPath.row == 5) { ProgressHUD.added(textAdded) } } } } diff --git a/README.md b/README.md index cb4afc9..6eeb701 100644 --- a/README.md +++ b/README.md @@ -44,55 +44,59 @@ If you prefer not to use any of the dependency managers above, you can integrate ## QUICK START ```swift -ProgressHUD.showBanner("Banner title", "Banner message to display.") +ProgressHUD.banner("Banner title", "Banner message to display.") ``` ```swift -ProgressHUD.showBanner("Banner title", "Message to display.", delay: 2.0) +ProgressHUD.banner("Banner title", "Message to display.", delay: 2.0) ``` ```swift -ProgressHUD.hideBanner() +ProgressHUD.bannerHide() ``` ```swift -ProgressHUD.show("Some text...") +ProgressHUD.animate("Some text...") ``` ```swift -ProgressHUD.show("Some text...", interaction: false) +ProgressHUD.animate("Some text...", interaction: false) ``` ```swift -ProgressHUD.showSucceed() +ProgressHUD.animate("Please wait...", .ballVerticalBounce) ``` ```swift -ProgressHUD.showSucceed("Some text...", delay: 1.5) +ProgressHUD.succeed() ``` ```swift -ProgressHUD.showFailed() +ProgressHUD.succeed("Some text...", delay: 1.5) ``` ```swift -ProgressHUD.showFailed("Some text...") +ProgressHUD.failed() ``` ```swift -ProgressHUD.showProgress(0.15) +ProgressHUD.failed("Some text...") ``` ```swift -ProgressHUD.showProgress("Loading...", 0.42) +ProgressHUD.progress(0.15) ``` ```swift -ProgressHUD.show(symbol: "box.truck") +ProgressHUD.progress("Loading...", 0.42) ``` ```swift -ProgressHUD.show("Some text...", symbol: "figure.2.arms.open") +ProgressHUD.symbol(name: "box.truck") +``` + +```swift +ProgressHUD.symbol("Some text...", name: "sun.max") ``` ```swift @@ -149,7 +153,7 @@ ProgressHUD.imageSuccess = UIImage(named: "success.png") ProgressHUD.imageError = UIImage(named: "error.png") ``` -A comprehensive list of the predefined animation types: +A comprehensive list of the predefined enums: ```swift public enum AnimationType: CaseIterable { @@ -179,7 +183,7 @@ public enum AnimationType: CaseIterable { ``` ```swift -public enum AnimatedIcon { +public enum LiveIcon { case succeed case failed case added diff --git a/VERSION.txt b/VERSION.txt index 4b964e9..7b3b6e0 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -14.0.0 +14.1.0