Skip to content

Commit

Permalink
Merge pull request #47 from TimOliver/audit
Browse files Browse the repository at this point in the history
Audit all of the internal references to instance properties
  • Loading branch information
TimOliver authored Oct 8, 2023
2 parents 1225e62 + cf6e91a commit 3848f64
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions TORoundedButton/TORoundedButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// Objective-C direct methods - https://nshipster.com/direct/
#define TOROUNDEDBUTTON_OBJC_DIRECT __attribute__((objc_direct))

#import "TORoundedButton.h"
Expand Down Expand Up @@ -283,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 @@ -308,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 @@ -318,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 @@ -332,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 @@ -344,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 @@ -365,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 @@ -375,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 @@ -393,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 3848f64

Please sign in to comment.