Skip to content

Commit

Permalink
Merge pull request soffes#66 from tflhyl/fix-xcode-warnings
Browse files Browse the repository at this point in the history
Fix xcode warnings
  • Loading branch information
soffes authored Nov 22, 2017
2 parents fe567fb + 9a7fd08 commit 47a5271
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
10 changes: 5 additions & 5 deletions SSPullToRefresh/SSPullToRefreshDefaultContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ - (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
CGFloat width = self.bounds.size.width;

_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 14.0f, width, 20.0f)];
_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 14.0, width, 20.0)];
_statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_statusLabel.font = [UIFont boldSystemFontOfSize:14.0f];
_statusLabel.font = [UIFont boldSystemFontOfSize:14.0];
_statusLabel.textColor = [UIColor blackColor];
_statusLabel.backgroundColor = [UIColor clearColor];
_statusLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:_statusLabel];

_lastUpdatedAtLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 34.0f, width, 20.0f)];
_lastUpdatedAtLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 34.0, width, 20.0)];
_lastUpdatedAtLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_lastUpdatedAtLabel.font = [UIFont systemFontOfSize:12.0f];
_lastUpdatedAtLabel.font = [UIFont systemFontOfSize:12.0];
_lastUpdatedAtLabel.textColor = [UIColor lightGrayColor];
_lastUpdatedAtLabel.backgroundColor = [UIColor clearColor];
_lastUpdatedAtLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:_lastUpdatedAtLabel];

_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_activityIndicatorView.frame = CGRectMake(30.0f, 25.0f, 20.0f, 20.0f);
_activityIndicatorView.frame = CGRectMake(30.0, 25.0, 20.0, 20.0);
[self addSubview:_activityIndicatorView];
}
return self;
Expand Down
22 changes: 11 additions & 11 deletions SSPullToRefresh/SSPullToRefreshSimpleContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ - (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
CGFloat width = self.bounds.size.width;

_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 14.0f, width, 20.0f)];
_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 14.0, width, 20.0)];
_statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_statusLabel.font = [UIFont boldSystemFontOfSize:14.0f];
_statusLabel.font = [UIFont boldSystemFontOfSize:14.0];
_statusLabel.textColor = [UIColor blackColor];
_statusLabel.backgroundColor = [UIColor clearColor];
_statusLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:_statusLabel];

_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_activityIndicatorView.frame = CGRectMake(30.0f, 25.0f, 20.0f, 20.0f);
_activityIndicatorView.frame = CGRectMake(30.0, 25.0, 20.0, 20.0);
[self addSubview:_activityIndicatorView];
}
return self;
Expand All @@ -38,8 +38,8 @@ - (id)initWithFrame:(CGRect)frame {

- (void)layoutSubviews {
CGSize size = self.bounds.size;
self.statusLabel.frame = CGRectMake(20.0f, roundf((size.height - 30.0f) / 2.0f), size.width - 40.0f, 30.0f);
self.activityIndicatorView.frame = CGRectMake(roundf((size.width - 20.0f) / 2.0f), roundf((size.height - 20.0f) / 2.0f), 20.0f, 20.0f);
self.statusLabel.frame = CGRectMake(20.0, round((size.height - 30.0) / 2.0), size.width - 40.0, 30.0);
self.activityIndicatorView.frame = CGRectMake(round((size.width - 20.0) / 2.0), round((size.height - 20.0) / 2.0), 20.0, 20.0);
}


Expand All @@ -50,28 +50,28 @@ - (void)setState:(SSPullToRefreshViewState)state withPullToRefreshView:(SSPullTo
case SSPullToRefreshViewStateReady: {
self.statusLabel.text = NSLocalizedString(@"Release to refresh", nil);
[self.activityIndicatorView startAnimating];
self.activityIndicatorView.alpha = 0.0f;
self.activityIndicatorView.alpha = 0.0;
break;
}

case SSPullToRefreshViewStateNormal: {
self.statusLabel.text = NSLocalizedString(@"Pull down to refresh", nil);
self.statusLabel.alpha = 1.0f;
self.statusLabel.alpha = 1.0;
[self.activityIndicatorView stopAnimating];
self.activityIndicatorView.alpha = 0.0f;
self.activityIndicatorView.alpha = 0.0;
break;
}

case SSPullToRefreshViewStateLoading: {
self.statusLabel.alpha = 0.0f;
self.statusLabel.alpha = 0.0;
[self.activityIndicatorView startAnimating];
self.activityIndicatorView.alpha = 1.0f;
self.activityIndicatorView.alpha = 1.0;
break;
}

case SSPullToRefreshViewStateClosing: {
self.statusLabel.text = nil;
self.activityIndicatorView.alpha = 0.0f;
self.activityIndicatorView.alpha = 0.0;
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions SSPullToRefresh/SSPullToRefreshView.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ typedef NS_ENUM(NSUInteger, SSPullToRefreshViewStyle) {
animate down the pull to refresh view to show that it's loading.
*/
- (void)startLoadingAndExpand:(BOOL)shouldExpand animated:(BOOL)animated;
- (void)startLoadingAndExpand:(BOOL)shouldExpand animated:(BOOL)animated completion:(void(^)())block;
- (void)startLoadingAndExpand:(BOOL)shouldExpand animated:(BOOL)animated completion:(void(^)(void))block;

/**
Call this when you finish loading.
*/
- (void)finishLoading;
- (void)finishLoadingAnimated:(BOOL)animated completion:(void(^)())block;
- (void)finishLoadingAnimated:(BOOL)animated completion:(void(^)(void))block;

/**
Manually update the last updated at time. This will automatically get called when the pull to refresh view finishes laoding.
Expand Down
24 changes: 12 additions & 12 deletions SSPullToRefresh/SSPullToRefreshView.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (void)setState:(SSPullToRefreshViewState)state {
[delegate pullToRefreshViewDidFinishLoading:self];
}
} else if (!wasLoading && _state == SSPullToRefreshViewStateLoading) {
[self _setPullProgress:1.0f];
[self _setPullProgress:1.0];
if ([delegate respondsToSelector:@selector(pullToRefreshViewDidStartLoading:)]) {
[delegate pullToRefreshViewDidStartLoading:self];
}
Expand All @@ -58,7 +58,7 @@ - (void)setState:(SSPullToRefreshViewState)state {

- (void)setExpanded:(BOOL)expanded {
_expanded = expanded;
[self _setContentInsetTop:expanded ? self.expandedHeight : 0.0f];
[self _setContentInsetTop:expanded ? self.expandedHeight : 0.0];
}


Expand Down Expand Up @@ -138,7 +138,7 @@ - (void)layoutSubviews {
}

CGRect contentFrame;
contentFrame.origin.x = roundf((size.width - contentSize.width) / 2.0f);
contentFrame.origin.x = round((size.width - contentSize.width) / 2.0);
contentFrame.size = contentSize;
switch (self.style) {
case SSPullToRefreshViewStyleScrolling:
Expand All @@ -156,7 +156,7 @@ - (void)layoutSubviews {
#pragma mark - Initializer

- (id)initWithScrollView:(UIScrollView *)scrollView delegate:(id<SSPullToRefreshViewDelegate>)delegate {
CGRect frame = CGRectMake(0.0f, 0.0f - scrollView.bounds.size.height, scrollView.bounds.size.width,
CGRect frame = CGRectMake(0.0, 0.0 - scrollView.bounds.size.height, scrollView.bounds.size.width,
scrollView.bounds.size.height);
if ((self = [super initWithFrame:frame])) {
for (UIView *view in self.scrollView.subviews) {
Expand All @@ -169,7 +169,7 @@ - (id)initWithScrollView:(UIScrollView *)scrollView delegate:(id<SSPullToRefresh
self.scrollView = scrollView;
self.delegate = delegate;
self.state = SSPullToRefreshViewStateNormal;
self.expandedHeight = 70.0f;
self.expandedHeight = 70.0;
self.defaultContentInset = scrollView.contentInset;

// Add to scroll view
Expand All @@ -194,7 +194,7 @@ - (void)startLoadingAndExpand:(BOOL)shouldExpand animated:(BOOL)animated {
[self startLoadingAndExpand:shouldExpand animated:animated completion:nil];
}

- (void)startLoadingAndExpand:(BOOL)shouldExpand animated:(BOOL)animated completion:(void(^)())block {
- (void)startLoadingAndExpand:(BOOL)shouldExpand animated:(BOOL)animated completion:(void(^)(void))block {
// If we're not loading, this method has no effect
if (self.state == SSPullToRefreshViewStateLoading) {
return;
Expand All @@ -209,7 +209,7 @@ - (void)finishLoading {
[self finishLoadingAnimated:YES completion:nil];
}

- (void)finishLoadingAnimated:(BOOL)animated completion:(void(^)())block {
- (void)finishLoadingAnimated:(BOOL)animated completion:(void(^)(void))block {
// If we're not loading, this method has no effect
if (self.state != SSPullToRefreshViewStateLoading) {
return;
Expand Down Expand Up @@ -270,8 +270,8 @@ - (void)_setContentInsetTop:(CGFloat)topInset {
}

// If scrollView is on top, scroll again to the top (needed for scrollViews with content > scrollView).
if (self.scrollView.contentOffset.y <= 0.0f) {
[self.scrollView scrollRectToVisible:CGRectMake(0.0f, 0.0f, 1.0f, 1.0f) animated:NO];
if (self.scrollView.contentOffset.y <= 0.0) {
[self.scrollView scrollRectToVisible:CGRectMake(0.0, 0.0, 1.0, 1.0) animated:NO];
}

// Tell the delegate
Expand Down Expand Up @@ -335,7 +335,7 @@ - (void)_setPullProgress:(CGFloat)pullProgress {
}

// Ensure the value is between 0 and 1 (or higher if they keep pulling)
pullProgress = fmaxf(0.0f, pullProgress);
pullProgress = fmax(0.0, pullProgress);

// Notify the content view
[self.contentView setPullProgress:pullProgress];
Expand Down Expand Up @@ -372,7 +372,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
[self _setPullProgress:-y / self.expandedHeight];

// Dragged enough to refresh
if (y > -self.expandedHeight && y < 0.0f) {
if (y > -self.expandedHeight && y < 0.0) {
self.state = SSPullToRefreshViewStateNormal;
}
// Scroll view is normal
Expand All @@ -386,7 +386,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
}
// Scroll view is loading
} else if (self.state == SSPullToRefreshViewStateLoading) {
CGFloat insetAdjustment = y < 0 ? fmaxf(0, self.expandedHeight + y) : self.expandedHeight;
CGFloat insetAdjustment = y < 0 ? fmax(0, self.expandedHeight + y) : self.expandedHeight;
[self _setContentInsetTop:self.expandedHeight - insetAdjustment];
}
return;
Expand Down

0 comments on commit 47a5271

Please sign in to comment.