Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Commit

Permalink
Hard fork.
Browse files Browse the repository at this point in the history
  • Loading branch information
zwaldowski committed Apr 1, 2012
1 parent ffad5c5 commit ec73138
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 1,668 deletions.
50 changes: 25 additions & 25 deletions MBProgressHUD.h → DZProgressHUD.h
@@ -1,5 +1,5 @@
//
// MBProgressHUD.h
// DZProgressHUD.h
//
// (c) 2009-2011 Matej Bukovinski and contributors.
// This code is licensed under MIT. See LICENSE for more information.
Expand All @@ -8,19 +8,19 @@
#import <UIKit/UIKit.h>

/** When set as the HUD's custom view, the HUD will show a check image. **/
extern const id MBProgressHUDSuccessImageView;
extern const id DZProgressHUDSuccessImageView;

/** When set as the HUD's custom view, the HUD will show an error image. **/
extern const id MBProgressHUDErrorImageView;
extern const id DZProgressHUDErrorImageView;

typedef enum {
/** Progress is shown using an UIActivityIndicatorView. This is the default. */
MBProgressHUDModeIndeterminate,
/** Progress is shown using a MBRoundProgressView. */
MBProgressHUDModeDeterminate,
DZProgressHUDModeIndeterminate,
/** Progress is shown using a DZRoundProgressView. */
DZProgressHUDModeDeterminate,
/** Shows a custom view */
MBProgressHUDModeCustomView
} MBProgressHUDMode;
DZProgressHUDModeCustomView
} DZProgressHUDMode;

/**
* Displays a simple HUD window containing a progress indicator and two optional labels for short messages.
Expand All @@ -32,16 +32,16 @@ typedef enum {
* a rounded semi-transparent box that resizes depending on its content.
*
* The HUD supports three modes of operation:
* - MBProgressHUDModeIndeterminate - shows a UIActivityIndicatorView
* - MBProgressHUDModeDeterminate - shows a custom round progress indicator
* - MBProgressHUDModeCustomView - shows an arbitrary, user specified view
* - DZProgressHUDModeIndeterminate - shows a UIActivityIndicatorView
* - DZProgressHUDModeDeterminate - shows a custom round progress indicator
* - DZProgressHUDModeCustomView - shows an arbitrary, user specified view
*
* All three modes have an optional label. If the label has text, then the label
* is placed below the indicator view.
*
* @see customView
*/
@interface MBProgressHUD : UIView
@interface DZProgressHUD : UIView

/**
* Creates a new HUD and shows it on the current window.
Expand All @@ -51,7 +51,7 @@ typedef enum {
* @see showOnView:
* @see hide
*/
+ (MBProgressHUD *)show;
+ (DZProgressHUD *)show;

/**
* Creates a new HUD and shows it on the provided view.
Expand All @@ -62,7 +62,7 @@ typedef enum {
* @see show
* @see hide
*/
+ (MBProgressHUD *)showOnView:(UIView *)view;
+ (DZProgressHUD *)showOnView:(UIView *)view;

/**
* Shows a HUD on the current window using while executing a block in the background.
Expand All @@ -75,7 +75,7 @@ typedef enum {
*
* @see showWithText:whileExecuting:
*/
+ (void)showWhileExecuting:(void(^)(MBProgressHUD *))block;
+ (void)showWhileExecuting:(void(^)(DZProgressHUD *))block;

/**
* Shows a HUD on the current window using while executing a block in the background.
Expand All @@ -90,29 +90,29 @@ typedef enum {
* @see label
* @see showWhileExecuting:
*/
+ (void)showWithText:(NSString *)statusText whileExecuting:(void(^)(MBProgressHUD *))block;
+ (void)showWithText:(NSString *)statusText whileExecuting:(void(^)(DZProgressHUD *))block;

/**
* The view to be shown when the HUD is set to MBProgressHUDModeCustomView.
* The view to be shown when the HUD is set to DZProgressHUDModeCustomView.
* For best results, use a 37x37 view (so the bounds match the default indicator bounds).
*
* Pass `MBProgressHUDSuccessImageView` for an image view with a check.
* Pass `MBProgressHUDErrorImageView`, for an image view with an error symbol.
* Pass `DZProgressHUDSuccessImageView` for an image view with a check.
* Pass `DZProgressHUDErrorImageView`, for an image view with an error symbol.
**/
@property (nonatomic, strong) UIView *customView;

/**
* HUD operation mode. The default is MBProgressHUDModeIndeterminate.
* HUD operation mode. The default is DZProgressHUDModeIndeterminate.
*
* @see MBProgressHUDMode
* @see DZProgressHUDMode
*/
@property (nonatomic) MBProgressHUDMode mode;
@property (nonatomic) DZProgressHUDMode mode;

/** A callback fired when the HUD is tapped. */
@property (nonatomic, copy) void(^wasTappedBlock)(MBProgressHUD *);
@property (nonatomic, copy) void(^wasTappedBlock)(DZProgressHUD *);

/** A callback fired when the HUD is hidden. */
@property (nonatomic, copy) void(^wasHiddenBlock)(MBProgressHUD *);
@property (nonatomic, copy) void(^wasHiddenBlock)(DZProgressHUD *);

/*
* The show delay is the time (in seconds) that your method may run without the HUD
Expand Down Expand Up @@ -203,7 +203,7 @@ typedef enum {
/**
* A progress view for showing definite progress by filling up a circle (pie chart).
*/
@interface MBRoundProgressView : UIView
@interface DZRoundProgressView : UIView

@property (nonatomic) CGFloat progress;

Expand Down
74 changes: 37 additions & 37 deletions MBProgressHUD.m → DZProgressHUD.m
@@ -1,19 +1,19 @@
//
// MBProgressHUD.m
// DZProgressHUD.m
//
// (c) 2009-2011 Matej Bukovinski and contributors.
// This code is licensed under MIT. See LICENSE for more information.
//

#import "MBProgressHUD.h"
#import "DZProgressHUD.h"

#pragma mark Constants and Functions

typedef void(^MBUnlockBlock)(NSTimeInterval);
typedef void(^MBLockBlock)(const MBUnlockBlock unlock);
typedef void(^DZProgressHUDUnlockBlock)(NSTimeInterval);
typedef void(^DZProgressHUDLockBlock)(const DZProgressHUDUnlockBlock unlock);

NSString *const MBProgressHUDSuccessImageView = @"MBProgressHUDSuccessImageView";
NSString *const MBProgressHUDErrorImageView = @"MBProgressHUDErrorImageView";
NSString *const DZProgressHUDSuccessImageView = @"DZProgressHUDSuccessImageView";
NSString *const DZProgressHUDErrorImageView = @"DZProgressHUDErrorImageView";

static const CGFloat padding = 4.0f;
static const CGFloat margin = 18.0f;
Expand All @@ -32,7 +32,7 @@ static void dispatch_reentrant_main(dispatch_block_t block) {
}
}

static void dispatch_semaphore_execute(dispatch_semaphore_t semaphore, MBLockBlock block) {
static void dispatch_semaphore_execute(dispatch_semaphore_t semaphore, DZProgressHUDLockBlock block) {
NSCParameterAssert(block);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
Expand All @@ -54,7 +54,7 @@ static void dispatch_semaphore_execute(dispatch_semaphore_t semaphore, MBLockBlo

#pragma mark -

@implementation MBProgressHUD {
@implementation DZProgressHUD {
UIStatusBarStyle _statusBarStyle;
CGRect _HUDRect;
CGAffineTransform _rotationTransform;
Expand All @@ -72,24 +72,24 @@ @implementation MBProgressHUD {

#pragma mark - Class methods

+ (MBProgressHUD *)show {
+ (DZProgressHUD *)show {
return [self showOnView:nil];
}

+ (MBProgressHUD *)showOnView:(UIView *)view {
MBProgressHUD *hud = [MBProgressHUD new];
+ (DZProgressHUD *)showOnView:(UIView *)view {
DZProgressHUD *hud = [DZProgressHUD new];
[hud showOnView:view];
return hud;
}

+ (void)showWhileExecuting:(void(^)(MBProgressHUD *))block {
+ (void)showWhileExecuting:(void(^)(DZProgressHUD *))block {
[self showWithText:nil whileExecuting:block];
}

+ (void)showWithText:(NSString *)statusText whileExecuting:(void(^)(MBProgressHUD *))block {
+ (void)showWithText:(NSString *)statusText whileExecuting:(void(^)(DZProgressHUD *))block {
if (!block) return;

MBProgressHUD *thisHUD = [self new];
DZProgressHUD *thisHUD = [self new];
thisHUD.label.text = statusText;
[thisHUD showWhileExecuting:^{
block(thisHUD);
Expand Down Expand Up @@ -169,7 +169,7 @@ - (void)reloadIndicatorView:(UIView *)newIndicator {
[_indicator removeFromSuperview];
_indicator = newIndicator;
[self addSubview:newIndicator];
if (mode == MBProgressHUDModeIndeterminate)
if (mode == DZProgressHUDModeIndeterminate)
[(UIActivityIndicatorView *)newIndicator startAnimating];
[self setNeedsLayout];
});
Expand Down Expand Up @@ -233,7 +233,7 @@ - (void)showOnView:(UIView *)view {
if (!self.superview && !view)
view = [[[UIApplication sharedApplication] delegate] respondsToSelector:@selector(window)] ? [[[UIApplication sharedApplication] delegate] window] : [[[UIApplication sharedApplication] windows] objectAtIndex:0];

dispatch_semaphore_execute(_animationSemaphore, ^(const MBUnlockBlock unlock) {
dispatch_semaphore_execute(_animationSemaphore, ^(const DZProgressHUDUnlockBlock unlock) {
if (!self.superview)
[view addSubview:self];

Expand All @@ -254,7 +254,7 @@ - (void)showOnView:(UIView *)view {
}

- (void)hide {
dispatch_semaphore_execute(_animationSemaphore, ^(const MBUnlockBlock unlock) {
dispatch_semaphore_execute(_animationSemaphore, ^(const DZProgressHUDUnlockBlock unlock) {
if (!self.superview)
return;

Expand Down Expand Up @@ -292,7 +292,7 @@ - (void)showWhileExecuting:(void(^)(void))block {

- (void)performChanges:(void(^)(void))animations {
NSCParameterAssert(animations);
dispatch_semaphore_execute(_animationSemaphore, ^(const MBUnlockBlock unlock) {
dispatch_semaphore_execute(_animationSemaphore, ^(const DZProgressHUDUnlockBlock unlock) {
[UIView transitionWithView:self
duration:(1./3.)
options:UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionTransitionFlipFromRight|UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionLayoutSubviews|UIViewAnimationOptionAllowAnimatedContent
Expand Down Expand Up @@ -367,7 +367,7 @@ - (void)layoutSubviews {

#pragma mark - Accessors

- (void)setMode:(MBProgressHUDMode)newMode {
- (void)setMode:(DZProgressHUDMode)newMode {
// Don't change mode if it wasn't actually changed to prevent flickering
if (mode && (mode == newMode)) {
return;
Expand All @@ -377,21 +377,21 @@ - (void)setMode:(MBProgressHUDMode)newMode {

UIView *newIndicator = nil;

if (mode == MBProgressHUDModeDeterminate)
newIndicator = [MBRoundProgressView new];
else if (mode == MBProgressHUDModeIndeterminate)
if (mode == DZProgressHUDModeDeterminate)
newIndicator = [DZRoundProgressView new];
else if (mode == DZProgressHUDModeIndeterminate)
newIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
else if (mode == MBProgressHUDModeCustomView && self.customView)
else if (mode == DZProgressHUDModeCustomView && self.customView)
newIndicator = self.customView;

[self reloadIndicatorView:newIndicator];
}

- (void)setCustomView:(UIView *)newCustomView {
if ([newCustomView isKindOfClass:[NSString class]]) {
if ([newCustomView isEqual:MBProgressHUDSuccessImageView])
if ([newCustomView isEqual:DZProgressHUDSuccessImageView])
newCustomView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"success"]];
else if ([newCustomView isEqual:MBProgressHUDErrorImageView])
else if ([newCustomView isEqual:DZProgressHUDErrorImageView])
newCustomView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"error"]];
else
return;
Expand All @@ -403,18 +403,18 @@ - (void)setCustomView:(UIView *)newCustomView {
}

- (CGFloat)progress {
if (mode != MBProgressHUDModeDeterminate)
if (mode != DZProgressHUDModeDeterminate)
return 0.0f;

return [(MBRoundProgressView *)_indicator progress];
return [(DZRoundProgressView *)_indicator progress];
}

- (void)setProgress:(CGFloat)newProgress {
dispatch_reentrant_main(^{
if (![_indicator isKindOfClass:[MBRoundProgressView class]])
if (![_indicator isKindOfClass:[DZRoundProgressView class]])
return;

[(MBRoundProgressView *)_indicator setProgress:newProgress];
[(DZRoundProgressView *)_indicator setProgress:newProgress];
});
}

Expand All @@ -423,11 +423,11 @@ - (void)setProgress:(CGFloat)newProgress animated:(BOOL)animated {
[self setProgress:newProgress];

dispatch_reentrant_main(^{
if (![_indicator isKindOfClass:[MBRoundProgressView class]])
if (![_indicator isKindOfClass:[DZRoundProgressView class]])
return;

[UIView animateWithDuration:(1./3.) delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionAllowAnimatedContent animations:^{
[(MBRoundProgressView *)_indicator setProgress:newProgress];
[(DZRoundProgressView *)_indicator setProgress:newProgress];
} completion:NULL];
});
}
Expand Down Expand Up @@ -460,13 +460,13 @@ - (UILabel *)label {

#import <QuartzCore/QuartzCore.h>

@interface MBRoundProgressLayer : CALayer
@interface DZRoundProgressLayer : CALayer

@property (nonatomic) CGFloat progress;

@end

@implementation MBRoundProgressLayer
@implementation DZRoundProgressLayer

@dynamic progress;

Expand Down Expand Up @@ -501,10 +501,10 @@ - (id)actionForKey:(NSString *) aKey {

@end

@implementation MBRoundProgressView
@implementation DZRoundProgressView

+ (Class)layerClass {
return [MBRoundProgressLayer class];
return [DZRoundProgressLayer class];
}

- (id)init {
Expand All @@ -524,11 +524,11 @@ - (id)initWithFrame:(CGRect)frame {
}

- (void)setProgress:(CGFloat)progress {
[(MBRoundProgressLayer *)self.layer setProgress:progress];
[(id)self.layer setProgress:progress];
}

- (CGFloat)progress {
return [(MBRoundProgressLayer *)self.layer progress];
return [(id)self.layer progress];
}

@end
12 changes: 5 additions & 7 deletions MBProgressHUD.podspec → DZProgressHUD.podspec
@@ -1,14 +1,12 @@
Pod::Spec.new do |s|
s.name = 'MBProgressHUD'
s.name = 'DZProgressHUD'
s.platform = :ios
s.license = 'MIT'
s.summary = 'A dead simple, drop-in HUD view for iOS.'
s.homepage = 'https://github.com/zwaldowski/MBProgressHUD'
s.author = { 'Zachary Waldowski' => 'zwaldowski@gmail.com',
'Jonathan George' => 'jonathan@jdg.net',
'Matej Bukovinski' => 'matej@bukovinski.com' }
s.source = { :git => 'https://github.com/zwaldowski/MBProgressHUD.git' }
s.description = 'MBProgressHUD is a drop-in iOS class that displays a translucent HUD with a ' \
s.homepage = 'https://github.com/zwaldowski/DZProgressHUD'
s.author = { 'Zachary Waldowski' => 'zwaldowski@gmail.com' }
s.source = { :git => 'https://github.com/zwaldowski/DZProgressHUD.git' }
s.description = 'DZProgressHUD is a drop-in iOS class that displays a translucent HUD with a ' \
'progress indicator and an optional label while work is being done. It is meant ' \
'as an easy-to-use replacement for the undocumented, private class UIProgressHUD.'
s.source_files = '*.{h,m}'
Expand Down

0 comments on commit ec73138

Please sign in to comment.