Skip to content
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
2 changes: 1 addition & 1 deletion MMProgressHUD.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Pod::Spec.new do |s|
s.license = 'MIT'
s.author = { "Lars Anderson" => "[email protected]" }
s.source = {
:git => "https://github.com/mutualmobile/MMProgressHUD.git",
:git => "https://github.com/ryanmsmith/MMProgressHUD.git",
:tag => s.version.to_s
}
s.platform = :ios, '5.0'
Expand Down
77 changes: 76 additions & 1 deletion Source/MMProgressHUD+Class.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,82 @@ + (void)showWithTitle:(NSString *)title
}
}

//hold prior to dismissal

+ (void)holdWithError:(NSString *)status
{
[MMProgressHUD holdWithError:status
title:nil];
}

+ (void)holdWithError:(NSString *)status
title:(NSString *)title
{
[MMProgressHUD holdWithError:status
title:title
afterDelay:MMProgressHUDStandardDismissDelay];
}

+ (void)holdWithError:(NSString *)status
title:(NSString *)title
afterDelay:(NSTimeInterval)delay
{
if ([NSThread isMainThread] == NO)
{
dispatch_sync(dispatch_get_main_queue(), ^{
[[MMProgressHUD sharedHUD] holdWithCompletionState:MMProgressHUDCompletionStateError
title:title
status:status
afterDelay:delay];
});
}
else
{
[[MMProgressHUD sharedHUD] holdWithCompletionState:MMProgressHUDCompletionStateError
title:title
status:status
afterDelay:delay];
}
}

+ (void)holdWithSuccess:(NSString *)status
{
[MMProgressHUD holdWithSuccess:status
title:nil];
}

+ (void)holdWithSuccess:(NSString *)status
title:(NSString *)title
{
[MMProgressHUD holdWithSuccess:status
title:title
afterDelay:MMProgressHUDStandardDismissDelay];
}

+ (void)holdWithSuccess:(NSString *)status
title:(NSString *)title
afterDelay:(NSTimeInterval)delay
{
if ([NSThread isMainThread] == NO)
{
dispatch_sync(dispatch_get_main_queue(), ^{
[[MMProgressHUD sharedHUD] holdWithCompletionState:MMProgressHUDCompletionStateSuccess
title:title
status:status
afterDelay:delay];
});
}
else
{
[[MMProgressHUD sharedHUD] holdWithCompletionState:MMProgressHUDCompletionStateSuccess
title:title
status:status
afterDelay:delay];
}
}

//dismissal

+ (void)dismissWithError:(NSString *)status
title:(NSString *)title
afterDelay:(NSTimeInterval)delay {
Expand Down Expand Up @@ -269,7 +344,7 @@ + (void)dismissWithError:(NSString *)status
afterDelay:delay];
}

+ (void)dismissWithSuccess:(NSString *)status
+ (void)dismissWithSuccess:(NSString *)status
title:(NSString *)title
afterDelay:(NSTimeInterval)delay {
if ([NSThread isMainThread] == NO) {
Expand Down
42 changes: 42 additions & 0 deletions Source/MMProgressHUD.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ This message will be presented to the user when a cancelBlock is present after t
@property (nonatomic, assign) Class progressViewClass;

#pragma mark - Instance Methods

- (void)holdWithCompletionState:(MMProgressHUDCompletionState)completionState
title:(NSString *)title
status:(NSString *)status
afterDelay:(NSTimeInterval)delay;

- (void)showWithTitle:(NSString *)title
status:(NSString *)status
confirmationMessage:(NSString *)confirmationMessage
Expand Down Expand Up @@ -334,6 +340,39 @@ This message will be presented to the user when a cancelBlock is present after t
status:(NSString *)status
images:(NSArray *)images;


//-----------------------------------------------
/** @name Hold prior to dismissal */
//-----------------------------------------------

/** Holds the shared HUD with the current presentationStyle in an error-state. Dismiss with tap.

@param message Error message to display to the user.
*/
+ (void)holdWithError:(NSString *)message;

/** Holds the shared HUD with the current presentationStyle in an error-state. Dismiss with tap.

@param message Error message to display to the user.
@param title Error title to display to the user.
*/
+ (void)holdWithError:(NSString *)message
title:(NSString *)title;

/** Holds the shared HUD with the current presentationStyle in an error-state. Dismiss with tap.

@param message Success message to display to the user.
*/
+ (void)holdWithSuccess:(NSString *)message;

/** Holds the shared HUD with the current presentationStyle in an error-state. Dismiss with tap.

@param message Success message to display to the user.
@param title Success title to display to the user.
*/
+ (void)holdWithSuccess:(NSString *)message
title:(NSString *)title;

//-----------------------------------------------
/** @name Dismissal */
//-----------------------------------------------
Expand All @@ -347,6 +386,9 @@ This message will be presented to the user when a cancelBlock is present after t
*/
+ (void)dismissAfterDelay:(NSTimeInterval)delay;




#pragma mark - Dismiss with Error

/** Dismisses the shared HUD with the current presentationStyle in an error-state after a user-specified delay.
Expand Down
32 changes: 29 additions & 3 deletions Source/MMProgressHUD.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ - (void)dismissWithCompletionState:(MMProgressHUDCompletionState)completionState
}
}

- (void)holdWithCompletionState:(MMProgressHUDCompletionState)completionState
title:(NSString *)title
status:(NSString *)status
afterDelay:(NSTimeInterval)delay
{
if (title)
{
self.title = title;
}

if (status)
{
self.status = status;
}

self.hud.completionState = completionState;

if (self.isVisible)
{
[self _updateHUDAnimated:YES withCompletion:^(BOOL completed) {
self.confirmed = YES;
}];
}
}

- (void)updateProgress:(CGFloat)progress withStatus:(NSString *)status title:(NSString *)title{
[self setProgress:progress];

Expand Down Expand Up @@ -455,14 +480,15 @@ - (CGPoint)_windowCenterForHUDAnchor:(CGPoint)anchor {
CGFloat hudHeight = CGRectGetHeight(self.hud.frame);

CGPoint position;
if (UIInterfaceOrientationIsPortrait([[self.window rootViewController] interfaceOrientation])) {
CGFloat systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (UIInterfaceOrientationIsPortrait([[self.window rootViewController] interfaceOrientation]) || systemVersion>=8) {

CGFloat y = roundf(self.window.center.y + (anchor.y - 0.5f) * hudHeight);
CGFloat x = roundf(self.window.center.x);

position = CGPointMake(x, y);
}
else {
else if (UIInterfaceOrientationIsLandscape([[self.window rootViewController] interfaceOrientation])) {
CGFloat x = roundf(self.window.center.y);
CGFloat y = roundf(self.window.center.x + (anchor.y - 0.5f) * hudHeight);

Expand Down Expand Up @@ -709,7 +735,7 @@ - (void)_handleTap:(UITapGestureRecognizer *)recognizer {
self.cancelBlock();
}

self.hud.completionState = MMProgressHUDCompletionStateError;
// self.hud.completionState = MMProgressHUDCompletionStateNone;
[self.hud setNeedsUpdate:YES];
[self.hud updateAnimated:YES
withCompletion:^(__unused BOOL completed) {
Expand Down
38 changes: 19 additions & 19 deletions Source/MMProgressHUDWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,25 @@ - (void)setRootViewController:(UIViewController *)rootViewController {
}

- (void)orientRootViewControllerForOrientation:(UIInterfaceOrientation)interfaceOrientation {
CGAffineTransform transform;

switch (interfaceOrientation) {
case UIInterfaceOrientationLandscapeRight:
transform = CGAffineTransformMakeRotation(M_PI_2);
break;
case UIInterfaceOrientationLandscapeLeft:
transform = CGAffineTransformMakeRotation(-M_PI_2);
break;
case UIInterfaceOrientationPortraitUpsideDown:
transform = CGAffineTransformMakeRotation(M_PI);
break;
default:
case UIInterfaceOrientationPortrait:
transform = CGAffineTransformIdentity;
break;
}

self.rootViewController.view.transform = transform;
// CGAffineTransform transform;
//
// switch (interfaceOrientation) {
// case UIInterfaceOrientationLandscapeRight:
// transform = CGAffineTransformMakeRotation(M_PI_2);
// break;
// case UIInterfaceOrientationLandscapeLeft:
// transform = CGAffineTransformMakeRotation(-M_PI_2);
// break;
// case UIInterfaceOrientationPortraitUpsideDown:
// transform = CGAffineTransformMakeRotation(M_PI);
// break;
// default:
// case UIInterfaceOrientationPortrait:
// transform = CGAffineTransformIdentity;
// break;
// }
//
// self.rootViewController.view.transform = transform;
}

- (void)dealloc {
Expand Down