Partially complete refactoring of original webview into a nav controller being pushed onto the stack instead of a modal.

This commit is contained in:
Samuel Clay 2014-01-07 18:26:17 -08:00
parent 3254149067
commit b853f656be
6 changed files with 109 additions and 21 deletions

View file

@ -29,6 +29,8 @@
- (void)transitionToFeedDetail;
- (void)transitionToFeedDetail:(BOOL)resetLayout;
- (void)transitionToOriginalView;
- (void)transitionFromOriginalView;
- (void)interactiveTransitionFromFeedDetail:(CGFloat)percentage;
- (void)transitionFromFeedDetail;
- (void)transitionFromFeedDetail:(BOOL)resetLayout;

View file

@ -12,6 +12,7 @@
#import "DashboardViewController.h"
#import "StoryDetailViewController.h"
#import "StoryPageControl.h"
#import "OriginalStoryViewController.h"
#import "ShareViewController.h"
#import "UserProfileViewController.h"
#import "InteractionCell.h"
@ -40,6 +41,7 @@
@property (nonatomic, strong) FeedDetailViewController *feedDetailViewController;
@property (nonatomic, strong) DashboardViewController *dashboardViewController;
@property (nonatomic, strong) StoryDetailViewController *storyDetailViewController;
@property (nonatomic, strong) OriginalStoryViewController *originalViewController;
@property (nonatomic, strong) StoryPageControl *storyPageControl;
@property (nonatomic, strong) ShareViewController *shareViewController;
@property (nonatomic, strong) UIView *storyTitlesStub;
@ -65,6 +67,7 @@
@synthesize feedDetailViewController;
@synthesize dashboardViewController;
@synthesize storyDetailViewController;
@synthesize originalViewController;
@synthesize storyPageControl;
@synthesize shareViewController;
@synthesize feedDetailIsVisible;
@ -108,6 +111,7 @@
self.dashboardViewController = appDelegate.dashboardViewController;
self.feedDetailViewController = appDelegate.feedDetailViewController;
self.storyDetailViewController = appDelegate.storyDetailViewController;
self.originalViewController = appDelegate.originalStoryViewController;
self.storyPageControl = appDelegate.storyPageControl;
self.shareViewController = appDelegate.shareViewController;
@ -593,6 +597,64 @@
}
}
- (void)transitionToOriginalView {
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsPortrait(orientation)) {
}
CGRect viewFrame = [self.view bounds];
[self.view addSubview:self.originalViewController.view];
[self.originalViewController.view setFrame:CGRectMake(CGRectGetMaxX(viewFrame), 0,
CGRectGetWidth(viewFrame),
CGRectGetHeight(viewFrame))];
[UIView animateWithDuration:.35 delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
self.masterNavigationController.view.frame = CGRectMake(-100, 0, NB_DEFAULT_MASTER_WIDTH, viewFrame.size.height);
self.storyNavigationController.view.frame = CGRectMake(-100 + NB_DEFAULT_MASTER_WIDTH + 1, 0, viewFrame.size.width - NB_DEFAULT_MASTER_WIDTH - 1, viewFrame.size.height);
[self.originalViewController.view setFrame:CGRectMake(0, 0,
CGRectGetWidth(viewFrame),
CGRectGetHeight(viewFrame))];
} completion:^(BOOL finished) {
NSLog(@"Master frame pre: %@ to %@", NSStringFromCGRect(self.masterNavigationController.view.frame), NSStringFromCGRect(viewFrame));
NSLog(@"Master frame post: %@ to %@", NSStringFromCGRect(self.masterNavigationController.view.frame), NSStringFromCGRect(viewFrame));
}];
}
- (void)transitionFromOriginalView {
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsPortrait(orientation)) {
}
CGRect vb = [self.view bounds];
[UIView animateWithDuration:.35 delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
[self adjustFeedDetailScreen];
} completion:^(BOOL finished) {
}];
}
- (void)interactiveTransitionFromOriginalView:(CGFloat)percentage {
[self.view insertSubview:self.dashboardViewController.view atIndex:0];
[self.view addSubview:self.masterNavigationController.view];
CGRect storyNavFrame = self.storyNavigationController.view.frame;
storyNavFrame.origin.x = NB_DEFAULT_MASTER_WIDTH + 1 + storyNavFrame.size.width * percentage;
self.storyNavigationController.view.frame = storyNavFrame;
CGRect dashboardFrame = self.dashboardViewController.view.frame;
dashboardFrame.origin.x = NB_DEFAULT_MASTER_WIDTH + 1 + -1 * (1-percentage) * dashboardFrame.size.width/6;
self.dashboardViewController.view.frame = dashboardFrame;
}
- (void)interactiveTransitionFromFeedDetail:(CGFloat)percentage {
[self.view insertSubview:self.dashboardViewController.view atIndex:0];
[self.view addSubview:self.masterNavigationController.view];

View file

@ -1293,24 +1293,40 @@
return;
} else {
self.activeOriginalStoryURL = url;
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:self.originalStoryViewController];
navController.navigationBar.translucent = NO;
self.originalStoryViewNavController = navController;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.masterContainerViewController presentViewController:self.originalStoryViewNavController
animated:YES completion:nil];
[self.masterContainerViewController transitionToOriginalView];
} else {
[self.navigationController presentViewController:self.originalStoryViewNavController
animated:YES completion:nil];
NSLog(@"NavCon vc: %@", [navigationController viewControllers]);
if ([[navigationController viewControllers] containsObject:originalStoryViewController]) {
return;
}
[navigationController pushViewController:originalStoryViewController
animated:YES];
}
//
// UINavigationController *navController = [[UINavigationController alloc]
// initWithRootViewController:self.originalStoryViewController];
// navController.navigationBar.translucent = NO;
// self.originalStoryViewNavController = navController;
//
// if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// [self.masterContainerViewController presentViewController:self.originalStoryViewNavController
// animated:YES completion:nil];
// } else {
// [self.navigationController presentViewController:self.originalStoryViewNavController
// animated:YES completion:nil];
// }
}
}
- (void)closeOriginalStory {
if (![self.presentedViewController isBeingDismissed]) {
[originalStoryViewNavController dismissViewControllerAnimated:YES completion:nil];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.masterContainerViewController transitionFromOriginalView];
} else {
if ([[navigationController viewControllers] containsObject:originalStoryViewController]) {
[navigationController popToViewController:storyPageControl animated:YES];
}
}
}

View file

@ -43,6 +43,7 @@
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:appDelegate.activeOriginalStoryURL] ;
[self updateAddress:request];
[self.pageTitle setText:[[appDelegate activeStory] objectForKey:@"story_title"]];
self.navigationItem.title = [[appDelegate activeStory] objectForKey:@"story_title"];
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
[self layoutForInterfaceOrientation:orientation];
@ -58,6 +59,10 @@
}
- (void)viewWillDisappear:(BOOL)animated {
[appDelegate.masterContainerViewController transitionFromOriginalView];
}
- (void)viewDidDisappear:(BOOL)animated {
if ([self.webView isLoading]) {
[self.webView stopLoading];
}
@ -87,6 +92,7 @@
label.text = [[appDelegate activeStory] objectForKey:@"story_title"];
[navBar addSubview:label];
self.pageTitle = label;
self.navigationItem.title = [[appDelegate activeStory] objectForKey:@"story_title"];
UIBarButtonItem *close = [[UIBarButtonItem alloc]
initWithTitle:@"Close"
@ -187,7 +193,7 @@
} else {
self.toolbar.frame = (CGRect){CGPointMake(0.f, CGRectGetHeight(self.view.bounds) -
toolbarSize.height), toolbarSize};
self.webView.frame = (CGRect){CGPointMake(0, kNavBarHeight), CGSizeMake(CGRectGetWidth(self.view.bounds), CGRectGetMinY(self.toolbar.frame) - kNavBarHeight)};
self.webView.frame = (CGRect){CGPointMake(0, 0), CGSizeMake(CGRectGetWidth(self.view.bounds), CGRectGetMinY(self.toolbar.frame))};
}
}
@ -212,6 +218,8 @@
[self.webView loadRequest:request];
[self.pageUrl resignFirstResponder];
[self.pageTitle setText:@"Loading..."];
self.navigationItem.title = @"Loading...";
}
# pragma mark: -
@ -266,6 +274,7 @@
{
NSString *pageTitleValue = [aWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
self.pageTitle.text = [pageTitleValue stringByDecodingHTMLEntities];
self.navigationItem.title = [pageTitleValue stringByDecodingHTMLEntities];
}
- (void)updateAddress:(NSURLRequest*)request

View file

@ -221,7 +221,9 @@
}
titleImageView.hidden = YES;
titleImageView.contentMode = UIViewContentModeScaleAspectFit;
self.navigationItem.titleView = titleImageView;
if (!self.navigationItem.titleView) {
self.navigationItem.titleView = titleImageView;
}
titleImageView.hidden = NO;
} else {
NSString *feedIdStr = [NSString stringWithFormat:@"%@",
@ -332,6 +334,8 @@
}
- (void)resetPages {
self.navigationItem.titleView = nil;
[currentPage clearStory];
[nextPage clearStory];
[previousPage clearStory];

View file

@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="12F37" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment defaultVersion="1792" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="OriginalStoryViewController">
<connections>
<outlet property="back" destination="6" id="26"/>
<outlet property="forward" destination="14" id="23"/>
<outlet property="navBar" destination="wB4-Cq-a4Y" id="NzG-e5-D83"/>
<outlet property="pageAction" destination="17" id="22"/>
<outlet property="refresh" destination="52" id="60"/>
<outlet property="toolbar" destination="5" id="45"/>
@ -23,7 +22,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<webView multipleTouchEnabled="YES" contentMode="scaleToFill" scalesPageToFit="YES" id="4">
<rect key="frame" x="0.0" y="76" width="320" height="360"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="436"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
<dataDetectorType key="dataDetectorTypes" phoneNumber="YES" link="YES" address="YES" calendarEvent="YES"/>
@ -31,10 +30,6 @@
<outlet property="delegate" destination="-1" id="7"/>
</connections>
</webView>
<view contentMode="scaleToFill" id="wB4-Cq-a4Y" customClass="UINavigationBar">
<rect key="frame" x="0.0" y="0.0" width="320" height="78"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</view>
<toolbar clipsSubviews="YES" contentMode="scaleToFill" id="5">
<rect key="frame" x="0.0" y="436" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>