Skip to content

Commit

Permalink
Merge pull request #9 from mono0926/1.1
Browse files Browse the repository at this point in the history
Add FadeIn with Animation
  • Loading branch information
mono0926 committed May 20, 2017
2 parents cbdaaae + 7048c4b commit 1863181
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 89 deletions.
22 changes: 18 additions & 4 deletions Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" 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="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
Expand All @@ -24,13 +24,13 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
</imageView>
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hfa-GM-Q6d">
<rect key="frame" x="0.0" y="0.0" width="110" height="180"/>
<rect key="frame" x="0.0" y="0.0" width="110" height="240"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="BDZ-hc-dGd">
<rect key="frame" x="0.0" y="0.0" width="110" height="180"/>
<rect key="frame" x="0.0" y="0.0" width="110" height="240"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="1Qd-4G-b8f">
<rect key="frame" x="0.0" y="0.0" width="110" height="180"/>
<rect key="frame" x="0.0" y="0.0" width="110" height="240"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VXq-6g-Fy7">
<rect key="frame" x="0.0" y="0.0" width="110" height="30"/>
Expand Down Expand Up @@ -74,6 +74,20 @@
<action selector="longDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="jok-vX-ajz"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="g9m-dr-Kab">
<rect key="frame" x="0.0" y="180" width="110" height="30"/>
<state key="normal" title="FadeIn"/>
<connections>
<action selector="fadeInDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="fPD-YX-U6c"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dIe-Qf-ugv">
<rect key="frame" x="0.0" y="210" width="110" height="30"/>
<state key="normal" title="Done Animation"/>
<connections>
<action selector="doneAnimatinDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ivC-bu-MEk"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
Expand Down
18 changes: 15 additions & 3 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ class ViewController: UIViewController {
message: "フィードバックをありがとう\nございました。")
}
@IBAction func goodDidTap(_ sender: UIButton) {
NativePopup.show(image: NativePopup.Preset.Feedback.good,
NativePopup.show(image: Preset.Feedback.good,
title: "Helpful",
message: "Thanks for your feedback.")
}
@IBAction func badDidTap(_ sender: UIButton) {
NativePopup.show(image: NativePopup.Preset.Feedback.bad,
NativePopup.show(image: Preset.Feedback.bad,
title: "Not Helpful",
message: "Thanks for your feedback.")
}
@IBAction func emptyMessageDidTap(_ sender: UIButton) {
NativePopup.show(image: NativePopup.Preset.Feedback.good,
NativePopup.show(image: Preset.Feedback.good,
title: "Empty Message 🗑",
message: nil)
}
Expand All @@ -44,5 +44,17 @@ class ViewController: UIViewController {
message: "Long duration🙇",
duration: 10)
}
@IBAction func fadeInDidTap(_ sender: UIButton) {
NativePopup.show(image: Preset.Feedback.good,
title: "Helpful",
message: "Thanks for your feedback.",
initialEffectType: .fadeIn)
}
@IBAction func doneAnimatinDidTap(_ sender: UIButton) {
NativePopup.show(image: Preset.Native.done,
title: "Added to Library",
message: nil,
initialEffectType: .fadeIn)
}
}

Binary file removed Movies/good.mov
Binary file not shown.
35 changes: 26 additions & 9 deletions NativePopup.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

/* Begin PBXBuildFile section */
FE8533901EAC7C92004BB756 /* NativePopup.h in Headers */ = {isa = PBXBuildFile; fileRef = FE85338E1EAC7C92004BB756 /* NativePopup.h */; settings = {ATTRIBUTES = (Public, ); }; };
FEB0316D1ECFF6770039A1C6 /* Preset.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEB0316C1ECFF6770039A1C6 /* Preset.swift */; };
FEB031711ECFF6A30039A1C6 /* Bundle.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEB031701ECFF6A30039A1C6 /* Bundle.extension.swift */; };
FEB031731ECFF6E00039A1C6 /* InitialEffectType.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEB031721ECFF6E00039A1C6 /* InitialEffectType.swift */; };
FEB031751ECFFB6C0039A1C6 /* Animatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEB031741ECFFB6C0039A1C6 /* Animatable.swift */; };
FEB031771ECFFE120039A1C6 /* AnimatableDoneView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEB031761ECFFE120039A1C6 /* AnimatableDoneView.swift */; };
FEB031791ED014D70039A1C6 /* HasAnimatableLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEB031781ED014D70039A1C6 /* HasAnimatableLayer.swift */; };
FECA87BA1EAC7CCF00D07CB1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECA87B91EAC7CCF00D07CB1 /* AppDelegate.swift */; };
FECA87BC1EAC7CCF00D07CB1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECA87BB1EAC7CCF00D07CB1 /* ViewController.swift */; };
FECA87BF1EAC7CCF00D07CB1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FECA87BD1EAC7CCF00D07CB1 /* Main.storyboard */; };
Expand All @@ -17,9 +23,7 @@
FECA87D91EAC87B700D07CB1 /* NativePopup.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE85338B1EAC7C92004BB756 /* NativePopup.framework */; };
FECA87DA1EAC87B700D07CB1 /* NativePopup.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FE85338B1EAC7C92004BB756 /* NativePopup.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
FECA87DF1EAC94B300D07CB1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FECA87DE1EAC94B300D07CB1 /* Assets.xcassets */; };
FECA87E11EACC77800D07CB1 /* NativePopup.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECA87E01EACC77800D07CB1 /* NativePopup.extension.swift */; };
FECA87E31EACC7F000D07CB1 /* UIImageConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECA87E21EACC7F000D07CB1 /* UIImageConvertible.swift */; };
FECA87EE1EADAC3800D07CB1 /* Bundle.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECA87ED1EADAC3800D07CB1 /* Bundle.extension.swift */; };
FECA87F01EADB80700D07CB1 /* UIView.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECA87EF1EADB80700D07CB1 /* UIView.extension.swift */; };
FECA87F21EADBA3C00D07CB1 /* Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECA87F11EADBA3C00D07CB1 /* Extension.swift */; };
FECA87F51EADBD7F00D07CB1 /* UIImage.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECA87F41EADBD7F00D07CB1 /* UIImage.extension.swift */; };
Expand Down Expand Up @@ -53,6 +57,12 @@
FE85338B1EAC7C92004BB756 /* NativePopup.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NativePopup.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FE85338E1EAC7C92004BB756 /* NativePopup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NativePopup.h; sourceTree = "<group>"; };
FE85338F1EAC7C92004BB756 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
FEB0316C1ECFF6770039A1C6 /* Preset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Preset.swift; sourceTree = "<group>"; };
FEB031701ECFF6A30039A1C6 /* Bundle.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bundle.extension.swift; sourceTree = "<group>"; };
FEB031721ECFF6E00039A1C6 /* InitialEffectType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InitialEffectType.swift; sourceTree = "<group>"; };
FEB031741ECFFB6C0039A1C6 /* Animatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Animatable.swift; sourceTree = "<group>"; };
FEB031761ECFFE120039A1C6 /* AnimatableDoneView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatableDoneView.swift; sourceTree = "<group>"; };
FEB031781ED014D70039A1C6 /* HasAnimatableLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasAnimatableLayer.swift; sourceTree = "<group>"; };
FECA87B71EAC7CCF00D07CB1 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
FECA87B91EAC7CCF00D07CB1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
FECA87BB1EAC7CCF00D07CB1 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand All @@ -62,9 +72,7 @@
FECA87C51EAC7CCF00D07CB1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
FECA87D71EAC7D9E00D07CB1 /* NativePopup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativePopup.swift; sourceTree = "<group>"; };
FECA87DE1EAC94B300D07CB1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
FECA87E01EACC77800D07CB1 /* NativePopup.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativePopup.extension.swift; sourceTree = "<group>"; };
FECA87E21EACC7F000D07CB1 /* UIImageConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageConvertible.swift; sourceTree = "<group>"; };
FECA87ED1EADAC3800D07CB1 /* Bundle.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bundle.extension.swift; sourceTree = "<group>"; };
FECA87EF1EADB80700D07CB1 /* UIView.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIView.extension.swift; sourceTree = "<group>"; };
FECA87F11EADBA3C00D07CB1 /* Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Extension.swift; sourceTree = "<group>"; };
FECA87F41EADBD7F00D07CB1 /* UIImage.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImage.extension.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -116,6 +124,11 @@
FE85338E1EAC7C92004BB756 /* NativePopup.h */,
FECA87D71EAC7D9E00D07CB1 /* NativePopup.swift */,
FECA87E21EACC7F000D07CB1 /* UIImageConvertible.swift */,
FEB0316C1ECFF6770039A1C6 /* Preset.swift */,
FEB031721ECFF6E00039A1C6 /* InitialEffectType.swift */,
FEB031741ECFFB6C0039A1C6 /* Animatable.swift */,
FEB031761ECFFE120039A1C6 /* AnimatableDoneView.swift */,
FEB031781ED014D70039A1C6 /* HasAnimatableLayer.swift */,
);
path = NativePopup;
sourceTree = "<group>";
Expand All @@ -136,13 +149,11 @@
FECA87F31EADBC2500D07CB1 /* Extensions */ = {
isa = PBXGroup;
children = (
FECA87ED1EADAC3800D07CB1 /* Bundle.extension.swift */,
FECA87F11EADBA3C00D07CB1 /* Extension.swift */,
FECA87E01EACC77800D07CB1 /* NativePopup.extension.swift */,
FEB031701ECFF6A30039A1C6 /* Bundle.extension.swift */,
FECA87F41EADBD7F00D07CB1 /* UIImage.extension.swift */,
FECA87EF1EADB80700D07CB1 /* UIView.extension.swift */,
);
name = Extensions;
path = Extensions;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -265,11 +276,15 @@
files = (
FECA87F01EADB80700D07CB1 /* UIView.extension.swift in Sources */,
FECA87F51EADBD7F00D07CB1 /* UIImage.extension.swift in Sources */,
FECA87E11EACC77800D07CB1 /* NativePopup.extension.swift in Sources */,
FEB031711ECFF6A30039A1C6 /* Bundle.extension.swift in Sources */,
FEB031731ECFF6E00039A1C6 /* InitialEffectType.swift in Sources */,
FEB031771ECFFE120039A1C6 /* AnimatableDoneView.swift in Sources */,
FEB031791ED014D70039A1C6 /* HasAnimatableLayer.swift in Sources */,
FEB031751ECFFB6C0039A1C6 /* Animatable.swift in Sources */,
FECA87E31EACC7F000D07CB1 /* UIImageConvertible.swift in Sources */,
FECA87F21EADBA3C00D07CB1 /* Extension.swift in Sources */,
FECA87EE1EADAC3800D07CB1 /* Bundle.extension.swift in Sources */,
FECA87D81EAC7D9E00D07CB1 /* NativePopup.swift in Sources */,
FEB0316D1ECFF6770039A1C6 /* Preset.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -459,6 +474,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -473,6 +489,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "D303033972D8A193CE6F4FE999E3808CBBD94BFA",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {

},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"D303033972D8A193CE6F4FE999E3808CBBD94BFA" : 9223372036854775807,
"2DFADC9AD84CF9C31D739A31DD9C69332B3E98FE" : 9223372036854775807
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "7D5F9D4E-23F6-4820-9348-4DF6EFC0F867",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"D303033972D8A193CE6F4FE999E3808CBBD94BFA" : "NativePopup\/",
"2DFADC9AD84CF9C31D739A31DD9C69332B3E98FE" : ""
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "NativePopup",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "NativePopup.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:mono0926\/gihyo.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "2DFADC9AD84CF9C31D739A31DD9C69332B3E98FE"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:mono0926\/NativePopup.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "D303033972D8A193CE6F4FE999E3808CBBD94BFA"
}
]
}
13 changes: 13 additions & 0 deletions NativePopup/Animatable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Animatable.swift
// NativePopup
//
// Created by mono on 2017/05/20.
// Copyright © 2017 mono. All rights reserved.
//

import Foundation

protocol Animatable {
func animate()
}
31 changes: 31 additions & 0 deletions NativePopup/AnimatableDoneView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// AnimatableDoneView.swift
// NativePopup
//
// Created by mono on 2017/05/20.
// Copyright © 2017 mono. All rights reserved.
//

import Foundation

class AnimatableDoneView: UIView, HasAnimatableLayer {

let animatableLayer = CAShapeLayer()
override func layoutSubviews() {
super.layoutSubviews()

let path = UIBezierPath()
path.move(to: CGPoint(x: 22, y: 59))
path.addLine(to: CGPoint(x: 53, y: 87))
path.addLine(to: CGPoint(x: 111, y: 28))

animatableLayer.path = path.cgPath
animatableLayer.fillColor = UIColor.clear.cgColor
animatableLayer.strokeColor = tintColor.cgColor
animatableLayer.lineWidth = 9
animatableLayer.lineCap = kCALineCapRound
animatableLayer.lineJoin = kCALineCapRound
animatableLayer.strokeEnd = 0
layer.addSublayer(animatableLayer)
}
}
24 changes: 0 additions & 24 deletions NativePopup/Extensions/NativePopup.extension.swift

This file was deleted.

25 changes: 25 additions & 0 deletions NativePopup/HasAnimatableLayer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// HasAnimatableLayer.swift
// NativePopup
//
// Created by mono on 2017/05/20.
// Copyright © 2017 mono. All rights reserved.
//

import Foundation

protocol HasAnimatableLayer: Animatable {
var animatableLayer: CAShapeLayer { get }
}

extension HasAnimatableLayer {
func animate() {
let animation = CABasicAnimation(keyPath: "strokeEnd")
animation.duration = 0.3
animation.fromValue = 0
animation.toValue = 1
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
animatableLayer.strokeEnd = 1
animatableLayer.add(animation, forKey: "animation")
}
}
Loading

0 comments on commit 1863181

Please sign in to comment.