Skip to content

Commit

Permalink
add zoom default animation
Browse files Browse the repository at this point in the history
  • Loading branch information
lkzhao committed Feb 11, 2017
1 parent 8ee6d32 commit c390f54
Show file tree
Hide file tree
Showing 9 changed files with 805 additions and 358 deletions.
6 changes: 6 additions & 0 deletions Examples/HeroExamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
B1275D941E4C0CFD0099A0E9 /* LabelMorphPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1275D921E4C0CFD0099A0E9 /* LabelMorphPlugin.swift */; };
B1275D971E4C0D850099A0E9 /* PluginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1275D961E4C0D850099A0E9 /* PluginViewController.swift */; };
B16A21A01E4E3907007B8B4C /* AnimationSelectTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B16A219F1E4E3907007B8B4C /* AnimationSelectTableViewController.swift */; };
B16ECD031E4FC0B300EAE0E0 /* HeroDefaultAnimations.swift in Sources */ = {isa = PBXBuildFile; fileRef = B16ECD021E4FC0B300EAE0E0 /* HeroDefaultAnimations.swift */; };
B16ECD041E4FC0B300EAE0E0 /* HeroDefaultAnimations.swift in Sources */ = {isa = PBXBuildFile; fileRef = B16ECD021E4FC0B300EAE0E0 /* HeroDefaultAnimations.swift */; };
B185A4E61DFA6E0C00C3B85D /* ListTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B185A4E51DFA6E0C00C3B85D /* ListTableViewController.swift */; };
B185A4E81DFA6FE200C3B85D /* GridCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B185A4E71DFA6FE200C3B85D /* GridCollectionViewController.swift */; };
B19F76991E46C38E002DBC58 /* AppleHomePage.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B19F76981E46C38E002DBC58 /* AppleHomePage.storyboard */; };
Expand Down Expand Up @@ -198,6 +200,7 @@
B1275D921E4C0CFD0099A0E9 /* LabelMorphPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelMorphPlugin.swift; sourceTree = "<group>"; };
B1275D961E4C0D850099A0E9 /* PluginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PluginViewController.swift; sourceTree = "<group>"; };
B16A219F1E4E3907007B8B4C /* AnimationSelectTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AnimationSelectTableViewController.swift; path = DefaultAnimation/AnimationSelectTableViewController.swift; sourceTree = "<group>"; };
B16ECD021E4FC0B300EAE0E0 /* HeroDefaultAnimations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeroDefaultAnimations.swift; sourceTree = "<group>"; };
B185A4E51DFA6E0C00C3B85D /* ListTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ListTableViewController.swift; path = ListToGrid/ListTableViewController.swift; sourceTree = "<group>"; };
B185A4E71DFA6FE200C3B85D /* GridCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GridCollectionViewController.swift; path = ListToGrid/GridCollectionViewController.swift; sourceTree = "<group>"; };
B19F76981E46C38E002DBC58 /* AppleHomePage.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = AppleHomePage.storyboard; path = AppleHomepage/AppleHomePage.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -332,6 +335,7 @@
isa = PBXGroup;
children = (
A37D7B511E2C0CBD00AC1959 /* Hero.swift */,
B16ECD021E4FC0B300EAE0E0 /* HeroDefaultAnimations.swift */,
A32D2D091E4BD20B008D35FF /* HeroIndependentController.swift */,
A32D2D061E4B84A1008D35FF /* HeroBaseController.swift */,
A37D7B521E2C0CBD00AC1959 /* HeroContext.swift */,
Expand Down Expand Up @@ -835,6 +839,7 @@
2D1F7FD31E49DD18004D944B /* CALayer+Hero.swift in Sources */,
2D1F7FC71E49DD02004D944B /* Hero.swift in Sources */,
2D1F7FC81E49DD04004D944B /* HeroContext.swift in Sources */,
B16ECD041E4FC0B300EAE0E0 /* HeroDefaultAnimations.swift in Sources */,
2D1F7FD11E49DD13004D944B /* SourcePreprocessor.swift in Sources */,
2D1F7FCF1E49DD13004D944B /* IgnoreSubviewModifiersPreprocessor.swift in Sources */,
2D1F7FCE1E49DD13004D944B /* CascadePreprocessor.swift in Sources */,
Expand Down Expand Up @@ -879,6 +884,7 @@
A37D7B4C1E2C0C9300AC1959 /* CALayer+Hero.swift in Sources */,
A37D7B431E2C0C7E00AC1959 /* MatchPreprocessor.swift in Sources */,
A37D7B5F1E2C0CBD00AC1959 /* HeroTargetState.swift in Sources */,
B16ECD031E4FC0B300EAE0E0 /* HeroDefaultAnimations.swift in Sources */,
A37D7B411E2C0C7E00AC1959 /* CascadePreprocessor.swift in Sources */,
A37D7B501E2C0C9300AC1959 /* UIKit+Hero.swift in Sources */,
A37D7B631E2C0CD100AC1959 /* HeroDebugPlugin.swift in Sources */,
Expand Down
31 changes: 21 additions & 10 deletions Examples/HeroExamples/Examples/BuiltInTransitions.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,29 @@
<scene sceneID="L1T-fO-G1u">
<objects>
<tableViewController storyboardIdentifier="animationSelect" id="540-XZ-2qf" customClass="AnimationSelectTableViewController" customModule="HeroExamples" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="G69-Nc-2Eq">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="G69-Nc-2Eq">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.33910316229999998" green="0.73554944990000004" blue="0.53971123700000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="header" rowHeight="300" id="en5-ZL-BAJ">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="header" rowHeight="300" id="en5-ZL-BAJ" customClass="AnimationSelectHeaderCell" customModule="HeroExamples" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="300"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="en5-ZL-BAJ" id="IQv-gx-fno">
<rect key="frame" x="0.0" y="0.0" width="375" height="299"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="300"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="HeroLogo" translatesAutoresizingMaskIntoConstraints="NO" id="zzi-xs-O5L">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="HeroLogo" translatesAutoresizingMaskIntoConstraints="NO" id="zzi-xs-O5L" customClass="TemplateImageView" customModule="HeroExamples" customModuleProvider="target">
<rect key="frame" x="40" y="20" width="295" height="250"/>
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="image" keyPath="templateImage" value="HeroLogo"/>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Built-in transitions" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Md3-qE-icu">
<rect key="frame" x="112" y="210" width="152" height="23"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="19"/>
<color key="textColor" red="0.99120575189590454" green="0.51333808898925781" blue="0.19727766513824463" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kXp-Zq-0Me">
Expand All @@ -41,7 +45,7 @@
<constraint firstAttribute="width" constant="48" id="M5K-7x-Vrb"/>
<constraint firstAttribute="height" constant="48" id="ppv-Hj-UEy"/>
</constraints>
<color key="tintColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<state key="normal" image="ic_keyboard_arrow_down"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
Expand All @@ -66,23 +70,30 @@
<constraint firstItem="Md3-qE-icu" firstAttribute="centerX" secondItem="IQv-gx-fno" secondAttribute="centerX" id="pAt-3f-dIp"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<connections>
<outlet property="backButton" destination="kXp-Zq-0Me" id="lDM-0t-2a1"/>
<outlet property="heroLogo" destination="zzi-xs-O5L" id="kkY-43-qM3"/>
<outlet property="promptLabel" destination="Md3-qE-icu" id="x2P-Tc-sXp"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="item" textLabel="Jff-m2-kij" style="IBUITableViewCellStyleDefault" id="9lb-Zz-xmu">
<rect key="frame" x="0.0" y="328" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="9lb-Zz-xmu" id="1Vx-Fz-mzw">
<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="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Jff-m2-kij">
<rect key="frame" x="15" y="0.0" width="345" height="43"/>
<rect key="frame" x="15" y="0.0" width="345" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tableViewCell>
</prototypes>
<connections>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
// The MIT License (MIT)
//
// AnimationSelectTableViewController.swift
// HeroExamples
// Copyright (c) 2016 Luke Zhao <[email protected]>
//
// Created by Luke Zhao on 2017-02-10.
// Copyright © 2017 Luke Zhao. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import UIKit
import Hero
import ChameleonFramework

class AnimationSelectHeaderCell: UITableViewCell {
@IBOutlet weak var backButton: UIButton!
@IBOutlet weak var heroLogo: TemplateImageView!
@IBOutlet weak var promptLabel: UILabel!
}

class AnimationSelectTableViewController: UITableViewController {

var animations: [HeroAnimationType] = [
var animations: [HeroDefaultAnimationType] = [
.push(direction: .left),
.pull(direction: .left),
.slide(direction: .left),
Expand All @@ -21,9 +42,19 @@ class AnimationSelectTableViewController: UITableViewController {
.pageIn(direction: .left),
.pageOut(direction: .left),
.fade,
.zoom,
.zoomOut,
.none
]

var labelColor: UIColor!

override func viewDidLoad() {
super.viewDidLoad()
tableView.backgroundColor = UIColor.randomFlat
labelColor = UIColor(contrastingBlackOrWhiteColorOn: tableView.backgroundColor!, isFlat: true)
}

override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
Expand All @@ -34,11 +65,16 @@ class AnimationSelectTableViewController: UITableViewController {

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
return tableView.dequeueReusableCell(withIdentifier: "header", for: indexPath)
let header = tableView.dequeueReusableCell(withIdentifier: "header", for: indexPath) as! AnimationSelectHeaderCell
header.heroLogo.tintColor = labelColor
header.promptLabel.textColor = labelColor
header.backButton.tintColor = labelColor
return header
}

let cell = tableView.dequeueReusableCell(withIdentifier: "item", for: indexPath)
cell.textLabel?.text = animations[indexPath.item].label
cell.textLabel!.text = animations[indexPath.item].label
cell.textLabel!.textColor = labelColor
return cell
}

Expand Down
8 changes: 8 additions & 0 deletions Examples/HeroExamples/UIKit+HeroExamples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,11 @@ public extension UIView {
func viewController(forStoryboardName: String) -> UIViewController {
return UIStoryboard(name: forStoryboardName, bundle: nil).instantiateInitialViewController()!
}

class TemplateImageView: UIImageView {
@IBInspectable var templateImage: UIImage? {
didSet {
image = templateImage?.withRenderingMode(.alwaysTemplate)
}
}
}
Loading

0 comments on commit c390f54

Please sign in to comment.