Commit debf975c by Daniel Dahan

updated MaterialSwitch to detect trackLayer touches.

parent dd800745
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
9656CD231C6CFA6200EBCEF1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9656CD221C6CFA6200EBCEF1 /* ViewController.swift */; }; 9656CD231C6CFA6200EBCEF1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9656CD221C6CFA6200EBCEF1 /* ViewController.swift */; };
9656CD281C6CFA6200EBCEF1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9656CD271C6CFA6200EBCEF1 /* Assets.xcassets */; }; 9656CD281C6CFA6200EBCEF1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9656CD271C6CFA6200EBCEF1 /* Assets.xcassets */; };
9656CD2B1C6CFA6200EBCEF1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9656CD291C6CFA6200EBCEF1 /* LaunchScreen.storyboard */; }; 9656CD2B1C6CFA6200EBCEF1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9656CD291C6CFA6200EBCEF1 /* LaunchScreen.storyboard */; };
96A71F241C72754D00C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F231C72754D00C0C4AE /* Material.framework */; };
96A71F251C72754D00C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F231C72754D00C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96A71F251C72754D00C0C4AE /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -36,7 +33,6 @@ ...@@ -36,7 +33,6 @@
9656CD271C6CFA6200EBCEF1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 9656CD271C6CFA6200EBCEF1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
9656CD2A1C6CFA6200EBCEF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 9656CD2A1C6CFA6200EBCEF1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
9656CD2C1C6CFA6200EBCEF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 9656CD2C1C6CFA6200EBCEF1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96A71F231C72754D00C0C4AE /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96A71F241C72754D00C0C4AE /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -54,7 +49,6 @@ ...@@ -54,7 +49,6 @@
9656CD141C6CFA6200EBCEF1 = { 9656CD141C6CFA6200EBCEF1 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96A71F231C72754D00C0C4AE /* Material.framework */,
9656CD1F1C6CFA6200EBCEF1 /* Grid */, 9656CD1F1C6CFA6200EBCEF1 /* Grid */,
9656CD1E1C6CFA6200EBCEF1 /* Products */, 9656CD1E1C6CFA6200EBCEF1 /* Products */,
); );
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
9642FA251C1B50E700022BC6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9642FA231C1B50E700022BC6 /* LaunchScreen.storyboard */; }; 9642FA251C1B50E700022BC6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9642FA231C1B50E700022BC6 /* LaunchScreen.storyboard */; };
9642FA331C1B909700022BC6 /* LeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9642FA321C1B909700022BC6 /* LeftViewController.swift */; }; 9642FA331C1B909700022BC6 /* LeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9642FA321C1B909700022BC6 /* LeftViewController.swift */; };
967585381C569AA9001E4268 /* RightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967585371C569AA9001E4268 /* RightViewController.swift */; }; 967585381C569AA9001E4268 /* RightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967585371C569AA9001E4268 /* RightViewController.swift */; };
96A71F1E1C71960900C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F1D1C71960900C0C4AE /* Material.framework */; };
96A71F1F1C71960900C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F1D1C71960900C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96A71F271C7275F200C0C4AE /* FeedCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F261C7275F200C0C4AE /* FeedCollectionView.swift */; }; 96A71F271C7275F200C0C4AE /* FeedCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F261C7275F200C0C4AE /* FeedCollectionView.swift */; };
96A71F291C72761700C0C4AE /* FeedCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F281C72761700C0C4AE /* FeedCollectionViewLayout.swift */; }; 96A71F291C72761700C0C4AE /* FeedCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F281C72761700C0C4AE /* FeedCollectionViewLayout.swift */; };
96A71F2B1C72766700C0C4AE /* FeedCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F2A1C72766700C0C4AE /* FeedCollectionViewCell.swift */; }; 96A71F2B1C72766700C0C4AE /* FeedCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F2A1C72766700C0C4AE /* FeedCollectionViewCell.swift */; };
96A71F321C73607B00C0C4AE /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F311C73607B00C0C4AE /* FeedViewController.swift */; }; 96A71F321C73607B00C0C4AE /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F311C73607B00C0C4AE /* FeedViewController.swift */; };
96A71F3C1C739D1E00C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F3B1C739D1E00C0C4AE /* Material.framework */; };
96A71F3D1C739D1E00C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F3B1C739D1E00C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96A71F1F1C71960900C0C4AE /* Material.framework in Embed Frameworks */, 96A71F3D1C739D1E00C0C4AE /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -44,11 +44,11 @@ ...@@ -44,11 +44,11 @@
9642FA261C1B50E700022BC6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 9642FA261C1B50E700022BC6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9642FA321C1B909700022BC6 /* LeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftViewController.swift; sourceTree = "<group>"; }; 9642FA321C1B909700022BC6 /* LeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftViewController.swift; sourceTree = "<group>"; };
967585371C569AA9001E4268 /* RightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightViewController.swift; sourceTree = "<group>"; }; 967585371C569AA9001E4268 /* RightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightViewController.swift; sourceTree = "<group>"; };
96A71F1D1C71960900C0C4AE /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
96A71F261C7275F200C0C4AE /* FeedCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedCollectionView.swift; sourceTree = "<group>"; }; 96A71F261C7275F200C0C4AE /* FeedCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedCollectionView.swift; sourceTree = "<group>"; };
96A71F281C72761700C0C4AE /* FeedCollectionViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedCollectionViewLayout.swift; sourceTree = "<group>"; }; 96A71F281C72761700C0C4AE /* FeedCollectionViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedCollectionViewLayout.swift; sourceTree = "<group>"; };
96A71F2A1C72766700C0C4AE /* FeedCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedCollectionViewCell.swift; sourceTree = "<group>"; }; 96A71F2A1C72766700C0C4AE /* FeedCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedCollectionViewCell.swift; sourceTree = "<group>"; };
96A71F311C73607B00C0C4AE /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; }; 96A71F311C73607B00C0C4AE /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; };
96A71F3B1C739D1E00C0C4AE /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96A71F1E1C71960900C0C4AE /* Material.framework in Frameworks */, 96A71F3C1C739D1E00C0C4AE /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
9642FA0E1C1B50E700022BC6 = { 9642FA0E1C1B50E700022BC6 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96A71F1D1C71960900C0C4AE /* Material.framework */, 96A71F3B1C739D1E00C0C4AE /* Material.framework */,
9642FA191C1B50E700022BC6 /* SideNavigationViewController */, 9642FA191C1B50E700022BC6 /* SideNavigationViewController */,
9642FA181C1B50E700022BC6 /* Products */, 9642FA181C1B50E700022BC6 /* Products */,
); );
......
...@@ -97,7 +97,7 @@ class AppViewController: NavigationViewController { ...@@ -97,7 +97,7 @@ class AppViewController: NavigationViewController {
sideNavigationViewController?.enabled = true sideNavigationViewController?.enabled = true
// Position the menuBackdropLayer for the animation when closing. // Position the menuBackdropLayer for the animation when closing.
menuBackdropLayer.addAnimation(MaterialAnimation.scale(1, duration: 0.25), forKey: nil) menuBackdropLayer.animate(MaterialAnimation.scale(1, duration: 0.25))
menuView.menu.close() menuView.menu.close()
image = UIImage(named: "ic_add_white") image = UIImage(named: "ic_add_white")
...@@ -110,7 +110,7 @@ class AppViewController: NavigationViewController { ...@@ -110,7 +110,7 @@ class AppViewController: NavigationViewController {
self.menuBackdropLayer.frame = self.menuView.frame self.menuBackdropLayer.frame = self.menuView.frame
self.menuBackdropLayer.shape = .Circle self.menuBackdropLayer.shape = .Circle
} }
menuBackdropLayer.addAnimation(MaterialAnimation.scale(30, duration: 0.25), forKey: nil) menuBackdropLayer.animate(MaterialAnimation.scale(30, duration: 0.25))
menuBackdropLayer.hidden = false menuBackdropLayer.hidden = false
menuView.menu.open() { (v: UIView) in menuView.menu.open() { (v: UIView) in
...@@ -135,7 +135,7 @@ class AppViewController: NavigationViewController { ...@@ -135,7 +135,7 @@ class AppViewController: NavigationViewController {
private func prepareNavigationBarView() { private func prepareNavigationBarView() {
// Title label. // Title label.
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
titleLabel.text = "Rcipes" titleLabel.text = "Recipes"
titleLabel.textAlignment = .Left titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20) titleLabel.font = RobotoFont.regularWithSize(20)
......
...@@ -53,6 +53,6 @@ class FeedCollectionView : UICollectionView { ...@@ -53,6 +53,6 @@ class FeedCollectionView : UICollectionView {
internal func prepareView() { internal func prepareView() {
registerClass(FeedCollectionViewCell.self, forCellWithReuseIdentifier: "FeedCollectionViewCell") registerClass(FeedCollectionViewCell.self, forCellWithReuseIdentifier: "FeedCollectionViewCell")
backgroundColor = MaterialColor.clear backgroundColor = MaterialColor.clear
contentInset = UIEdgeInsetsMake(4, 0, 4, 0) contentInset = UIEdgeInsetsMake(4, 0, 0, 0)
} }
} }
...@@ -52,7 +52,7 @@ class FeedCollectionViewCell : UICollectionViewCell { ...@@ -52,7 +52,7 @@ class FeedCollectionViewCell : UICollectionViewCell {
} }
private func prepareView() { private func prepareView() {
cardView = MaterialPulseView(frame: CGRectMake(4, 0, bounds.width - 8, 156)) cardView = MaterialPulseView()
cardView.pulseScale = false cardView.pulseScale = false
cardView.pulseColor = MaterialColor.blue.lighten4 cardView.pulseColor = MaterialColor.blue.lighten4
addSubview(cardView) addSubview(cardView)
...@@ -86,37 +86,46 @@ class FeedCollectionViewCell : UICollectionViewCell { ...@@ -86,37 +86,46 @@ class FeedCollectionViewCell : UICollectionViewCell {
detailLabel.backgroundColor = MaterialColor.clear detailLabel.backgroundColor = MaterialColor.clear
contentView.addSubview(detailLabel) contentView.addSubview(detailLabel)
let g: Int = Int(bounds.width / 48)
grid.axis.columns = g
grid.views = [cardView]
imageView.grid.columns = 4 imageView.grid.columns = 4
contentView.grid.columns = 8 contentView.grid.columns = g - 4
cardView.grid.contentInset.right = 8
cardView.grid.axis.columns = g
cardView.grid.views = [ cardView.grid.views = [
imageView, imageView,
contentView contentView
] ]
titleLabel.grid.rows = 4
titleLabel.grid.columns = 7
titleLabel.grid.offset.columns = 1
moreButton.grid.rows = 4
moreButton.grid.columns = 2
moreButton.grid.offset.columns = 8
detailLabel.grid.rows = 7 titleLabel.grid.rows = 4
detailLabel.grid.offset.rows = 4 titleLabel.grid.columns = contentView.grid.columns
detailLabel.grid.columns = 7 // titleLabel.grid.offset.columns = 1
detailLabel.grid.offset.columns = 1 //
// moreButton.grid.rows = 4
contentView.grid.spacing = 8 // moreButton.grid.columns = 2
contentView.grid.axis.columns = 10 // moreButton.grid.offset.columns = 8
contentView.grid.axis.direction = .None //
contentView.grid.axis.inherited = false // detailLabel.grid.rows = 7
contentView.grid.contentInsetPreset = .Square2 // detailLabel.grid.offset.rows = 4
// detailLabel.grid.columns = 7
// detailLabel.grid.offset.columns = 1
//
// contentView.grid.spacing = 8
// contentView.grid.axis.columns = 10
// contentView.grid.axis.direction = .None
// contentView.grid.axis.inherited = false
// contentView.grid.contentInsetPreset = .Square2
contentView.grid.views = [ contentView.grid.views = [
titleLabel, titleLabel,
moreButton, // moreButton,
detailLabel // detailLabel
] ]
} }
} }
...@@ -33,8 +33,8 @@ import UIKit ...@@ -33,8 +33,8 @@ import UIKit
class FeedCollectionViewLayout : UICollectionViewLayout { class FeedCollectionViewLayout : UICollectionViewLayout {
private var contentSize: CGSize = CGSizeZero private var contentSize: CGSize = CGSizeZero
private var layoutItems: Array<(UICollectionViewLayoutAttributes, NSIndexPath)>? private var layoutItems: Array<(UICollectionViewLayoutAttributes, NSIndexPath)>?
internal var height: CGFloat = 160 internal var height: CGFloat = 128
internal var offset: CGFloat = 1 internal var offset: CGFloat = 4
override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? { override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
let attributes: UICollectionViewLayoutAttributes = UICollectionViewLayoutAttributes(forCellWithIndexPath: indexPath) let attributes: UICollectionViewLayoutAttributes = UICollectionViewLayoutAttributes(forCellWithIndexPath: indexPath)
......
...@@ -58,6 +58,11 @@ class FeedViewController: UIViewController { ...@@ -58,6 +58,11 @@ class FeedViewController: UIViewController {
prepareCollectionView() prepareCollectionView()
} }
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
collectionView.reloadData()
}
/// Prepares view. /// Prepares view.
private func prepareView() { private func prepareView() {
view.backgroundColor = MaterialColor.white view.backgroundColor = MaterialColor.white
...@@ -113,9 +118,9 @@ class FeedViewController: UIViewController { ...@@ -113,9 +118,9 @@ class FeedViewController: UIViewController {
collectionView.delegate = self collectionView.delegate = self
collectionView.dataSource = self collectionView.dataSource = self
collectionView.backgroundColor = MaterialColor.grey.lighten4 collectionView.backgroundColor = MaterialColor.grey.lighten4
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView) view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: collectionView) MaterialLayout.alignToParent(view, child: collectionView)
} }
} }
...@@ -129,6 +134,7 @@ extension FeedViewController: UICollectionViewDelegate { ...@@ -129,6 +134,7 @@ extension FeedViewController: UICollectionViewDelegate {
c.titleLabel.text = item.title c.titleLabel.text = item.title
c.detailLabel.text = item.detail c.detailLabel.text = item.detail
c.imageView.image = item.image c.imageView.image = item.image
c.grid.reloadLayout()
return c return c
} }
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UISupportedInterfaceOrientations~ipad</key> <key>UISupportedInterfaceOrientations~ipad</key>
<array> <array>
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; }; 966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; };
966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; }; 966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; };
966F57AB1C226BAA009185B7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A91C226BAA009185B7 /* LaunchScreen.storyboard */; }; 966F57AB1C226BAA009185B7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A91C226BAA009185B7 /* LaunchScreen.storyboard */; };
96A71F2D1C72B64900C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F2C1C72B64900C0C4AE /* Material.framework */; };
96A71F2E1C72B64900C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F2C1C72B64900C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96A71F2E1C72B64900C0C4AE /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -36,7 +33,6 @@ ...@@ -36,7 +33,6 @@
966F57A71C226BAA009185B7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 966F57A71C226BAA009185B7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
966F57AA1C226BAA009185B7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 966F57AA1C226BAA009185B7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
966F57AC1C226BAA009185B7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 966F57AC1C226BAA009185B7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96A71F2C1C72B64900C0C4AE /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96A71F2D1C72B64900C0C4AE /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -54,7 +49,6 @@ ...@@ -54,7 +49,6 @@
966F57941C226BAA009185B7 = { 966F57941C226BAA009185B7 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96A71F2C1C72B64900C0C4AE /* Material.framework */,
966F579F1C226BAA009185B7 /* TextField */, 966F579F1C226BAA009185B7 /* TextField */,
966F579E1C226BAA009185B7 /* Products */, 966F579E1C226BAA009185B7 /* Products */,
); );
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
96A71EC71C6FFF0500C0C4AE /* MaterialSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71EC61C6FFF0500C0C4AE /* MaterialSwitch.swift */; }; 96A71EC71C6FFF0500C0C4AE /* MaterialSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71EC61C6FFF0500C0C4AE /* MaterialSwitch.swift */; };
96A71EF61C71127100C0C4AE /* SearchBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71EF51C71127100C0C4AE /* SearchBarView.swift */; }; 96A71EF61C71127100C0C4AE /* SearchBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71EF51C71127100C0C4AE /* SearchBarView.swift */; };
96A71F301C72E41100C0C4AE /* NavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F2F1C72E41100C0C4AE /* NavigationViewController.swift */; }; 96A71F301C72E41100C0C4AE /* NavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F2F1C72E41100C0C4AE /* NavigationViewController.swift */; };
96A71F351C7395C200C0C4AE /* MaterialCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F341C7395C200C0C4AE /* MaterialCollectionViewCell.swift */; };
96A71F371C73967E00C0C4AE /* MaterialPulseCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F361C73967E00C0C4AE /* MaterialPulseCollectionViewCell.swift */; };
96D88C1E1C1328D800B91418 /* CaptureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF51C1328D800B91418 /* CaptureView.swift */; }; 96D88C1E1C1328D800B91418 /* CaptureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF51C1328D800B91418 /* CaptureView.swift */; };
96D88C1F1C1328D800B91418 /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF61C1328D800B91418 /* CardView.swift */; }; 96D88C1F1C1328D800B91418 /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF61C1328D800B91418 /* CardView.swift */; };
96D88C201C1328D800B91418 /* CapturePreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF71C1328D800B91418 /* CapturePreviewView.swift */; }; 96D88C201C1328D800B91418 /* CapturePreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF71C1328D800B91418 /* CapturePreviewView.swift */; };
...@@ -143,6 +145,8 @@ ...@@ -143,6 +145,8 @@
96A71EC61C6FFF0500C0C4AE /* MaterialSwitch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialSwitch.swift; sourceTree = "<group>"; }; 96A71EC61C6FFF0500C0C4AE /* MaterialSwitch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialSwitch.swift; sourceTree = "<group>"; };
96A71EF51C71127100C0C4AE /* SearchBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBarView.swift; sourceTree = "<group>"; }; 96A71EF51C71127100C0C4AE /* SearchBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBarView.swift; sourceTree = "<group>"; };
96A71F2F1C72E41100C0C4AE /* NavigationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationViewController.swift; sourceTree = "<group>"; }; 96A71F2F1C72E41100C0C4AE /* NavigationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationViewController.swift; sourceTree = "<group>"; };
96A71F341C7395C200C0C4AE /* MaterialCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewCell.swift; sourceTree = "<group>"; };
96A71F361C73967E00C0C4AE /* MaterialPulseCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialPulseCollectionViewCell.swift; sourceTree = "<group>"; };
96D88BF51C1328D800B91418 /* CaptureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureView.swift; sourceTree = "<group>"; }; 96D88BF51C1328D800B91418 /* CaptureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureView.swift; sourceTree = "<group>"; };
96D88BF61C1328D800B91418 /* CardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardView.swift; sourceTree = "<group>"; }; 96D88BF61C1328D800B91418 /* CardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardView.swift; sourceTree = "<group>"; };
96D88BF71C1328D800B91418 /* CapturePreviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapturePreviewView.swift; sourceTree = "<group>"; }; 96D88BF71C1328D800B91418 /* CapturePreviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapturePreviewView.swift; sourceTree = "<group>"; };
...@@ -281,6 +285,15 @@ ...@@ -281,6 +285,15 @@
name = Search; name = Search;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
96A71F331C73959100C0C4AE /* CollectionView */ = {
isa = PBXGroup;
children = (
96A71F361C73967E00C0C4AE /* MaterialPulseCollectionViewCell.swift */,
96A71F341C7395C200C0C4AE /* MaterialCollectionViewCell.swift */,
);
name = CollectionView;
sourceTree = "<group>";
};
96D88BF41C1328D800B91418 /* Sources */ = { 96D88BF41C1328D800B91418 /* Sources */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -302,6 +315,7 @@ ...@@ -302,6 +315,7 @@
96D88C471C1328F500B91418 /* Font */, 96D88C471C1328F500B91418 /* Font */,
966F57B61C226D65009185B7 /* Text */, 966F57B61C226D65009185B7 /* Text */,
96442ADC1C28EF1400C3C574 /* TableView */, 96442ADC1C28EF1400C3C574 /* TableView */,
96A71F331C73959100C0C4AE /* CollectionView */,
965C58BD1C6B8D3300CFB4E1 /* Grid */, 965C58BD1C6B8D3300CFB4E1 /* Grid */,
96A71E921C6FBC2900C0C4AE /* Menu */, 96A71E921C6FBC2900C0C4AE /* Menu */,
96A71EC51C6FFEF300C0C4AE /* Switch */, 96A71EC51C6FFEF300C0C4AE /* Switch */,
...@@ -624,6 +638,7 @@ ...@@ -624,6 +638,7 @@
96D88C2B1C1328D800B91418 /* MaterialButton.swift in Sources */, 96D88C2B1C1328D800B91418 /* MaterialButton.swift in Sources */,
96D88C311C1328D800B91418 /* MaterialKeyframeAnimation.swift in Sources */, 96D88C311C1328D800B91418 /* MaterialKeyframeAnimation.swift in Sources */,
96D88C2E1C1328D800B91418 /* MaterialFont.swift in Sources */, 96D88C2E1C1328D800B91418 /* MaterialFont.swift in Sources */,
96A71F371C73967E00C0C4AE /* MaterialPulseCollectionViewCell.swift in Sources */,
9656CD0C1C6BD33700EBCEF1 /* Grid.swift in Sources */, 9656CD0C1C6BD33700EBCEF1 /* Grid.swift in Sources */,
960B23461C38480E00E96216 /* Text.swift in Sources */, 960B23461C38480E00E96216 /* Text.swift in Sources */,
96D88C351C1328D800B91418 /* MaterialLayout.swift in Sources */, 96D88C351C1328D800B91418 /* MaterialLayout.swift in Sources */,
...@@ -661,6 +676,7 @@ ...@@ -661,6 +676,7 @@
96D88C381C1328D800B91418 /* MaterialShape.swift in Sources */, 96D88C381C1328D800B91418 /* MaterialShape.swift in Sources */,
960B23331C383EAA00E96216 /* Material+UIImage+Size.swift in Sources */, 960B23331C383EAA00E96216 /* Material+UIImage+Size.swift in Sources */,
96A71E911C6FBC2200C0C4AE /* MenuView.swift in Sources */, 96A71E911C6FBC2200C0C4AE /* MenuView.swift in Sources */,
96A71F351C7395C200C0C4AE /* MaterialCollectionViewCell.swift in Sources */,
96D88C271C1328D800B91418 /* Material+UIFont.swift in Sources */, 96D88C271C1328D800B91418 /* Material+UIFont.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
......
///*
//* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
//* All rights reserved.
//*
//* Redistribution and use in source and binary forms, with or without
//* modification, are permitted provided that the following conditions are met:
//*
//* * Redistributions of source code must retain the above copyright notice, this
//* list of conditions and the following disclaimer.
//*
//* * Redistributions in binary form must reproduce the above copyright notice,
//* this list of conditions and the following disclaimer in the documentation
//* and/or other materials provided with the distribution.
//*
//* * Neither the name of Material nor the names of its
//* contributors may be used to endorse or promote products derived from
//* this software without specific prior written permission.
//*
//* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
//* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
//* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
//* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
//* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
//* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//*/
//
//import UIKit
//
//@objc(floatingViewControllerCollectionViewCellDelegate)
//public protocol MaterialCollectionViewCellDelegate : MaterialDelegate {
// optional func collectionViewCellWillPassThresholdForLeftLayer(cell: MaterialCollectionViewCell)
// optional func collectionViewCellWillPassThresholdForRightLayer(cell: MaterialCollectionViewCell)
// optional func collectionViewCellDidRevealLeftLayer(cell: MaterialCollectionViewCell)
// optional func collectionViewCellDidRevealRightLayer(cell: MaterialCollectionViewCell)
// optional func collectionViewCellDidCloseLeftLayer(cell: MaterialCollectionViewCell)
// optional func collectionViewCellDidCloseRightLayer(cell: MaterialCollectionViewCell)
//}
//
//@objc(MaterialCollectionViewCell)
//public class MaterialCollectionViewCell : MaterialPulseCollectionViewCell, UIGestureRecognizerDelegate {
// //
// // :name: panRecognizer
// //
// private var panRecognizer: UIPanGestureRecognizer!
//
// //
// // :name: originalPosition
// //
// private var originalPosition: CGPoint!
//
// //
// // :name: leftOnDragRelease
// //
// private lazy var leftOnDragRelease: Bool = false
//
// //
// // :name: rightOnDragRelease
// //
// private lazy var rightOnDragRelease: Bool = false
//
// /**
// :name: leftView
// */
// public private(set) lazy var leftView: MaterialView = MaterialView()
//
// /**
// :name: rightView
// */
// public private(set) lazy var rightView: MaterialView = MaterialView()
//
// /**
// :name: revealed
// */
// public private(set) lazy var revealed: Bool = false
//
// /**
// :name: closeAutomatically
// */
// public lazy var closeAutomatically: Bool = true
//
// /**
// :name: gestureRecognizerShouldBegin
// */
// public override func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
// if let panGestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer {
// let translation = panGestureRecognizer.translationInView(superview!)
// return fabs(translation.x) > fabs(translation.y)
// }
// return false
// }
//
// /**
// :name: prepareView
// */
// public override func prepareView() {
// super.prepareView()
//
// userInteractionEnabled = MaterialTheme.pulseCollectionView.userInteractionEnabled
// backgroundColor = MaterialTheme.pulseCollectionView.backgroundColor
// pulseColorOpacity = MaterialTheme.pulseCollectionView.pulseColorOpacity
// pulseColor = MaterialTheme.pulseCollectionView.pulseColor
//
// depth = MaterialTheme.pulseCollectionView.depth
// shadowColor = MaterialTheme.pulseCollectionView.shadowColor
// zPosition = MaterialTheme.pulseCollectionView.zPosition
// borderWidth = MaterialTheme.pulseCollectionView.borderWidth
// borderColor = MaterialTheme.pulseCollectionView.bordercolor
// masksToBounds = true
//
// prepareLeftView()
// prepareRightView()
// preparePanGesture()
// }
//
// /**
// :name: animationDidStop
// */
// public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
// super.animationDidStop(anim, finished: flag)
//
// if let a: CABasicAnimation = anim as? CABasicAnimation {
// if "position" == a.keyPath {
// masksToBounds = true
// if leftOnDragRelease {
// (delegate as? MaterialCollectionViewCellDelegate)?.collectionViewCellDidCloseLeftLayer?(self)
// } else if rightOnDragRelease {
// (delegate as? MaterialCollectionViewCellDelegate)?.collectionViewCellDidCloseRightLayer?(self)
// }
// }
// }
// }
//
// /**
// :name: open
// */
// public func open() {
// animate(MaterialAnimation.position(CGPointMake(width * 1.5, y + height / 2), duration: 0.25))
// }
//
// /**
// :name: close
// */
// public func close() {
// animate(MaterialAnimation.position(CGPointMake(width / 2, y + height / 2), duration: 0.25))
// }
//
// //
// // :name: prepareLeftView
// //
// internal func prepareLeftView() {
// leftView.frame = CGRectMake(-width, 0, width, height)
// addSubview(leftView)
// }
//
// //
// // :name: prepareRightView
// //
// internal func prepareRightView() {
// rightView.frame = CGRectMake(width, 0, width, height)
// addSubview(rightView)
// }
//
// //
// // :name: preparePanGesture
// //
// internal func preparePanGesture() {
// panRecognizer = UIPanGestureRecognizer(target: self, action: "handlePanGesture:")
// panRecognizer.delegate = self
// addGestureRecognizer(panRecognizer)
// }
//
// //
// // :name: handlePanGesture
// //
// internal func handlePanGesture(recognizer: UIPanGestureRecognizer) {
// switch recognizer.state {
// case .Began:
// originalPosition = position
// masksToBounds = false
// leftOnDragRelease = x > width / 2
// rightOnDragRelease = x < -width / 2
//
// case .Changed:
// let translation = recognizer.translationInView(self)
// MaterialAnimation.animationDisabled {
// self.position.x = self.originalPosition.x + translation.x
// }
//
// leftOnDragRelease = x > width / 2
// rightOnDragRelease = x < -width / 2
//
// if !revealed && (leftOnDragRelease || rightOnDragRelease) {
// revealed = true
// if leftOnDragRelease {
// (delegate as? MaterialCollectionViewCellDelegate)?.collectionViewCellWillPassThresholdForLeftLayer?(self)
// } else if rightOnDragRelease {
// (delegate as? MaterialCollectionViewCellDelegate)?.collectionViewCellWillPassThresholdForRightLayer?(self)
// }
// }
// case .Ended:
// revealed = false
//
// if leftOnDragRelease {
// (delegate as? MaterialCollectionViewCellDelegate)?.collectionViewCellDidRevealLeftLayer?(self)
// } else if rightOnDragRelease {
// (delegate as? MaterialCollectionViewCellDelegate)?.collectionViewCellDidRevealRightLayer?(self)
// }
//
// if !leftOnDragRelease && !rightOnDragRelease {
// close()
// } else if closeAutomatically && (leftOnDragRelease || rightOnDragRelease) {
// close()
// }
// default:break
// }
// }
//}
\ No newline at end of file
...@@ -251,7 +251,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -251,7 +251,7 @@ public class MaterialLayer : CAShapeLayer {
public func animate(animation: CAAnimation) { public func animate(animation: CAAnimation) {
animation.delegate = self animation.delegate = self
if let a: CABasicAnimation = animation as? CABasicAnimation { if let a: CABasicAnimation = animation as? CABasicAnimation {
a.fromValue = valueForKeyPath(a.keyPath!) a.fromValue = (nil == presentationLayer() ? self : presentationLayer() as! CALayer).valueForKeyPath(a.keyPath!)
} }
if let a: CAPropertyAnimation = animation as? CAPropertyAnimation { if let a: CAPropertyAnimation = animation as? CAPropertyAnimation {
addAnimation(a, forKey: a.keyPath!) addAnimation(a, forKey: a.keyPath!)
...@@ -287,7 +287,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -287,7 +287,7 @@ public class MaterialLayer : CAShapeLayer {
} }
} }
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag) (delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
removeAnimationForKey(a.keyPath!) // removeAnimationForKey(a.keyPath!)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup { } else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! { for x in a.animations! {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
......
...@@ -152,7 +152,7 @@ public class MaterialSwitch: UIControl { ...@@ -152,7 +152,7 @@ public class MaterialSwitch: UIControl {
public var trackOffDisabledColor: UIColor = MaterialColor.clear public var trackOffDisabledColor: UIColor = MaterialColor.clear
/// Track view reference. /// Track view reference.
public private(set) var track: MaterialView { public private(set) var trackLayer: MaterialLayer {
didSet { didSet {
prepareTrack() prepareTrack()
} }
...@@ -231,7 +231,7 @@ public class MaterialSwitch: UIControl { ...@@ -231,7 +231,7 @@ public class MaterialSwitch: UIControl {
- Parameter aDecoder: A NSCoder instance. - Parameter aDecoder: A NSCoder instance.
*/ */
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
track = MaterialView(frame: CGRectZero) trackLayer = MaterialLayer(frame: CGRectZero)
button = FabButton(frame: CGRectZero) button = FabButton(frame: CGRectZero)
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareTrack() prepareTrack()
...@@ -248,7 +248,7 @@ public class MaterialSwitch: UIControl { ...@@ -248,7 +248,7 @@ public class MaterialSwitch: UIControl {
- Parameter size: A MaterialSwitchSize value. - Parameter size: A MaterialSwitchSize value.
*/ */
public init(state: MaterialSwitchState = .Off, style: MaterialSwitchStyle = .Default, size: MaterialSwitchSize = .Default) { public init(state: MaterialSwitchState = .Off, style: MaterialSwitchStyle = .Default, size: MaterialSwitchSize = .Default) {
track = MaterialView(frame: CGRectZero) trackLayer = MaterialLayer(frame: CGRectZero)
button = FabButton(frame: CGRectZero) button = FabButton(frame: CGRectZero)
super.init(frame: CGRectZero) super.init(frame: CGRectZero)
prepareTrack() prepareTrack()
...@@ -368,9 +368,16 @@ public class MaterialSwitch: UIControl { ...@@ -368,9 +368,16 @@ public class MaterialSwitch: UIControl {
} }
} }
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
if true == CGRectContainsPoint(trackLayer.frame, layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)) {
setSwitchState(.On == switchState ? .Off : .On)
}
}
/// Prepares the track. /// Prepares the track.
private func prepareTrack() { private func prepareTrack() {
addSubview(track) layer.addSublayer(trackLayer)
} }
/// Prepares the button. /// Prepares the button.
...@@ -429,10 +436,10 @@ public class MaterialSwitch: UIControl { ...@@ -429,10 +436,10 @@ public class MaterialSwitch: UIControl {
private func updateColorForEnabledState(state: MaterialSwitchState) { private func updateColorForEnabledState(state: MaterialSwitchState) {
if .On == state { if .On == state {
button.backgroundColor = buttonOnColor button.backgroundColor = buttonOnColor
track.backgroundColor = trackOnColor trackLayer.backgroundColor = trackOnColor.CGColor
} else { } else {
button.backgroundColor = buttonOffColor button.backgroundColor = buttonOffColor
track.backgroundColor = trackOffColor trackLayer.backgroundColor = trackOffColor.CGColor
} }
} }
...@@ -443,10 +450,10 @@ public class MaterialSwitch: UIControl { ...@@ -443,10 +450,10 @@ public class MaterialSwitch: UIControl {
private func updateColorForDisabledState(state: MaterialSwitchState) { private func updateColorForDisabledState(state: MaterialSwitchState) {
if .On == state { if .On == state {
button.backgroundColor = buttonOnDisabledColor button.backgroundColor = buttonOnDisabledColor
track.backgroundColor = trackOnDisabledColor trackLayer.backgroundColor = trackOnDisabledColor.CGColor
} else { } else {
button.backgroundColor = buttonOffDisabledColor button.backgroundColor = buttonOffDisabledColor
track.backgroundColor = trackOffDisabledColor trackLayer.backgroundColor = trackOffDisabledColor.CGColor
} }
} }
...@@ -464,8 +471,8 @@ public class MaterialSwitch: UIControl { ...@@ -464,8 +471,8 @@ public class MaterialSwitch: UIControl {
let px: CGFloat = (width - w) / 2 let px: CGFloat = (width - w) / 2
track.frame = CGRectMake(px, (height - trackThickness) / 2, w, trackThickness) trackLayer.frame = CGRectMake(px, (height - trackThickness) / 2, w, trackThickness)
track.cornerRadius = min(track.height, track.width) / 2 trackLayer.cornerRadius = min(trackLayer.height, trackLayer.width) / 2
button.frame = CGRectMake(px, (height - buttonDiameter) / 2, buttonDiameter, buttonDiameter) button.frame = CGRectMake(px, (height - buttonDiameter) / 2, buttonDiameter, buttonDiameter)
onPosition = width - px - buttonDiameter onPosition = width - px - buttonDiameter
......
...@@ -30,6 +30,11 @@ ...@@ -30,6 +30,11 @@
import UIKit import UIKit
@objc(NavigationBarViewDelegate)
public protocol NavigationBarViewDelegate : MaterialDelegate {
optional func navigationBarViewLayoutChanged(navigationBarView: NavigationBarView)
}
public class NavigationBarView : MaterialView { public class NavigationBarView : MaterialView {
/// TitleView that holds the titleLabel and detailLabel. /// TitleView that holds the titleLabel and detailLabel.
public private(set) lazy var titleView: MaterialView = MaterialView() public private(set) lazy var titleView: MaterialView = MaterialView()
...@@ -145,6 +150,7 @@ public class NavigationBarView : MaterialView { ...@@ -145,6 +150,7 @@ public class NavigationBarView : MaterialView {
// Column adjustment. // Column adjustment.
width = UIScreen.mainScreen().bounds.width width = UIScreen.mainScreen().bounds.width
grid.axis.columns = Int(width / 48) grid.axis.columns = Int(width / 48)
(delegate as? NavigationBarViewDelegate)?.navigationBarViewLayoutChanged?(self)
reloadView() reloadView()
} }
......
...@@ -128,14 +128,13 @@ public class NavigationViewController: UIViewController { ...@@ -128,14 +128,13 @@ public class NavigationViewController: UIViewController {
/// Prepares the NavigationBarView. /// Prepares the NavigationBarView.
private func prepareNavigationBarView() { private func prepareNavigationBarView() {
navigationBarView.delegate = self
view.addSubview(navigationBarView) view.addSubview(navigationBarView)
} }
/// A method that prepares the mainViewController. /// A method that prepares the mainViewController.
private func prepareMainViewController() { private func prepareMainViewController() {
prepareViewControllerWithinContainer(mainViewController, container: view) prepareViewControllerWithinContainer(mainViewController, container: view)
mainViewController.view.frame = CGRectMake(0, navigationBarView.height, view.bounds.width, view.bounds.height - navigationBarView.height)
mainViewController.view.frame.origin.y = navigationBarView.height
} }
/** /**
...@@ -156,6 +155,14 @@ public class NavigationViewController: UIViewController { ...@@ -156,6 +155,14 @@ public class NavigationViewController: UIViewController {
/// Layout subviews. /// Layout subviews.
private func layoutSubviews() { private func layoutSubviews() {
let size: CGSize = UIScreen.mainScreen().bounds.size
mainViewController.view.frame = CGRectMake(0, navigationBarView.height, size.width, size.height - navigationBarView.height)
}
}
extension NavigationViewController : NavigationBarViewDelegate {
/// Monitor layout changes.
public func navigationBarViewLayoutChanged(navigationBarView: NavigationBarView) {
layoutSubviews()
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment