Skip to content

Commit

Permalink
13.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
relatedcode committed Dec 17, 2022
1 parent 3ae24c8 commit 2b80c6f
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 40 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Related Code
Copyright (c) 2022 Related Code

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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 = '13.6'
s.version = '13.6.2'
s.license = 'MIT'

s.summary = 'A lightweight and easy-to-use Progress HUD for iOS.'
Expand Down
85 changes: 54 additions & 31 deletions ProgressHUD/Sources/ProgressHUD.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2021 Related Code - https://relatedcode.com
// Copyright (c) 2022 Related Code - https://relatedcode.com
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand All @@ -11,6 +11,7 @@

import UIKit

// MARK: -
//-----------------------------------------------------------------------------------------------------------------------------------------------
public enum AnimationType {

Expand Down Expand Up @@ -59,6 +60,7 @@ public enum AlertIcon {
case search
}

// MARK: -
//-----------------------------------------------------------------------------------------------------------------------------------------------
extension AlertIcon {

Expand Down Expand Up @@ -87,6 +89,7 @@ extension AlertIcon {
}
}

// MARK: -
//-----------------------------------------------------------------------------------------------------------------------------------------------
public extension ProgressHUD {

Expand Down Expand Up @@ -136,14 +139,23 @@ public extension ProgressHUD {
}
}

// MARK: -
//-----------------------------------------------------------------------------------------------------------------------------------------------
public extension ProgressHUD {

//-------------------------------------------------------------------------------------------------------------------------------------------
class func dismiss() {

DispatchQueue.main.async {
shared.hudHide()
shared.dismissHUD()
}
}

//-------------------------------------------------------------------------------------------------------------------------------------------
class func remove() {

DispatchQueue.main.async {
shared.removeHUD()
}
}

Expand All @@ -155,68 +167,67 @@ public extension ProgressHUD {
}
}

// MARK: -
// MARK: - Animated Icon
//-------------------------------------------------------------------------------------------------------------------------------------------
class func show(_ status: String? = nil, icon: AlertIcon, interaction: Bool = true) {

let image = icon.image?.withTintColor(shared.colorAnimation, renderingMode: .alwaysOriginal)
class func show(_ status: String? = nil, icon: AnimatedIcon, interaction: Bool = true, delay: TimeInterval? = nil) {

DispatchQueue.main.async {
shared.setup(status: status, staticImage: image, hide: true, interaction: interaction)
shared.setup(status: status, animatedIcon: icon, hide: true, interaction: interaction, delay: delay)
}
}

//-------------------------------------------------------------------------------------------------------------------------------------------
class func show(_ status: String? = nil, icon animatedIcon: AnimatedIcon, interaction: Bool = true) {
class func showSucceed(_ status: String? = nil, interaction: Bool = true, delay: TimeInterval? = nil) {

DispatchQueue.main.async {
shared.setup(status: status, animatedIcon: animatedIcon, hide: true, interaction: interaction)
shared.setup(status: status, animatedIcon: .succeed, hide: true, interaction: interaction, delay: delay)
}
}

// MARK: -
//-------------------------------------------------------------------------------------------------------------------------------------------
class func showSuccess(_ status: String? = nil, image: UIImage? = nil, interaction: Bool = true) {
class func showFailed(_ status: String? = nil, interaction: Bool = true, delay: TimeInterval? = nil) {

DispatchQueue.main.async {
shared.setup(status: status, staticImage: image ?? shared.imageSuccess, hide: true, interaction: interaction)
shared.setup(status: status, animatedIcon: .failed, hide: true, interaction: interaction, delay: delay)
}
}

//-------------------------------------------------------------------------------------------------------------------------------------------
class func showError(_ status: String? = nil, image: UIImage? = nil, interaction: Bool = true) {
class func showAdded(_ status: String? = nil, interaction: Bool = true, delay: TimeInterval? = nil) {

DispatchQueue.main.async {
shared.setup(status: status, staticImage: image ?? shared.imageError, hide: true, interaction: interaction)
shared.setup(status: status, animatedIcon: .added, hide: true, interaction: interaction, delay: delay)
}
}

// MARK: -
// MARK: - Static Image
//-------------------------------------------------------------------------------------------------------------------------------------------
class func showSucceed(_ status: String? = nil, interaction: Bool = true) {
class func show(_ status: String? = nil, icon: AlertIcon, interaction: Bool = true, delay: TimeInterval? = nil) {

let image = icon.image?.withTintColor(shared.colorAnimation, renderingMode: .alwaysOriginal)

DispatchQueue.main.async {
shared.setup(status: status, animatedIcon: .succeed, hide: true, interaction: interaction)
shared.setup(status: status, staticImage: image, hide: true, interaction: interaction, delay: delay)
}
}

//-------------------------------------------------------------------------------------------------------------------------------------------
class func showFailed(_ status: String? = nil, interaction: Bool = true) {
class func showSuccess(_ status: String? = nil, image: UIImage? = nil, interaction: Bool = true, delay: TimeInterval? = nil) {

DispatchQueue.main.async {
shared.setup(status: status, animatedIcon: .failed, hide: true, interaction: interaction)
shared.setup(status: status, staticImage: image ?? shared.imageSuccess, hide: true, interaction: interaction, delay: delay)
}
}

//-------------------------------------------------------------------------------------------------------------------------------------------
class func showAdded(_ status: String? = nil, interaction: Bool = true) {
class func showError(_ status: String? = nil, image: UIImage? = nil, interaction: Bool = true, delay: TimeInterval? = nil) {

DispatchQueue.main.async {
shared.setup(status: status, animatedIcon: .added, hide: true, interaction: interaction)
shared.setup(status: status, staticImage: image ?? shared.imageError, hide: true, interaction: interaction, delay: delay)
}
}

// MARK: -
// MARK: - Progress
//-------------------------------------------------------------------------------------------------------------------------------------------
class func showProgress(_ progress: CGFloat, interaction: Bool = false) {

Expand All @@ -234,6 +245,7 @@ public extension ProgressHUD {
}
}

// MARK: -
//-----------------------------------------------------------------------------------------------------------------------------------------------
public class ProgressHUD: UIView {

Expand Down Expand Up @@ -294,7 +306,8 @@ public class ProgressHUD: UIView {

// MARK: -
//-------------------------------------------------------------------------------------------------------------------------------------------
private func setup(status: String? = nil, progress: CGFloat? = nil, animatedIcon: AnimatedIcon? = nil, staticImage: UIImage? = nil, hide: Bool, interaction: Bool) {
private func setup(status: String? = nil, progress: CGFloat? = nil, animatedIcon: AnimatedIcon? = nil, staticImage: UIImage? = nil,
hide: Bool, interaction: Bool, delay: TimeInterval? = nil) {

setupNotifications()
setupBackground(interaction)
Expand All @@ -309,13 +322,13 @@ public class ProgressHUD: UIView {
setupSize()
setupPosition()

hudShow()
displayHUD()

if (hide) {
let text = labelStatus?.text ?? ""
let delay = Double(text.count) * 0.03 + 1.25
let delay = delay ?? Double(text.count) * 0.03 + 1.25
timer = Timer.scheduledTimer(withTimeInterval: delay, repeats: false) { _ in
self.hudHide()
self.dismissHUD()
}
}
}
Expand Down Expand Up @@ -568,12 +581,12 @@ public class ProgressHUD: UIView {

// MARK: -
//-------------------------------------------------------------------------------------------------------------------------------------------
private func hudShow() {
private func displayHUD() {

timer?.invalidate()
timer = nil

if (self.alpha != 1) {
if (self.alpha == 0) {
self.alpha = 1
toolbarHUD?.alpha = 0
toolbarHUD?.transform = CGAffineTransform(scaleX: 1.4, y: 1.4)
Expand All @@ -586,21 +599,31 @@ public class ProgressHUD: UIView {
}

//-------------------------------------------------------------------------------------------------------------------------------------------
private func hudHide() {
private func dismissHUD() {

if (self.alpha == 1) {
UIView.animate(withDuration: 0.15, delay: 0, options: [.allowUserInteraction, .curveEaseIn], animations: {
self.toolbarHUD?.transform = CGAffineTransform(scaleX: 0.3, y: 0.3)
self.toolbarHUD?.alpha = 0
}, completion: { isFinished in
self.hudDestroy()
self.destroyHUD()
self.alpha = 0
})
}
}

//-------------------------------------------------------------------------------------------------------------------------------------------
private func hudDestroy() {
private func removeHUD() {

if (self.alpha == 1) {
toolbarHUD?.alpha = 0
destroyHUD()
self.alpha = 0
}
}

//-------------------------------------------------------------------------------------------------------------------------------------------
private func destroyHUD() {

NotificationCenter.default.removeObserver(self)

Expand Down
4 changes: 2 additions & 2 deletions ProgressHUD/app.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
INFOPLIST_FILE = app/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited)";
MARKETING_VERSION = 13.6;
MARKETING_VERSION = 13.6.2;
PRODUCT_BUNDLE_IDENTIFIER = com.relatedcode.progresshud;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -336,7 +336,7 @@
INFOPLIST_FILE = app/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited)";
MARKETING_VERSION = 13.6;
MARKETING_VERSION = 13.6.2;
PRODUCT_BUNDLE_IDENTIFIER = com.relatedcode.progresshud;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
2 changes: 1 addition & 1 deletion ProgressHUD/app/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2021 Related Code - https://relatedcode.com
// Copyright (c) 2022 Related Code - https://relatedcode.com
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand Down
6 changes: 4 additions & 2 deletions ProgressHUD/app/ViewController.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2021 Related Code - https://relatedcode.com
// Copyright (c) 2022 Related Code - https://relatedcode.com
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand Down Expand Up @@ -148,7 +148,7 @@ extension ViewController {
//-------------------------------------------------------------------------------------------------------------------------------------------
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

if (section == 0) { return 3 }
if (section == 0) { return 4 }
if (section == 1) { return actions1.count }
if (section == 2) { return types.count }
if (section == 3) { return actions2.count }
Expand All @@ -167,6 +167,7 @@ extension ViewController {

if (indexPath.section == 0) && (indexPath.row == 1) { return self.tableView(tableView, cellWithText: "Dismiss Keyboard") }
if (indexPath.section == 0) && (indexPath.row == 2) { return self.tableView(tableView, cellWithText: "Dismiss HUD") }
if (indexPath.section == 0) && (indexPath.row == 3) { return self.tableView(tableView, cellWithText: "Remove HUD") }

if (indexPath.section == 1) { return self.tableView(tableView, cellWithText: actions1[indexPath.row]) }
if (indexPath.section == 2) { return self.tableView(tableView, cellWithText: types[indexPath.row]) }
Expand Down Expand Up @@ -215,6 +216,7 @@ extension ViewController {

if (indexPath.section == 0) && (indexPath.row == 1) { view.endEditing(true) }
if (indexPath.section == 0) && (indexPath.row == 2) { ProgressHUD.dismiss() }
if (indexPath.section == 0) && (indexPath.row == 3) { ProgressHUD.remove() }

if (indexPath.section == 1) {
if (indexPath.row == 0) { ProgressHUD.show(); status = nil }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public enum AlertIcon {

MIT License

Copyright (c) 2021 Related Code
Copyright (c) 2022 Related Code

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13.6.1
13.6.2

0 comments on commit 2b80c6f

Please sign in to comment.