[New Example] 500pxgram updates

- addressed all comments in PR except autolayout of UIKit code
This commit is contained in:
Hannah Troisi
2016-04-10 23:34:41 -07:00
parent 16ece60a3e
commit 44d483b7fe
29 changed files with 86 additions and 94 deletions

View File

@@ -11,6 +11,7 @@
3EC0CDCBA10D483D9F386E5E /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D24B17D1E4A4E7A9566C5E9 /* libPods.a */; };
6C2C82AC19EE274300767484 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AA19EE274300767484 /* Default-667h@2x.png */; };
6C2C82AD19EE274300767484 /* Default-736h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AB19EE274300767484 /* Default-736h@3x.png */; };
76229A781CBB79E000B62CEF /* WindowWithStatusBarUnderlay.m in Sources */ = {isa = PBXBuildFile; fileRef = 76229A771CBB79E000B62CEF /* WindowWithStatusBarUnderlay.m */; };
767A5F111CAA3BFE004CDA8D /* tabBarIcons in Resources */ = {isa = PBXBuildFile; fileRef = 767A5F101CAA3BFE004CDA8D /* tabBarIcons */; };
767A5F131CAA3C66004CDA8D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 767A5F121CAA3C66004CDA8D /* Assets.xcassets */; };
768843801CAA37EF00D8629E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 768843681CAA37EF00D8629E /* AppDelegate.m */; };
@@ -39,6 +40,8 @@
3D24B17D1E4A4E7A9566C5E9 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
6C2C82AA19EE274300767484 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = SOURCE_ROOT; };
6C2C82AB19EE274300767484 /* Default-736h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-736h@3x.png"; sourceTree = SOURCE_ROOT; };
76229A761CBB79E000B62CEF /* WindowWithStatusBarUnderlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowWithStatusBarUnderlay.h; sourceTree = "<group>"; };
76229A771CBB79E000B62CEF /* WindowWithStatusBarUnderlay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WindowWithStatusBarUnderlay.m; sourceTree = "<group>"; };
767A5F101CAA3BFE004CDA8D /* tabBarIcons */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tabBarIcons; sourceTree = "<group>"; };
767A5F121CAA3C66004CDA8D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
768843511CAA37EF00D8629E /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = AppDelegate.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
@@ -57,7 +60,7 @@
768843621CAA37EF00D8629E /* PhotoFeedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoFeedViewController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
768843631CAA37EF00D8629E /* UserModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = UserModel.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
768843661CAA37EF00D8629E /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Utilities.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
768843671CAA37EF00D8629E /* Flickrgram.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Flickrgram.pch; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
768843671CAA37EF00D8629E /* Sample.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Sample.pch; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
768843681CAA37EF00D8629E /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AppDelegate.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
768843691CAA37EF00D8629E /* CommentFeedModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CommentFeedModel.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
7688436A1CAA37EF00D8629E /* CommentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CommentModel.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
@@ -117,6 +120,8 @@
children = (
768843511CAA37EF00D8629E /* AppDelegate.h */,
768843681CAA37EF00D8629E /* AppDelegate.m */,
76229A761CBB79E000B62CEF /* WindowWithStatusBarUnderlay.h */,
76229A771CBB79E000B62CEF /* WindowWithStatusBarUnderlay.m */,
767A5F141CAA3D8A004CDA8D /* Controller */,
767A5F181CAA3DB0004CDA8D /* View */,
767A5F171CAA3DA1004CDA8D /* Model */,
@@ -128,7 +133,7 @@
05E2128419D4DB510098F589 /* Supporting Files */ = {
isa = PBXGroup;
children = (
768843671CAA37EF00D8629E /* Flickrgram.pch */,
768843671CAA37EF00D8629E /* Sample.pch */,
7688437F1CAA37EF00D8629E /* Info.plist */,
768843711CAA37EF00D8629E /* main.m */,
767A5F121CAA3C66004CDA8D /* Assets.xcassets */,
@@ -367,6 +372,7 @@
768843891CAA37EF00D8629E /* main.m in Sources */,
7688438C1CAA37EF00D8629E /* PhotoCollectionViewCell.m in Sources */,
768843921CAA37EF00D8629E /* PhotoFeedViewController.m in Sources */,
76229A781CBB79E000B62CEF /* WindowWithStatusBarUnderlay.m in Sources */,
768843821CAA37EF00D8629E /* CommentModel.m in Sources */,
768843831CAA37EF00D8629E /* CommentsNode.m in Sources */,
768843961CAA37EF00D8629E /* Utilities.m in Sources */,
@@ -471,6 +477,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Sample/Sample.pch;
INFOPLIST_FILE = Sample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -488,6 +496,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Sample/Sample.pch;
INFOPLIST_FILE = Sample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

View File

@@ -6,16 +6,11 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol PhotoFeedViewControllerProtocol <NSObject>
@protocol PhotoFeedControllerProtocol <NSObject>
- (void)resetAllData;
@end
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIView *statusBarOpaqueUnderlayView;
@end

View File

@@ -9,17 +9,21 @@
#import "AppDelegate.h"
#import "PhotoFeedViewController.h"
#import "PhotoFeedNodeController.h"
#import "WindowWithStatusBarUnderlay.h"
#import "Utilities.h"
@interface AppDelegate () <UITabBarControllerDelegate>
@end
@implementation AppDelegate
{
WindowWithStatusBarUnderlay *_window;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
_window = [[WindowWithStatusBarUnderlay alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_window.backgroundColor = [UIColor whiteColor];
// UIKit Home Feed viewController & navController
PhotoFeedNodeController *asdkHomeFeedVC = [[PhotoFeedNodeController alloc] init];
@@ -50,20 +54,13 @@
uikitHomeFeedNavCtrl.navigationBar.barStyle = UIBarStyleBlack;
asdkHomeFeedNavCtrl.navigationBar.barStyle = UIBarStyleBlack;
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
_window.rootViewController = tabBarController;
[_window makeKeyAndVisible];
// iOS8 hides the status bar in landscape orientation, this forces the status bar hidden status to NO
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[application setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
// opaque status bar background
self.statusBarOpaqueUnderlayView = [[UIView alloc] init];
self.statusBarOpaqueUnderlayView.backgroundColor = [UIColor darkBlueColor];
self.statusBarOpaqueUnderlayView.frame = [[UIApplication sharedApplication] statusBarFrame];
if ( ![[UIApplication sharedApplication] isStatusBarHidden] ) {
[[[UIApplication sharedApplication] keyWindow] addSubview:self.statusBarOpaqueUnderlayView];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleDidChangeStatusBarOrientationNotification:)
name:UIApplicationWillChangeStatusBarOrientationNotification
object:nil];
return YES;
}
@@ -73,44 +70,11 @@
if ([viewController isKindOfClass:[UINavigationController class]]) {
NSArray *viewControllers = [(UINavigationController *)viewController viewControllers];
UIViewController *rootViewController = viewControllers[0];
if ([rootViewController conformsToProtocol:@protocol(PhotoFeedViewControllerProtocol)]) {
if ([rootViewController conformsToProtocol:@protocol(PhotoFeedControllerProtocol)]) {
// FIXME: the dataModel does not currently handle clearing data during loading properly
// [(id <PhotoFeedViewControllerProtocol>)rootViewController resetAllData];
}
}
}
- (void)handleDidChangeStatusBarOrientationNotification:(NSNotification *)notification;
{
NSNumber *newOrientation = [notification.userInfo objectForKey: UIApplicationStatusBarOrientationUserInfoKey];
NSInteger newOrientationInt = [newOrientation integerValue];
if (UIInterfaceOrientationIsLandscape(newOrientationInt)) {
[self.statusBarOpaqueUnderlayView removeFromSuperview];
} else {
[[[UIApplication sharedApplication] keyWindow] addSubview:self.statusBarOpaqueUnderlayView];
}
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end

View File

@@ -6,7 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CommentModel.h"
@interface CommentFeedModel : NSObject

View File

@@ -7,9 +7,10 @@
//
#import "CommentFeedModel.h"
#import <UIKit/UIKit.h>
#import "Utilities.h"
#define NUM_COMMENTS_TO_SHOW 3
#define fiveHundredPX_ENDPOINT_HOST @"https://api.500px.com/v1/"
#define fiveHundredPX_ENDPOINT_COMMENTS @"photos/4928401/comments"
#define fiveHundredPX_ENDPOINT_SEARCH @"photos/search?geo=" //latitude,longitude,radius<units>
@@ -157,8 +158,8 @@
if ([comments isKindOfClass:[NSArray class]]) {
NSUInteger numComments = [comments count];
if (numComments > 3) {
comments = [comments subarrayWithRange:(NSRange){numComments-3, 3}];
if (numComments > NUM_COMMENTS_TO_SHOW) {
comments = [comments subarrayWithRange:(NSRange){numComments-NUM_COMMENTS_TO_SHOW, NUM_COMMENTS_TO_SHOW}];
}
for (NSDictionary *commentDictionary in comments) {

View File

@@ -6,9 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface CommentModel : NSObject
@property (nonatomic, assign, readonly) NSUInteger ID;

View File

@@ -6,7 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CommentFeedModel.h"
@interface CommentView : UIView

View File

@@ -6,9 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface ImageURLModel : NSObject
+ (NSString *)imageParameterForClosestImageSize:(CGSize)size;

View File

@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>

View File

@@ -6,7 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CoreLocation/CoreLocation.h"
@interface LocationModel : NSObject

View File

@@ -7,7 +7,6 @@
//
#import "LocationModel.h"
#import <UIKit/UIKit.h>
#import <CoreLocation/CLGeocoder.h>
@implementation LocationModel

View File

@@ -6,7 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CoreLocation/CLLocation.h>
#import "PhotoModel.h"
#import <AsyncDisplayKit/AsyncDisplayKit.h>

View File

@@ -6,7 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "PhotoModel.h"
@interface PhotoCollectionViewCell : UICollectionViewCell

View File

@@ -6,7 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PhotoModel.h"
typedef NS_ENUM(NSInteger, PhotoFeedModelType) {

View File

@@ -9,6 +9,6 @@
#import <AsyncDisplayKit/AsyncDisplayKit.h>
#import "AppDelegate.h"
@interface PhotoFeedNodeController : ASViewController <PhotoFeedViewControllerProtocol>
@interface PhotoFeedNodeController : ASViewController <PhotoFeedControllerProtocol>
@end

View File

@@ -22,7 +22,6 @@
{
PhotoFeedModel *_photoFeed;
ASTableNode *_tableNode;
UIView *_statusBarOpaqueUnderlayView;
}
#pragma mark - Lifecycle

View File

@@ -6,9 +6,8 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
@interface PhotoFeedViewController : UIViewController <PhotoFeedViewControllerProtocol>
@interface PhotoFeedViewController : UIViewController <PhotoFeedControllerProtocol>
@end

View File

@@ -21,7 +21,6 @@
{
PhotoFeedModel *_photoFeed;
UITableView *_tableView;
UIView *_statusBarOpaqueUnderlayView;
}
#pragma mark - Lifecycle

View File

@@ -6,7 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CoreGraphics/CoreGraphics.h"
#import "UserModel.h"
#import "LocationModel.h"

View File

@@ -7,10 +7,8 @@
//
#import "PhotoModel.h"
#import <UIKit/UIKit.h>
#import "Utilities.h"
@implementation PhotoModel
{
NSDictionary *_dictionaryRepresentation;

View File

@@ -6,7 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CoreLocation/CLLocation.h>
#import "PhotoModel.h"

View File

@@ -10,8 +10,6 @@
#define Flickrgram_pch
#import <UIKit/UIKit.h>
// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
#import <Foundation/Foundation.h>
#endif /* Flickrgram_pch */

View File

@@ -6,9 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface UserModel : NSObject
@property (nonatomic, assign, readonly) NSDictionary *dictionaryRepresentation;

View File

@@ -7,7 +7,6 @@
//
#import "UserModel.h"
#import <UIKit/UIKit.h>
#import "Utilities.h"
@implementation UserModel

View File

@@ -6,9 +6,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface UIColor (Additions)
+ (UIColor *)darkBlueColor;

View File

@@ -7,7 +7,6 @@
//
#import "Utilities.h"
#import <UIKit/UIKit.h>
#define StrokeRoundedImages 0

View File

@@ -0,0 +1,11 @@
//
// WindowWithStatusBarUnderlay.h
// Sample
//
// Created by Hannah Troisi on 4/10/16.
// Copyright © 2016 Facebook. All rights reserved.
//
@interface WindowWithStatusBarUnderlay : UIWindow
@end

View File

@@ -0,0 +1,40 @@
//
// WindowWithStatusBarUnderlay.m
// Sample
//
// Created by Hannah Troisi on 4/10/16.
// Copyright © 2016 Facebook. All rights reserved.
//
#import "WindowWithStatusBarUnderlay.h"
#import "Utilities.h"
@implementation WindowWithStatusBarUnderlay
{
UIView *_statusBarOpaqueUnderlayView;
}
-(instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
_statusBarOpaqueUnderlayView = [[UIView alloc] init];
_statusBarOpaqueUnderlayView.backgroundColor = [UIColor darkBlueColor];
[self addSubview:_statusBarOpaqueUnderlayView];
}
return self;
}
-(void)layoutSubviews
{
[super layoutSubviews];
[self bringSubviewToFront:_statusBarOpaqueUnderlayView];
_statusBarOpaqueUnderlayView.frame = CGRectMake(0,
0,
[[UIScreen mainScreen] bounds].size.width,
[[UIApplication sharedApplication] statusBarFrame].size.height);
}
@end

View File

@@ -11,7 +11,6 @@
// Copyright © 2016 Hannah Troisi. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {