From f05acc0229c1d66fc9082f409a7849e97a04e4a8 Mon Sep 17 00:00:00 2001 From: Roy Yang Date: Tue, 24 Jul 2012 11:44:16 -0700 Subject: [PATCH] adding in the master container and rotation logic --- media/ios/Classes/ActivityCell.m | 1 - media/ios/Classes/NBContainerViewController.h | 21 +++ media/ios/Classes/NBContainerViewController.m | 108 +++++++++++++++ media/ios/Classes/NewsBlurAppDelegate.h | 3 + media/ios/Classes/NewsBlurAppDelegate.m | 31 +++-- media/ios/Classes/SmallActivityCell.m | 1 - media/ios/NewsBlur.xcodeproj/project.pbxproj | 6 + media/ios/NewsBlur_Prefix.pch | 4 +- .../ios/Other Sources/MGSplitViewController.m | 2 +- media/ios/Resources-iPad/MainWindow~ipad.xib | 126 +++++++++++++++--- 10 files changed, 262 insertions(+), 41 deletions(-) create mode 100644 media/ios/Classes/NBContainerViewController.h create mode 100644 media/ios/Classes/NBContainerViewController.m diff --git a/media/ios/Classes/ActivityCell.m b/media/ios/Classes/ActivityCell.m index 9ccbac305..f01ab7d0d 100644 --- a/media/ios/Classes/ActivityCell.m +++ b/media/ios/Classes/ActivityCell.m @@ -88,7 +88,6 @@ NSString *faviconUrl = [NSString stringWithFormat:@"http://%@/rss_feeds/icon/%i", NEWSBLUR_URL, [[activity objectForKey:@"feed_id"] intValue]]; - NSLog(@"faviconUrl is %@", faviconUrl); [self.faviconView setImageWithURL:[NSURL URLWithString:faviconUrl ] placeholderImage:placeholder]; self.faviconView.contentMode = UIViewContentModeScaleAspectFit; diff --git a/media/ios/Classes/NBContainerViewController.h b/media/ios/Classes/NBContainerViewController.h new file mode 100644 index 000000000..662221011 --- /dev/null +++ b/media/ios/Classes/NBContainerViewController.h @@ -0,0 +1,21 @@ +// +// NBContainerViewController.h +// NewsBlur +// +// Created by Roy Yang on 7/24/12. +// Copyright (c) 2012 NewsBlur. All rights reserved. +// + +#import + +@class NewsBlurAppDelegate; + +@interface NBContainerViewController : UIViewController { + NewsBlurAppDelegate *appDelegate; +} + +@property (atomic, strong) IBOutlet NewsBlurAppDelegate *appDelegate; + +- (void)adjustDashboardFrame; +- (void)transitionToFeedDetail; +@end diff --git a/media/ios/Classes/NBContainerViewController.m b/media/ios/Classes/NBContainerViewController.m new file mode 100644 index 000000000..9b7c5f87d --- /dev/null +++ b/media/ios/Classes/NBContainerViewController.m @@ -0,0 +1,108 @@ +// +// NBContainerViewController.m +// NewsBlur +// +// Created by Roy Yang on 7/24/12. +// Copyright (c) 2012 NewsBlur. All rights reserved. +// + +#import "NBContainerViewController.h" +#import "NewsBlurViewController.h" +#import "FeedDetailViewController.h" +#import "DashboardViewController.h" +#import "StoryDetailViewController.h" +#import "ShareViewController.h" + +#define NB_DEFAULT_MASTER_WIDTH 270 + +@interface NBContainerViewController () + +@property (nonatomic, strong) UINavigationController *masterNavigationController; +@property (nonatomic, strong) NewsBlurViewController *feedsViewController; +@property (nonatomic, strong) FeedDetailViewController *feedDetailViewController; +@property (nonatomic, strong) DashboardViewController *dashboardViewController; +@property (nonatomic, strong) StoryDetailViewController *storyDetailViewController; +@property (nonatomic, strong) ShareViewController *shareViewController; + +@end + +@implementation NBContainerViewController + +@synthesize appDelegate; +@synthesize masterNavigationController; +@synthesize feedsViewController; +@synthesize feedDetailViewController; +@synthesize dashboardViewController; +@synthesize storyDetailViewController; +@synthesize shareViewController; + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + + + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. + self.view.backgroundColor = [UIColor blackColor]; + + self.masterNavigationController = appDelegate.navigationController; + self.feedsViewController = appDelegate.feedsViewController; + self.dashboardViewController = appDelegate.dashboardViewController; + + // adding master navigation controller + [self addChildViewController:self.masterNavigationController]; + [self.view addSubview:self.masterNavigationController.view]; + [self.masterNavigationController didMoveToParentViewController:self]; + + // adding dashboardViewController + [self addChildViewController:self.dashboardViewController]; + [self.view addSubview:self.dashboardViewController.view]; + [self.dashboardViewController didMoveToParentViewController:self]; +} + +- (void)viewWillLayoutSubviews { + [self adjustDashboardFrame]; +} + +- (void)viewDidUnload { + [super viewDidUnload]; + // Release any retained subviews of the main view. +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + return YES; +} + +- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { + [self adjustDashboardFrame]; +} + +# pragma mark Screen Transitions and Layout + +- (void)adjustDashboardFrame { + CGRect vb = [self.view bounds]; + self.masterNavigationController.view.frame = CGRectMake(0, 0, NB_DEFAULT_MASTER_WIDTH, vb.size.height); + self.dashboardViewController.view.frame = CGRectMake(NB_DEFAULT_MASTER_WIDTH + 1, 0, vb.size.width - NB_DEFAULT_MASTER_WIDTH - 1, vb.size.height); +} + +- (void)transitionToFeedDetail { + UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; + if (UIInterfaceOrientationIsPortrait(orientation)) { + + } + +} + +@end diff --git a/media/ios/Classes/NewsBlurAppDelegate.h b/media/ios/Classes/NewsBlurAppDelegate.h index 04d85ac6d..1807d8777 100644 --- a/media/ios/Classes/NewsBlurAppDelegate.h +++ b/media/ios/Classes/NewsBlurAppDelegate.h @@ -38,6 +38,7 @@ @class OriginalStoryViewController; @class MGSplitViewController; @class UserProfileViewController; +@class NBContainerViewController; @interface NewsBlurAppDelegate : BaseViewController { @@ -47,6 +48,7 @@ UINavigationController *navigationController; UINavigationController *splitStoryDetailNavigationController; UINavigationController *findFriendsNavigationController; + NBContainerViewController *masterContainerViewController; FirstTimeUserViewController *firstTimeUserViewController; FirstTimeUserAddSitesViewController *firstTimeUserAddSitesViewController; @@ -118,6 +120,7 @@ @property (nonatomic, readonly) IBOutlet UINavigationController *navigationController; @property (nonatomic, readonly) IBOutlet UINavigationController *findFriendsNavigationController; @property (nonatomic, readonly) IBOutlet UINavigationController *splitStoryDetailNavigationController; +@property (nonatomic) IBOutlet NBContainerViewController *masterContainerViewController; @property (nonatomic) IBOutlet DashboardViewController *dashboardViewController; @property (nonatomic) IBOutlet NewsBlurViewController *feedsViewController; @property (nonatomic) IBOutlet FeedsMenuViewController *feedsMenuViewController; diff --git a/media/ios/Classes/NewsBlurAppDelegate.m b/media/ios/Classes/NewsBlurAppDelegate.m index 4729dc0a9..8ee810941 100644 --- a/media/ios/Classes/NewsBlurAppDelegate.m +++ b/media/ios/Classes/NewsBlurAppDelegate.m @@ -8,6 +8,7 @@ #import "NewsBlurAppDelegate.h" #import "NewsBlurViewController.h" +#import "NBContainerViewController.h" #import "FeedDetailViewController.h" #import "DashboardViewController.h" #import "FeedDashboardViewController.h" @@ -38,6 +39,7 @@ @synthesize navigationController; @synthesize findFriendsNavigationController; @synthesize splitStoryDetailNavigationController; +@synthesize masterContainerViewController; @synthesize googleReaderViewController; @synthesize dashboardViewController; @synthesize feedsViewController; @@ -122,8 +124,8 @@ self.splitStoryDetailNavigationController.viewControllers = [NSArray arrayWithObject:self.dashboardViewController]; self.splitStoryController.viewControllers = [NSArray arrayWithObjects:navigationController, splitStoryDetailNavigationController, nil]; - [window addSubview:self.splitStoryController.view]; - self.window.rootViewController = self.splitStoryController; + [window addSubview:self.masterContainerViewController.view]; + self.window.rootViewController = self.masterContainerViewController; } else { self.navigationController.viewControllers = [NSArray arrayWithObject:self.feedsViewController]; [window addSubview:self.navigationController.view]; @@ -435,18 +437,19 @@ [feedDetailViewController fetchFeedDetail:1 withCallback:nil]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - if ([[self.splitStoryDetailNavigationController viewControllers] containsObject:self.feedDashboardViewController]) { - //[self.storyDetailViewController initStory]; - } else { - if (self.inFindingStoryMode) { - [self showFindingStoryHUD]; - [self.splitStoryDetailNavigationController pushViewController:self.feedDashboardViewController animated:NO]; - } else { - [self.splitStoryDetailNavigationController pushViewController:self.feedDashboardViewController animated:YES]; - [self showNoSelectedStoryLabel]; - } - - } + [self.masterContainerViewController transitionToFeedDetail]; +// if ([[self.splitStoryDetailNavigationController viewControllers] containsObject:self.feedDashboardViewController]) { +// //[self.storyDetailViewController initStory]; +// } else { +// if (self.inFindingStoryMode) { +// [self showFindingStoryHUD]; +// [self.splitStoryDetailNavigationController pushViewController:self.feedDashboardViewController animated:NO]; +// } else { +// [self.splitStoryDetailNavigationController pushViewController:self.feedDashboardViewController animated:YES]; +// [self showNoSelectedStoryLabel]; +// } +// +// } } } diff --git a/media/ios/Classes/SmallActivityCell.m b/media/ios/Classes/SmallActivityCell.m index c22b47993..04e56d56c 100644 --- a/media/ios/Classes/SmallActivityCell.m +++ b/media/ios/Classes/SmallActivityCell.m @@ -82,7 +82,6 @@ NSString *faviconUrl = [NSString stringWithFormat:@"http://%@/rss_feeds/icon/%i", NEWSBLUR_URL, [[activity objectForKey:@"feed_id"] intValue]]; - NSLog(@"faviconUrl is %@", faviconUrl); [self.faviconView setImageWithURL:[NSURL URLWithString:faviconUrl ] placeholderImage:placeholder]; self.faviconView.contentMode = UIViewContentModeScaleAspectFit; diff --git a/media/ios/NewsBlur.xcodeproj/project.pbxproj b/media/ios/NewsBlur.xcodeproj/project.pbxproj index d8be6f7a7..f09e053d6 100755 --- a/media/ios/NewsBlur.xcodeproj/project.pbxproj +++ b/media/ios/NewsBlur.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ 433D24851582EEC800AE9E72 /* NewsBlurViewController~ipad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43D045201565BC150085F811 /* NewsBlurViewController~ipad.xib */; }; 433D24861582EECA00AE9E72 /* OriginalStoryViewController~ipad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43D045251565BC150085F811 /* OriginalStoryViewController~ipad.xib */; }; 433D24871582EECD00AE9E72 /* StoryDetailViewController~ipad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43D045221565BC150085F811 /* StoryDetailViewController~ipad.xib */; }; + 436ACA8D15BF1088004E01CC /* NBContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 436ACA8C15BF1088004E01CC /* NBContainerViewController.m */; }; 43763AD1158F90B100B3DBE2 /* FontSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 43763ACF158F90B100B3DBE2 /* FontSettingsViewController.m */; }; 43763AD2158F90B100B3DBE2 /* FontSettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43763AD0158F90B100B3DBE2 /* FontSettingsViewController.xib */; }; 437AA8AD15922D13005463F5 /* FeedDashboardViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 437AA8AB15922D13005463F5 /* FeedDashboardViewController.m */; }; @@ -331,6 +332,8 @@ 433323CA158968ED0025064D /* FirstTimeUserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FirstTimeUserViewController.h; sourceTree = ""; }; 433323CB158968ED0025064D /* FirstTimeUserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FirstTimeUserViewController.m; sourceTree = ""; }; 433323CC158968ED0025064D /* FirstTimeUserViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FirstTimeUserViewController.xib; sourceTree = ""; }; + 436ACA8B15BF1088004E01CC /* NBContainerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBContainerViewController.h; sourceTree = ""; }; + 436ACA8C15BF1088004E01CC /* NBContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBContainerViewController.m; sourceTree = ""; }; 43763ACE158F90B100B3DBE2 /* FontSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSettingsViewController.h; sourceTree = ""; }; 43763ACF158F90B100B3DBE2 /* FontSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FontSettingsViewController.m; sourceTree = ""; }; 43763AD0158F90B100B3DBE2 /* FontSettingsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = FontSettingsViewController.xib; path = Classes/FontSettingsViewController.xib; sourceTree = ""; }; @@ -789,6 +792,8 @@ FFE5322E144C8AC300ACFDE0 /* Utilities.m */, 43D818A115B940C200733444 /* DataUtilities.h */, 43D818A215B940C200733444 /* DataUtilities.m */, + 436ACA8B15BF1088004E01CC /* NBContainerViewController.h */, + 436ACA8C15BF1088004E01CC /* NBContainerViewController.m */, ); path = Classes; sourceTree = ""; @@ -1963,6 +1968,7 @@ 43E8382015BC73EB000553BE /* FirstTimeUserAddNewsBlurViewController.m in Sources */, 43E8382215BC73EB000553BE /* FirstTimeUserAddSitesViewController.m in Sources */, 43DACC3F15BDE47F004A938B /* StoryDetailContainerViewController.m in Sources */, + 436ACA8D15BF1088004E01CC /* NBContainerViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/media/ios/NewsBlur_Prefix.pch b/media/ios/NewsBlur_Prefix.pch index 337f4d2f0..3dfbf39bd 100644 --- a/media/ios/NewsBlur_Prefix.pch +++ b/media/ios/NewsBlur_Prefix.pch @@ -15,8 +15,8 @@ // #define BACKGROUND_REFRESH_SECONDS -5 #define BACKGROUND_REFRESH_SECONDS -10*60 - #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.host"] -// #define NEWSBLUR_URL [NSString stringWithFormat:@"dev.newsblur.com"] +// #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.host"] + #define NEWSBLUR_URL [NSString stringWithFormat:@"dev.newsblur.com"] #define NEWSBLUR_ORANGE 0xAE5D15 diff --git a/media/ios/Other Sources/MGSplitViewController.m b/media/ios/Other Sources/MGSplitViewController.m index 87cac7230..6f0b4e18e 100644 --- a/media/ios/Other Sources/MGSplitViewController.m +++ b/media/ios/Other Sources/MGSplitViewController.m @@ -10,7 +10,7 @@ #import "MGSplitDividerView.h" #import "MGSplitCornersView.h" -#define MG_DEFAULT_SPLIT_POSITION 270.0 // default width of master view in UISplitViewController. +#define MG_DEFAULT_SPLIT_POSITION 400.0 // default width of master view in UISplitViewController. #define MG_DEFAULT_SPLIT_WIDTH 1.0 // default width of split-gutter in UISplitViewController. #define MG_DEFAULT_CORNER_RADIUS 5.0 // default corner-radius of overlapping split-inner corners on the master and detail views. #define MG_DEFAULT_CORNER_COLOR [UIColor blackColor] // default color of intruding inner corners (and divider background). diff --git a/media/ios/Resources-iPad/MainWindow~ipad.xib b/media/ios/Resources-iPad/MainWindow~ipad.xib index 2d3f45e7d..628ab3843 100644 --- a/media/ios/Resources-iPad/MainWindow~ipad.xib +++ b/media/ios/Resources-iPad/MainWindow~ipad.xib @@ -290,6 +290,17 @@ IBIPadFramework NO + + + 2 + + + 1 + 1 + + IBIPadFramework + NO + YES @@ -302,6 +313,7 @@ NO + FindFriends 2 @@ -325,6 +337,7 @@ + Main 2 @@ -347,6 +360,7 @@ YES + Title IBIPadFramework @@ -576,6 +590,14 @@ 261 + + + masterContainerViewController + + + + 266 + appDelegate @@ -688,14 +710,6 @@ 193 - - - masterViewController - - - - 189 - appDelegate @@ -752,6 +766,14 @@ 262 + + + appDelegate + + + + 267 + @@ -943,6 +965,11 @@ + + 264 + + + @@ -1008,6 +1035,8 @@ 253.IBPluginDependency 260.CustomClassName 260.IBPluginDependency + 264.CustomClassName + 264.IBPluginDependency 3.CustomClassName 3.IBPluginDependency 51.CustomClassName @@ -1099,6 +1128,8 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin StoryDetailContainerViewController com.apple.InterfaceBuilder.IBCocoaTouchPlugin + NBContainerViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin NewsBlurAppDelegate com.apple.InterfaceBuilder.IBCocoaTouchPlugin FeedDetailViewController @@ -1127,7 +1158,7 @@ - 262 + 267 @@ -2802,6 +2833,25 @@ ./Classes/MoveSiteViewController.h + + NBContainerViewController + UIViewController + + appDelegate + NewsBlurAppDelegate + + + appDelegate + + appDelegate + NewsBlurAppDelegate + + + + IBProjectSource + ./Classes/NBContainerViewController.h + + NewsBlurAppDelegate BaseViewController @@ -2825,6 +2875,7 @@ ftuxNavigationController googleReaderViewController loginViewController + masterContainerViewController moveSiteViewController navigationController originalStoryViewController @@ -2854,6 +2905,7 @@ UINavigationController GoogleReaderViewController LoginViewController + NBContainerViewController MoveSiteViewController UINavigationController OriginalStoryViewController @@ -2886,6 +2938,7 @@ ftuxNavigationController googleReaderViewController loginViewController + masterContainerViewController moveSiteViewController navigationController originalStoryViewController @@ -2963,6 +3016,10 @@ loginViewController LoginViewController + + masterContainerViewController + NBContainerViewController + moveSiteViewController MoveSiteViewController @@ -3390,15 +3447,47 @@ StoryDetailContainerViewController UIViewController + + toggleFontSize: + id + + + toggleFontSize: + + toggleFontSize: + id + + - appDelegate - NewsBlurAppDelegate + YES + + YES + appDelegate + toggleViewButton + + + YES + NewsBlurAppDelegate + UIBarButtonItem + - appDelegate - - appDelegate - NewsBlurAppDelegate + YES + + YES + appDelegate + toggleViewButton + + + YES + + appDelegate + NewsBlurAppDelegate + + + toggleViewButton + UIBarButtonItem + @@ -3468,7 +3557,6 @@ feedTitleGradient innerView progressView - toggleViewButton toolbar webView @@ -3483,7 +3571,6 @@ UIView UIView UIProgressView - UIBarButtonItem UIToolbar UIWebView @@ -3501,7 +3588,6 @@ feedTitleGradient innerView progressView - toggleViewButton toolbar webView @@ -3543,10 +3629,6 @@ progressView UIProgressView - - toggleViewButton - UIBarButtonItem - toolbar UIToolbar