diff --git a/examples/ASDKgram/Sample.xcodeproj/project.pbxproj b/examples/ASDKgram/Sample.xcodeproj/project.pbxproj index afb3882a4d..a534c90a35 100644 --- a/examples/ASDKgram/Sample.xcodeproj/project.pbxproj +++ b/examples/ASDKgram/Sample.xcodeproj/project.pbxproj @@ -42,42 +42,42 @@ 6C2C82AB19EE274300767484 /* Default-736h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-736h@3x.png"; sourceTree = SOURCE_ROOT; }; 767A5F101CAA3BFE004CDA8D /* tabBarIcons */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tabBarIcons; sourceTree = ""; }; 767A5F121CAA3C66004CDA8D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 768843511CAA37EF00D8629E /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 768843521CAA37EF00D8629E /* CommentFeedModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentFeedModel.h; sourceTree = ""; }; - 768843531CAA37EF00D8629E /* CommentModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentModel.h; sourceTree = ""; }; - 768843541CAA37EF00D8629E /* CommentsNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentsNode.h; sourceTree = ""; }; - 768843551CAA37EF00D8629E /* CommentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentView.h; sourceTree = ""; }; - 768843561CAA37EF00D8629E /* ImageURLModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageURLModel.h; sourceTree = ""; }; - 768843591CAA37EF00D8629E /* LocationModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocationModel.h; sourceTree = ""; }; - 7688435B1CAA37EF00D8629E /* PhotoCellNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoCellNode.h; sourceTree = ""; }; - 7688435C1CAA37EF00D8629E /* PhotoCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoCollectionViewCell.h; sourceTree = ""; }; - 7688435D1CAA37EF00D8629E /* PhotoFeedModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoFeedModel.h; sourceTree = ""; }; - 7688435E1CAA37EF00D8629E /* PhotoFeedNodeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoFeedNodeController.h; sourceTree = ""; }; - 768843601CAA37EF00D8629E /* PhotoModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoModel.h; sourceTree = ""; }; - 768843611CAA37EF00D8629E /* PhotoTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoTableViewCell.h; sourceTree = ""; }; - 768843621CAA37EF00D8629E /* PhotoTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoTableViewController.h; sourceTree = ""; }; - 768843631CAA37EF00D8629E /* UserModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserModel.h; sourceTree = ""; }; - 768843651CAA37EF00D8629E /* UserRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserRowView.h; sourceTree = ""; }; - 768843661CAA37EF00D8629E /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utilities.h; sourceTree = ""; }; - 768843671CAA37EF00D8629E /* Flickrgram.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Flickrgram.pch; sourceTree = ""; }; - 768843681CAA37EF00D8629E /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 768843691CAA37EF00D8629E /* CommentFeedModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentFeedModel.m; sourceTree = ""; }; - 7688436A1CAA37EF00D8629E /* CommentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentModel.m; sourceTree = ""; }; - 7688436B1CAA37EF00D8629E /* CommentsNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentsNode.m; sourceTree = ""; }; - 7688436C1CAA37EF00D8629E /* CommentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentView.m; sourceTree = ""; }; - 7688436D1CAA37EF00D8629E /* ImageURLModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageURLModel.m; sourceTree = ""; }; - 768843701CAA37EF00D8629E /* LocationModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocationModel.m; sourceTree = ""; }; - 768843711CAA37EF00D8629E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 768843731CAA37EF00D8629E /* PhotoCellNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoCellNode.m; sourceTree = ""; }; - 768843741CAA37EF00D8629E /* PhotoCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoCollectionViewCell.m; sourceTree = ""; }; - 768843751CAA37EF00D8629E /* PhotoFeedModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoFeedModel.m; sourceTree = ""; }; - 768843761CAA37EF00D8629E /* PhotoFeedNodeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoFeedNodeController.m; sourceTree = ""; }; - 768843781CAA37EF00D8629E /* PhotoModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoModel.m; sourceTree = ""; }; - 768843791CAA37EF00D8629E /* PhotoTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoTableViewCell.m; sourceTree = ""; }; - 7688437A1CAA37EF00D8629E /* PhotoTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoTableViewController.m; sourceTree = ""; }; - 7688437B1CAA37EF00D8629E /* UserModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserModel.m; sourceTree = ""; }; - 7688437D1CAA37EF00D8629E /* UserRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserRowView.m; sourceTree = ""; }; - 7688437E1CAA37EF00D8629E /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utilities.m; sourceTree = ""; }; + 768843511CAA37EF00D8629E /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = AppDelegate.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843521CAA37EF00D8629E /* CommentFeedModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CommentFeedModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843531CAA37EF00D8629E /* CommentModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CommentModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843541CAA37EF00D8629E /* CommentsNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CommentsNode.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843551CAA37EF00D8629E /* CommentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CommentView.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843561CAA37EF00D8629E /* ImageURLModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = ImageURLModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843591CAA37EF00D8629E /* LocationModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = LocationModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 7688435B1CAA37EF00D8629E /* PhotoCellNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoCellNode.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 7688435C1CAA37EF00D8629E /* PhotoCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoCollectionViewCell.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 7688435D1CAA37EF00D8629E /* PhotoFeedModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoFeedModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 7688435E1CAA37EF00D8629E /* PhotoFeedNodeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoFeedNodeController.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843601CAA37EF00D8629E /* PhotoModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843611CAA37EF00D8629E /* PhotoTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoTableViewCell.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843621CAA37EF00D8629E /* PhotoTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PhotoTableViewController.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843631CAA37EF00D8629E /* UserModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = UserModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843651CAA37EF00D8629E /* UserRowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = UserRowView.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843661CAA37EF00D8629E /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Utilities.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 768843671CAA37EF00D8629E /* Flickrgram.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Flickrgram.pch; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843681CAA37EF00D8629E /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AppDelegate.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843691CAA37EF00D8629E /* CommentFeedModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CommentFeedModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 7688436A1CAA37EF00D8629E /* CommentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CommentModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 7688436B1CAA37EF00D8629E /* CommentsNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CommentsNode.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 7688436C1CAA37EF00D8629E /* CommentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CommentView.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 7688436D1CAA37EF00D8629E /* ImageURLModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ImageURLModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843701CAA37EF00D8629E /* LocationModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = LocationModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843711CAA37EF00D8629E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = main.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843731CAA37EF00D8629E /* PhotoCellNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoCellNode.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843741CAA37EF00D8629E /* PhotoCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoCollectionViewCell.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843751CAA37EF00D8629E /* PhotoFeedModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoFeedModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843761CAA37EF00D8629E /* PhotoFeedNodeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoFeedNodeController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843781CAA37EF00D8629E /* PhotoModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 768843791CAA37EF00D8629E /* PhotoTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoTableViewCell.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 7688437A1CAA37EF00D8629E /* PhotoTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PhotoTableViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 7688437B1CAA37EF00D8629E /* UserModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = UserModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 7688437D1CAA37EF00D8629E /* UserRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = UserRowView.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 7688437E1CAA37EF00D8629E /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = Utilities.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 7688437F1CAA37EF00D8629E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ diff --git a/examples/ASDKgram/Sample/AppDelegate.h b/examples/ASDKgram/Sample/AppDelegate.h index cc8d409ef3..27836849e9 100644 --- a/examples/ASDKgram/Sample/AppDelegate.h +++ b/examples/ASDKgram/Sample/AppDelegate.h @@ -1,6 +1,6 @@ // // AppDelegate.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/16/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/AppDelegate.m b/examples/ASDKgram/Sample/AppDelegate.m index 123a398d46..593d1516bc 100644 --- a/examples/ASDKgram/Sample/AppDelegate.m +++ b/examples/ASDKgram/Sample/AppDelegate.m @@ -1,6 +1,6 @@ // // AppDelegate.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/16/16. // Copyright © 2016 Hannah Troisi. All rights reserved. @@ -10,45 +10,42 @@ #import "PhotoTableViewController.h" #import "PhotoFeedNodeController.h" #import "Utilities.h" -#import "AsyncDisplayKit+Debug.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - + + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.backgroundColor = [UIColor whiteColor]; + + // UIKit Home Feed viewController & navController + PhotoFeedNodeController *asdkHomeFeedVC = [[PhotoFeedNodeController alloc] init]; + UINavigationController *asdkHomeFeedNavCtrl = [[UINavigationController alloc] initWithRootViewController:asdkHomeFeedVC]; + asdkHomeFeedNavCtrl.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"ASDK" image:[UIImage imageNamed:@"home"] tag:0]; + + // ASDK Home Feed viewController & navController + PhotoTableViewController *uikitHomeFeedVC = [[PhotoTableViewController alloc] init]; + UINavigationController *uikitHomeFeedNavCtrl = [[UINavigationController alloc] initWithRootViewController:uikitHomeFeedVC]; + uikitHomeFeedNavCtrl.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"UIKit" image:[UIImage imageNamed:@"home"] tag:0]; + + // UITabBarController + UITabBarController *tabBarController = [[UITabBarController alloc] init]; + tabBarController.viewControllers = @[uikitHomeFeedNavCtrl, asdkHomeFeedNavCtrl]; + tabBarController.selectedViewController = asdkHomeFeedNavCtrl; + // Nav Bar appearance [[UINavigationBar appearance] setBarTintColor:[UIColor darkBlueColor]]; [[UINavigationBar appearance] setTranslucent:NO]; NSDictionary *attributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]}; [[UINavigationBar appearance] setTitleTextAttributes:attributes]; - - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.window.backgroundColor = [UIColor whiteColor]; - UITabBarController *tabBarController = [[UITabBarController alloc] init]; - self.window.rootViewController = tabBarController; - [self.window makeKeyAndVisible]; - - // create UIKit-powered Home Feed viewController & navController - PhotoFeedNodeController *asdkPoweredHomeFeedVC = [[PhotoFeedNodeController alloc] init]; - UINavigationController *asdkHomeFeedNavCtrl = [[UINavigationController alloc] initWithRootViewController:asdkPoweredHomeFeedVC]; - asdkHomeFeedNavCtrl.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"ASDK" image:[UIImage imageNamed:@"home"] tag:0]; - - // create ASDK-powered Home Feed viewController & navController - PhotoTableViewController *uikitPoweredHomeFeedVC = [[PhotoTableViewController alloc] init]; - UINavigationController *uikitHomeFeedNavCtrl = [[UINavigationController alloc] initWithRootViewController:uikitPoweredHomeFeedVC]; - uikitHomeFeedNavCtrl.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"UIKit" image:[UIImage imageNamed:@"home"] tag:0]; - + // Hack to make the status bar have white text (changes after scrolling, but not on initial app startup) // UINavigationController does not forward on preferredStatusBarStyle calls to its child view controllers. - // Instead it manages its own state... - //http://stackoverflow.com/questions/19022210/preferredstatusbarstyle-isnt-called/19513714#19513714 + // Instead it manages its own state...http://stackoverflow.com/questions/19022210/preferredstatusbarstyle-isnt-called/19513714#19513714 uikitHomeFeedNavCtrl.navigationBar.barStyle = UIBarStyleBlack; - asdkHomeFeedNavCtrl.navigationBar.barStyle = UIBarStyleBlack; + asdkHomeFeedNavCtrl.navigationBar.barStyle = UIBarStyleBlack; - // configure UITabBarController and add viewControllers - tabBarController.viewControllers = @[uikitHomeFeedNavCtrl, asdkHomeFeedNavCtrl]; - tabBarController.selectedViewController = asdkHomeFeedNavCtrl; - -// [KMCGeigerCounter sharedGeigerCounter].enabled = YES; + self.window.rootViewController = tabBarController; + [self.window makeKeyAndVisible]; return YES; } diff --git a/examples/ASDKgram/Sample/CommentFeedModel.h b/examples/ASDKgram/Sample/CommentFeedModel.h index 4707d2fb96..87504b5ab5 100644 --- a/examples/ASDKgram/Sample/CommentFeedModel.h +++ b/examples/ASDKgram/Sample/CommentFeedModel.h @@ -1,6 +1,6 @@ // // CommentFeedModel.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/9/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/CommentFeedModel.m b/examples/ASDKgram/Sample/CommentFeedModel.m index c5256a0054..bebd32018a 100644 --- a/examples/ASDKgram/Sample/CommentFeedModel.m +++ b/examples/ASDKgram/Sample/CommentFeedModel.m @@ -1,6 +1,6 @@ // // CommentFeedModel.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/9/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/CommentModel.h b/examples/ASDKgram/Sample/CommentModel.h index 417b9f5cd3..e584aed7b5 100644 --- a/examples/ASDKgram/Sample/CommentModel.h +++ b/examples/ASDKgram/Sample/CommentModel.h @@ -1,6 +1,6 @@ // // CommentModel.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/9/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/CommentModel.m b/examples/ASDKgram/Sample/CommentModel.m index e2dd9f07e3..714a401567 100644 --- a/examples/ASDKgram/Sample/CommentModel.m +++ b/examples/ASDKgram/Sample/CommentModel.m @@ -1,6 +1,6 @@ // // CommentModel.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/9/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/CommentView.h b/examples/ASDKgram/Sample/CommentView.h index 7443d8f71c..8aa021634b 100644 --- a/examples/ASDKgram/Sample/CommentView.h +++ b/examples/ASDKgram/Sample/CommentView.h @@ -1,6 +1,6 @@ // // CommentView.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/9/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/CommentView.m b/examples/ASDKgram/Sample/CommentView.m index fd3b62fe4c..0a22df118a 100644 --- a/examples/ASDKgram/Sample/CommentView.m +++ b/examples/ASDKgram/Sample/CommentView.m @@ -1,6 +1,6 @@ // // CommentView.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/9/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/CommentsNode.h b/examples/ASDKgram/Sample/CommentsNode.h index 35929a7886..62ebd92ead 100644 --- a/examples/ASDKgram/Sample/CommentsNode.h +++ b/examples/ASDKgram/Sample/CommentsNode.h @@ -1,6 +1,6 @@ // // CommentsNode.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/21/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/CommentsNode.m b/examples/ASDKgram/Sample/CommentsNode.m index 458062cf4f..4cf148baeb 100644 --- a/examples/ASDKgram/Sample/CommentsNode.m +++ b/examples/ASDKgram/Sample/CommentsNode.m @@ -1,6 +1,6 @@ // // CommentsNode.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/21/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/Flickrgram.pch b/examples/ASDKgram/Sample/Flickrgram.pch index 5748014ec6..5005dea697 100644 --- a/examples/ASDKgram/Sample/Flickrgram.pch +++ b/examples/ASDKgram/Sample/Flickrgram.pch @@ -1,6 +1,6 @@ // -// Flickrgram.pch -// Flickrgram +// ASDKgram.pch +// ASDKgram // // Created by Hannah Troisi on 2/26/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/ImageURLModel.h b/examples/ASDKgram/Sample/ImageURLModel.h index 22281b2b86..b39367dfa9 100644 --- a/examples/ASDKgram/Sample/ImageURLModel.h +++ b/examples/ASDKgram/Sample/ImageURLModel.h @@ -1,6 +1,6 @@ // // ImageURLModel.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/11/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/ImageURLModel.m b/examples/ASDKgram/Sample/ImageURLModel.m index a8d966aef9..e6723a163d 100644 --- a/examples/ASDKgram/Sample/ImageURLModel.m +++ b/examples/ASDKgram/Sample/ImageURLModel.m @@ -1,6 +1,6 @@ // // ImageURLModel.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/11/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/LocationModel.h b/examples/ASDKgram/Sample/LocationModel.h index 68bb8accbf..c8727a887c 100644 --- a/examples/ASDKgram/Sample/LocationModel.h +++ b/examples/ASDKgram/Sample/LocationModel.h @@ -1,6 +1,6 @@ // // LocationModel.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/26/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/LocationModel.m b/examples/ASDKgram/Sample/LocationModel.m index 60ce47f1b0..4ed7af4d41 100644 --- a/examples/ASDKgram/Sample/LocationModel.m +++ b/examples/ASDKgram/Sample/LocationModel.m @@ -1,6 +1,6 @@ // // LocationModel.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/26/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoCellNode.h b/examples/ASDKgram/Sample/PhotoCellNode.h index 9a9634557e..5a331c727b 100644 --- a/examples/ASDKgram/Sample/PhotoCellNode.h +++ b/examples/ASDKgram/Sample/PhotoCellNode.h @@ -1,6 +1,6 @@ // // PhotoCellNode.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/17/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoCellNode.m b/examples/ASDKgram/Sample/PhotoCellNode.m index c0a8a2eac5..9b6708f70f 100644 --- a/examples/ASDKgram/Sample/PhotoCellNode.m +++ b/examples/ASDKgram/Sample/PhotoCellNode.m @@ -1,6 +1,6 @@ // // PhotoCellNode.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/17/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoCollectionViewCell.h b/examples/ASDKgram/Sample/PhotoCollectionViewCell.h index 4aea2f2add..c043f78367 100644 --- a/examples/ASDKgram/Sample/PhotoCollectionViewCell.h +++ b/examples/ASDKgram/Sample/PhotoCollectionViewCell.h @@ -1,6 +1,6 @@ // // PhotoCollectionViewCell.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/2/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoCollectionViewCell.m b/examples/ASDKgram/Sample/PhotoCollectionViewCell.m index 1d7bae2ddf..def3b6b6da 100644 --- a/examples/ASDKgram/Sample/PhotoCollectionViewCell.m +++ b/examples/ASDKgram/Sample/PhotoCollectionViewCell.m @@ -1,6 +1,6 @@ // // PhotoCollectionViewCell.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/2/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoFeedModel.h b/examples/ASDKgram/Sample/PhotoFeedModel.h index 1f5d58ecc6..acc8c34be1 100644 --- a/examples/ASDKgram/Sample/PhotoFeedModel.h +++ b/examples/ASDKgram/Sample/PhotoFeedModel.h @@ -1,6 +1,6 @@ // // PhotoFeedModel.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/28/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoFeedModel.m b/examples/ASDKgram/Sample/PhotoFeedModel.m index de351e1584..a6ce8e2620 100644 --- a/examples/ASDKgram/Sample/PhotoFeedModel.m +++ b/examples/ASDKgram/Sample/PhotoFeedModel.m @@ -1,6 +1,6 @@ // // PhotoFeedModel.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/28/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoFeedNodeController.h b/examples/ASDKgram/Sample/PhotoFeedNodeController.h index 4e993cbc0a..106e7485ab 100644 --- a/examples/ASDKgram/Sample/PhotoFeedNodeController.h +++ b/examples/ASDKgram/Sample/PhotoFeedNodeController.h @@ -1,14 +1,13 @@ // // PhotoFeedNodeController.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/17/16. // Copyright © 2016 Hannah Troisi. All rights reserved. // -#import - -@interface PhotoFeedNodeController : UIViewController +#import +@interface PhotoFeedNodeController : ASViewController @end diff --git a/examples/ASDKgram/Sample/PhotoFeedNodeController.m b/examples/ASDKgram/Sample/PhotoFeedNodeController.m index b5c7de33c5..d66e06d281 100644 --- a/examples/ASDKgram/Sample/PhotoFeedNodeController.m +++ b/examples/ASDKgram/Sample/PhotoFeedNodeController.m @@ -1,18 +1,17 @@ // // PhotoFeedNodeController.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/17/16. // Copyright © 2016 Hannah Troisi. All rights reserved. // #import "PhotoFeedNodeController.h" -#import "PhotoModel.h" -#import "PhotoCellNode.h" -#import "PhotoTableViewCell.h" -#import "PhotoFeedModel.h" #import #import "Utilities.h" +#import "PhotoModel.h" +#import "PhotoCellNode.h" +#import "PhotoFeedModel.h" #define AUTO_TAIL_LOADING_NUM_SCREENFULS 2.5 @@ -22,48 +21,124 @@ @implementation PhotoFeedNodeController { PhotoFeedModel *_photoFeed; - ASTableView *_tableView; + ASTableNode *_tableNode; UIView *_statusBarOpaqueUnderlayView; } - #pragma mark - Lifecycle -- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil +- (instancetype)init { - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + _tableNode = [[ASTableNode alloc] init]; + self = [super initWithNode:_tableNode]; if (self) { - - self.navigationItem.title = @"ASDK"; + self.navigationItem.title = @"ASDK"; [self.navigationController setNavigationBarHidden:YES]; -// _tableView.refreshControl = [[UIRefreshControl alloc] init]; -// [self.refreshControl addTarget:self action:@selector(refreshFeed) forControlEvents:UIControlEventValueChanged]; - - _photoFeed = [[PhotoFeedModel alloc] initWithPhotoFeedModelType:PhotoFeedModelTypePopular imageSize:[self imageSizeForScreenWidth]]; + _photoFeed = [[PhotoFeedModel alloc] initWithPhotoFeedModelType:PhotoFeedModelTypePopular + imageSize:[self imageSizeForScreenWidth]]; [self refreshFeed]; - + + _tableNode.dataSource = self; + _tableNode.delegate = self; + + // hack to make status bar opaque _statusBarOpaqueUnderlayView = [[UIView alloc] init]; _statusBarOpaqueUnderlayView.backgroundColor = [UIColor darkBlueColor]; [[[UIApplication sharedApplication] keyWindow] addSubview:_statusBarOpaqueUnderlayView]; - - - // ASTABLEVIEW - _tableView = [[ASTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain asyncDataFetching:YES]; - _tableView.asyncDataSource = self; - _tableView.asyncDelegate = self; - _tableView.allowsSelection = NO; - _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - - // enable tableView pull-to-refresh & add target-action pair -// self.refreshControl = [[UIRefreshControl alloc] init]; -// [self.refreshControl addTarget:self action:@selector(refreshFeed) forControlEvents:UIControlEventValueChanged]; } return self; } +// do any ASDK view stuff in loadView +- (void)loadView +{ + [super loadView]; + + self.view.backgroundColor = [UIColor whiteColor]; + _tableNode.view.allowsSelection = NO; + _tableNode.view.separatorStyle = UITableViewCellSeparatorStyleNone; + +} + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + // auto-hide navigation bar + self.navigationController.hidesBarsOnSwipe = YES; +} + +- (void)viewWillLayoutSubviews +{ + [super viewWillLayoutSubviews]; + + // hack to make status bar opaque view float over scroll + _statusBarOpaqueUnderlayView.frame = [[UIApplication sharedApplication] statusBarFrame]; +} + +#pragma mark - helper methods + +- (void)refreshFeed +{ + // small first batch + [_photoFeed refreshFeedWithCompletionBlock:^(NSArray *newPhotos){ + + [self insertNewRowsInTableView:newPhotos]; + [self requestCommentsForPhotos:newPhotos]; + + // immediately start second larger fetch + [self loadPage]; + + } numResultsToReturn:4]; +} + +- (void)loadPage +{ + [_photoFeed requestPageWithCompletionBlock:^(NSArray *newPhotos){ + [self insertNewRowsInTableView:newPhotos]; + [self requestCommentsForPhotos:newPhotos]; + } numResultsToReturn:20]; +} + +- (void)requestCommentsForPhotos:(NSArray *)newPhotos +{ + for (PhotoModel *photo in newPhotos) { + [photo.commentFeed refreshFeedWithCompletionBlock:^(NSArray *newComments) { + + NSInteger rowNum = [_photoFeed indexOfPhotoModel:photo]; + PhotoCellNode *cell = (PhotoCellNode *)[_tableNode.view nodeForRowAtIndexPath:[NSIndexPath indexPathForRow:rowNum inSection:0]]; + + if (cell) { + [cell loadCommentsForPhoto:photo]; + [_tableNode.view beginUpdates]; + [_tableNode.view endUpdates]; + } + }]; + } +} + +- (void)insertNewRowsInTableView:(NSArray *)newPhotos +{ + NSInteger section = 0; + NSMutableArray *indexPaths = [NSMutableArray array]; + + NSUInteger newTotalNumberOfPhotos = [_photoFeed numberOfItemsInFeed]; + for (NSUInteger row = newTotalNumberOfPhotos - newPhotos.count; row < newTotalNumberOfPhotos; row++) { + NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section]; + [indexPaths addObject:path]; + } + + [_tableNode.view insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; +} + +- (UIStatusBarStyle)preferredStatusBarStyle +{ + return UIStatusBarStyleLightContent; +} + - (CGSize)imageSizeForScreenWidth { CGRect screenRect = [[UIScreen mainScreen] bounds]; @@ -71,135 +146,7 @@ return CGSizeMake(screenRect.size.width * screenScale, screenRect.size.width * screenScale); } -- (void)loadView -{ - [super loadView]; - - [self.view addSubview:_tableView]; //FIXME: self use implicit heirarchy? - self.view.backgroundColor = [UIColor whiteColor]; //ditto -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - self.navigationController.hidesBarsOnSwipe = YES; -} - -- (void)viewWillLayoutSubviews -{ - [super viewWillLayoutSubviews]; - - _tableView.frame = self.view.bounds; - _statusBarOpaqueUnderlayView.frame = [[UIApplication sharedApplication] statusBarFrame]; -} - -#pragma mark - Gesture Handling - -- (void)refreshFeed -{ - // small first batch - [_photoFeed refreshFeedWithCompletionBlock:^(NSArray *newPhotos){ - - [_tableView reloadData]; // overwrite tableView instead of inserting new rows -// [self.refreshControl endRefreshing]; - [self requestCommentsForPhotos:newPhotos]; - - // immediately start second larger fetch - [self loadPage]; - - } numResultsToReturn:4]; -} - -- (UIStatusBarStyle)preferredStatusBarStyle // FIXME - doesn't work? -{ - return UIStatusBarStyleLightContent; -} - -- (void)loadPage -{ -// NSLog(@"_photoFeed number of items = %lu", [_photoFeed numberOfItemsInFeed]); - - [self logPhotoIDsInPhotoFeed]; - - [_photoFeed requestPageWithCompletionBlock:^(NSArray *newPhotos){ - - [self insertNewRowsInTableView:newPhotos]; - [self requestCommentsForPhotos:newPhotos]; - [self logPhotoIDsInPhotoFeed]; - - } numResultsToReturn:20]; -} - -- (void)requestCommentsForPhotos:(NSArray *)newPhotos -{ - for (PhotoModel *photo in newPhotos) { - - [photo.commentFeed refreshFeedWithCompletionBlock:^(NSArray *newComments) { - - NSInteger rowNum = [_photoFeed indexOfPhotoModel:photo]; - PhotoCellNode *cell = (PhotoCellNode *)[_tableView nodeForRowAtIndexPath:[NSIndexPath indexPathForRow:rowNum inSection:0]]; - - if (cell) { - [cell loadCommentsForPhoto:photo]; - [_tableView beginUpdates]; - [_tableView endUpdates]; - } - }]; - } -} - -- (void)logPhotoIDsInPhotoFeed -{ -// NSLog(@"_photoFeed number of items = %lu", [_photoFeed numberOfItemsInFeed]); - -// for (int i = 0; i < [_photoFeed numberOfItemsInFeed]; i++) { -// if (i % 4 == 0 && i > 0) { -// NSLog(@"\t-----"); -// } - -// [_photoFeed return] -// NSString *duplicate = ? @"(DUPLICATE)" : @""; -// NSLog(@"\t%@ %@", [[_photoFeed objectAtIndex:i] photoID], @""); -// } -} - -- (void)insertNewRowsInTableView:(NSArray *)newPhotos -{ -// NSLog(@"_photoFeed number of items = %lu (%lu total)", (unsigned long)[_photoFeed numberOfItemsInFeed], (long)[_photoFeed totalNumberOfPhotos]); - - // instead of doing tableView reloadData, use table editing commands - NSMutableArray *indexPaths = [NSMutableArray array]; - - NSInteger section = 0; - NSUInteger newTotalNumberOfPhotos = [_photoFeed numberOfItemsInFeed]; - for (NSUInteger row = newTotalNumberOfPhotos - newPhotos.count; row < newTotalNumberOfPhotos; row++) { - - NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section]; - [indexPaths addObject:path]; - } - - [_tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; -} - -#pragma mark - ASTableDelegate protocol methods --(void)scrollViewDidScroll:(UIScrollView *)scrollView -{ - - CGFloat currentOffSetY = scrollView.contentOffset.y; - CGFloat contentHeight = scrollView.contentSize.height; - CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; - - // automatic tail loading - CGFloat screenfullsBeforeBottom = (contentHeight - currentOffSetY) / screenHeight; - if (screenfullsBeforeBottom < AUTO_TAIL_LOADING_NUM_SCREENFULS) { -// NSLog(@"AUTOMATIC TAIL LOADING BEGIN"); - [self loadPage]; - } -} - - -#pragma mark - ASTableDataSource protocol methods +#pragma mark - ASTableDataSource methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { @@ -208,9 +155,24 @@ - (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath; { - PhotoCellNode *cell = [[PhotoCellNode alloc] initWithPhotoObject:[_photoFeed objectAtIndex:indexPath.row]]; + PhotoCellNode *cellNode = [[PhotoCellNode alloc] initWithPhotoObject:[_photoFeed objectAtIndex:indexPath.row]]; - return cell; + return cellNode; +} + +#pragma mark - ASTableDelegate methods + +// table automatic tail loading +-(void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + CGFloat currentOffSetY = scrollView.contentOffset.y; + CGFloat contentHeight = scrollView.contentSize.height; + CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; + + CGFloat screenfullsBeforeBottom = (contentHeight - currentOffSetY) / screenHeight; + if (screenfullsBeforeBottom < AUTO_TAIL_LOADING_NUM_SCREENFULS) { + [self loadPage]; + } } @end diff --git a/examples/ASDKgram/Sample/PhotoModel.h b/examples/ASDKgram/Sample/PhotoModel.h index 8cddcf9a26..97e6a5c646 100644 --- a/examples/ASDKgram/Sample/PhotoModel.h +++ b/examples/ASDKgram/Sample/PhotoModel.h @@ -1,6 +1,6 @@ // // PhotoModel.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/26/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoModel.m b/examples/ASDKgram/Sample/PhotoModel.m index b692df1f4f..b482258ab0 100644 --- a/examples/ASDKgram/Sample/PhotoModel.m +++ b/examples/ASDKgram/Sample/PhotoModel.m @@ -1,6 +1,6 @@ // // PhotoModel.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/26/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoTableViewCell.h b/examples/ASDKgram/Sample/PhotoTableViewCell.h index 00fa4b4046..13c396d73a 100644 --- a/examples/ASDKgram/Sample/PhotoTableViewCell.h +++ b/examples/ASDKgram/Sample/PhotoTableViewCell.h @@ -1,6 +1,6 @@ // // PhotoTableViewCell.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/17/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoTableViewCell.m b/examples/ASDKgram/Sample/PhotoTableViewCell.m index a65b7b010e..ac5cc494d4 100644 --- a/examples/ASDKgram/Sample/PhotoTableViewCell.m +++ b/examples/ASDKgram/Sample/PhotoTableViewCell.m @@ -1,6 +1,6 @@ // // PhotoTableViewCell.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/17/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoTableViewController.h b/examples/ASDKgram/Sample/PhotoTableViewController.h index 129728e22c..54f002daec 100644 --- a/examples/ASDKgram/Sample/PhotoTableViewController.h +++ b/examples/ASDKgram/Sample/PhotoTableViewController.h @@ -1,6 +1,6 @@ // // PhotoTableViewController.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/17/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/PhotoTableViewController.m b/examples/ASDKgram/Sample/PhotoTableViewController.m index c2a285a058..040f45eb2f 100644 --- a/examples/ASDKgram/Sample/PhotoTableViewController.m +++ b/examples/ASDKgram/Sample/PhotoTableViewController.m @@ -1,27 +1,24 @@ // // PhotoTableViewController.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/17/16. // Copyright © 2016 Hannah Troisi. All rights reserved. // #import "PhotoTableViewController.h" +#import "Utilities.h" #import "PhotoTableViewCell.h" #import "PhotoFeedModel.h" -#import "Utilities.h" - #define AUTO_TAIL_LOADING_NUM_SCREENFULS 2.5 - @implementation PhotoTableViewController { PhotoFeedModel *_photoFeed; UIView *_statusBarOpaqueUnderlayView; } - #pragma mark - Lifecycle - (instancetype)initWithStyle:(UITableViewStyle)style @@ -30,15 +27,16 @@ if (self) { - self.navigationItem.title = @"UIKit"; + self.navigationItem.title = @"UIKit"; [self.navigationController setNavigationBarHidden:YES]; - self.refreshControl = [[UIRefreshControl alloc] init]; - [self.refreshControl addTarget:self action:@selector(refreshFeed) forControlEvents:UIControlEventValueChanged]; - - _photoFeed = [[PhotoFeedModel alloc] initWithPhotoFeedModelType:PhotoFeedModelTypePopular imageSize:[self imageSizeForScreenWidth]]; + _photoFeed = [[PhotoFeedModel alloc] initWithPhotoFeedModelType:PhotoFeedModelTypePopular imageSize:[self imageSizeForScreenWidth]]; [self refreshFeed]; + self.refreshControl = [[UIRefreshControl alloc] init]; + [self.refreshControl addTarget:self action:@selector(refreshFeed) forControlEvents:UIControlEventValueChanged]; + + // hack to make status bar opaque _statusBarOpaqueUnderlayView = [[UIView alloc] init]; _statusBarOpaqueUnderlayView.backgroundColor = [UIColor darkBlueColor]; [[[UIApplication sharedApplication] keyWindow] addSubview:_statusBarOpaqueUnderlayView]; @@ -47,7 +45,8 @@ return self; } -- (void)viewDidLoad // anything involving the view should go here, not init +// anything involving the view should go here, not init +- (void)viewDidLoad { [super viewDidLoad]; @@ -61,6 +60,7 @@ { [super viewWillAppear:animated]; + // auto-hide navigation bar self.navigationController.hidesBarsOnSwipe = YES; } @@ -68,18 +68,18 @@ { [super viewWillLayoutSubviews]; + // hack to make status bar opaque view float over scroll _statusBarOpaqueUnderlayView.frame = [[UIApplication sharedApplication] statusBarFrame]; } -#pragma mark - Instance Methods +#pragma mark - helper methods - (void)refreshFeed { // small first batch [_photoFeed refreshFeedWithCompletionBlock:^(NSArray *newPhotos){ - [self.tableView reloadData]; // overwrite tableView instead of inserting new rows - [self.refreshControl endRefreshing]; + [self insertNewRowsInTableView:newPhotos]; [self requestCommentsForPhotos:newPhotos]; // immediately start second larger fetch @@ -88,13 +88,6 @@ } numResultsToReturn:4]; } -- (UIStatusBarStyle)preferredStatusBarStyle -{ - return UIStatusBarStyleLightContent; -} - -#pragma mark - Helper Methods - - (void)loadPage { [_photoFeed requestPageWithCompletionBlock:^(NSArray *newPhotos){ @@ -106,7 +99,6 @@ - (void)requestCommentsForPhotos:(NSArray *)newPhotos { for (PhotoModel *photo in newPhotos) { - [photo.commentFeed refreshFeedWithCompletionBlock:^(NSArray *newComments) { NSInteger rowNum = [_photoFeed indexOfPhotoModel:photo]; @@ -116,12 +108,30 @@ [cell loadCommentsForPhoto:photo]; [self.tableView beginUpdates]; [self.tableView endUpdates]; - // FIXME: adjust content offset - iterate over cells above to get heights... } }]; } } +- (void)insertNewRowsInTableView:(NSArray *)newPhotos +{ + NSInteger section = 0; + NSMutableArray *indexPaths = [NSMutableArray array]; + + NSUInteger newTotalNumberOfPhotos = [_photoFeed numberOfItemsInFeed]; + for (NSUInteger row = newTotalNumberOfPhotos - newPhotos.count; row < newTotalNumberOfPhotos; row++) { + NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section]; + [indexPaths addObject:path]; + } + + [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; +} + +- (UIStatusBarStyle)preferredStatusBarStyle +{ + return UIStatusBarStyleLightContent; +} + - (CGSize)imageSizeForScreenWidth { CGRect screenRect = [[UIScreen mainScreen] bounds]; @@ -129,58 +139,7 @@ return CGSizeMake(screenRect.size.width * screenScale, screenRect.size.width * screenScale); } -- (void)insertNewRowsInTableView:(NSArray *)newPhotos -{ -// NSLog(@"_photoFeed number of items = %lu (%lu total)", (unsigned long)[_photoFeed numberOfItemsInFeed], (long)[_photoFeed totalNumberOfPhotos]); - - // instead of doing tableView reloadData, use table editing commands - NSMutableArray *indexPaths = [NSMutableArray array]; - - NSInteger section = 0; - NSUInteger newTotalNumberOfPhotos = [_photoFeed numberOfItemsInFeed]; - for (NSUInteger row = newTotalNumberOfPhotos - newPhotos.count; row < newTotalNumberOfPhotos; row++) { - - NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section]; - [indexPaths addObject:path]; - } - - [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; -} - -//- (void)logPhotoIDsInPhotoFeed -//{ -// NSLog(@"_photoFeed number of items = %lu", (unsigned long)[_photoFeed numberOfItemsInFeed]); -// -// for (int i = 0; i < [_photoFeed numberOfItemsInFeed]; i++) { -// if (i % 4 == 0 && i > 0) { -// NSLog(@"\t-----"); -// } -// -//// [_photoFeed return] -//// NSString *duplicate = ? @"(DUPLICATE)" : @""; -// NSLog(@"\t%@ %@", [[_photoFeed objectAtIndex:i] photoID], @""); -// } -//} - -#pragma mark - UITableViewDelegate - --(void)scrollViewDidScroll:(UIScrollView *)scrollView -{ - - CGFloat currentOffSetY = scrollView.contentOffset.y; - CGFloat contentHeight = scrollView.contentSize.height; - CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; - - // automatic tail loading - CGFloat screenfullsBeforeBottom = (contentHeight - currentOffSetY) / screenHeight; - if (screenfullsBeforeBottom < AUTO_TAIL_LOADING_NUM_SCREENFULS) { -// NSLog(@"AUTOMATIC TAIL LOADING BEGIN"); - [self loadPage]; - } -} - - -#pragma mark - UITableViewDataSource +#pragma mark - UITableViewDataSource methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { @@ -190,7 +149,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { PhotoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"photoCell" forIndexPath:indexPath]; - [cell updateCellWithPhotoObject:[_photoFeed objectAtIndex:indexPath.row]]; return cell; @@ -202,4 +160,22 @@ return [PhotoTableViewCell heightForPhotoModel:photo withWidth:self.view.bounds.size.width]; } +#pragma mark - UITableViewDelegate methods + +// table automatic tail loading +-(void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + CGFloat currentOffSetY = scrollView.contentOffset.y; + CGFloat contentHeight = scrollView.contentSize.height; + CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; + + CGFloat screenfullsBeforeBottom = (contentHeight - currentOffSetY) / screenHeight; + if (screenfullsBeforeBottom < AUTO_TAIL_LOADING_NUM_SCREENFULS) { + [self loadPage]; + } +} + + + + @end diff --git a/examples/ASDKgram/Sample/UserModel.h b/examples/ASDKgram/Sample/UserModel.h index 27cca7acde..7c41dd8389 100644 --- a/examples/ASDKgram/Sample/UserModel.h +++ b/examples/ASDKgram/Sample/UserModel.h @@ -1,6 +1,6 @@ // // UserModel.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/26/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/UserModel.m b/examples/ASDKgram/Sample/UserModel.m index 4d5f7ddaf7..644b3cf3da 100644 --- a/examples/ASDKgram/Sample/UserModel.m +++ b/examples/ASDKgram/Sample/UserModel.m @@ -1,6 +1,6 @@ // // UserModel.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/26/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/UserRowView.h b/examples/ASDKgram/Sample/UserRowView.h index 98fd10460b..088121f14d 100644 --- a/examples/ASDKgram/Sample/UserRowView.h +++ b/examples/ASDKgram/Sample/UserRowView.h @@ -1,6 +1,6 @@ // // UserRowView.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/13/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/UserRowView.m b/examples/ASDKgram/Sample/UserRowView.m index 7e71f42eb3..9a73b51bfc 100644 --- a/examples/ASDKgram/Sample/UserRowView.m +++ b/examples/ASDKgram/Sample/UserRowView.m @@ -1,6 +1,6 @@ // // UserRowView.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/13/16. // Copyright © 2016 Hannah Troisi. All rights reserved. diff --git a/examples/ASDKgram/Sample/Utilities.h b/examples/ASDKgram/Sample/Utilities.h index 111c237d27..af8e1f121f 100644 --- a/examples/ASDKgram/Sample/Utilities.h +++ b/examples/ASDKgram/Sample/Utilities.h @@ -1,6 +1,6 @@ // // Utilities.h -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/9/16. // Copyright © 2016 Hannah Troisi. All rights reserved. @@ -33,7 +33,9 @@ @interface NSAttributedString (Additions) -+ (NSAttributedString *)attributedStringWithString:(NSString *)string fontSize:(CGFloat)size - color:(UIColor *)color firstWordColor:(UIColor *)firstWordColor; ++ (NSAttributedString *)attributedStringWithString:(NSString *)string + fontSize:(CGFloat)size + color:(UIColor *)color + firstWordColor:(UIColor *)firstWordColor; @end \ No newline at end of file diff --git a/examples/ASDKgram/Sample/Utilities.m b/examples/ASDKgram/Sample/Utilities.m index ac0c93c3cc..590376dc85 100644 --- a/examples/ASDKgram/Sample/Utilities.m +++ b/examples/ASDKgram/Sample/Utilities.m @@ -1,6 +1,6 @@ // // Utilities.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 3/9/16. // Copyright © 2016 Hannah Troisi. All rights reserved. @@ -171,15 +171,19 @@ + (NSAttributedString *)attributedStringWithString:(NSString *)string fontSize:(CGFloat)size color:(nullable UIColor *)color firstWordColor:(nullable UIColor *)firstWordColor { - NSDictionary *attributes = @{NSForegroundColorAttributeName: color ? : [UIColor blackColor], - NSFontAttributeName: [UIFont systemFontOfSize:size]}; - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string]; - [attributedString addAttributes:attributes range:NSMakeRange(0, string.length)]; + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init]; - if (firstWordColor) { - NSRange firstSpaceRange = [string rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]]; - NSRange firstWordRange = NSMakeRange(0, firstSpaceRange.location); - [attributedString addAttribute:NSForegroundColorAttributeName value:firstWordColor range:firstWordRange]; + if (string) { + NSDictionary *attributes = @{NSForegroundColorAttributeName: color ? : [UIColor blackColor], + NSFontAttributeName: [UIFont systemFontOfSize:size]}; + attributedString = [[NSMutableAttributedString alloc] initWithString:string]; + [attributedString addAttributes:attributes range:NSMakeRange(0, string.length)]; + + if (firstWordColor) { + NSRange firstSpaceRange = [string rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]]; + NSRange firstWordRange = NSMakeRange(0, firstSpaceRange.location); + [attributedString addAttribute:NSForegroundColorAttributeName value:firstWordColor range:firstWordRange]; + } } return attributedString; diff --git a/examples/ASDKgram/Sample/main.m b/examples/ASDKgram/Sample/main.m index 30ca31c2e8..ddf492b685 100644 --- a/examples/ASDKgram/Sample/main.m +++ b/examples/ASDKgram/Sample/main.m @@ -5,7 +5,7 @@ // main.m -// Flickrgram +// ASDKgram // // Created by Hannah Troisi on 2/16/16. // Copyright © 2016 Hannah Troisi. All rights reserved.