Skip to content

Commit

Permalink
1.2.7
Browse files Browse the repository at this point in the history
• Added Voice Over support.
  • Loading branch information
JonasGessner committed May 23, 2015
1 parent 48fd0e4 commit 0e21fb3
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 7 deletions.
4 changes: 2 additions & 2 deletions JGProgressHUD.podspec
@@ -1,14 +1,14 @@
Pod::Spec.new do |s|

s.name = "JGProgressHUD"
s.version = "1.2.6"
s.version = "1.2.7"
s.summary = "Powerful and modern progress HUD for iOS."
s.homepage = "https://github.com/JonasGessner/JGProgressHUD"
s.license = { :type => "MIT", :file => "LICENSE.txt" }
s.author = "Jonas Gessner"
s.social_media_url = "http://twitter.com/JonasGessner"
s.platform = :ios, "5.0"
s.source = { :git => "https://github.com/JonasGessner/JGProgressHUD.git", :tag => "v1.2.6" }
s.source = { :git => "https://github.com/JonasGessner/JGProgressHUD.git", :tag => "v1.2.7" }
s.source_files = "JGProgressHUD/JGProgressHUD/*.{h,m}"
s.resource = "JGProgressHUD/JGProgressHUD/JGProgressHUD Resources.bundle"
s.frameworks = "Foundation", "UIKit", "QuartzCore"
Expand Down
6 changes: 6 additions & 0 deletions JGProgressHUD/JGProgressHUD/JGProgressHUD.m
Expand Up @@ -359,6 +359,10 @@ - (void)cleanUpAfterPresentation {
_dismissAfterTransitionFinished = NO;
_dismissAfterTransitionFinishedWithAnimation = NO;
}

if (UIAccessibilityIsVoiceOverRunning()) {
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self);
}
}

- (void)showInView:(UIView *)view {
Expand Down Expand Up @@ -632,6 +636,7 @@ - (UILabel *)textLabel {
_textLabel.numberOfLines = 0;
[_textLabel addObserver:self forKeyPath:@"text" options:(NSKeyValueObservingOptions)kNilOptions context:NULL];
[_textLabel addObserver:self forKeyPath:@"font" options:(NSKeyValueObservingOptions)kNilOptions context:NULL];
_textLabel.isAccessibilityElement = YES;

[self.contentView addSubview:_textLabel];
}
Expand All @@ -649,6 +654,7 @@ - (UILabel *)detailTextLabel {
_detailTextLabel.numberOfLines = 0;
[_detailTextLabel addObserver:self forKeyPath:@"text" options:(NSKeyValueObservingOptions)kNilOptions context:NULL];
[_detailTextLabel addObserver:self forKeyPath:@"font" options:(NSKeyValueObservingOptions)kNilOptions context:NULL];
_detailTextLabel.isAccessibilityElement = YES;

[self.contentView addSubview:_detailTextLabel];
}
Expand Down
4 changes: 4 additions & 0 deletions JGProgressHUD/JGProgressHUD/JGProgressHUDErrorIndicatorView.m
Expand Up @@ -27,4 +27,8 @@ - (instancetype)init {
return [self initWithContentView:nil];
}

- (void)updateAccessibility {
self.accessibilityLabel = NSLocalizedString(@"Error",);
}

@end
Expand Up @@ -32,4 +32,8 @@ - (void)setColor:(UIColor *)color {
[(UIActivityIndicatorView *)self.contentView setColor:color];
}

- (void)updateAccessibility {
self.accessibilityLabel = NSLocalizedString(@"Indeterminate progress",);
}

@end
15 changes: 15 additions & 0 deletions JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.h
Expand Up @@ -40,4 +40,19 @@
*/
- (void)setProgress:(float)progress animated:(BOOL)animated;

/**
Schedules an accessibility update on the next run loop.
*/
- (void)setNeedsAccessibilityUpdate;

/**
Runs @c updateAccessibility immediately if an accessibility update has been scheduled (through @c setNeedsAccessibilityUpdate) but has not executed yet.
*/
- (void)updateAccessibilityIfNeeded;

/**
Override to set custom accessibility properties. This method gets called once when initializing the view and after calling @c setNeedsAccessibilityUpdate.
*/
- (void)updateAccessibility;

@end
46 changes: 46 additions & 0 deletions JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.m
Expand Up @@ -9,6 +9,18 @@
#import "JGProgressHUDIndicatorView.h"
#import "JGProgressHUD.h"

@interface JGProgressHUDIndicatorView () {
BOOL _accessibilityUpdateScheduled;
}

+ (void)runBlock:(void (^)(void))block;

@end

NS_INLINE void runOnNextRunLoop(void (^block)(void)) {
[[NSRunLoop currentRunLoop] performSelector:@selector(runBlock:) target:[JGProgressHUDIndicatorView class] argument:(id)block order:0 modes:@[NSRunLoopCommonModes]];
}

@implementation JGProgressHUDIndicatorView

#pragma mark - Initializers
Expand All @@ -27,6 +39,9 @@ - (instancetype)initWithContentView:(UIView *)contentView {
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];

self.isAccessibilityElement = YES;
[self setNeedsAccessibilityUpdate];

if (contentView) {
_contentView = contentView;

Expand All @@ -36,6 +51,35 @@ - (instancetype)initWithContentView:(UIView *)contentView {
return self;
}

#pragma mark - Accessibility

+ (void)runBlock:(void (^)(void))block {
if (block != nil) {
block();
}
}

- (void)setNeedsAccessibilityUpdate {
if (!_accessibilityUpdateScheduled) {
_accessibilityUpdateScheduled = YES;

runOnNextRunLoop(^{
[self updateAccessibilityIfNeeded];
});
}
}

- (void)updateAccessibilityIfNeeded {
if (_accessibilityUpdateScheduled) {
[self updateAccessibility];
_accessibilityUpdateScheduled = NO;
}
}

- (void)updateAccessibility {
self.accessibilityLabel = [NSLocalizedString(@"Loading",) stringByAppendingFormat:@" %.f %%", self.progress];
}

#pragma mark - Getters & Setters

- (void)setProgress:(float)progress {
Expand All @@ -48,6 +92,8 @@ - (void)setProgress:(float)progress animated:(BOOL __unused)animated {
}

_progress = progress;

[self setNeedsAccessibilityUpdate];
}

@end
Expand Up @@ -27,4 +27,8 @@ - (instancetype)init {
return [self initWithContentView:nil];
}

- (void)updateAccessibility {
self.accessibilityLabel = NSLocalizedString(@"Success",);
}

@end
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -16,21 +16,22 @@ Overview
• Backward compatibility to iOS 5.<br>
• Well documented and maintained.<br>
• Detects and repositions when Keyboards appear/disappear.<br>
• Voice Over/`UIAccessibility` support.<br>
• And most importantly, it looks good!<br>
<br>
The <a href="JGProgressHUD%20Tests">JGProgressHUD Tests</a> example project contains all kinds of different uses of JGProgressHUD. Check out the code and see how much JGProgressHUD can do!
<br>
#####Current Version: 1.2.6
[![GitHub license](https://img.shields.io/github/license/JonasGessner/JGProgressHUD.svg)]()<br>
[![CocoaPods](https://img.shields.io/cocoapods/v/JGProgressHUD.svg)]()
#####Current Version: 1.2.7
![GitHub license](https://img.shields.io/github/license/JonasGessner/JGProgressHUD.svg)<br>
![CocoaPods](https://img.shields.io/cocoapods/v/JGProgressHUD.svg)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
##Customization:

###Styles:
JGProgressHUD can be displayed in 3 styles:<br>
• <b>Extra Light</b><br>
• <b>Light<br>
• <b>Dark<br>
• <b>Light</b><br>
• <b>Dark</b><br>

###Indicator Views:
By default a HUD will display an indeterminate progress indicator. You can not show an indicator view at all by setting the `indicatorView` property to nil. These indicator views are available:<br>
Expand Down

0 comments on commit 0e21fb3

Please sign in to comment.