Skip to content

Commit

Permalink
Removed logs from the source.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Escrig Ventura committed Feb 22, 2016
1 parent 49ca7cb commit e8eb954
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 47 deletions.
5 changes: 4 additions & 1 deletion Examples/Examples/Example1ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ - (void)viewDidLoad {
button.horizontalOffset = -30.0f;
button.verticalOffset = -30.0f;
button.rounded = YES;

button.shadowColor = [UIColor lightGrayColor];
button.shadowOffset = CGSizeMake(3, 3);
button.shadowOpacity = 0.6f;
button.shadowRadius = 3.0f;
[self.tableView setFloatingButtonView:button];
[self.tableView setFloatingButtonDelegate:self];

Expand Down
5 changes: 5 additions & 0 deletions Examples/Examples/Example4ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ - (void)viewDidLoad {
button.imagePadding = 15.0f;
button.horizontalOffset = -30.0f;
button.verticalOffset = -30.0f;
button.rounded = YES;
button.shadowColor = [UIColor lightGrayColor];
button.shadowOffset = CGSizeMake(3, 3);
button.shadowOpacity = 0.6f;
button.shadowRadius = 3.0f;
[self.tableView setFloatingButtonView:button];
[self.tableView setFloatingButtonDelegate:self];

Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ - (void)viewDidLoad {
button.imagePadding = 20.0f;
button.horizontalOffset = 20.0f;
button.verticalOffset = -30.0f;
button.hideWhenScrollToTop = NO;
button.rounded = YES;
button.hideWhenScrollToTop = YES;
[self.tableView setFloatingButtonView:button];
[self.tableView setFloatingButtonDelegate:self];

Expand Down
37 changes: 30 additions & 7 deletions Source/UIScrollView+FloatingButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define DLog(s, ... ) NSLog(@"%@ | %@ | %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], NSStringFromSelector(_cmd), [NSString stringWithFormat:(s), ##__VA_ARGS__] )

@protocol MEVFloatingButtonDelegate;

/*! @enum MEVFloatingButtonDisplayMode
Expand Down Expand Up @@ -83,17 +81,41 @@ typedef NS_ENUM(NSInteger, MEVFloatingButtonPosition) {
*/
@property (nonatomic, strong) UIImage *image;

/*! @abstract Sets the image color for the MEVFloatingButton.
@param imageColor An UIColor object.
@discussion [UIColor whiteColor] is the default color when this property is not assigned.
*/
@property (nonatomic, strong) UIColor *imageColor;

/*! @abstract Sets the background color for the MEVFloatingButton.
@param backgroundColor An UIColor object.
@discussion [UIColor blueColor] is the default color when this property is not assigned.
*/
@property (nonatomic, strong) UIColor *backgroundColor;

/*! @abstract Sets the image color for the MEVFloatingButton.
@param imageColor An UIColor object.
@discussion [UIColor whiteColor] is the default color when this property is not assigned.
/*! @abstract Sets the shadow color for the MEVFloatingButton.
@param shadowColor An UIColor object.
@discussion [UIColor clearColor] is the default color when this property is not assigned.
*/
@property (nonatomic, strong) UIColor *imageColor;
@property (nonatomic, strong) UIColor *shadowColor;

/*! @abstract Sets the shadow offset for the MEVFloatingButton.
@param shadowOffset A CGSize struct indicating the offset.
@discussion CGSizeMake(0, 0) is the default value when this property is not assigned.
*/
@property (nonatomic) CGSize shadowOffset;

/*! @abstract Sets the opacity shadow for the MEVFloatingButton.
@param shadowOpacity A float indicating the shadow opacity.
@discussion 1.0f is the default value when this property is not assigned.
*/
@property (nonatomic) float shadowOpacity;

/*! @abstract Sets the radious shadow for the MEVFloatingButton.
@param shadowRadius A float indicating the shadow radius.
@discussion 1.0f is the default value when this property is not assigned.
*/
@property (nonatomic) float shadowRadius;

/*! @abstract Sets the outline color for the MEVFloatingButton.
@param outlineColor An UIColor object.
Expand Down Expand Up @@ -127,12 +149,13 @@ typedef NS_ENUM(NSInteger, MEVFloatingButtonPosition) {

/*! @abstract Indicates if the MEVFloatingButton should be either square or rounded.
@param rounded A BOOL value.
@discussion Default value is YES.
@discussion Default value is NO.
*/
@property (nonatomic, getter=isRounded) BOOL rounded;

/*! @abstract Indicates if the MEVFloatingButton will be hidden when on the scroll view is scroll to top.
@param hideWhenScrollToTop A BOOL value.
@discussion Default value is NO.
*/
@property (nonatomic, getter=isHideWhenScrollToTop) BOOL hideWhenScrollToTop;

Expand Down
48 changes: 10 additions & 38 deletions Source/UIScrollView+FloatingButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ - (instancetype)init
_position = MEVFloatingButtonPositionBottomCenter;
_imageColor = [UIColor whiteColor];
_backgroundColor = [UIColor blueColor];
_shadowColor = [UIColor clearColor];
_shadowOffset = CGSizeMake(0, 0);
_shadowOpacity = 1;
_shadowRadius = 1;
_outlineColor = [UIColor blueColor];
_outlineWidth = kMEFlatingButtonDefaultOutlineWidth;
_imagePadding = kMEFlatingButtonDefaultImagePadding;
_horizontalOffset = kMEFlatingButtonDefaultHorizontalOffset;
_verticalOffset = kMEFlatingButtonDefaultVerticalOffset;
_rounded = YES;
_rounded = NO;
_hideWhenScrollToTop = NO;

[self addSubview:self.contentView];
Expand Down Expand Up @@ -166,6 +170,11 @@ - (UIButton *)button
_button.userInteractionEnabled = YES;
_button.backgroundColor = _backgroundColor;
_button.tintColor = _imageColor;
_button.layer.masksToBounds = NO;
_button.layer.shadowColor = _shadowColor.CGColor;
_button.layer.shadowOffset = _shadowOffset;
_button.layer.shadowOpacity = _shadowOpacity;
_button.layer.shadowRadius = _shadowRadius;
_button.layer.borderColor = _outlineColor.CGColor;
_button.layer.borderWidth = _outlineWidth;
_button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
Expand Down Expand Up @@ -283,15 +292,12 @@ void Swizzle(Class c, SEL orig, SEL new)

- (void)mev_dealloc
{
DLog(@"");

@try {
[self removeObserver:self forKeyPath:kObserverContentOffset context:nil];
[self removeObserver:self forKeyPath:kObserverContentSize context:nil];
[self removeObserver:self forKeyPath:kObserverFrame context:nil];
} @catch(id exception) {
// Do nothing, obviously it wasn't attached because an exception was thrown
DLog(@"exception - %@", exception);
}

// This calls original dealloc method
Expand All @@ -301,8 +307,6 @@ - (void)mev_dealloc

- (void)mev_willMoveToWindow:(UIWindow *)newWindow
{
DLog(@"newWindow = %@ - %@", newWindow, self.floatingButtonDelegate);

if (!newWindow) {
[self mev_stopTimer];
[self mev_didDisappear];
Expand All @@ -313,8 +317,6 @@ - (void)mev_willMoveToWindow:(UIWindow *)newWindow

- (void)mev_didMoveToWindow
{
DLog(@"self.floatingButtonDelegate = %@", self.floatingButtonDelegate);

[self mev_didMoveToWindow];
}

Expand Down Expand Up @@ -365,7 +367,6 @@ - (MEVFloatingButton *)floatingButton

- (void)mev_willAppear
{
DLog(@"self.floatingButtonDelegate = %@", self.floatingButtonDelegate);
self.floatingButton.buttonState = MEFloatingButtonStateWillAppear;
self.floatingButton.hidden = NO;

Expand All @@ -376,7 +377,6 @@ - (void)mev_willAppear

- (void)mev_didAppear
{
DLog(@"self.floatingButtonDelegate = %@", self.floatingButtonDelegate);
self.floatingButton.buttonState = MEFloatingButtonStateDidAppear;

if (self.floatingButtonDelegate && [self.floatingButtonDelegate respondsToSelector:@selector(floatingButtonDidAppear:)]) {
Expand All @@ -386,7 +386,6 @@ - (void)mev_didAppear

- (void)mev_willDisappear
{
DLog(@"self.floatingButtonDelegate = %@", self.floatingButtonDelegate);
self.floatingButton.buttonState = MEFloatingButtonStateWillDisappear;

if (self.floatingButtonDelegate && [self.floatingButtonDelegate respondsToSelector:@selector(floatingButtonWillDisappear:)]) {
Expand All @@ -396,7 +395,6 @@ - (void)mev_willDisappear

- (void)mev_didDisappear
{
DLog(@"self.floatingButtonDelegate = %@", self.floatingButtonDelegate);
self.floatingButton.buttonState = MEFloatingButtonStateDidDisappear;
self.floatingButton.hidden = YES;

Expand All @@ -407,8 +405,6 @@ - (void)mev_didDisappear

- (void)mev_didTapDataButton:(id)sender
{
DLog(@"self.floatingButtonDelegate = %@", self.floatingButtonDelegate);

if (self.floatingButtonDelegate && [self.floatingButtonDelegate respondsToSelector:@selector(floatingButton:didTapButton:)]) {
[self.floatingButtonDelegate floatingButton:self didTapButton:sender];
}
Expand Down Expand Up @@ -464,8 +460,6 @@ - (void)mev_validateView

-(void)mev_showFloatingButtonView
{
DLog(@"self.floatingButton.buttonState = %d", self.floatingButton.buttonState);

if (self.floatingButton.buttonState == MEFloatingButtonStateDidDisappear) {

[self mev_willAppear];
Expand All @@ -489,8 +483,6 @@ -(void)mev_showFloatingButtonView

-(void)mev_hideFloatingButtonView
{
DLog(@"self.floatingButton.buttonState = %d", self.floatingButton.buttonState);

[self mev_stopTimer];

if (self.floatingButton.buttonState == MEFloatingButtonStateDidAppear) {
Expand All @@ -516,8 +508,6 @@ -(void)mev_hideFloatingButtonView

- (void)mev_repositionFloatingButtonViewFrame:(CGPoint)point
{
DLog(@"");

[self bringSubviewToFront:self.floatingButton];

CGRect fixedFrame = self.floatingButton.frame;
Expand All @@ -529,25 +519,19 @@ - (void)mev_repositionFloatingButtonViewFrame:(CGPoint)point

- (void)mev_stopTimer
{
DLog(@"");

[self.floatingButton.fadeOutTimer invalidate];
self.floatingButton.fadeOutTimer = nil;
}

- (void)mev_startTimer
{
DLog(@"");

self.floatingButton.fadeOutTimer = [NSTimer scheduledTimerWithTimeInterval:kFloatingButtonDefaultTime target:self selector:@selector(mev_hideFloatingButtonView) userInfo:nil repeats:YES];
}

#pragma mark - Animation Methods (Private)

- (void)mev_fadeInView:(BOOL)animated
{
DLog(@"");

[UIView animateWithDuration:animated ? kFloatingButtonDefaultFadingAnimationTime : 0.0f
animations:^{
[self.floatingButton setAlpha:1];
Expand All @@ -558,8 +542,6 @@ - (void)mev_fadeInView:(BOOL)animated

- (void)mev_fadeOutView:(BOOL)animated
{
DLog(@"");

[UIView animateWithDuration:animated ? kFloatingButtonDefaultFadingAnimationTime : 0.0f
animations:^{
[self.floatingButton setAlpha:0.0];
Expand All @@ -572,8 +554,6 @@ - (void)mev_fadeOutView:(BOOL)animated

- (void)mev_animateInView
{
DLog(@"");

CGRect frame = self.floatingButton.frame;
CGPoint finalPosition = CGPointMake(0, self.frame.size.height - self.floatingButton.frame.size.height - self.floatingButton.verticalOffset);
CGPoint previousPosition = CGPointMake(finalPosition.x, finalPosition.y + self.floatingButton.frame.size.height + self.floatingButton.verticalOffset);
Expand All @@ -589,8 +569,6 @@ - (void)mev_animateInView

- (void)mev_animateOutView
{
DLog(@"");

CGRect frame = self.floatingButton.frame;
frame.origin.y += self.floatingButton.frame.size.height + self.floatingButton.verticalOffset;

Expand All @@ -615,13 +593,9 @@ -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NS

if (!CGRectEqualToRect(self.floatingButton.frame, CGRectZero) && self.window) {


DLog(@"kObserverContentOffset - self.contentOffset.y = %f", self.contentOffset.y);

if ([self.floatingButton isHideWhenScrollToTop] && self.contentOffset.y <= 0) {
[self mev_hideFloatingButtonView];


} else {

switch (self.floatingButton.displayMode) {
Expand All @@ -635,7 +609,6 @@ -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NS
CGPoint old = [[change valueForKey:@"old"] CGPointValue];
if (new.y != old.y) {
self.floatingButton.scrollThreshold += 1;
DLog(@"kObserverContentOffset - scrollThreshold = %f", self.floatingButton.scrollThreshold);
if (self.floatingButton.scrollThreshold > 10) {
self.floatingButton.scrollThreshold = 0;
[self mev_showFloatingButtonView];
Expand All @@ -652,7 +625,6 @@ -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NS
default:
break;
}

}
}
}
Expand Down

0 comments on commit e8eb954

Please sign in to comment.