Skip to content

Commit

Permalink
14.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
relatedcode committed Oct 15, 2023
1 parent d0f7e5d commit 5a7e1ba
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 155 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ProgressHUD.podspec
Original file line number Diff line number Diff line change
@@ -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.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions ProgressHUD/Sources/ProgressHUD+Enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
89 changes: 58 additions & 31 deletions ProgressHUD/Sources/ProgressHUD+Public.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public extension ProgressHUD {
}
}

// MARK: - HUD General
// MARK: - HUD Removal
public extension ProgressHUD {

class func dismiss() {
Expand All @@ -123,104 +123,131 @@ 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)
}
}
}

// 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)
}
}
}

// 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()
}
Expand Down
Loading

0 comments on commit 5a7e1ba

Please sign in to comment.