remove flip transition between settings and disk views
it's based on ancient hacks that don't look good on modern iOS
This commit is contained in:
parent
d2b8238109
commit
038ea05f0b
|
@ -15,13 +15,12 @@ static AppDelegate *sharedAppDelegate = nil;
|
|||
static NSObject<Emulator> *sharedEmulator = nil;
|
||||
NSString *DocumentsChangedNotification = @"documentsChanged";
|
||||
|
||||
@interface AppDelegate () <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning, BTCMouseDelegate>
|
||||
@interface AppDelegate () <BTCMouseDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
{
|
||||
UISwipeGestureRecognizerDirection modalPanePresentationDirection;
|
||||
}
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
|
@ -160,97 +159,11 @@ NSString *DocumentsChangedNotification = @"documentsChanged";
|
|||
#pragma mark - Settings / Insert Disk panels
|
||||
|
||||
- (void)showSettings:(id)sender {
|
||||
[self showModalPanel:@"settings" sender:sender];
|
||||
[self.window.rootViewController performSelector:@selector(showSettings:) withObject:sender];
|
||||
}
|
||||
|
||||
- (void)showInsertDisk:(id)sender {
|
||||
[self showModalPanel:@"disk" sender:sender];
|
||||
}
|
||||
|
||||
- (void)showModalPanel:(NSString*)name sender:(id)sender {
|
||||
Class classToShow, otherClass;
|
||||
if ([name isEqualToString:@"settings"]) {
|
||||
classToShow = [SettingsViewController class];
|
||||
otherClass = [InsertDiskViewController class];
|
||||
} else {
|
||||
classToShow = [InsertDiskViewController class];
|
||||
otherClass = [SettingsViewController class];
|
||||
}
|
||||
|
||||
UIViewController *rootViewController = self.window.rootViewController;
|
||||
UIViewController *presentedViewController = rootViewController.presentedViewController;
|
||||
UIViewController *presentedTopViewController = [presentedViewController isKindOfClass:[UINavigationController class]] ? [(UINavigationController*)presentedViewController topViewController] : nil;
|
||||
|
||||
if ([presentedTopViewController isKindOfClass:classToShow]) {
|
||||
[presentedViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
return;
|
||||
} else if ([presentedTopViewController isKindOfClass:otherClass]) {
|
||||
// flip
|
||||
UIViewController *viewController = [rootViewController.storyboard instantiateViewControllerWithIdentifier:name];
|
||||
viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
|
||||
viewController.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
UIView *windowSnapshotView = [self.window snapshotViewAfterScreenUpdates:NO];
|
||||
[self.window addSubview:windowSnapshotView];
|
||||
UIView *oldPanelSnapshotView = [presentedViewController.view snapshotViewAfterScreenUpdates:NO];
|
||||
[viewController.view addSubview:oldPanelSnapshotView];
|
||||
[rootViewController dismissViewControllerAnimated:NO completion:^{
|
||||
[rootViewController presentViewController:viewController animated:NO completion:^{
|
||||
UIView *emptyView = [[UIView alloc] initWithFrame:viewController.view.bounds];
|
||||
[windowSnapshotView removeFromSuperview];
|
||||
viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
|
||||
[UIView transitionFromView:oldPanelSnapshotView
|
||||
toView:emptyView
|
||||
duration:0.5
|
||||
options:UIViewAnimationOptionTransitionFlipFromRight
|
||||
completion:^(BOOL finished) {
|
||||
[emptyView removeFromSuperview];
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
} else {
|
||||
UIViewController *viewController = [rootViewController.storyboard instantiateViewControllerWithIdentifier:name];
|
||||
viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
|
||||
viewController.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
if ([sender isKindOfClass:[UISwipeGestureRecognizer class]] && NSFoundationVersionNumber >= NSFoundationVersionNumber_iOS_8_0) {
|
||||
modalPanePresentationDirection = [(UISwipeGestureRecognizer*)sender direction];
|
||||
viewController.transitioningDelegate = self;
|
||||
}
|
||||
[rootViewController presentViewController:viewController animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
|
||||
UIView *containerView = [transitionContext containerView];
|
||||
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
|
||||
|
||||
[containerView addSubview:toView];
|
||||
switch (modalPanePresentationDirection) {
|
||||
case UISwipeGestureRecognizerDirectionLeft:
|
||||
toView.transform = CGAffineTransformMakeTranslation(containerView.bounds.size.width, 0);
|
||||
break;
|
||||
case UISwipeGestureRecognizerDirectionRight:
|
||||
toView.transform = CGAffineTransformMakeTranslation(-containerView.bounds.size.width, 0);
|
||||
break;
|
||||
case UISwipeGestureRecognizerDirectionDown:
|
||||
toView.transform = CGAffineTransformMakeTranslation(0, -containerView.bounds.size.height);
|
||||
break;
|
||||
default:
|
||||
toView.transform = CGAffineTransformMakeTranslation(0, containerView.bounds.size.height);
|
||||
}
|
||||
|
||||
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
|
||||
toView.transform = CGAffineTransformIdentity;
|
||||
} completion:^(BOOL finished) {
|
||||
[transitionContext completeTransition:finished];
|
||||
}];
|
||||
[self.window.rootViewController performSelector:@selector(showInsertDisk:) withObject:sender];
|
||||
}
|
||||
|
||||
#pragma mark - Files
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<!--View Controller-->
|
||||
<scene sceneID="tne-QT-ifu">
|
||||
<objects>
|
||||
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
|
||||
<viewController modalPresentationStyle="currentContext" id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
|
||||
|
@ -34,13 +34,13 @@
|
|||
</view>
|
||||
<connections>
|
||||
<outlet property="screenView" destination="70W-4V-tYr" id="W9r-vA-9kk"/>
|
||||
<segue destination="DCD-sd-Fu5" kind="presentation" identifier="disk" modalPresentationStyle="formSheet" id="wkd-we-QI6"/>
|
||||
<segue destination="j8f-3L-8mp" kind="presentation" identifier="settings" modalPresentationStyle="formSheet" id="ak4-wm-owU"/>
|
||||
<segue destination="cRQ-kQ-dxG" kind="presentation" identifier="disk" id="WX7-3F-M1R"/>
|
||||
<segue destination="BoP-db-djl" kind="presentation" identifier="settings" id="QXf-fV-uw4"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="548" y="390.14778325123154"/>
|
||||
<point key="canvasLocation" x="346" y="381"/>
|
||||
</scene>
|
||||
<!--Settings-->
|
||||
<scene sceneID="Lht-Fe-oRx">
|
||||
|
@ -240,20 +240,40 @@
|
|||
<point key="canvasLocation" x="1996" y="31"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="UQ7-sc-pir">
|
||||
<scene sceneID="4eA-xl-dqR">
|
||||
<objects>
|
||||
<navigationController storyboardIdentifier="settings" id="j8f-3L-8mp" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="7OA-7b-rux">
|
||||
<navigationController storyboardIdentifier="settings" id="BoP-db-djl" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="0OU-GK-QgK">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="56"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="WUA-f8-k8g" kind="relationship" relationship="rootViewController" id="Zpb-kg-HM5"/>
|
||||
<segue destination="WUA-f8-k8g" kind="relationship" relationship="rootViewController" id="pw5-9i-jPL"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="8IW-lr-03G" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Jpf-Y3-KcP" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1318" y="31"/>
|
||||
<point key="canvasLocation" x="1270" y="30"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="HCe-cW-vFN">
|
||||
<objects>
|
||||
<navigationController storyboardIdentifier="disk" toolbarHidden="NO" id="cRQ-kQ-dxG" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Aek-q5-RuY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="56"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Cuq-Py-BdB">
|
||||
<rect key="frame" x="0.0" y="675" width="375" height="49"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</toolbar>
|
||||
<connections>
|
||||
<segue destination="mbX-kA-h6M" kind="relationship" relationship="rootViewController" id="X1p-Xh-YQJ"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="DV1-vt-RIw" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1270" y="734"/>
|
||||
</scene>
|
||||
<!--Insert Disk-->
|
||||
<scene sceneID="a1s-tB-X2g">
|
||||
|
@ -334,26 +354,6 @@
|
|||
</objects>
|
||||
<point key="canvasLocation" x="2102" y="734"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="V4m-xV-cjV">
|
||||
<objects>
|
||||
<navigationController storyboardIdentifier="disk" toolbarHidden="NO" id="DCD-sd-Fu5" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="jFP-L0-vQk">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="56"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="TXk-M9-69L">
|
||||
<rect key="frame" x="0.0" y="675" width="375" height="49"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</toolbar>
|
||||
<connections>
|
||||
<segue destination="mbX-kA-h6M" kind="relationship" relationship="rootViewController" id="2hT-RO-fgU"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="oTI-h8-BGr" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1318" y="735"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="Interrupt" width="30" height="30"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
|
||||
|
||||
@interface ViewController ()
|
||||
@interface ViewController () <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning>
|
||||
|
||||
@end
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
|||
KBKeyboardView *keyboardView;
|
||||
UISwipeGestureRecognizer *showKeyboardGesture, *hideKeyboardGesture, *insertDiskGesture, *showSettingsGesture;
|
||||
UIControl *pointingDeviceView;
|
||||
UISwipeGestureRecognizerDirection modalPanePresentationDirection;
|
||||
#ifdef __IPHONE_13_4
|
||||
UIPointerInteraction* interaction;
|
||||
#endif
|
||||
|
@ -57,12 +58,12 @@
|
|||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self installKeyboardGestures];
|
||||
insertDiskGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:[AppDelegate sharedInstance] action:@selector(showInsertDisk:)];
|
||||
insertDiskGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(showInsertDisk:)];
|
||||
insertDiskGesture.direction = UISwipeGestureRecognizerDirectionLeft;
|
||||
insertDiskGesture.numberOfTouchesRequired = 2;
|
||||
[self.view addGestureRecognizer:insertDiskGesture];
|
||||
|
||||
showSettingsGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:[AppDelegate sharedInstance] action:@selector(showSettings:)];
|
||||
showSettingsGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(showSettings:)];
|
||||
showSettingsGesture.direction = UISwipeGestureRecognizerDirectionRight;
|
||||
showSettingsGesture.numberOfTouchesRequired = 2;
|
||||
[self.view addGestureRecognizer:showSettingsGesture];
|
||||
|
@ -70,6 +71,61 @@
|
|||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(emulatorDidShutDown:) name:[AppDelegate sharedEmulator].shutdownNotification object:nil];
|
||||
}
|
||||
|
||||
- (void)showSettings:(id)sender {
|
||||
[self performSegueWithIdentifier:@"settings" sender:sender];
|
||||
}
|
||||
|
||||
- (void)showInsertDisk:(id)sender {
|
||||
[self performSegueWithIdentifier:@"disk" sender:sender];
|
||||
}
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
if ([sender isKindOfClass:[UIGestureRecognizer class]]) {
|
||||
UISwipeGestureRecognizer *gestureRecognizer = (UISwipeGestureRecognizer*)sender;
|
||||
modalPanePresentationDirection = gestureRecognizer.direction;
|
||||
segue.destinationViewController.transitioningDelegate = self;
|
||||
} else if (self.presentedViewController != nil && [@[@"disk", @"settings"] containsObject:segue.identifier]) {
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
|
||||
UIView *containerView = [transitionContext containerView];
|
||||
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
|
||||
|
||||
[containerView addSubview:toView];
|
||||
switch (modalPanePresentationDirection) {
|
||||
case UISwipeGestureRecognizerDirectionLeft:
|
||||
toView.transform = CGAffineTransformMakeTranslation(containerView.bounds.size.width, 0);
|
||||
break;
|
||||
case UISwipeGestureRecognizerDirectionRight:
|
||||
toView.transform = CGAffineTransformMakeTranslation(-containerView.bounds.size.width, 0);
|
||||
break;
|
||||
case UISwipeGestureRecognizerDirectionDown:
|
||||
toView.transform = CGAffineTransformMakeTranslation(0, -containerView.bounds.size.height);
|
||||
break;
|
||||
case UISwipeGestureRecognizerDirectionUp:
|
||||
toView.transform = CGAffineTransformMakeTranslation(0, containerView.bounds.size.height);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
|
||||
toView.transform = CGAffineTransformIdentity;
|
||||
} completion:^(BOOL finished) {
|
||||
[transitionContext completeTransition:finished];
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
UIScreen *screen = self.view.window.screen;
|
||||
return CGRectEqualToRect(screen.bounds, self.view.window.bounds);
|
||||
|
|
Loading…
Reference in New Issue