use default modal presentation transition for settings and disks

getting it right on iPad and iPhone seems too much of a hack
This commit is contained in:
Jesús A. Álvarez 2022-05-26 17:42:45 +02:00
parent ada4e0a4dd
commit d93ae3ce89
2 changed files with 42 additions and 69 deletions

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@ -48,7 +49,7 @@
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Swipe2Left" translatesAutoresizingMaskIntoConstraints="NO" id="pzY-d9-3Z5">
<rect key="frame" x="15" y="66" width="64" height="64"/>
<color key="tintColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="tintColor" systemColor="labelColor"/>
<constraints>
<constraint firstAttribute="height" constant="64" id="CmV-Bq-j5o"/>
<constraint firstAttribute="width" constant="64" id="gH6-fx-cgO"/>
@ -56,7 +57,7 @@
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Swipe2Right" translatesAutoresizingMaskIntoConstraints="NO" id="7WX-Kv-Q7i">
<rect key="frame" x="15" y="152" width="64" height="64"/>
<color key="tintColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="tintColor" systemColor="labelColor"/>
<constraints>
<constraint firstAttribute="height" constant="64" id="8yn-GP-Kd1"/>
<constraint firstAttribute="width" constant="64" id="dEn-fC-loh"/>
@ -64,7 +65,7 @@
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Swipe2Up" translatesAutoresizingMaskIntoConstraints="NO" id="ogt-xN-NKI">
<rect key="frame" x="15" y="238" width="64" height="64"/>
<color key="tintColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="tintColor" systemColor="labelColor"/>
<constraints>
<constraint firstAttribute="height" constant="64" id="L2w-OD-WT1"/>
<constraint firstAttribute="width" constant="64" id="yKv-YC-eFy"/>
@ -72,14 +73,14 @@
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Swipe2Down" translatesAutoresizingMaskIntoConstraints="NO" id="GSB-g7-f2Y">
<rect key="frame" x="15" y="324" width="64" height="64"/>
<color key="tintColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="tintColor" systemColor="labelColor"/>
<constraints>
<constraint firstAttribute="width" constant="64" id="1ZM-my-t5g"/>
<constraint firstAttribute="height" constant="64" id="9hg-7C-WG2"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Insert Disk" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IYD-cg-suz">
<rect key="frame" x="87" y="66" width="81.666666666666686" height="21"/>
<rect key="frame" x="87" y="66" width="80.666666666666686" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -101,7 +102,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Show Keyboard" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QcY-8W-bqI">
<rect key="frame" x="87" y="238" width="120" height="21"/>
<rect key="frame" x="87" y="238" width="119" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -112,13 +113,13 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hide Keyboard" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8kk-bG-T9V">
<rect key="frame" x="87" y="324" width="113" height="21"/>
<rect key="frame" x="87" y="324" width="112" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Swipe down with two fingers" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5ZP-Fp-fg5">
<rect key="frame" x="87.000000000000014" y="353" width="181.33333333333337" height="17"/>
<rect key="frame" x="87" y="353" width="182" height="17"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="14"/>
<nil key="highlightedColor"/>
</label>
@ -219,10 +220,10 @@
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="9gA-gD-7Wx">
<rect key="frame" x="0.0" y="0.0" width="375" height="758"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<color key="backgroundColor" systemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="speed" id="v4I-0T-H8m">
<rect key="frame" x="0.0" y="55.333332061767578" width="375" height="44"/>
<rect key="frame" x="0.0" y="49" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="v4I-0T-H8m" id="cO5-De-1JT">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@ -252,7 +253,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="mouse" id="JgY-zN-3ID">
<rect key="frame" x="0.0" y="99.333332061767578" width="375" height="44"/>
<rect key="frame" x="0.0" y="93" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="JgY-zN-3ID" id="iUk-se-WGk">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@ -281,7 +282,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="keyboard" textLabel="6WO-0z-y7c" style="IBUITableViewCellStyleDefault" id="q7C-00-4ss">
<rect key="frame" x="0.0" y="143.33333206176758" width="375" height="44"/>
<rect key="frame" x="0.0" y="137" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="q7C-00-4ss" id="yUn-mI-DwM">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@ -297,7 +298,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationWidth="60" reuseIdentifier="machine" textLabel="znE-ML-UrQ" detailTextLabel="xcq-HY-ZDe" style="IBUITableViewCellStyleSubtitle" id="MGj-K1-5lZ">
<rect key="frame" x="0.0" y="187.33333206176758" width="375" height="44"/>
<rect key="frame" x="0.0" y="181" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="MGj-K1-5lZ" id="ueO-zm-JQP">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@ -313,7 +314,7 @@
<rect key="frame" x="15.999999999999998" y="25.333333333333332" width="30.333333333333332" height="13.333333333333334"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" systemColor="secondaryLabelColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
@ -321,7 +322,7 @@
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="display" id="P6n-Bf-s6h">
<rect key="frame" x="0.0" y="231.33333206176758" width="375" height="44"/>
<rect key="frame" x="0.0" y="225" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="P6n-Bf-s6h" id="NgN-Fe-hXo">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@ -347,7 +348,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="about" textLabel="YWX-qF-gPj" detailTextLabel="xr3-v1-hzM" style="IBUITableViewCellStyleValue1" id="Mon-vq-IrO">
<rect key="frame" x="0.0" y="275.33333206176758" width="375" height="44"/>
<rect key="frame" x="0.0" y="269" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Mon-vq-IrO" id="mGZ-Jb-6j4">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@ -363,14 +364,14 @@
<rect key="frame" x="317.33333333333331" y="12.999999999999998" width="41.666666666666664" height="19.333333333333332"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" systemColor="secondaryLabelColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="toggle" textLabel="a1l-XI-MEz" style="IBUITableViewCellStyleDefault" id="1nB-54-Qfk">
<rect key="frame" x="0.0" y="319.33333206176758" width="375" height="44"/>
<rect key="frame" x="0.0" y="313" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="1nB-54-Qfk" id="fZu-5X-Z4B">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@ -452,10 +453,10 @@
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="EFr-QR-Vqc">
<rect key="frame" x="0.0" y="0.0" width="375" height="758"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="cell" textLabel="8ef-Se-DXA" detailTextLabel="CbL-Kq-e9s" style="IBUITableViewCellStyleValue1" id="iZQ-DG-qho" customClass="FileTableViewCell">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<rect key="frame" x="0.0" y="44.666666030883789" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="iZQ-DG-qho" id="pcB-3f-clB">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
@ -471,12 +472,12 @@
<rect key="frame" x="324" y="16" width="35" height="15.666666666666666"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" systemColor="secondaryLabelColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<color key="tintColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="tintColor" systemColor="labelColor"/>
</tableViewCell>
</prototypes>
<connections>
@ -534,5 +535,17 @@
<image name="Swipe2Right" width="64" height="64"/>
<image name="Swipe2Up" width="64" height="64"/>
<image name="floppy30" width="30" height="30"/>
<systemColor name="groupTableViewBackgroundColor">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="labelColor">
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="secondaryLabelColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>

View File

@ -13,7 +13,7 @@
#import "KBKeyboardView.h"
#import "KBKeyboardLayout.h"
@interface ViewController () <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning, UIAdaptivePresentationControllerDelegate>
@interface ViewController () <UIAdaptivePresentationControllerDelegate>
@end
@ -29,7 +29,6 @@ API_AVAILABLE(ios(13.4))
KBKeyboardView *keyboardView;
UISwipeGestureRecognizer *showKeyboardGesture, *hideKeyboardGesture, *insertDiskGesture, *showSettingsGesture;
UIControl *pointingDeviceView;
UISwipeGestureRecognizerDirection modalPanePresentationDirection;
id interaction;
}
@ -70,53 +69,14 @@ API_AVAILABLE(ios(13.4))
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
[self cancelHelpPresentation];
if ([sender isKindOfClass:[UIGestureRecognizer class]]) {
UISwipeGestureRecognizer *gestureRecognizer = (UISwipeGestureRecognizer*)sender;
modalPanePresentationDirection = gestureRecognizer.direction;
segue.destinationViewController.transitioningDelegate = self;
if ([@[@"disk", @"settings"] containsObject:segue.identifier]) {
segue.destinationViewController.presentationController.delegate = self;
} else if (self.presentedViewController != nil && [@[@"disk", @"settings"] containsObject:segue.identifier]) {
[self dismissViewControllerAnimated:YES completion:nil];
if (self.presentedViewController != nil) {
[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];
}];
}
- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController {
// hack to fix the presenting view controller not returning back to normal size on iOS 13
// when the sheet is dismissed interactively (ie dragging it down) after a contextual menu