mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Swiping back from original view works pretty well on ipad now. Needs a button and better navigation title support. Also rotation support. Also fixing iPhone.
This commit is contained in:
parent
44fd7ca58b
commit
0620af0674
4 changed files with 69 additions and 49 deletions
|
@ -672,6 +672,8 @@
|
|||
containsObject:self.originalViewController]) {
|
||||
[self.originalNavigationController pushViewController:self.originalViewController
|
||||
animated:NO];
|
||||
} else {
|
||||
[self.originalViewController viewWillAppear:YES];
|
||||
}
|
||||
|
||||
[self.view insertSubview:self.originalNavigationController.view
|
||||
|
@ -714,6 +716,9 @@
|
|||
- (void)transitionFromOriginalView {
|
||||
NSLog(@"Transition from Original View");
|
||||
|
||||
[self.originalViewController viewWillDisappear:YES];
|
||||
self.originalNavigationController.navigationBar.alpha = 1;
|
||||
|
||||
[UIView animateWithDuration:0.35 delay:0
|
||||
options:UIViewAnimationOptionCurveEaseOut
|
||||
animations:^
|
||||
|
@ -723,6 +728,7 @@
|
|||
self.interactiveOriginalTransition = NO;
|
||||
[self.originalNavigationController removeFromParentViewController];
|
||||
[self.originalNavigationController.view setHidden:YES];
|
||||
[self.originalViewController viewDidDisappear:YES];
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -731,11 +737,11 @@
|
|||
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
|
||||
|
||||
if (UIInterfaceOrientationIsPortrait(orientation) && !self.storyTitlesOnLeft) {
|
||||
CGRect originalNavFrame = self.originalNavigationController.view.frame;
|
||||
originalNavFrame.origin.x = vb.size.width * percentage;
|
||||
self.originalNavigationController.view.frame = originalNavFrame;
|
||||
self.originalViewController.view.frame = originalNavFrame;
|
||||
NSLog(@"Original frame: %@", NSStringFromCGRect(self.originalViewController.view.frame));
|
||||
// CGRect originalNavFrame = self.originalNavigationController.view.frame;
|
||||
// originalNavFrame.origin.x = vb.size.width * percentage;
|
||||
// self.originalNavigationController.view.frame = originalNavFrame;
|
||||
// self.originalViewController.view.frame = originalNavFrame;
|
||||
// NSLog(@"Original frame: %@", NSStringFromCGRect(self.originalViewController.view.frame));
|
||||
|
||||
CGRect feedDetailFrame = self.feedDetailViewController.view.frame;
|
||||
feedDetailFrame.origin.x = -1 * (1-percentage) * feedDetailFrame.size.width/6;
|
||||
|
@ -749,7 +755,7 @@
|
|||
originalNavFrame.origin.x = vb.size.width * percentage * 0;
|
||||
// self.originalNavigationController.view.frame = originalNavFrame;
|
||||
// self.originalViewController.view.frame = originalNavFrame;
|
||||
NSLog(@"Original frame: %@", NSStringFromCGRect([[[[self.originalNavigationController viewControllers] objectAtIndex:0] view] frame]));
|
||||
// NSLog(@"Original frame: %@", NSStringFromCGRect([[[[self.originalNavigationController viewControllers] objectAtIndex:0] view] frame]));
|
||||
|
||||
CGRect feedDetailFrame = self.masterNavigationController.view.frame;
|
||||
feedDetailFrame.origin.x = -1 * (1-percentage) * feedDetailFrame.size.width/6;
|
||||
|
@ -760,6 +766,10 @@
|
|||
self.storyNavigationController.view.frame = storyNavFrame;
|
||||
}
|
||||
|
||||
// self.originalNavigationController.navigationBar.alpha = 1 - percentage;
|
||||
// NSLog(@"Original subviews; %@", self.originalNavigationController.view.subviews);
|
||||
self.originalViewController.navigationItem.titleView.alpha = 1 - percentage;
|
||||
|
||||
// CGRect leftBorderFrame = leftBorder.frame;
|
||||
// leftBorderFrame.origin.x = storyNavFrame.origin.x - 1;
|
||||
// leftBorder.frame = leftBorderFrame;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
NSMutableArray *visitedUrls;
|
||||
UIWebView *webView;
|
||||
UIBarButtonItem *backBarButton;
|
||||
UILabel *titleView;
|
||||
}
|
||||
|
||||
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
|
||||
|
|
|
@ -29,13 +29,37 @@
|
|||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
NSLog(@"Original Story View: %@", [appDelegate activeOriginalStoryURL]);
|
||||
|
||||
appDelegate.originalStoryViewNavController.navigationBar.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated {
|
||||
if ([self.webView isLoading]) {
|
||||
[self.webView stopLoading];
|
||||
}
|
||||
activeUrl = nil;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
// self.navigationItem.title = [[appDelegate activeStory] objectForKey:@"story_title"];
|
||||
|
||||
UIImage *separatorImage = [UIImage imageNamed:@"bar-separator.png"];
|
||||
UIBarButtonItem *separatorBarButton = [UIBarButtonItem barItemWithImage:separatorImage
|
||||
target:nil
|
||||
action:nil];
|
||||
[separatorBarButton setEnabled:NO];
|
||||
|
||||
|
||||
UIBarButtonItem *sendToBarButton = [UIBarButtonItem
|
||||
barItemWithImage:[UIImage imageNamed:@"barbutton_sendto.png"]
|
||||
target:self
|
||||
|
@ -45,43 +69,20 @@
|
|||
target:self
|
||||
action:@selector(webViewGoBack:)];
|
||||
backBarButton.enabled = NO;
|
||||
|
||||
|
||||
titleView = [[UILabel alloc] init];
|
||||
titleView.textColor = UIColorFromRGB(0x303030);
|
||||
titleView.font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0];
|
||||
titleView.text = @"Loading...";
|
||||
[titleView sizeToFit];
|
||||
titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
self.navigationItem.titleView = titleView;
|
||||
|
||||
self.navigationItem.rightBarButtonItems = @[sendToBarButton,
|
||||
separatorBarButton,
|
||||
backBarButton
|
||||
];
|
||||
|
||||
|
||||
appDelegate.originalStoryViewNavController.navigationBar.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
if (!appDelegate.masterContainerViewController.interactiveOriginalTransition) {
|
||||
[appDelegate.masterContainerViewController transitionFromOriginalView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated {
|
||||
if ([self.webView isLoading]) {
|
||||
[self.webView stopLoading];
|
||||
}
|
||||
activeUrl = nil;
|
||||
|
||||
NSLog(@"Original disappear: %@ - %@", NSStringFromCGRect(self.view.frame), NSStringFromCGPoint(self.view.center));
|
||||
CGRect frame = self.view.frame;
|
||||
frame.origin.x = 0;
|
||||
self.view.frame = frame;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
// self.navigationItem.title = [[appDelegate activeStory] objectForKey:@"story_title"];
|
||||
UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc]
|
||||
initWithTarget:self action:@selector(handlePanGesture:)];
|
||||
[self.view addGestureRecognizer:gesture];
|
||||
|
@ -91,7 +92,6 @@
|
|||
CGFloat percentage = 1 - (recognizer.view.frame.size.width - recognizer.view.frame.origin.x) / recognizer.view.frame.size.width;
|
||||
CGPoint center = recognizer.view.center;
|
||||
CGPoint translation = [recognizer translationInView:recognizer.view];
|
||||
NSLog(@"Panning %f%%. (%@ - %@)", percentage, NSStringFromCGRect(recognizer.view.frame), NSStringFromCGPoint(translation));
|
||||
|
||||
if (recognizer.state == UIGestureRecognizerStateChanged) {
|
||||
center = CGPointMake(MAX(recognizer.view.frame.size.width / 2, center.x + translation.x),
|
||||
|
@ -108,7 +108,7 @@
|
|||
if ([recognizer state] == UIGestureRecognizerStateEnded ||
|
||||
[recognizer state] == UIGestureRecognizerStateCancelled) {
|
||||
CGFloat velocity = [recognizer velocityInView:recognizer.view].x;
|
||||
if (velocity > 0) {
|
||||
if (percentage > 0.25 && velocity > 0) {
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
[appDelegate.masterContainerViewController transitionFromOriginalView];
|
||||
} else {
|
||||
|
@ -126,8 +126,9 @@
|
|||
|
||||
- (void)loadInitialStory {
|
||||
[self loadAddress:nil];
|
||||
self.navigationItem.title = [[appDelegate activeStory] objectForKey:@"story_title"];
|
||||
|
||||
titleView.text = [[appDelegate activeStory] objectForKey:@"story_title"];
|
||||
[titleView sizeToFit];
|
||||
|
||||
[MBProgressHUD hideHUDForView:self.webView animated:YES];
|
||||
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.webView animated:YES];
|
||||
HUD.labelText = @"On its way...";
|
||||
|
@ -196,7 +197,8 @@
|
|||
- (void)updateTitle:(UIWebView*)aWebView
|
||||
{
|
||||
NSString *pageTitleValue = [aWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
|
||||
self.navigationItem.title = [pageTitleValue stringByDecodingHTMLEntities];
|
||||
titleView.text = [pageTitleValue stringByDecodingHTMLEntities];
|
||||
[titleView sizeToFit];
|
||||
}
|
||||
|
||||
- (IBAction)loadAddress:(id)sender {
|
||||
|
@ -215,8 +217,8 @@
|
|||
}
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
[self.webView loadRequest:request];
|
||||
self.navigationItem.title = @"Loading...";
|
||||
|
||||
titleView.text = @"Loading...";
|
||||
[titleView sizeToFit];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
|
|
|
@ -114,7 +114,7 @@ static NSMutableDictionary *imageCache;
|
|||
+ (void)saveimagesToDisk {
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
|
||||
|
||||
dispatch_async(queue, [^{
|
||||
dispatch_async(queue, ^{
|
||||
for (NSString *filename in [imageCache allKeys]) {
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
NSString *cacheDirectory = [paths objectAtIndex:0];
|
||||
|
@ -126,10 +126,17 @@ static NSMutableDictionary *imageCache;
|
|||
NSString *path = [cacheDirectory stringByAppendingPathComponent:filename];
|
||||
|
||||
// Save image to disk
|
||||
UIImage *image = [imageCache objectForKey:filename];
|
||||
UIImage *image;
|
||||
@try {
|
||||
image = [imageCache objectForKey:filename];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSLog(@"Warning: imageCache EXC_BAD_ACCESS!!!");
|
||||
return;
|
||||
}
|
||||
[UIImagePNGRepresentation(image) writeToFile:path atomically:YES];
|
||||
}
|
||||
} copy]);
|
||||
});
|
||||
}
|
||||
|
||||
+ (UIImage *)roundCorneredImage: (UIImage*) orig radius:(CGFloat) r {
|
||||
|
|
Loading…
Add table
Reference in a new issue