Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add simple content view

  • Loading branch information...
commit 2747cdd7971a73dc34f4bd52a686d12d52867b9d 1 parent d367cf9
@soffes soffes authored
View
3  SSPullToRefresh.h
@@ -7,4 +7,5 @@
//
#import "SSPullToRefreshView.h"
-#import "SSSimplePullToRefreshContentView.h"
+#import "SSPullToRefreshDefaultContentView.h"
+#import "SSPullToRefreshSimpleContentView.h"
View
4 SSSimplePullToRefreshContentView.h → SSPullToRefreshDefaultContentView.h
@@ -1,5 +1,5 @@
//
-// SSSimplePullToRefreshContentView.h
+// SSPullToRefreshDefaultContentView
// SSPullToRefresh
//
// Created by Sam Soffes on 4/9/12.
@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import "SSPullToRefreshView.h"
-@interface SSSimplePullToRefreshContentView : UIView <SSPullToRefreshContentView>
+@interface SSPullToRefreshDefaultContentView : UIView <SSPullToRefreshContentView>
@property (nonatomic, strong, readonly) UILabel *statusLabel;
@property (nonatomic, strong, readonly) UILabel *lastUpdatedAtLabel;
View
6 SSSimplePullToRefreshContentView.m → SSPullToRefreshDefaultContentView.m
@@ -1,14 +1,14 @@
//
-// SSSimplePullToRefreshContentView.m
+// SSPullToRefreshDefaultContentView
// SSPullToRefresh
//
// Created by Sam Soffes on 4/9/12.
// Copyright (c) 2012 Sam Soffes. All rights reserved.
//
-#import "SSSimplePullToRefreshContentView.h"
+#import "SSPullToRefreshDefaultContentView.h"
-@implementation SSSimplePullToRefreshContentView
+@implementation SSPullToRefreshDefaultContentView
@synthesize statusLabel = _statusLabel;
@synthesize lastUpdatedAtLabel = _lastUpdatedAtLabel;
View
12 SSPullToRefreshSimpleContentView.h
@@ -0,0 +1,12 @@
+//
+// SSPullToRefreshSimpleContentView.h
+// SSPullToRefreshView
+//
+// Created by Sam Soffes on 5/17/12.
+// Copyright (c) 2012 Sam Soffes. All rights reserved.
+//
+
+#import "SSPullToRefreshDefaultContentView.h"
+
+@interface SSPullToRefreshSimpleContentView : SSPullToRefreshDefaultContentView
+@end
View
64 SSPullToRefreshSimpleContentView.m
@@ -0,0 +1,64 @@
+//
+// SSPullToRefreshSimpleContentView.m
+// SSPullToRefreshView
+//
+// Created by Sam Soffes on 5/17/12.
+// Copyright (c) 2012 Sam Soffes. All rights reserved.
+//
+
+#import "SSPullToRefreshSimpleContentView.h"
+
+@implementation SSPullToRefreshSimpleContentView
+
+#pragma mark - UIView
+
+- (id)initWithFrame:(CGRect)frame {
+ if ((self = [super initWithFrame:frame])) {
+ self.lastUpdatedAtLabel.hidden = YES;
+ }
+ return self;
+}
+
+
+- (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);
+}
+
+
+#pragma mark - SSPullToRefreshContentView
+
+- (void)setState:(SSPullToRefreshViewState)state withPullToRefreshView:(SSPullToRefreshView *)view {
+ switch (state) {
+ case SSPullToRefreshViewStateReady: {
+ self.statusLabel.text = @"Release to refresh";
+ [self.activityIndicatorView startAnimating];
+ self.activityIndicatorView.alpha = 0.0f;
+ break;
+ }
+
+ case SSPullToRefreshViewStateNormal: {
+ self.statusLabel.text = @"Pull down to refresh";
+ self.statusLabel.alpha = 1.0f;
+ [self.activityIndicatorView stopAnimating];
+ self.activityIndicatorView.alpha = 0.0f;
+ break;
+ }
+
+ case SSPullToRefreshViewStateLoading: {
+ self.statusLabel.alpha = 0.0f;
+ [self.activityIndicatorView startAnimating];
+ self.activityIndicatorView.alpha = 1.0f;
+ break;
+ }
+
+ case SSPullToRefreshViewStateClosing: {
+ self.statusLabel.text = nil;
+ self.activityIndicatorView.alpha = 0.0f;
+ break;
+ }
+ }
+}
+
+@end
View
4 SSPullToRefreshView.m
@@ -7,7 +7,7 @@
//
#import "SSPullToRefreshView.h"
-#import "SSSimplePullToRefreshContentView.h"
+#import "SSPullToRefreshDefaultContentView.h"
@interface SSPullToRefreshView ()
@property (nonatomic, assign, readwrite) SSPullToRefreshViewState state;
@@ -76,7 +76,7 @@ - (void)setScrollView:(UIScrollView *)scrollView {
- (UIView<SSPullToRefreshContentView> *)contentView {
// Use the simple content view as the default
if (!_contentView) {
- self.contentView = [[SSSimplePullToRefreshContentView alloc] initWithFrame:CGRectZero];
+ self.contentView = [[SSPullToRefreshDefaultContentView alloc] initWithFrame:CGRectZero];
}
return _contentView;
}
Please sign in to comment.
Something went wrong with that request. Please try again.