Skip to content

Commit

Permalink
Fixed Issues #9, #14, #16
Browse files Browse the repository at this point in the history
Also updated the documentation to reflect the changes.
  • Loading branch information
NinjaKittenProductions committed Feb 19, 2014
1 parent 5be2d27 commit 4b4ec1d
Show file tree
Hide file tree
Showing 43 changed files with 531 additions and 93 deletions.
7 changes: 7 additions & 0 deletions Classes/HUD/M13ProgressHUD.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ typedef enum {
@property (nonatomic, assign) BOOL dismissAfterAction;
/**Wether or not the HUD is currenty visible.*/
- (BOOL)isVisible;
/**Wether or not the HUD will auto rotate to the device orientation.
@note If set to `YES`, The HUD will rotate automatically to the device orientation, regardless of the interface orientation. This setting is suggested if the displayed view controller rotates and the HUD is displayed in a UIWindow. If the HUD is contained in a UIViewController. This setting should be set to NO, and the rotation should be set manually via the rotation property.
*/
@property (nonatomic, assign) BOOL shouldAutorotate;
/**The orientation of the HUD.*/
@property (nonatomic, assign) UIInterfaceOrientation orientation;

/**@name Actions*/
/**Set the progress of the `M13ProgressView`.
Expand All @@ -101,6 +107,7 @@ typedef enum {
@param animated Wether or not to animate the change*/
- (void)show:(BOOL)animated;
/**Hide the progress HUD.
@note This method should be used when the HUD is going to be reused. When the HUD needs to be shown again, use `show:` do not initalize another instance. That will cause a memory leak. If the HUD is not going to be reused, use `dismiss:` instead. To retreive a hidden HUD, either hold onto it with a global variable, or use the `progressHUD` method for UIView.
@param animated Wether or not to animate the change*/
- (void)hide:(BOOL)animated;
/**Dismiss the progress HUD and remove it from its superview.
Expand Down
47 changes: 37 additions & 10 deletions Classes/HUD/M13ProgressHUD.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ - (void)setup
_secondaryColor = [UIColor colorWithRed:181/255.0 green:182/255.0 blue:183/255.0 alpha:1.0];
_progress = 0;
_indeterminate = NO;
_shouldAutorotate = YES;
if (self.frame.size.height != 0 && self.frame.size.width != 0) {
_progressViewSize = CGSizeMake(150 / 4, 150 / 4);
}
Expand Down Expand Up @@ -278,6 +279,7 @@ - (void)performAction:(M13ProgressViewAction)action animated:(BOOL)animated
- (void)show:(BOOL)animated
{
//reset the blurs to the curent screen if need be
[self registerForNotificationCenter];
[self setNeedsLayout];
[self setNeedsDisplay];

Expand Down Expand Up @@ -309,6 +311,8 @@ - (void)show:(BOOL)animated

- (void)hide:(BOOL)animated
{
[self unregisterFromNotificationCenter];

CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnimation.fromValue = [NSNumber numberWithFloat:1.0];
fadeAnimation.toValue = [NSNumber numberWithFloat:0.0];
Expand Down Expand Up @@ -342,6 +346,9 @@ - (void)hide:(BOOL)animated
- (void)dismiss:(BOOL)animated
{
[self hide:animated];

//Removes the HUD from the superview, dismissing it.
[self performSelector:@selector(removeFromSuperview) withObject:Nil afterDelay:_animationDuration];
}

#pragma mark - Notifications
Expand All @@ -357,11 +364,23 @@ - (void)unregisterFromNotificationCenter {
}

- (void)deviceOrientationDidChange:(NSNotification *)notification {
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^{
[self setNeedsLayout];
[self setNeedsDisplay];
});
if (_shouldAutorotate) {
UIDeviceOrientation deviceOrientation = [notification.object orientation];
if (UIDeviceOrientationIsPortrait(deviceOrientation)) {
if (deviceOrientation == UIDeviceOrientationPortraitUpsideDown) {
_orientation = UIInterfaceOrientationPortraitUpsideDown;
} else {
_orientation = UIInterfaceOrientationPortrait;
}
} else {
if (deviceOrientation == UIDeviceOrientationLandscapeLeft) {
_orientation = UIInterfaceOrientationLandscapeLeft;
} else {
_orientation = UIInterfaceOrientationLandscapeRight;
}
}
[self layoutHUD];
}
}

#pragma mark Layout
Expand Down Expand Up @@ -502,10 +521,19 @@ - (void)layoutHUD
statusRect.size.height = 0.0;
}

//Swap height and with on rotation
if (_orientation == UIInterfaceOrientationLandscapeLeft || _orientation == UIInterfaceOrientationLandscapeRight) {
//Flip the width and height.
CGFloat temp = backgroundRect.size.width;
backgroundRect.size.width = backgroundRect.size.height;
backgroundRect.size.height = temp;
}

//Set the frame of the background and its subviews
[UIView animateWithDuration:_animationDuration animations:^{
backgroundView.frame = CGRectIntegral(backgroundRect);
_progressView.frame = CGRectIntegral(progressRect);
backgroundView.transform = CGAffineTransformMakeRotation([self angleForDeviceOrientation]);
//Fade the label
statusLabel.alpha = 0.0;
} completion:^(BOOL finished) {
Expand Down Expand Up @@ -712,12 +740,11 @@ - (UIImage *)snapshotForBlurredBackgroundInView:(UIView *)view

- (CGFloat)angleForDeviceOrientation
{
UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation;
if (orientation == UIInterfaceOrientationLandscapeLeft) {
return -M_PI_2;
} else if (orientation == UIInterfaceOrientationLandscapeRight) {
if (_orientation == UIInterfaceOrientationLandscapeLeft) {
return M_PI_2;
} else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
} else if (_orientation == UIInterfaceOrientationLandscapeRight) {
return -M_PI_2;
} else if (_orientation == UIInterfaceOrientationPortraitUpsideDown) {
return M_PI;
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion Documentation/docset-installed.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Documentation set was installed to Xcode!

Path: /Users/Brandon/Library/Developer/Shared/Documentation/DocSets/com.BrandonMcQuilkin.M13ProgressSuite.docset
Time: 2014-01-17 16:58:14 +0000
Time: 2014-02-19 14:59:02 +0000
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
<p><span class="copyright">&copy; 2014 Marxon13 Productions (Brandon McQuilkin). All rights reserved. (Last updated: 2014-01-17)</span><br />
<p><span class="copyright">&copy; 2014 Marxon13 Productions (Brandon McQuilkin). All rights reserved. (Last updated: 2014-02-19)</span><br />

<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.2 (build 961)</a>.</span></p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
<p><span class="copyright">&copy; 2014 Marxon13 Productions (Brandon McQuilkin). All rights reserved. (Last updated: 2014-01-17)</span><br />
<p><span class="copyright">&copy; 2014 Marxon13 Productions (Brandon McQuilkin). All rights reserved. (Last updated: 2014-02-19)</span><br />

<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.2 (build 961)</a>.</span></p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ <h1 class="hideInXcode">M13ProgressHUD Class Reference</h1>

<option value="//api/name/animationDuration">&nbsp;&nbsp;&nbsp;&nbsp;animationDuration</option>

<option value="//api/name/animationPoint">&nbsp;&nbsp;&nbsp;&nbsp;animationPoint</option>

<option value="//api/name/applyBlurToBackground">&nbsp;&nbsp;&nbsp;&nbsp;applyBlurToBackground</option>

<option value="//api/name/contentMargin">&nbsp;&nbsp;&nbsp;&nbsp;contentMargin</option>
Expand All @@ -61,6 +63,8 @@ <h1 class="hideInXcode">M13ProgressHUD Class Reference</h1>

<option value="//api/name/offsetFromCenter">&nbsp;&nbsp;&nbsp;&nbsp;offsetFromCenter</option>

<option value="//api/name/orientation">&nbsp;&nbsp;&nbsp;&nbsp;orientation</option>

<option value="//api/name/primaryColor">&nbsp;&nbsp;&nbsp;&nbsp;primaryColor</option>

<option value="//api/name/progress">&nbsp;&nbsp;&nbsp;&nbsp;progress</option>
Expand All @@ -71,6 +75,8 @@ <h1 class="hideInXcode">M13ProgressHUD Class Reference</h1>

<option value="//api/name/secondaryColor">&nbsp;&nbsp;&nbsp;&nbsp;secondaryColor</option>

<option value="//api/name/shouldAutorotate">&nbsp;&nbsp;&nbsp;&nbsp;shouldAutorotate</option>

<option value="//api/name/status">&nbsp;&nbsp;&nbsp;&nbsp;status</option>

<option value="//api/name/statusColor">&nbsp;&nbsp;&nbsp;&nbsp;statusColor</option>
Expand Down Expand Up @@ -136,6 +142,8 @@ <h1 class="hideInXcode">M13ProgressHUD Class Reference</h1>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/animationDuration">animationDuration</a></span></li>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/animationPoint">animationPoint</a></span></li>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/applyBlurToBackground">applyBlurToBackground</a></span></li>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/contentMargin">contentMargin</a></span></li>
Expand All @@ -156,6 +164,8 @@ <h1 class="hideInXcode">M13ProgressHUD Class Reference</h1>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/offsetFromCenter">offsetFromCenter</a></span></li>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/orientation">orientation</a></span></li>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/primaryColor">primaryColor</a></span></li>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/progress">progress</a></span></li>
Expand All @@ -166,6 +176,8 @@ <h1 class="hideInXcode">M13ProgressHUD Class Reference</h1>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/secondaryColor">secondaryColor</a></span></li>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/shouldAutorotate">shouldAutorotate</a></span></li>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/status">status</a></span></li>

<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/statusColor">statusColor</a></span></li>
Expand Down Expand Up @@ -367,6 +379,12 @@ <h3 class="subsubtitle task-title">Appearance</h3>
</span>
<span class="task-item-suffix">property</span>

</li><li>
<span class="tooltip">
<code><a href="#//api/name/animationPoint">&nbsp;&nbsp;animationPoint</a></code>
</span>
<span class="task-item-suffix">property</span>

</li>
</ul>

Expand Down Expand Up @@ -405,6 +423,18 @@ <h3 class="subsubtitle task-title">Properties</h3>
</span>


</li><li>
<span class="tooltip">
<code><a href="#//api/name/shouldAutorotate">&nbsp;&nbsp;shouldAutorotate</a></code>
</span>
<span class="task-item-suffix">property</span>

</li><li>
<span class="tooltip">
<code><a href="#//api/name/orientation">&nbsp;&nbsp;orientation</a></code>
</span>
<span class="task-item-suffix">property</span>

</li>
</ul>

Expand Down Expand Up @@ -484,6 +514,42 @@ <h3 class="subsubtitle method-title">animationDuration</h3>



<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">M13ProgressHUD.h</code><br />
</div>


</div>

<div class="section-method">
<a name="//api/name/animationPoint" title="animationPoint"></a>
<h3 class="subsubtitle method-title">animationPoint</h3>



<div class="method-subsection brief-description">
<p>The origin of the show/hide animation. <a href="#//api/name/show:">show:</a> will animate from this point, and <a href="#//api/name/hide:">hide:</a> will animate to this point.</p>
</div>



<div class="method-subsection method-declaration"><code>@property (nonatomic, assign) CGPoint animationPoint</code></div>















<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">M13ProgressHUD.h</code><br />
Expand Down Expand Up @@ -849,6 +915,42 @@ <h3 class="subsubtitle method-title">offsetFromCenter</h3>



<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">M13ProgressHUD.h</code><br />
</div>


</div>

<div class="section-method">
<a name="//api/name/orientation" title="orientation"></a>
<h3 class="subsubtitle method-title">orientation</h3>



<div class="method-subsection brief-description">
<p>The orientation of the HUD.</p>
</div>



<div class="method-subsection method-declaration"><code>@property (nonatomic, assign) UIInterfaceOrientation orientation</code></div>















<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">M13ProgressHUD.h</code><br />
Expand Down Expand Up @@ -1029,6 +1131,47 @@ <h3 class="subsubtitle method-title">secondaryColor</h3>



<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">M13ProgressHUD.h</code><br />
</div>


</div>

<div class="section-method">
<a name="//api/name/shouldAutorotate" title="shouldAutorotate"></a>
<h3 class="subsubtitle method-title">shouldAutorotate</h3>



<div class="method-subsection brief-description">
<p>Wether or not the HUD will auto rotate to the device <a href="#//api/name/orientation">orientation</a>.</p>
</div>



<div class="method-subsection method-declaration"><code>@property (nonatomic, assign) BOOL shouldAutorotate</code></div>









<div class="method-subsection discussion-section">
<h4 class="method-subtitle">Discussion</h4>
<div class="note"><p><strong>Note:</strong> If set to <code>YES</code>, The HUD will rotate automatically to the device <a href="#//api/name/orientation">orientation</a>, regardless of the interface <a href="#//api/name/orientation">orientation</a>. This setting is suggested if the displayed view controller rotates and the HUD is displayed in a UIWindow. If the HUD is contained in a UIViewController. This setting should be set to NO, and the rotation should be set manually via the rotation property.</p></div>
</div>







<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">M13ProgressHUD.h</code><br />
Expand Down Expand Up @@ -1269,6 +1412,11 @@ <h4 class="method-subtitle parameter-title">Parameters</h4>



<div class="method-subsection discussion-section">
<h4 class="method-subtitle">Discussion</h4>
<div class="note"><p><strong>Note:</strong> This method should be used when the HUD is going to be reused. When the HUD needs to be shown again, use <a href="#//api/name/show:"><code>show:</code></a> do not initalize another instance. That will cause a memory leak. If the HUD is not going to be reused, use <a href="#//api/name/dismiss:"><code>dismiss:</code></a> instead. To retreive a hidden HUD, either hold onto it with a global variable, or use the <code>progressHUD</code> method for UIView.</p></div>
</div>




Expand Down Expand Up @@ -1533,7 +1681,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
<p><span class="copyright">&copy; 2014 Marxon13 Productions (Brandon McQuilkin). All rights reserved. (Last updated: 2014-01-17)</span><br />
<p><span class="copyright">&copy; 2014 Marxon13 Productions (Brandon McQuilkin). All rights reserved. (Last updated: 2014-02-19)</span><br />

<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.2 (build 961)</a>.</span></p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ <h4 class="method-subtitle">Declared In</h4>
<div id="footer">
<hr />
<div class="footer-copyright">
<p><span class="copyright">&copy; 2014 Marxon13 Productions (Brandon McQuilkin). All rights reserved. (Last updated: 2014-01-17)</span><br />
<p><span class="copyright">&copy; 2014 Marxon13 Productions (Brandon McQuilkin). All rights reserved. (Last updated: 2014-02-19)</span><br />

<span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.2 (build 961)</a>.</span></p>

Expand Down
Loading

0 comments on commit 4b4ec1d

Please sign in to comment.