Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for optimization #246

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions PKHUD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
F996324F19514FEF001F73CA /* PKHUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = F996324819514FEF001F73CA /* PKHUD.swift */; };
F996325019514FEF001F73CA /* FrameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F996324919514FEF001F73CA /* FrameView.swift */; };
F996325219514FEF001F73CA /* Window.swift in Sources */ = {isa = PBXBuildFile; fileRef = F996324B19514FEF001F73CA /* Window.swift */; };
F996325319514FEF001F73CA /* WindowRootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F996324C19514FEF001F73CA /* WindowRootViewController.swift */; };
F996325519514FF3001F73CA /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F996325419514FF3001F73CA /* Images.xcassets */; };
F996325919515052001F73CA /* DemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F996325819515052001F73CA /* DemoViewController.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -109,7 +108,6 @@
F996324819514FEF001F73CA /* PKHUD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUD.swift; sourceTree = "<group>"; };
F996324919514FEF001F73CA /* FrameView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FrameView.swift; sourceTree = "<group>"; };
F996324B19514FEF001F73CA /* Window.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Window.swift; sourceTree = "<group>"; };
F996324C19514FEF001F73CA /* WindowRootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowRootViewController.swift; sourceTree = "<group>"; };
F996325419514FF3001F73CA /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
F996325819515052001F73CA /* DemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -245,7 +243,6 @@
children = (
F996324919514FEF001F73CA /* FrameView.swift */,
F996324B19514FEF001F73CA /* Window.swift */,
F996324C19514FEF001F73CA /* WindowRootViewController.swift */,
);
name = Internal;
sourceTree = "<group>";
Expand Down Expand Up @@ -439,7 +436,6 @@
640011571C5B6C080013F32B /* HUD.swift in Sources */,
3097AF3A1C4843AE007DD42B /* PKHUDRotatingImageView.swift in Sources */,
F935B1611B2B8C8E003C3734 /* PKHUDTextView.swift in Sources */,
F996325319514FEF001F73CA /* WindowRootViewController.swift in Sources */,
F908BEC31BB84D0B0015E5A8 /* PKHUDAnimating.swift in Sources */,
F908BEC81BB85EA70015E5A8 /* PKHUDProgressView.swift in Sources */,
F908BEC01BB849290015E5A8 /* PKHUDSuccessView.swift in Sources */,
Expand Down
8 changes: 4 additions & 4 deletions PKHUD/FrameView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// HUDView.swift
// FrameView.swift
// PKHUD
//
// Created by Philip Kluz on 6/16/14.
Expand All @@ -10,7 +10,7 @@
import UIKit

/// Provides the general look and feel of the PKHUD, into which the eventual content is inserted.
internal class FrameView: UIVisualEffectView {
internal final class FrameView: UIVisualEffectView {

internal init() {
super.init(effect: UIBlurEffect(style: .light))
Expand All @@ -22,7 +22,7 @@ internal class FrameView: UIVisualEffectView {
commonInit()
}

fileprivate func commonInit() {
private func commonInit() {
backgroundColor = UIColor(white: 0.8, alpha: 0.36)
layer.cornerRadius = 9.0
layer.masksToBounds = true
Expand All @@ -45,7 +45,7 @@ internal class FrameView: UIVisualEffectView {
addMotionEffect(group)
}

fileprivate var _content = UIView()
private var _content = UIView()
internal var content: UIView {
get {
return _content
Expand Down
2 changes: 1 addition & 1 deletion PKHUD/HUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public final class HUD {
}

// MARK: Private methods
fileprivate static func contentView(_ content: HUDContentType) -> UIView {
private static func contentView(_ content: HUDContentType) -> UIView {
switch content {
case .success:
return PKHUDSuccessView()
Expand Down
16 changes: 8 additions & 8 deletions PKHUD/PKHUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import UIKit
/// The PKHUD object controls showing and hiding of the HUD, as well as its contents and touch response behavior.
open class PKHUD: NSObject {

fileprivate struct Constants {
private struct Constants {
static let sharedHUD = PKHUD()
}

public var viewToPresentOn: UIView?

fileprivate let container = ContainerView()
fileprivate var hideTimer: Timer?
private let container = Window()
private var hideTimer: Timer?

public typealias TimerAction = (Bool) -> Void
fileprivate var timerActions = [String: TimerAction]()
private var timerActions = [String: TimerAction]()

/// Grace period is the time (in seconds) that the invoked method may be run without
/// showing the HUD. If the task finishes before the grace time runs out, the HUD will
Expand All @@ -45,7 +45,7 @@ open class PKHUD: NSObject {
/// This may be used to prevent HUD display for very short tasks.
/// Defaults to 0 (no grace time).
public var gracePeriod: TimeInterval = 0
fileprivate var graceTimer: Timer?
private var graceTimer: Timer?

// MARK: Public

Expand Down Expand Up @@ -149,7 +149,7 @@ open class PKHUD: NSObject {
}
}

func showContent() {
private func showContent() {
graceTimer?.invalidate()
container.showFrameView()
startAnimatingContentView()
Expand Down Expand Up @@ -187,13 +187,13 @@ open class PKHUD: NSObject {
self.startAnimatingContentView()
}

internal func startAnimatingContentView() {
private func startAnimatingContentView() {
if let animatingContentView = contentView as? PKHUDAnimating, isVisible {
animatingContentView.startAnimation()
}
}

internal func stopAnimatingContentView() {
private func stopAnimatingContentView() {
if let animatingContentView = contentView as? PKHUDAnimating {
animatingContentView.stopAnimation?()
}
Expand Down
2 changes: 1 addition & 1 deletion PKHUD/PKHUDAssets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ open class PKHUDAssets: NSObject {
open class var progressActivityImage: UIImage { return PKHUDAssets.bundledImage(named: "progress_activity") }
open class var progressCircularImage: UIImage { return PKHUDAssets.bundledImage(named: "progress_circular") }

internal class func bundledImage(named name: String) -> UIImage {
private class func bundledImage(named name: String) -> UIImage {
let primaryBundle = Bundle(for: PKHUDAssets.self)
if let image = UIImage(named: name, in: primaryBundle, compatibleWith: nil) {
// Load image in cases where PKHUD is directly integrated
Expand Down
6 changes: 3 additions & 3 deletions PKHUD/PKHUDErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import UIKit
/// PKHUDErrorView provides an animated error (cross) view.
open class PKHUDErrorView: PKHUDSquareBaseView, PKHUDAnimating {

var dashOneLayer = PKHUDErrorView.generateDashLayer()
var dashTwoLayer = PKHUDErrorView.generateDashLayer()
private var dashOneLayer = PKHUDErrorView.generateDashLayer()
private var dashTwoLayer = PKHUDErrorView.generateDashLayer()

class func generateDashLayer() -> CAShapeLayer {
let dash = CAShapeLayer()
Expand Down Expand Up @@ -57,7 +57,7 @@ open class PKHUDErrorView: PKHUDSquareBaseView, PKHUDAnimating {
dashTwoLayer.position = layer.position
}

func rotationAnimation(_ angle: CGFloat) -> CABasicAnimation {
private func rotationAnimation(_ angle: CGFloat) -> CABasicAnimation {
var animation: CABasicAnimation
if #available(iOS 9.0, *) {
let springAnimation = CASpringAnimation(keyPath: "transform.rotation.z")
Expand Down
2 changes: 1 addition & 1 deletion PKHUD/PKHUDSystemActivityIndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class PKHUDSystemActivityIndicatorView: PKHUDSquareBaseView, PKHUDA
commonInit()
}

func commonInit () {
private func commonInit () {
backgroundColor = UIColor.clear
alpha = 0.8

Expand Down
2 changes: 1 addition & 1 deletion PKHUD/PKHUDTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open class PKHUDTextView: PKHUDWideBaseView {
commonInit("")
}

func commonInit(_ text: String?) {
private func commonInit(_ text: String?) {
titleLabel.text = text
addSubview(titleLabel)
}
Expand Down
10 changes: 5 additions & 5 deletions PKHUD/Window.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// HUDWindow.swift
// Window.swift
// PKHUD
//
// Created by Philip Kluz on 6/16/14.
Expand All @@ -10,7 +10,7 @@
import UIKit

/// The window used to display the PKHUD within. Placed atop the applications main window.
internal class ContainerView: UIView {
internal final class Window: UIView {

private var keyboardIsVisible = false
private var keyboardHeight: CGFloat = 0.0
Expand All @@ -28,7 +28,7 @@ internal class ContainerView: UIView {
commonInit()
}

fileprivate func commonInit() {
private func commonInit() {
backgroundColor = UIColor.clear
isHidden = true

Expand All @@ -52,7 +52,7 @@ internal class ContainerView: UIView {
isHidden = false
}

fileprivate var willHide = false
private var willHide = false

internal func hideFrameView(animated anim: Bool, completion: ((Bool) -> Void)? = nil) {
let finalize: (_ finished: Bool) -> Void = { finished in
Expand Down Expand Up @@ -80,7 +80,7 @@ internal class ContainerView: UIView {
}
}

fileprivate let backgroundView: UIView = {
private let backgroundView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(white: 0.0, alpha: 0.25)
view.alpha = 0.0
Expand Down
46 changes: 0 additions & 46 deletions PKHUD/WindowRootViewController.swift

This file was deleted.