Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Commit

Permalink
Change method bracket coding conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardtack committed Jul 9, 2014
1 parent 620cf37 commit 3dc4d9e
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 77 deletions.
105 changes: 70 additions & 35 deletions HTProgressHUD/HTProgressHUD.m
Expand Up @@ -30,7 +30,8 @@ @implementation HTProgressHUD

#pragma mark - Class methods

+ (NSOperationQueue *)operationQueue {
+ (NSOperationQueue *)operationQueue
{
static dispatch_once_t onceToken;
static NSOperationQueue *queue;
dispatch_once(&onceToken, ^{
Expand All @@ -43,7 +44,8 @@ + (NSOperationQueue *)operationQueue {

#pragma mark Layout

- (CGRect)updatePositionForHUDFrame:(CGRect)frame {
- (CGRect)updatePositionForHUDFrame:(CGRect)frame
{
CGRect viewBounds = [self bounds];
CGPoint center = CGPointMake(viewBounds.origin.x + floorf(viewBounds.size.width / 2.0f),
viewBounds.origin.y + floorf(viewBounds.size.height / 2.0f));
Expand Down Expand Up @@ -90,7 +92,8 @@ - (CGRect)updatePositionForHUDFrame:(CGRect)frame {
return frame;
}

- (void)updatePosition {
- (void)updatePosition
{
CGRect frame = [self updatePositionForHUDFrame:self.hudView.frame];
switch (self.position) {
case HTProgressHUDPositionTopLeft:
Expand Down Expand Up @@ -126,7 +129,8 @@ - (void)updatePosition {
self.hudView.frame = frame;
}

- (void)updateHUD {
- (void)updateHUD
{
// Indicator size
CGRect indicatorFrame = self.indicatorView.frame;
indicatorFrame.origin.y = self.hudView.bounds.origin.y + self.paddingInsets.top;
Expand Down Expand Up @@ -157,7 +161,8 @@ - (void)updateHUD {
self.hudView.frame = frame;
}

- (void)updateViews {
- (void)updateViews
{
if (self.animateWhenLayoutChanged && !self.hidden) {
if (![[NSThread currentThread] isMainThread]) {
[self performSelectorOnMainThread:@selector(updateViews) withObject:nil waitUntilDone:NO];
Expand Down Expand Up @@ -186,11 +191,13 @@ - (void)updateViews {

#pragma mark - Initializers

- (instancetype)init {
- (instancetype)init
{
return [self initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
}

- (instancetype)initWithFrame:(CGRect)frame {
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Self-Configurations
Expand Down Expand Up @@ -268,27 +275,33 @@ - (instancetype)initWithFrame:(CGRect)frame {

#pragma mark Showing methods

- (void)showInView:(UIView *)view {
- (void)showInView:(UIView *)view
{
[self showInView:view animated:YES];
}

- (void)showAboveView:(UIView *)view {
- (void)showAboveView:(UIView *)view
{
[self showInRect:view.frame inView:view.superview];
}

- (void)showInView:(UIView *)view animated:(BOOL)animated {
- (void)showInView:(UIView *)view animated:(BOOL)animated
{
[self showInRect:view.bounds inView:view animated:animated];
}

- (void)showAboveView:(UIView *)view animated:(BOOL)animated {
- (void)showAboveView:(UIView *)view animated:(BOOL)animated
{
[self showInRect:view.frame inView:view.superview animated:animated];
}

- (void)showInRect:(CGRect)rect inView:(UIView *)view {
- (void)showInRect:(CGRect)rect inView:(UIView *)view
{
[self showInRect:rect inView:view animated:YES];
}

- (void)showInRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated {
- (void)showInRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated
{
if (![[NSThread currentThread] isMainThread]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self showInRect:rect inView:view animated:animated];
Expand Down Expand Up @@ -325,15 +338,18 @@ - (void)showInRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated {

#pragma mark Showing with thread methods

- (void)showInView:(UIView *)view whileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated {
- (void)showInView:(UIView *)view whileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated
{
[self showInRect:view.bounds inView:view whileExecuting:method onTarget:target withObject:object animated:animated];
}

- (void)showAboveView:(UIView *)view whileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated {
- (void)showAboveView:(UIView *)view whileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated
{
[self showInRect:view.frame inView:view.superview whileExecuting:method onTarget:target withObject:object animated:animated];
}

- (void)showInRect:(CGRect)rect inView:(UIView *)view whileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated {
- (void)showInRect:(CGRect)rect inView:(UIView *)view whileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated
{
NSMethodSignature *signature = [[target class] instanceMethodSignatureForSelector:method];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget:target];
Expand All @@ -345,15 +361,18 @@ - (void)showInRect:(CGRect)rect inView:(UIView *)view whileExecuting:(SEL)method
[self showInRect:rect inView:view whileExecutingInvocation:invocation animated:animated];
}

- (void)showInView:(UIView *)view whileExecutingInvocation:(NSInvocation *)invocation animated:(BOOL)animated {
- (void)showInView:(UIView *)view whileExecutingInvocation:(NSInvocation *)invocation animated:(BOOL)animated
{
[self showInRect:view.bounds inView:view whileExecutingInvocation:invocation animated:animated];
}

- (void)showAboveView:(UIView *)view whileExecutingInvocation:(NSInvocation *)invocation animated:(BOOL)animated {
- (void)showAboveView:(UIView *)view whileExecutingInvocation:(NSInvocation *)invocation animated:(BOOL)animated
{
[self showInRect:view.frame inView:view.superview whileExecutingInvocation:invocation animated:animated];
}

- (void)showInRect:(CGRect)rect inView:(UIView *)view whileExecutingInvocation:(NSInvocation *)invocation animated:(BOOL)animated {
- (void)showInRect:(CGRect)rect inView:(UIView *)view whileExecutingInvocation:(NSInvocation *)invocation animated:(BOOL)animated
{
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithInvocation:invocation];
[operation setCompletionBlock:^{
[self hideWithAnimation:animated];
Expand All @@ -363,15 +382,18 @@ - (void)showInRect:(CGRect)rect inView:(UIView *)view whileExecutingInvocation:(
}


- (void)showWithAnimation:(BOOL)animated inView:(UIView *)view whileExecutingBlock:(dispatch_block_t)block {
- (void)showWithAnimation:(BOOL)animated inView:(UIView *)view whileExecutingBlock:(dispatch_block_t)block
{
[self showWithAnimation:animated inRect:view.bounds inView:view whileExecutingBlock:block];
}

- (void)showWithAnimation:(BOOL)animated aboveView:(UIView *)view whileExecutingBlock:(dispatch_block_t)block {
- (void)showWithAnimation:(BOOL)animated aboveView:(UIView *)view whileExecutingBlock:(dispatch_block_t)block
{
[self showWithAnimation:animated inRect:view.frame inView:view.superview whileExecutingBlock:block];
}

- (void)showWithAnimation:(BOOL)animated inRect:(CGRect)rect inView:(UIView *)view whileExecutingBlock:(dispatch_block_t)block {
- (void)showWithAnimation:(BOOL)animated inRect:(CGRect)rect inView:(UIView *)view whileExecutingBlock:(dispatch_block_t)block
{
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:block];
[operation setCompletionBlock:^{
[self hideWithAnimation:animated];
Expand All @@ -383,11 +405,13 @@ - (void)showWithAnimation:(BOOL)animated inRect:(CGRect)rect inView:(UIView *)vi
#pragma mark Hiding methods


- (void)hide {
- (void)hide
{
[self hideWithAnimation:YES];
}

- (void)hideWithAnimation:(BOOL)animated {
- (void)hideWithAnimation:(BOOL)animated
{
if (![[NSThread currentThread] isMainThread]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self hideWithAnimation:animated];
Expand Down Expand Up @@ -418,11 +442,13 @@ - (void)hideWithAnimation:(BOOL)animated {
}
}

- (void)hideAfterDelay:(NSTimeInterval)delay {
- (void)hideAfterDelay:(NSTimeInterval)delay
{
[self hideAfterDelay:delay animated:YES];
}

- (void)hideAfterDelay:(NSTimeInterval)delay animated:(BOOL)animated {
- (void)hideAfterDelay:(NSTimeInterval)delay animated:(BOOL)animated
{
NSMethodSignature *signature = [[self class] instanceMethodSignatureForSelector:@selector(hideWithAnimation:)];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget:self];
Expand All @@ -434,7 +460,8 @@ - (void)hideAfterDelay:(NSTimeInterval)delay animated:(BOOL)animated {

#pragma mark Animation callback

- (void)animationDidFinishWithType:(HTProgressHUDAnimationType)animationType {
- (void)animationDidFinishWithType:(HTProgressHUDAnimationType)animationType
{
self.onShowingAnimation = NO;
switch (animationType) {
case HTProgressHUDAnimationTypeShowing:
Expand Down Expand Up @@ -467,43 +494,50 @@ - (void)animationDidFinishWithType:(HTProgressHUDAnimationType)animationType {

#pragma mark - Getters and Setters

- (void)setPosition:(HTProgressHUDPosition)position {
- (void)setPosition:(HTProgressHUDPosition)position
{
_position = position;
[self updateViews];
}

- (void)setText:(NSString *)text {
- (void)setText:(NSString *)text
{
_text = text;
dispatch_async(dispatch_get_main_queue(), ^{
self.textLabel.text = text;
[self updateViews];
});
}

- (void)setIndicatorView:(HTProgressHUDIndicatorView *)indicatorView {
- (void)setIndicatorView:(HTProgressHUDIndicatorView *)indicatorView
{
[_indicatorView removeFromSuperview];
_indicatorView = indicatorView;
[self.hudView addSubview:indicatorView];
[self updateViews];
}

- (void)setMarginInsets:(UIEdgeInsets)marginInsets {
- (void)setMarginInsets:(UIEdgeInsets)marginInsets
{
_marginInsets = marginInsets;
[self updateViews];
}

- (void)setPaddingInsets:(UIEdgeInsets)paddingInsets {
- (void)setPaddingInsets:(UIEdgeInsets)paddingInsets
{
_paddingInsets = paddingInsets;
[self updateViews];
}

- (void)setProgress:(float)progress {
- (void)setProgress:(float)progress
{
_progress = progress;
self.indicatorView.progress = progress;
[self updateViews];
}

- (void)setOnShowingAnimation:(BOOL)onShowingAnimation {
- (void)setOnShowingAnimation:(BOOL)onShowingAnimation
{
_onShowingAnimation = onShowingAnimation;
if (!onShowingAnimation && self.shouldHideWithAnimation) {
[self hideWithAnimation:YES];
Expand All @@ -515,7 +549,8 @@ - (void)setOnShowingAnimation:(BOOL)onShowingAnimation {

#pragma mark UIView overrides

- (void)layoutSubviews {
- (void)layoutSubviews
{
[super layoutSubviews];
[self updateHUD];
[self updatePosition];
Expand Down
24 changes: 16 additions & 8 deletions HTProgressHUD/HTProgressHUDAnimation.m
Expand Up @@ -17,36 +17,44 @@ @implementation HTProgressHUDAnimation

#pragma mark - Class methods

+ (instancetype)animation {
+ (instancetype)animation
{
return [[[self class] alloc] init];
}

#pragma mark - Public methods

- (void)setUpShowingAnimation:(HTProgressHUD *)progressHUD {
- (void)setUpShowingAnimation:(HTProgressHUD *)progressHUD
{
}

- (void)performShowingAnimation:(HTProgressHUD *)progressHUD {
- (void)performShowingAnimation:(HTProgressHUD *)progressHUD
{

}

- (void)tearDownShowingAnimation:(HTProgressHUD *)progressHUD {
- (void)tearDownShowingAnimation:(HTProgressHUD *)progressHUD
{

}

- (void)setUpHidingAnimation:(HTProgressHUD *)progressHUD {
- (void)setUpHidingAnimation:(HTProgressHUD *)progressHUD
{

}

- (void)performHidingAnimation:(HTProgressHUD *)progressHUD {
- (void)performHidingAnimation:(HTProgressHUD *)progressHUD
{

}

- (void)tearDownHidingAnimation:(HTProgressHUD *)progressHUD {
- (void)tearDownHidingAnimation:(HTProgressHUD *)progressHUD
{

}

- (void)finishAnimation {
- (void)finishAnimation
{
[self.performingHUD animationDidFinishWithType:self.animationType];
self.performingHUD = nil;
}
Expand Down
21 changes: 14 additions & 7 deletions HTProgressHUD/HTProgressHUDFadeAnimation.m
Expand Up @@ -11,7 +11,8 @@ @implementation HTProgressHUDFadeAnimation

#pragma mark - Initializers

- (instancetype)init {
- (instancetype)init
{
self = [super init];
if (self) {
self.duration = 0.3;
Expand All @@ -28,11 +29,13 @@ - (instancetype)init {

#pragma mark Showing animation

- (void)setUpShowingAnimation:(HTProgressHUD *)progressHUD {
- (void)setUpShowingAnimation:(HTProgressHUD *)progressHUD
{
progressHUD.alpha = 0.0f;
}

- (void)performShowingAnimation:(HTProgressHUD *)progressHUD {
- (void)performShowingAnimation:(HTProgressHUD *)progressHUD
{
[UIView setAnimationCurve:self.curve];
[UIView animateWithDuration:self.duration
animations:^{
Expand All @@ -43,15 +46,18 @@ - (void)performShowingAnimation:(HTProgressHUD *)progressHUD {
}];
}

- (void)tearDownShowingAnimation:(HTProgressHUD *)progressHUD {
- (void)tearDownShowingAnimation:(HTProgressHUD *)progressHUD
{
}

#pragma mark Hiding animation

- (void)setUpHidingAnimation:(HTProgressHUD *)progressHUD {
- (void)setUpHidingAnimation:(HTProgressHUD *)progressHUD
{
}

- (void)performHidingAnimation:(HTProgressHUD *)progressHUD {
- (void)performHidingAnimation:(HTProgressHUD *)progressHUD
{
[UIView setAnimationCurve:self.curve];
[UIView animateWithDuration:self.duration
animations:^{
Expand All @@ -62,7 +68,8 @@ - (void)performHidingAnimation:(HTProgressHUD *)progressHUD {
}];
}

- (void)tearDownHidingAnimation:(HTProgressHUD *)progressHUD {
- (void)tearDownHidingAnimation:(HTProgressHUD *)progressHUD
{

}

Expand Down

0 comments on commit 3dc4d9e

Please sign in to comment.