Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions WordPress/Classes/UIView+Subviews.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// UIView+Subviews.h
// WordPress
//
// Created by Tom Witkin on 12/6/13.
// Copyright (c) 2013 WordPress. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIView (Subviews)

- (void)addSubviewWithFadeAnimation:(UIView *)subview;

@end
24 changes: 24 additions & 0 deletions WordPress/Classes/UIView+Subviews.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// UIView+Subviews.m
// WordPress
//
// Created by Tom Witkin on 12/6/13.
// Copyright (c) 2013 WordPress. All rights reserved.
//

#import "UIView+Subviews.h"

@implementation UIView (Subviews)

- (void)addSubviewWithFadeAnimation:(UIView *)subview {

CGFloat finalAlpha = subview.alpha;

subview.alpha = 0.0;
[self addSubview:subview];
[UIView animateWithDuration:0.2 animations:^{
subview.alpha = finalAlpha;
}];
}

@end
42 changes: 34 additions & 8 deletions WordPress/Classes/WPTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#import "WPNoResultsView.h"
#import "SupportViewController.h"
#import "ContextManager.h"
#import "UIView+Subviews.h"

NSTimeInterval const WPTableViewControllerRefreshTimeout = 300; // 5 minutes
CGFloat const WPTableViewTopMargin = 40;
Expand All @@ -27,6 +28,7 @@ @interface WPTableViewController ()
@property (nonatomic, strong, readonly) UIView *swipeView;
@property (nonatomic, strong) UITableViewCell *swipeCell;
@property (nonatomic, strong) UIView *noResultsView;
@property (nonatomic, strong) UIActivityIndicatorView *noResultsActivityIndicator;

@end

Expand Down Expand Up @@ -568,15 +570,29 @@ - (void)configureNoResultsView {
}

[self.noResultsView removeFromSuperview];
[self.noResultsActivityIndicator stopAnimating];
[self.noResultsActivityIndicator removeFromSuperview];

if (self.resultsController && [[_resultsController fetchedObjects] count] == 0 && !self.isSyncing) {
// Show no results view.

if (self.noResultsView == nil) {
self.noResultsView = [self createNoResultsView];
}

[self.tableView addSubview:self.noResultsView];
if (self.resultsController && [[_resultsController fetchedObjects] count] == 0) {
if (self.isSyncing) {
// Show activity indicator view when syncing is occuring
// and the fetched results controller has no objects

if (self.noResultsActivityIndicator == nil) {
self.noResultsActivityIndicator = [self createNoResultsActivityIndicator];
}

[self.noResultsActivityIndicator startAnimating];
[self.tableView addSubview:self.noResultsActivityIndicator];
} else {
// Show no results view if the fetched results controller
// has no objects and syncing is not happening.

if (self.noResultsView == nil) {
self.noResultsView = [self createNoResultsView];
}
[self.tableView addSubviewWithFadeAnimation:self.noResultsView];
}
}
}

Expand All @@ -588,6 +604,16 @@ - (UIView *)createNoResultsView {
return view;
}

- (UIActivityIndicatorView *)createNoResultsActivityIndicator {

UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.hidesWhenStopped = YES;
activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
activityIndicator.center = [self.tableView convertPoint:self.tableView.center fromView:self.tableView.superview];

return activityIndicator;
}

- (void)hideRefreshHeader {
[self.refreshControl endRefreshing];
didTriggerRefresh = NO;
Expand Down
6 changes: 6 additions & 0 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@
E2586BD41832F31D004B5B67 /* icon-site-field.png in Resources */ = {isa = PBXBuildFile; fileRef = E2586BD21832F31D004B5B67 /* icon-site-field.png */; };
E2AA879D1850F91E00886693 /* icon-jetpack-gray.png in Resources */ = {isa = PBXBuildFile; fileRef = E2AA879B1850F91E00886693 /* icon-jetpack-gray.png */; };
E2AA879E1850F91E00886693 /* icon-jetpack-gray@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E2AA879C1850F91E00886693 /* icon-jetpack-gray@2x.png */; };
E2AA87A518523E5300886693 /* UIView+Subviews.m in Sources */ = {isa = PBXBuildFile; fileRef = E2AA87A418523E5300886693 /* UIView+Subviews.m */; };
EC4696FF0EA75D460040EE8E /* PagesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EC4696FE0EA75D460040EE8E /* PagesViewController.m */; };
FD21397F13128C5300099582 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FD21397E13128C5300099582 /* libiconv.dylib */; };
FD22C2B716CD2B20002BA030 /* navbar_settings.png in Resources */ = {isa = PBXBuildFile; fileRef = FD22C2B516CD2B20002BA030 /* navbar_settings.png */; };
Expand Down Expand Up @@ -2134,6 +2135,8 @@
E2586BD21832F31D004B5B67 /* icon-site-field.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-site-field.png"; sourceTree = "<group>"; };
E2AA879B1850F91E00886693 /* icon-jetpack-gray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon-jetpack-gray.png"; path = "Resources/Images/icon-jetpack-gray.png"; sourceTree = "<group>"; };
E2AA879C1850F91E00886693 /* icon-jetpack-gray@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon-jetpack-gray@2x.png"; path = "Resources/Images/icon-jetpack-gray@2x.png"; sourceTree = "<group>"; };
E2AA87A318523E5300886693 /* UIView+Subviews.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Subviews.h"; sourceTree = "<group>"; };
E2AA87A418523E5300886693 /* UIView+Subviews.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Subviews.m"; sourceTree = "<group>"; };
EBC24772E5CD4036B5AFD803 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = ../Pods/Pods.xcconfig; sourceTree = SOURCE_ROOT; };
EC4696FD0EA75D460040EE8E /* PagesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PagesViewController.h; sourceTree = "<group>"; };
EC4696FE0EA75D460040EE8E /* PagesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PagesViewController.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3706,6 +3709,8 @@
851734421798C64700A30E27 /* NSURL+Util.m */,
46F8714D1838C41600BC149B /* NSDate+StringFormatting.h */,
46F8714E1838C41600BC149B /* NSDate+StringFormatting.m */,
E2AA87A318523E5300886693 /* UIView+Subviews.h */,
E2AA87A418523E5300886693 /* UIView+Subviews.m */,
);
name = Categories;
sourceTree = "<group>";
Expand Down Expand Up @@ -4971,6 +4976,7 @@
1D60589B0D05DD56006BFB54 /* main.m in Sources */,
1D3623260D0F684500981E51 /* WordPressAppDelegate.m in Sources */,
2F970F740DF92274006BD934 /* PostsViewController.m in Sources */,
E2AA87A518523E5300886693 /* UIView+Subviews.m in Sources */,
93C486511810445D00A24725 /* ActivityLogViewController.m in Sources */,
ACC156CC0E10E67600D6E1A0 /* EditPostViewController.m in Sources */,
ACBAB5FE0E121C7300F38795 /* PostSettingsViewController.m in Sources */,
Expand Down