Skip to content

Commit

Permalink
Standardized directly calling ivars
Browse files Browse the repository at this point in the history
  • Loading branch information
TimOliver committed Oct 8, 2023
1 parent 68ebc5f commit cf6e91a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions TORoundedButton/TORoundedButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ - (void)_didTouchUpInside {
[self sendActionsForControlEvents:UIControlEventPrimaryActionTriggered];

// Broadcast the tap event to all subscribed objects.
if (self.tappedHandler) { self.tappedHandler(); }
if (_tappedHandler) { _tappedHandler(); }
[_delegate roundedButtonDidTap:self];
}

Expand All @@ -309,7 +309,7 @@ - (void)_didDragInside {
#pragma mark - Animation -

- (void)_setBackgroundColorTappedAnimated:(BOOL)animated TOROUNDEDBUTTON_OBJC_DIRECT {
if (!self.tappedTintColor || _isTranslucent) { return; }
if (!_tappedTintColor || _isTranslucent) { return; }

// Toggle the background color of the title label
void (^updateTitleOpacity)(void) = ^{
Expand All @@ -319,7 +319,7 @@ - (void)_setBackgroundColorTappedAnimated:(BOOL)animated TOROUNDEDBUTTON_OBJC_DI
// -----------------------------------------------------

void (^animationBlock)(void) = ^{
self->_backgroundView.backgroundColor = self->_isTapped ? self.tappedTintColor : self.tintColor;
self->_backgroundView.backgroundColor = self->_isTapped ? self->_tappedTintColor : self.tintColor;
};

void (^completionBlock)(BOOL) = ^(BOOL completed){
Expand All @@ -333,7 +333,7 @@ - (void)_setBackgroundColorTappedAnimated:(BOOL)animated TOROUNDEDBUTTON_OBJC_DI
}
else {
_titleLabel.backgroundColor = [UIColor clearColor];
[UIView animateWithDuration:self.tapAnimationDuration
[UIView animateWithDuration:_tapAnimationDuration
delay:0.0f
usingSpringWithDamping:1.0f
initialSpringVelocity:0.5f
Expand All @@ -345,9 +345,9 @@ - (void)_setBackgroundColorTappedAnimated:(BOOL)animated TOROUNDEDBUTTON_OBJC_DI
}

- (void)_setLabelAlphaTappedAnimated:(BOOL)animated TOROUNDEDBUTTON_OBJC_DIRECT {
if (self.tappedTextAlpha > 1.0f - FLT_EPSILON) { return; }
if (_tappedTextAlpha > 1.0f - FLT_EPSILON) { return; }

CGFloat alpha = _isTapped ? self.tappedTextAlpha : 1.0f;
CGFloat alpha = _isTapped ? _tappedTextAlpha : 1.0f;

// Animate the alpha value of the label
void (^animationBlock)(void) = ^{
Expand All @@ -366,7 +366,7 @@ - (void)_setLabelAlphaTappedAnimated:(BOOL)animated TOROUNDEDBUTTON_OBJC_DIRECT
_titleLabel.backgroundColor = [UIColor clearColor];

// Animate the button alpha
[UIView animateWithDuration:self.tapAnimationDuration
[UIView animateWithDuration:_tapAnimationDuration
delay:0.0f
usingSpringWithDamping:1.0f
initialSpringVelocity:0.5f
Expand All @@ -376,9 +376,9 @@ - (void)_setLabelAlphaTappedAnimated:(BOOL)animated TOROUNDEDBUTTON_OBJC_DIRECT
}

- (void)_setButtonScaledTappedAnimated:(BOOL)animated TOROUNDEDBUTTON_OBJC_DIRECT {
if (self.tappedButtonScale < FLT_EPSILON) { return; }
if (_tappedButtonScale < FLT_EPSILON) { return; }

CGFloat scale = _isTapped ? self.tappedButtonScale : 1.0f;
CGFloat scale = _isTapped ? _tappedButtonScale : 1.0f;

// Animate the alpha value of the label
void (^animationBlock)(void) = ^{
Expand All @@ -394,7 +394,7 @@ - (void)_setButtonScaledTappedAnimated:(BOOL)animated TOROUNDEDBUTTON_OBJC_DIREC
}

// Animate the button alpha
[UIView animateWithDuration:self.tapAnimationDuration
[UIView animateWithDuration:_tapAnimationDuration
delay:0.0f
usingSpringWithDamping:1.0f
initialSpringVelocity:0.5f
Expand Down

0 comments on commit cf6e91a

Please sign in to comment.