Add slide in/out transition for Add Feed / Add Folder.

This commit is contained in:
Maurice Parker 2019-11-16 14:19:51 -06:00
parent 5ce5175bc0
commit 75d00f4692
4 changed files with 77 additions and 39 deletions

View File

@ -17,7 +17,7 @@
<sections> <sections>
<tableViewSection id="3tl-Mb-Eno"> <tableViewSection id="3tl-Mb-Eno">
<cells> <cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="44" id="lyJ-rf-8GA"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="44" id="lyJ-rf-8GA">
<rect key="frame" x="16" y="18" width="343" height="44"/> <rect key="frame" x="16" y="18" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="lyJ-rf-8GA" id="eNS-Rp-w0A"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="lyJ-rf-8GA" id="eNS-Rp-w0A">
@ -38,7 +38,7 @@
</constraints> </constraints>
</tableViewCellContentView> </tableViewCellContentView>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="44" id="Pxz-fv-QhQ"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="44" id="Pxz-fv-QhQ">
<rect key="frame" x="16" y="62" width="343" height="44"/> <rect key="frame" x="16" y="62" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Pxz-fv-QhQ" id="8aP-2A-8jc"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Pxz-fv-QhQ" id="8aP-2A-8jc">
@ -59,21 +59,21 @@
</constraints> </constraints>
</tableViewCellContentView> </tableViewCellContentView>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="Cell" rowHeight="44" id="rlc-34-flT" customClass="AddWebFeedTableViewCell" customModule="NetNewsWire" customModuleProvider="target"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="44" id="rlc-34-flT" customClass="AddWebFeedTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="16" y="106" width="343" height="44"/> <rect key="frame" x="16" y="106" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="rlc-34-flT" id="ZbC-Z6-dtq"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="rlc-34-flT" id="ZbC-Z6-dtq">
<rect key="frame" x="0.0" y="0.0" width="317" height="44"/> <rect key="frame" x="0.0" y="0.0" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Folder" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RtT-rR-5LA"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Folder:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RtT-rR-5LA">
<rect key="frame" x="18.999999999999996" y="11.666666666666664" width="48.666666666666657" height="21"/> <rect key="frame" x="19.000000000000004" y="11.666666666666664" width="53.333333333333343" height="21"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="htg-Nn-3xi"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="htg-Nn-3xi">
<rect key="frame" x="267" y="11.666666666666664" width="42" height="21"/> <rect key="frame" x="80.333333333333329" y="11.666666666666664" width="42" height="21"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
@ -81,8 +81,8 @@
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="htg-Nn-3xi" firstAttribute="centerY" secondItem="ZbC-Z6-dtq" secondAttribute="centerY" id="Z4n-Wi-s5H"/> <constraint firstItem="htg-Nn-3xi" firstAttribute="centerY" secondItem="ZbC-Z6-dtq" secondAttribute="centerY" id="Z4n-Wi-s5H"/>
<constraint firstItem="htg-Nn-3xi" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="RtT-rR-5LA" secondAttribute="trailing" constant="8" id="grG-sv-OgE"/> <constraint firstItem="htg-Nn-3xi" firstAttribute="leading" secondItem="RtT-rR-5LA" secondAttribute="trailing" constant="8" symbolic="YES" id="grG-sv-OgE"/>
<constraint firstItem="htg-Nn-3xi" firstAttribute="trailing" secondItem="ZbC-Z6-dtq" secondAttribute="trailingMargin" id="izx-09-DWe"/> <constraint firstAttribute="trailingMargin" relation="greaterThanOrEqual" secondItem="htg-Nn-3xi" secondAttribute="trailing" id="n9c-zc-0mQ"/>
<constraint firstItem="RtT-rR-5LA" firstAttribute="leading" secondItem="ZbC-Z6-dtq" secondAttribute="leadingMargin" constant="4" id="q2d-LR-YGh"/> <constraint firstItem="RtT-rR-5LA" firstAttribute="leading" secondItem="ZbC-Z6-dtq" secondAttribute="leadingMargin" constant="4" id="q2d-LR-YGh"/>
<constraint firstItem="RtT-rR-5LA" firstAttribute="centerY" secondItem="ZbC-Z6-dtq" secondAttribute="centerY" id="wHc-B0-lLE"/> <constraint firstItem="RtT-rR-5LA" firstAttribute="centerY" secondItem="ZbC-Z6-dtq" secondAttribute="centerY" id="wHc-B0-lLE"/>
</constraints> </constraints>
@ -116,6 +116,22 @@
</objects> </objects>
<point key="canvasLocation" x="-1711.2" y="89.408866995073893"/> <point key="canvasLocation" x="-1711.2" y="89.408866995073893"/>
</scene> </scene>
<!--Navigation Controller-->
<scene sceneID="hbe-Yu-anW">
<objects>
<navigationController storyboardIdentifier="AddWebFeedFolderNavViewController" id="WDg-F7-gfk" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="akM-T1-shZ">
<rect key="frame" x="0.0" y="44" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="acA-n7-ohN" kind="relationship" relationship="rootViewController" id="L5I-0H-Oci"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ndl-Bj-xD7" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2452" y="757"/>
</scene>
<!--Web Feed Folder--> <!--Web Feed Folder-->
<scene sceneID="wnD-aY-W32"> <scene sceneID="wnD-aY-W32">
<objects> <objects>
@ -198,11 +214,17 @@
<outlet property="delegate" destination="acA-n7-ohN" id="x4s-jR-1Aw"/> <outlet property="delegate" destination="acA-n7-ohN" id="x4s-jR-1Aw"/>
</connections> </connections>
</tableView> </tableView>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/> <navigationItem key="navigationItem" id="e4Y-zR-cTn">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="aTX-Fj-7pf">
<connections>
<action selector="cancel:" destination="acA-n7-ohN" id="euP-3Q-f0K"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController> </tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="gE2-fq-mL5" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="gE2-fq-mL5" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="-1058.4000000000001" y="88.669950738916256"/> <point key="canvasLocation" x="-1686" y="757"/>
</scene> </scene>
<!--Navigation Controller--> <!--Navigation Controller-->
<scene sceneID="9m0-Wv-Ipq"> <scene sceneID="9m0-Wv-Ipq">
@ -410,7 +432,7 @@
</tableViewController> </tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yp4-mF-DZV" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="yp4-mF-DZV" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="-399" y="89"/> <point key="canvasLocation" x="-961" y="89"/>
</scene> </scene>
</scenes> </scenes>
</document> </document>

View File

@ -113,7 +113,6 @@ private extension AddContainerViewController {
navigationItem.title = NSLocalizedString("Add Web Feed", comment: "Add Web Feed") navigationItem.title = NSLocalizedString("Add Web Feed", comment: "Add Web Feed")
resetUI() resetUI()
hideCurrentController()
let addFeedController = UIStoryboard.add.instantiateController(ofType: AddWebFeedViewController.self) let addFeedController = UIStoryboard.add.instantiateController(ofType: AddWebFeedViewController.self)
addFeedController.initialFeed = initialFeed addFeedController.initialFeed = initialFeed
@ -131,7 +130,6 @@ private extension AddContainerViewController {
navigationItem.title = NSLocalizedString("Add Folder", comment: "Add Folder") navigationItem.title = NSLocalizedString("Add Folder", comment: "Add Folder")
resetUI() resetUI()
hideCurrentController()
displayContentController(UIStoryboard.add.instantiateController(ofType: AddFolderViewController.self)) displayContentController(UIStoryboard.add.instantiateController(ofType: AddFolderViewController.self))
} }
@ -141,30 +139,32 @@ private extension AddContainerViewController {
} }
func displayContentController(_ controller: AddContainerViewControllerChild) { func displayContentController(_ controller: AddContainerViewControllerChild) {
if let currentViewController = currentViewController {
let transition = CATransition()
transition.type = .push
transition.subtype = currentViewController is AddWebFeedViewController ? .fromRight : .fromLeft
containerView.layer.add(transition, forKey: "transition")
containerView.addSubview(controller.view)
addChild(controller)
controller.didMove(toParent: self)
currentViewController.willMove(toParent: nil)
currentViewController.view.removeFromSuperview()
currentViewController.removeFromParent()
} else {
containerView.addSubview(controller.view)
addChild(controller)
controller.didMove(toParent: self)
}
currentViewController = controller currentViewController = controller
controller.delegate = self currentViewController?.delegate = self
addChild(controller)
containerView.addSubview(controller.view)
controller.view.translatesAutoresizingMaskIntoConstraints = false
controller.view.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true
controller.view.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true
controller.view.leadingAnchor.constraint(equalTo: containerView.leadingAnchor).isActive = true
controller.view.trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true
controller.didMove(toParent: self)
} }
func hideCurrentController() {
guard let currentViewController = currentViewController else {
return
}
currentViewController.willMove(toParent: nil)
currentViewController.view.removeFromSuperview()
currentViewController.removeFromParent()
}
} }

View File

@ -76,8 +76,22 @@ class AddWebFeedFolderViewController: UITableViewController {
let cell = tableView.cellForRow(at: indexPath) let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .checkmark cell?.accessoryType = .checkmark
delegate?.didSelect(container: container) delegate?.didSelect(container: container)
navigationController?.popViewController(animated: true) dismiss()
} }
} }
// MARK: Actions
@IBAction func cancel(_ sender: Any) {
dismiss()
}
}
private extension AddWebFeedFolderViewController {
func dismiss() {
dismiss(animated: true)
}
} }

View File

@ -121,10 +121,12 @@ class AddWebFeedViewController: UITableViewController, AddContainerViewControlle
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.row == 2 { if indexPath.row == 2 {
let folderViewController = UIStoryboard.add.instantiateController(ofType: AddWebFeedFolderViewController.self) let navController = UIStoryboard.add.instantiateViewController(withIdentifier: "AddWebFeedFolderNavViewController") as! UINavigationController
navController.modalPresentationStyle = .currentContext
let folderViewController = navController.topViewController as! AddWebFeedFolderViewController
folderViewController.delegate = self folderViewController.delegate = self
folderViewController.initialContainer = container folderViewController.initialContainer = container
navigationController?.pushViewController(folderViewController, animated: true) present(navController, animated: true)
} }
} }