mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
iOS: removed transition & gesture for Safari view controller
This commit is contained in:
parent
e2f679674e
commit
9b0b1a7693
7 changed files with 5 additions and 215 deletions
|
@ -12,7 +12,7 @@
|
|||
@class NewsBlurAppDelegate;
|
||||
|
||||
@interface NBContainerViewController : UIViewController
|
||||
<UIPopoverControllerDelegate, SFSafariViewControllerDelegate, UIViewControllerTransitioningDelegate> {
|
||||
<UIPopoverControllerDelegate> {
|
||||
NewsBlurAppDelegate *appDelegate;
|
||||
|
||||
BOOL interactiveOriginalTransition;
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
//
|
||||
// NBModalPushPopTransition.h
|
||||
// NewsBlur
|
||||
//
|
||||
// Created by David Sinclair on 2015-10-23.
|
||||
// Copyright © 2015 NewsBlur. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NBModalPushPopTransition : UIPercentDrivenInteractiveTransition <UIViewControllerAnimatedTransitioning>
|
||||
|
||||
@property (nonatomic) BOOL dismissing;
|
||||
@property (nonatomic) BOOL percentageDriven;
|
||||
|
||||
@end
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
//
|
||||
// NBModalPushPopTransition.m
|
||||
// NewsBlur
|
||||
//
|
||||
// Created by David Sinclair on 2015-10-23.
|
||||
// Copyright © 2015 NewsBlur. All rights reserved.
|
||||
//
|
||||
// Based on Swift code from https://github.com/stringcode86/SCSafariViewController
|
||||
//
|
||||
|
||||
#import "NBModalPushPopTransition.h"
|
||||
|
||||
@implementation NBModalPushPopTransition
|
||||
|
||||
- (id)init {
|
||||
if ((self = [super init])) {
|
||||
self.dismissing = NO;
|
||||
self.percentageDriven = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGFloat)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
|
||||
return 0.35;
|
||||
}
|
||||
|
||||
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
|
||||
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
|
||||
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
|
||||
|
||||
UIView *topView = self.dismissing ? fromViewController.view : toViewController.view;
|
||||
UIViewController *bottomViewController = self.dismissing ? toViewController : fromViewController;
|
||||
UIView *bottomView = bottomViewController.view;
|
||||
CGFloat offset = bottomView.bounds.size.width;
|
||||
|
||||
if ([bottomViewController isKindOfClass:[UINavigationController class]]) {
|
||||
bottomView = ((UINavigationController *)bottomViewController).topViewController.view;
|
||||
}
|
||||
|
||||
[transitionContext.containerView insertSubview:toViewController.view aboveSubview:fromViewController.view];
|
||||
|
||||
if (self.dismissing) {
|
||||
[transitionContext.containerView insertSubview:toViewController.view belowSubview:fromViewController.view];
|
||||
}
|
||||
|
||||
topView.frame = fromViewController.view.frame;
|
||||
topView.transform = self.dismissing ? CGAffineTransformIdentity : CGAffineTransformMakeTranslation(offset, 0.0);
|
||||
|
||||
UIImageView *shadowView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"safari_shadow"]];
|
||||
|
||||
shadowView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
shadowView.layer.anchorPoint = CGPointMake(0.0, 0.5);
|
||||
shadowView.frame = bottomView.bounds;
|
||||
[bottomView addSubview:shadowView];
|
||||
shadowView.transform = self.dismissing ? CGAffineTransformMakeScale(0.01, 1.0) : CGAffineTransformIdentity;
|
||||
shadowView.alpha = self.dismissing ? 1.0 : 0.0;
|
||||
|
||||
[UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0.0 options:[self animationOpts] animations:^{
|
||||
topView.transform = self.dismissing ? CGAffineTransformMakeTranslation(offset, 0.0) : CGAffineTransformIdentity;
|
||||
shadowView.transform = self.dismissing ? CGAffineTransformIdentity : CGAffineTransformMakeScale(0.01, 1.0);
|
||||
shadowView.alpha = self.dismissing ? 0.0 : 1.0;
|
||||
} completion:^(BOOL finished) {
|
||||
topView.transform = CGAffineTransformIdentity;
|
||||
[shadowView removeFromSuperview];
|
||||
[transitionContext completeTransition:!transitionContext.transitionWasCancelled];
|
||||
}];
|
||||
}
|
||||
|
||||
- (UIViewAnimationOptions)animationOpts {
|
||||
UIViewAnimationOptions opts = self.percentageDriven ? UIViewAnimationOptionCurveLinear : UIViewAnimationOptionCurveEaseInOut;
|
||||
|
||||
return opts | UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionLayoutSubviews;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
//
|
||||
// NBSafariViewController.h
|
||||
// NewsBlur
|
||||
//
|
||||
// Created by David Sinclair on 2015-10-23.
|
||||
// Copyright © 2015 NewsBlur. All rights reserved.
|
||||
//
|
||||
|
||||
#import <SafariServices/SafariServices.h>
|
||||
|
||||
@interface NBSafariViewController : SFSafariViewController
|
||||
|
||||
@property (nonatomic, strong, readonly) UIView *edgeView;
|
||||
|
||||
@end
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
//
|
||||
// NBSafariViewController.m
|
||||
// NewsBlur
|
||||
//
|
||||
// Created by David Sinclair on 2015-10-23.
|
||||
// Copyright © 2015 NewsBlur. All rights reserved.
|
||||
//
|
||||
// Based on Swift code from https://github.com/stringcode86/SCSafariViewController
|
||||
//
|
||||
|
||||
#import "NBSafariViewController.h"
|
||||
|
||||
@interface NBSafariViewController ()
|
||||
|
||||
@property (nonatomic, strong) UIView *edgeView;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NBSafariViewController
|
||||
|
||||
- (UIView *)edgeView {
|
||||
if (_edgeView == nil && self.isViewLoaded) {
|
||||
self.edgeView = [UIView new];
|
||||
_edgeView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[self.view addSubview:_edgeView];
|
||||
_edgeView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.005];
|
||||
|
||||
NSDictionary *bindings = @{@"edgeView" : _edgeView};
|
||||
NSLayoutFormatOptions options = 0;
|
||||
NSArray *hConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-0-[edgeView(20)]" options:options metrics:nil views:bindings];
|
||||
NSArray *vConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[edgeView]-0-|" options:options metrics:nil views:bindings];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:hConstraints];
|
||||
[NSLayoutConstraint activateConstraints:vConstraints];
|
||||
}
|
||||
|
||||
return _edgeView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -38,8 +38,6 @@
|
|||
#import "ARChromeActivity.h"
|
||||
#import "NBCopyLinkActivity.h"
|
||||
#import "MBProgressHUD.h"
|
||||
#import "NBSafariViewController.h"
|
||||
#import "NBModalPushPopTransition.h"
|
||||
#import "Utilities.h"
|
||||
#import "StringHelper.h"
|
||||
#import "AuthorizeServicesViewController.h"
|
||||
|
@ -66,8 +64,7 @@
|
|||
@interface NewsBlurAppDelegate () <UIViewControllerTransitioningDelegate>
|
||||
|
||||
@property (nonatomic, strong) UIApplicationShortcutItem *launchedShortcutItem;
|
||||
@property (nonatomic, strong) NBSafariViewController *safariViewController;
|
||||
//@property (nonatomic, strong) NBModalPushPopTransition *safariAnimator;
|
||||
@property (nonatomic, strong) SFSafariViewController *safariViewController;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -1374,16 +1371,10 @@
|
|||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:operaURL]];
|
||||
return;
|
||||
} else if ([[preferences stringForKey:@"story_browser"] isEqualToString:@"inappsafari"]) {
|
||||
// self.safariAnimator = [NBModalPushPopTransition new];
|
||||
self.safariViewController = [[NBSafariViewController alloc] initWithURL:url
|
||||
entersReaderIfAvailable:NO];
|
||||
self.safariViewController = [[SFSafariViewController alloc] initWithURL:url
|
||||
entersReaderIfAvailable:NO];
|
||||
self.safariViewController.delegate = self;
|
||||
// self.safariViewController.transitioningDelegate = self;
|
||||
[navigationController presentViewController:self.safariViewController animated:YES completion:^{
|
||||
UIScreenEdgePanGestureRecognizer *recognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
|
||||
recognizer.edges = UIRectEdgeLeft;
|
||||
[self.safariViewController.edgeView addGestureRecognizer:recognizer];
|
||||
}];
|
||||
[navigationController presentViewController:self.safariViewController animated:YES completion:nil];
|
||||
} else {
|
||||
if (!originalStoryViewController) {
|
||||
originalStoryViewController = [[OriginalStoryViewController alloc] init];
|
||||
|
@ -1415,43 +1406,6 @@
|
|||
[controller dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)handleGesture:(UIScreenEdgePanGestureRecognizer *)recognizer {
|
||||
// self.safariAnimator.percentageDriven = YES;
|
||||
// UIView *view = self.window.rootViewController.view;
|
||||
// CGFloat percentComplete = [recognizer locationInView:view].x / view.bounds.size.width;
|
||||
|
||||
switch (recognizer.state) {
|
||||
case UIGestureRecognizerStateBegan:
|
||||
self.safariViewController.delegate = nil;
|
||||
[navigationController dismissViewControllerAnimated:YES completion:nil];
|
||||
break;
|
||||
case UIGestureRecognizerStateChanged:
|
||||
// [self.safariAnimator updateInteractiveTransition:percentComplete > 0.99 ? 0.99 : percentComplete];
|
||||
break;
|
||||
case UIGestureRecognizerStateEnded:
|
||||
case UIGestureRecognizerStateCancelled:
|
||||
// ([recognizer velocityInView:view].x < 0.0) ? [self.safariAnimator cancelInteractiveTransition] : [self.safariAnimator finishInteractiveTransition];
|
||||
// self.safariAnimator.percentageDriven = NO;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
|
||||
// self.safariAnimator.dismissing = NO;
|
||||
return nil; //self.safariAnimator;
|
||||
}
|
||||
|
||||
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
|
||||
// self.safariAnimator.dismissing = YES;
|
||||
return nil; //self.safariAnimator;
|
||||
}
|
||||
|
||||
- (id<UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id<UIViewControllerAnimatedTransitioning>)animator {
|
||||
return nil; //self.safariAnimator.percentageDriven ? self.safariAnimator : nil;
|
||||
}
|
||||
|
||||
- (void)navigationController:(UINavigationController *)_navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
||||
if ([viewController isKindOfClass:[SFSafariViewController class]] || [viewController isKindOfClass:[FontSettingsViewController class]]) {
|
||||
[_navigationController setNavigationBarHidden:YES animated:YES];
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
17EB50601BE46A900021358B /* FontListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 17EB505F1BE46A900021358B /* FontListViewController.m */; };
|
||||
17EB50621BE46BB00021358B /* FontListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 17EB50611BE46BB00021358B /* FontListViewController.xib */; };
|
||||
17EB50651BE47C160021358B /* FontTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 17EB50641BE47C160021358B /* FontTableViewCell.m */; };
|
||||
17F1566C1BDAB0930092EBFD /* NBSafariViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 17F1566B1BDAB0930092EBFD /* NBSafariViewController.m */; };
|
||||
17F1566F1BDAB14F0092EBFD /* NBModalPushPopTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 17F1566E1BDAB14F0092EBFD /* NBModalPushPopTransition.m */; };
|
||||
17F156711BDABBF60092EBFD /* safari_shadow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 17F156701BDABBF60092EBFD /* safari_shadow@2x.png */; };
|
||||
1D3623260D0F684500981E51 /* NewsBlurAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* NewsBlurAppDelegate.m */; };
|
||||
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
|
||||
|
@ -480,10 +478,6 @@
|
|||
17EB50611BE46BB00021358B /* FontListViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = FontListViewController.xib; path = Classes/FontListViewController.xib; sourceTree = SOURCE_ROOT; };
|
||||
17EB50631BE47C160021358B /* FontTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontTableViewCell.h; sourceTree = "<group>"; };
|
||||
17EB50641BE47C160021358B /* FontTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FontTableViewCell.m; sourceTree = "<group>"; };
|
||||
17F1566A1BDAB0930092EBFD /* NBSafariViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBSafariViewController.h; sourceTree = "<group>"; };
|
||||
17F1566B1BDAB0930092EBFD /* NBSafariViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBSafariViewController.m; sourceTree = "<group>"; };
|
||||
17F1566D1BDAB14F0092EBFD /* NBModalPushPopTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBModalPushPopTransition.h; sourceTree = "<group>"; };
|
||||
17F1566E1BDAB14F0092EBFD /* NBModalPushPopTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBModalPushPopTransition.m; sourceTree = "<group>"; };
|
||||
17F156701BDABBF60092EBFD /* safari_shadow@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "safari_shadow@2x.png"; sourceTree = "<group>"; };
|
||||
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
1D3623240D0F684500981E51 /* NewsBlurAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = NewsBlurAppDelegate.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
|
@ -1870,10 +1864,6 @@
|
|||
FFA0483D19CA5B8400618DC4 /* EventWindow.m */,
|
||||
FF1C4E151A3FB1F4000995E3 /* NBActivityItemProvider.h */,
|
||||
FF1C4E161A3FB1F4000995E3 /* NBActivityItemProvider.m */,
|
||||
17F1566D1BDAB14F0092EBFD /* NBModalPushPopTransition.h */,
|
||||
17F1566E1BDAB14F0092EBFD /* NBModalPushPopTransition.m */,
|
||||
17F1566A1BDAB0930092EBFD /* NBSafariViewController.h */,
|
||||
17F1566B1BDAB0930092EBFD /* NBSafariViewController.m */,
|
||||
);
|
||||
name = Foundation;
|
||||
sourceTree = "<group>";
|
||||
|
@ -2584,7 +2574,6 @@
|
|||
FF5EA47F143B691000B7563D /* AddSiteViewController.m in Sources */,
|
||||
FF1F13D818AAC97900FDA816 /* UIImage+Resize.m in Sources */,
|
||||
FFD887F01445F1E800385399 /* AddSiteAutocompleteCell.m in Sources */,
|
||||
17F1566F1BDAB14F0092EBFD /* NBModalPushPopTransition.m in Sources */,
|
||||
FF62820A1A098EA800271FDB /* WYPopoverController.m in Sources */,
|
||||
FF8D1ECD1BAA311000725D8A /* SBJson4StreamParser.m in Sources */,
|
||||
FFE5322F144C8AC300ACFDE0 /* Utilities.m in Sources */,
|
||||
|
@ -2633,7 +2622,6 @@
|
|||
FF2EB7BE1AA65504002549A7 /* IASKTextField.m in Sources */,
|
||||
FF8D1ECF1BAA311000725D8A /* SBJson4StreamTokeniser.m in Sources */,
|
||||
FFD660641BACA46D006E4B8D /* AFNetworkReachabilityManager.m in Sources */,
|
||||
17F1566C1BDAB0930092EBFD /* NBSafariViewController.m in Sources */,
|
||||
FF8D1ED81BAA33BA00725D8A /* NSObject+SBJSON.m in Sources */,
|
||||
FF2EB7B11AA65504002549A7 /* IASKAppSettingsWebViewController.m in Sources */,
|
||||
FF1F13D418A9C2BE00FDA816 /* TMDiskCache.m in Sources */,
|
||||
|
|
Loading…
Add table
Reference in a new issue