Skip to content

Commit

Permalink
Changed date format
Browse files Browse the repository at this point in the history
  • Loading branch information
palkop committed Oct 1, 2012
1 parent fbab96f commit 4259024
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ - (void)refreshLastUpdatedDate {
if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceLastUpdated:)]) {

NSDate *date = [_delegate egoRefreshTableHeaderDataSourceLastUpdated:self];

if (!date) return;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setAMSymbol:@"AM"];
[formatter setPMSymbol:@"PM"];
[formatter setDateFormat:@"MM/dd/yyyy hh:mm:a"];
[formatter setAMSymbol:@"am"];
[formatter setPMSymbol:@"pm"];
[formatter setDateFormat:@"M/dd/yy at h:mma"];
_lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:date]];
[[NSUserDefaults standardUserDefaults] setObject:_lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"];
[[NSUserDefaults standardUserDefaults] synchronize];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,25 @@
typedef enum{
EGOOPullRefreshPulling = 0,
EGOOPullRefreshNormal,
EGOOPullRefreshLoading,
EGOOPullRefreshLoading,
} EGOPullRefreshState;

@protocol EGORefreshTableHeaderDelegate;
@interface EGORefreshTableHeaderView : UIView {

id __weak _delegate;
EGOPullRefreshState _state;

UILabel *_lastUpdatedLabel;
UILabel *_statusLabel;
CALayer *_arrowImage;
UIActivityIndicatorView *_activityView;


}

@property(nonatomic,weak) id <EGORefreshTableHeaderDelegate> delegate;

- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor;

- (void)refreshLastUpdatedDate;
- (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView;
- (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView;
Expand Down
40 changes: 18 additions & 22 deletions EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ @implementation EGORefreshTableHeaderView
@synthesize delegate=_delegate;


- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor {
if((self = [super initWithFrame:frame])) {
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {

self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.backgroundColor = [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:237.0/255.0 alpha:1.0];

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 30.0f, self.frame.size.width, 20.0f)];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
label.font = [UIFont systemFontOfSize:12.0f];
label.textColor = textColor;
label.textColor = TEXT_COLOR;
label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
label.shadowOffset = CGSizeMake(0.0f, 1.0f);
label.backgroundColor = [UIColor clearColor];
Expand All @@ -60,7 +60,7 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI
label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 48.0f, self.frame.size.width, 20.0f)];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
label.font = [UIFont boldSystemFontOfSize:13.0f];
label.textColor = textColor;
label.textColor = TEXT_COLOR;
label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
label.shadowOffset = CGSizeMake(0.0f, 1.0f);
label.backgroundColor = [UIColor clearColor];
Expand All @@ -71,7 +71,7 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(25.0f, frame.size.height - 65.0f, 30.0f, 55.0f);
layer.contentsGravity = kCAGravityResizeAspect;
layer.contents = (id)[UIImage imageNamed:arrow].CGImage;
layer.contents = (id)[UIImage imageNamed:@"blueArrow.png"].CGImage;

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
Expand All @@ -96,9 +96,6 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI

}

- (id)initWithFrame:(CGRect)frame {
return [self initWithFrame:frame arrowImageName:@"blueArrow.png" textColor:TEXT_COLOR];
}

#pragma mark -
#pragma mark Setters
Expand All @@ -108,13 +105,12 @@ - (void)refreshLastUpdatedDate {
if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceLastUpdated:)]) {

NSDate *date = [_delegate egoRefreshTableHeaderDataSourceLastUpdated:self];

[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehaviorDefault];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];

_lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [dateFormatter stringFromDate:date]];
if (!date) return;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setAMSymbol:@"am"];
[formatter setPMSymbol:@"pm"];
[formatter setDateFormat:@"M/dd/yy at h:mma"];
_lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:date]];
[[NSUserDefaults standardUserDefaults] setObject:_lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"];
[[NSUserDefaults standardUserDefaults] synchronize];

Expand All @@ -123,7 +119,7 @@ - (void)refreshLastUpdatedDate {
_lastUpdatedLabel.text = nil;

}

}

- (void)setState:(EGOPullRefreshState)aState{
Expand All @@ -150,7 +146,7 @@ - (void)setState:(EGOPullRefreshState)aState{
_statusLabel.text = NSLocalizedString(@"Pull down to refresh...", @"Pull down to refresh status");
[_activityView stopAnimating];
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
_arrowImage.hidden = NO;
_arrowImage.transform = CATransform3DIdentity;
[CATransaction commit];
Expand All @@ -165,7 +161,7 @@ - (void)setState:(EGOPullRefreshState)aState{
_statusLabel.text = NSLocalizedString(@"Loading...", @"Loading Status");
[_activityView startAnimating];
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
_arrowImage.hidden = YES;
[CATransaction commit];

Expand All @@ -181,7 +177,7 @@ - (void)setState:(EGOPullRefreshState)aState{
#pragma mark -
#pragma mark ScrollView Methods

- (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView {
- (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView {

if (_state == EGOOPullRefreshLoading) {

Expand Down Expand Up @@ -232,14 +228,14 @@ - (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView {

}

- (void)egoRefreshScrollViewDataSourceDidFinishedLoading:(UIScrollView *)scrollView {
- (void)egoRefreshScrollViewDataSourceDidFinishedLoading:(UIScrollView *)scrollView {

[UIView animateWithDuration:0.3 animations:^ {
[scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)];
}];

[self setState:EGOOPullRefreshNormal];

}


Expand Down

0 comments on commit 4259024

Please sign in to comment.