Skip to content

Commit

Permalink
Merge pull request #37 from nakajijapan/add-push-animation
Browse files Browse the repository at this point in the history
Add the animation for Page Transition
  • Loading branch information
nakajijapan authored Feb 15, 2019
2 parents d3acb37 + 4697504 commit d1a3ec3
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 34 deletions.
12 changes: 12 additions & 0 deletions Shari-Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
B0A0CA5A1FC7010A00D132C9 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = B0A0CA591FC7010A00D132C9 /* README.md */; };
B0A0CA5D1FC708B200D132C9 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = B0A0CA5B1FC708B200D132C9 /* .swiftlint.yml */; };
B0A0CA5E1FC708B200D132C9 /* .travis.yml in Resources */ = {isa = PBXBuildFile; fileRef = B0A0CA5C1FC708B200D132C9 /* .travis.yml */; };
DC32CAE822166E560048B1AB /* NextViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC32CAE722166E560048B1AB /* NextViewController.swift */; };
DC32CAEB2216714D0048B1AB /* UIViewControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC32CAEA2216714D0048B1AB /* UIViewControllerExtension.swift */; };
DC32CAED221672AB0048B1AB /* NextViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC32CAEC221672AB0048B1AB /* NextViewController.storyboard */; };
DC38C9731DB750C900EFD83E /* TabBarControllerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC38C9721DB750C900EFD83E /* TabBarControllerUITests.swift */; };
DC54326D1C62214300612AE3 /* NavigationControllerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC54326C1C62214300612AE3 /* NavigationControllerUITests.swift */; };
DC9E67FE1C3005070095C3AB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9E67FD1C3005070095C3AB /* AppDelegate.swift */; };
Expand Down Expand Up @@ -73,6 +76,9 @@
B0A0CA591FC7010A00D132C9 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
B0A0CA5B1FC708B200D132C9 /* .swiftlint.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = "<group>"; };
B0A0CA5C1FC708B200D132C9 /* .travis.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .travis.yml; sourceTree = "<group>"; };
DC32CAE722166E560048B1AB /* NextViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextViewController.swift; sourceTree = "<group>"; };
DC32CAEA2216714D0048B1AB /* UIViewControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewControllerExtension.swift; sourceTree = "<group>"; };
DC32CAEC221672AB0048B1AB /* NextViewController.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NextViewController.storyboard; sourceTree = "<group>"; };
DC38C9721DB750C900EFD83E /* TabBarControllerUITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabBarControllerUITests.swift; sourceTree = "<group>"; };
DC54326A1C62214300612AE3 /* Shari-DemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Shari-DemoUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
DC54326C1C62214300612AE3 /* NavigationControllerUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationControllerUITests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -157,10 +163,13 @@
DC9E683A1C30088F0095C3AB /* DetailViewController.swift */,
DCBED0601DB727AC00D3453A /* TabBarViewController.swift */,
DC9E683B1C30088F0095C3AB /* ModalTableViewController.swift */,
DC32CAE722166E560048B1AB /* NextViewController.swift */,
DC9E68011C3005070095C3AB /* Main.storyboard */,
DC32CAEC221672AB0048B1AB /* NextViewController.storyboard */,
DC9E68041C3005070095C3AB /* Assets.xcassets */,
DC9E68091C3005070095C3AB /* Info.plist */,
DC9E68581C300C2E0095C3AB /* LaunchScreen.storyboard */,
DC32CAEA2216714D0048B1AB /* UIViewControllerExtension.swift */,
);
path = "Shari-Demo";
sourceTree = "<group>";
Expand Down Expand Up @@ -293,6 +302,7 @@
B0A0CA5E1FC708B200D132C9 /* .travis.yml in Resources */,
B0A0CA5D1FC708B200D132C9 /* .swiftlint.yml in Resources */,
DC9E68591C300C2E0095C3AB /* LaunchScreen.storyboard in Resources */,
DC32CAED221672AB0048B1AB /* NextViewController.storyboard in Resources */,
DC9E68051C3005070095C3AB /* Assets.xcassets in Resources */,
B0A0CA5A1FC7010A00D132C9 /* README.md in Resources */,
DC9E68031C3005070095C3AB /* Main.storyboard in Resources */,
Expand Down Expand Up @@ -332,9 +342,11 @@
buildActionMask = 2147483647;
files = (
DC9E683C1C30088F0095C3AB /* DetailViewController.swift in Sources */,
DC32CAE822166E560048B1AB /* NextViewController.swift in Sources */,
DC9E683D1C30088F0095C3AB /* ModalTableViewController.swift in Sources */,
DC9E68001C3005070095C3AB /* ViewController.swift in Sources */,
DCBED0611DB727AC00D3453A /* TabBarViewController.swift in Sources */,
DC32CAEB2216714D0048B1AB /* UIViewControllerExtension.swift in Sources */,
DC9E67FE1C3005070095C3AB /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
27 changes: 12 additions & 15 deletions Shari-Demo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D17a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Smc-VF-rFs">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Smc-VF-rFs">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -24,11 +23,11 @@
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="4Lo-wU-Ecr" id="r7v-XQ-o6X">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ALE-vz-lQD">
<rect key="frame" x="15" y="0.0" width="345" height="43"/>
<rect key="frame" x="16" y="0.0" width="343" height="43.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down Expand Up @@ -60,7 +59,7 @@
<objects>
<navigationController storyboardIdentifier="ModalNavigationController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="vLy-dl-QhB" customClass="ShariNavigationController" customModule="Shari" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="HXm-vs-MSe">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -76,7 +75,7 @@
<objects>
<tableViewController storyboardIdentifier="ViewController" id="i6N-Yi-MnI" customClass="ViewController" customModule="Shari_Demo" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="MSk-Xe-mW9">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<sections>
Expand All @@ -86,11 +85,11 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="0zV-9g-jmZ" id="o9R-sG-YiB">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail View Controller" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="TiZ-Hr-ggf">
<rect key="frame" x="15" y="0.0" width="345" height="43"/>
<rect key="frame" x="16" y="0.0" width="343" height="43.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -99,9 +98,7 @@
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="JDH-sg-6eo" kind="show" id="0NK-qP-wx1">
<nil key="action"/>
</segue>
<segue destination="JDH-sg-6eo" kind="show" id="0NK-qP-wx1"/>
</connections>
</tableViewCell>
</cells>
Expand Down Expand Up @@ -130,7 +127,7 @@
<viewControllerLayoutGuide type="bottom" id="iQB-HQ-0en"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="dgA-0E-p6n">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zJc-4S-9KJ">
Expand Down Expand Up @@ -195,7 +192,7 @@
<navigationController id="Nhi-YQ-e6E" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="TabBar" id="ELX-JB-AF3"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="mXd-0d-HBK">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand Down Expand Up @@ -231,7 +228,7 @@
<tabBarItem key="tabBarItem" title="Navigation" id="X1Q-oC-ugA"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="Qem-l4-3bV">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand Down
33 changes: 23 additions & 10 deletions Shari-Demo/ModalTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ class ModalTableViewController: UITableViewController, ShariNavigationController
}
tableView.isScrollEnabled = false
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

guard let currentController = navigationController as? ShariNavigationController else {
fatalError("Need the ShariNavigationController")
}
currentController.transition(height: nil)
}

// MARK: - UITableViewDataSource

Expand All @@ -40,20 +49,24 @@ class ModalTableViewController: UITableViewController, ShariNavigationController
// MARK: - UITableViewDelegate

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

guard let currentController = navigationController as? ShariNavigationController else {
fatalError("Need the ShariNavigationController")
}
let completion = {
print("close via cell")
}

if let parentController = currentController.parentNavigationController {
parentController.si.dismiss(completion: completion)
} else if let parentController = currentController.parentTabBarController {
parentController.si.dismiss(completion: completion)
}

if indexPath.row == 0 {
let viewController = NextViewController.loadFromStoryboard()
navigationController?.pushViewController(viewController, animated: true)
} else {
let completion = {
print("close via cell")
}

if let parentController = currentController.parentNavigationController {
parentController.si.dismiss(completion: completion)
} else if let parentController = currentController.parentTabBarController {
parentController.si.dismiss(completion: completion)
}
}
}

// MARK: - Button Actions
Expand Down
46 changes: 46 additions & 0 deletions Shari-Demo/NextViewController.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="qId-Qb-ucm">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Next View Controller-->
<scene sceneID="hjk-CO-qJn">
<objects>
<viewController id="qId-Qb-ucm" customClass="NextViewController" customModule="Shari_Demo" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="r2d-Rm-CcY"/>
<viewControllerLayoutGuide type="bottom" id="55j-SC-nOR"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="bnV-YY-ftr">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Next" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8sf-Og-Czn">
<rect key="frame" x="323" y="80" width="36" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="8sf-Og-Czn" firstAttribute="top" secondItem="r2d-Rm-CcY" secondAttribute="bottom" constant="16" id="Sb2-gc-Fdl"/>
<constraint firstAttribute="trailing" secondItem="8sf-Og-Czn" secondAttribute="trailing" constant="16" id="Xm9-0V-fTf"/>
</constraints>
<viewLayoutGuide key="safeArea" id="NsB-KZ-lC1"/>
</view>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="5fp-mw-V0p" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2068" y="1210"/>
</scene>
</scenes>
</document>
30 changes: 30 additions & 0 deletions Shari-Demo/NextViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// NextViewController.swift
// Shari-Demo
//
// Created by Daichi Nakajima on 2019/02/15.
// Copyright © 2019 nakajijapan. All rights reserved.
//

import UIKit
import Shari

class NextViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

guard let currentController = navigationController as? ShariNavigationController else {
fatalError("Need the ShariNavigationController")
}

DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
currentController.transition(height: 250)
}
}

}
Loading

0 comments on commit d1a3ec3

Please sign in to comment.