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

Adding VoiceOver Accessibility compatibility. #213

Open
wants to merge 6 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
8 changes: 4 additions & 4 deletions PKHUD.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Pod::Spec.new do |s|
s.name = 'PKHUD'
s.module_name = 'PKHUD'
s.version = '5.0.0'
s.summary = 'A Swift 3 based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8 and up'
s.homepage = 'https://github.com/pkluz/PKHUD'
s.version = '5.1.0'
s.summary = 'A Swift 4.2 based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8 and up'
s.homepage = 'https://github.com/hathway/PKHUD'
s.license = 'MIT'
s.author = { 'Philip Kluz' => 'Philip.Kluz@gmail.com' }
s.platform = :ios, '8.0'
s.ios.deployment_target = '8.0'
s.requires_arc = true
s.source = { :git => 'https://github.com/pkluz/PKHUD.git', :tag => s.version.to_s }
s.source = { :git => 'https://github.com/hathway/PKHUD.git', :tag => s.version.to_s }
s.source_files = 'PKHUD/**/*.{h,swift}'
s.resources = 'PKHUD/*.xcassets'
end
14 changes: 8 additions & 6 deletions PKHUD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = NSExceptional;
TargetAttributes = {
12CE19F01E25784C0062D873 = {
Expand All @@ -345,7 +345,7 @@
};
F996321D19514FD8001F73CA = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
};
};
};
Expand Down Expand Up @@ -530,12 +530,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -584,12 +586,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -672,8 +676,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -697,8 +700,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.NSExceptional.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down
4 changes: 1 addition & 3 deletions PKHUD.xcodeproj/xcshareddata/xcschemes/PKHUD Demo.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 1 addition & 3 deletions PKHUD.xcodeproj/xcshareddata/xcschemes/PKHUD.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -37,7 +36,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -10,7 +10,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand All @@ -31,7 +30,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
28 changes: 28 additions & 0 deletions PKHUD/HUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public final class HUD {
// MARK: Public methods, PKHUD based
public static func show(_ content: HUDContentType, onView view: UIView? = nil) {
PKHUD.sharedHUD.contentView = contentView(content)
PKHUD.sharedHUD.contentView.setAccessibilityProperties(for: content)
PKHUD.sharedHUD.show(onView: view)
}

Expand Down Expand Up @@ -102,3 +103,30 @@ public final class HUD {
}
}
}

fileprivate extension UIView {
fileprivate func setAccessibilityProperties(for content: HUDContentType) {
self.accessibilityLabel = "Please wait."
switch content {
case .success:
self.accessibilityLabel = "Success!"
case .error:
self.accessibilityLabel = "Error!"
case .image(_),
.rotatingImage(_):
self.accessibilityLabel = "Image"
case .label(let title):
guard let label = title else { break }
self.accessibilityLabel = label
case .labeledSuccess(let title, let subtitle),
.labeledError(let title, let subtitle),
.labeledProgress(let title, let subtitle),
.labeledImage(_, let title, let subtitle),
.labeledRotatingImage(_, let title, let subtitle):
guard title != nil || subtitle != nil else { break }
self.accessibilityLabel = (title ?? "") + "\n" + (subtitle ?? "")
default:
self.accessibilityLabel = "Please wait."
}
}
}
5 changes: 3 additions & 2 deletions PKHUD/PKHUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ open class PKHUD: NSObject {
super.init()
NotificationCenter.default.addObserver(self,
selector: #selector(PKHUD.willEnterForeground(_:)),
name: NSNotification.Name.UIApplicationWillEnterForeground,
name: UIApplication.willEnterForegroundNotification,
object: nil)
userInteractionOnUnderlyingViewsEnabled = false
container.frameView.autoresizingMask = [ .flexibleLeftMargin,
Expand Down Expand Up @@ -127,11 +127,12 @@ open class PKHUD: NSObject {
// If the grace time is set, postpone the HUD display
if gracePeriod > 0.0 {
let timer = Timer(timeInterval: gracePeriod, target: self, selector: #selector(PKHUD.handleGraceTimer(_:)), userInfo: nil, repeats: false)
RunLoop.current.add(timer, forMode: .commonModes)
RunLoop.current.add(timer, forMode: RunLoop.Mode.common)
graceTimer = timer
} else {
showContent()
}
UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: self.container.frameView.content)
}

func showContent() {
Expand Down
7 changes: 6 additions & 1 deletion PKHUD/PKHUDAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final class PKHUDAnimation {
NSNumber(value: 1.0)
]
animation.duration = 1.2
animation.calculationMode = "discrete"
animation.calculationMode = convertToCAAnimationCalculationMode("discrete")
animation.repeatCount = Float(INT_MAX)
return animation
}()
Expand All @@ -59,3 +59,8 @@ public final class PKHUDAnimation {
return animation
}()
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToCAAnimationCalculationMode(_ input: String) -> CAAnimationCalculationMode {
return CAAnimationCalculationMode(rawValue: input)
}
8 changes: 4 additions & 4 deletions PKHUD/PKHUDErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ open class PKHUDErrorView: PKHUDSquareBaseView, PKHUDAnimating {
path.addLine(to: CGPoint(x: 88.0, y: 44.0))
return path.cgPath
}()
dash.lineCap = kCALineCapRound
dash.lineJoin = kCALineJoinRound
dash.lineCap = CAShapeLayerLineCap.round
dash.lineJoin = CAShapeLayerLineJoin.round
dash.fillColor = nil
dash.strokeColor = UIColor(red: 0.15, green: 0.15, blue: 0.15, alpha: 1.0).cgColor
dash.lineWidth = 6
dash.fillMode = kCAFillModeForwards
dash.fillMode = CAMediaTimingFillMode.forwards
return dash
}

Expand Down Expand Up @@ -64,7 +64,7 @@ open class PKHUDErrorView: PKHUDSquareBaseView, PKHUDAnimating {
animation.fromValue = 0.0
animation.toValue = angle * CGFloat(.pi / 180.0)
animation.duration = 1.0
animation.timingFunction = CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseInEaseOut)
animation.timingFunction = CAMediaTimingFunction(name:CAMediaTimingFunctionName.easeInEaseOut)
return animation
}

Expand Down
6 changes: 3 additions & 3 deletions PKHUD/PKHUDSquareBaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ open class PKHUDSquareBaseView: UIView {
addSubview(subtitleLabel)
}

open let imageView: UIImageView = {
public let imageView: UIImageView = {
let imageView = UIImageView()
imageView.alpha = 0.85
imageView.clipsToBounds = true
imageView.contentMode = .center
return imageView
}()

open let titleLabel: UILabel = {
public let titleLabel: UILabel = {
let label = UILabel()
label.textAlignment = .center
label.font = UIFont.boldSystemFont(ofSize: 17.0)
Expand All @@ -51,7 +51,7 @@ open class PKHUDSquareBaseView: UIView {
return label
}()

open let subtitleLabel: UILabel = {
public let subtitleLabel: UILabel = {
let label = UILabel()
label.textAlignment = .center
label.font = UIFont.systemFont(ofSize: 14.0)
Expand Down
6 changes: 3 additions & 3 deletions PKHUD/PKHUDSuccessView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ open class PKHUDSuccessView: PKHUDSquareBaseView, PKHUDAnimating {
let layer = CAShapeLayer()
layer.frame = CGRect(x: 3.0, y: 3.0, width: 88.0, height: 56.0)
layer.path = checkmarkPath.cgPath
layer.fillMode = kCAFillModeForwards
layer.lineCap = kCALineCapRound
layer.lineJoin = kCALineJoinRound
layer.fillMode = CAMediaTimingFillMode.forwards
layer.lineCap = CAShapeLayerLineCap.round
layer.lineJoin = CAShapeLayerLineJoin.round
layer.fillColor = nil
layer.strokeColor = UIColor(red: 0.15, green: 0.15, blue: 0.15, alpha: 1.0).cgColor
layer.lineWidth = 6.0
Expand Down
2 changes: 1 addition & 1 deletion PKHUD/PKHUDSystemActivityIndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class PKHUDSystemActivityIndicatorView: PKHUDSquareBaseView, PKHUDA
}

let activityIndicatorView: UIActivityIndicatorView = {
let activity = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
let activity = UIActivityIndicatorView(style: .whiteLarge)
activity.color = UIColor.black
return activity
}()
Expand Down
2 changes: 1 addition & 1 deletion PKHUD/PKHUDTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class PKHUDTextView: PKHUDWideBaseView {
titleLabel.frame = bounds.insetBy(dx: padding, dy: padding)
}

open let titleLabel: UILabel = {
public let titleLabel: UILabel = {
let label = UILabel()
label.textAlignment = .center
label.font = UIFont.boldSystemFont(ofSize: 17.0)
Expand Down