Commit 0d4cf2d2 by Daniel Dahan

prepare for release

parent 4e5e7bcc
......@@ -49,25 +49,25 @@ class ViewController: UIViewController {
/// Prepare bottomNavigationBar.
private func prepareBottomNavigationBar() {
bottomNavigationBar = BottomNavigationBar()
// bottomNavigationBar.autoLayoutToSuperview // Set to false if you want to handle the layout yourself.
bottomNavigationBar.backgroundColor = MaterialColor.grey.darken4
view.addSubview(bottomNavigationBar)
let videoItem: BottomNavigationBarItem = BottomNavigationBarItem(title: "Video", image: MaterialIcon.videocam, selectedImage: nil)
let videoItem: UITabBarItem = UITabBarItem(title: "Video", image: MaterialIcon.videocam, selectedImage: nil)
videoItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
videoItem.setTitleColor(MaterialColor.teal.base, forState: .Selected)
let photoItem: BottomNavigationBarItem = BottomNavigationBarItem(title: "Photo", image: MaterialIcon.photoCamera, selectedImage: nil)
let photoItem: UITabBarItem = UITabBarItem(title: "Photo", image: MaterialIcon.photoCamera, selectedImage: nil)
photoItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
photoItem.setTitleColor(MaterialColor.teal.base, forState: .Selected)
let libraryItem: BottomNavigationBarItem = BottomNavigationBarItem(title: "Library", image: MaterialIcon.photoLibrary, selectedImage: nil)
let libraryItem: UITabBarItem = UITabBarItem(title: "Library", image: MaterialIcon.photoLibrary, selectedImage: nil)
libraryItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
libraryItem.setTitleColor(MaterialColor.teal.base, forState: .Selected)
bottomNavigationBar.setItems([videoItem, photoItem, libraryItem], animated: true)
bottomNavigationBar.tintColor = MaterialColor.teal.base // Sets the image color when highlighted.
bottomNavigationBar.itemPositioning = .Automatic // Sets the alignment of the BottomNavigationBarItems.
bottomNavigationBar.itemPositioning = .Automatic // Sets the alignment of the UITabBarItems.
bottomNavigationBar.selectedItem = videoItem
}
}
......@@ -19,11 +19,7 @@
<subviews>
<tabBar contentMode="scaleToFill" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sMP-AS-Zl9" customClass="BottomNavigationBar" customModule="Material">
<rect key="frame" x="0.0" y="551" width="600" height="49"/>
<items>
<tabBarItem title="Video" id="BkO-Yq-m1c" customClass="BottomNavigationBarItem" customModule="Material"/>
<tabBarItem title="Photo" id="vsG-AI-jYq" customClass="BottomNavigationBarItem" customModule="Material"/>
<tabBarItem title="Library" id="3fX-Ej-FRM" customClass="BottomNavigationBarItem" customModule="Material"/>
</items>
<items/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="backgroundColor">
<color key="value" red="0.12941176470588234" green="0.12941176470588234" blue="0.12941176470588234" alpha="1" colorSpace="calibratedRGB"/>
......@@ -40,9 +36,6 @@
</view>
<connections>
<outlet property="bottomNavigationBar" destination="sMP-AS-Zl9" id="sTP-Ix-Cds"/>
<outlet property="libraryItem" destination="3fX-Ej-FRM" id="Qxm-2T-kNf"/>
<outlet property="photoItem" destination="vsG-AI-jYq" id="6Ib-WG-Aed"/>
<outlet property="videoItem" destination="BkO-Yq-m1c" id="SLg-YG-4qI"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
......
......@@ -34,25 +34,24 @@ import Material
class ViewController: UIViewController {
@IBOutlet weak var bottomNavigationBar: BottomNavigationBar!
@IBOutlet weak var videoItem: BottomNavigationBarItem!
@IBOutlet weak var photoItem: BottomNavigationBarItem!
@IBOutlet weak var libraryItem: BottomNavigationBarItem!
override func viewDidLoad() {
super.viewDidLoad()
videoItem.image = MaterialIcon.videocam
let videoItem: UITabBarItem = UITabBarItem(title: "Video", image: MaterialIcon.videocam, selectedImage: nil)
videoItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
videoItem.setTitleColor(MaterialColor.teal.base, forState: .Selected)
photoItem.image = MaterialIcon.photoCamera
let photoItem: UITabBarItem = UITabBarItem(title: "Photo", image: MaterialIcon.photoCamera, selectedImage: nil)
photoItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
photoItem.setTitleColor(MaterialColor.teal.base, forState: .Selected)
libraryItem.image = MaterialIcon.photoLibrary
let libraryItem: UITabBarItem = UITabBarItem(title: "Library", image: MaterialIcon.photoLibrary, selectedImage: nil)
libraryItem.setTitleColor(MaterialColor.grey.base, forState: .Normal)
libraryItem.setTitleColor(MaterialColor.teal.base, forState: .Selected)
bottomNavigationBar.setItems([videoItem, photoItem, libraryItem], animated: true)
bottomNavigationBar.tintColor = MaterialColor.teal.base // Sets the image color when highlighted.
bottomNavigationBar.itemPositioning = .Automatic // Sets the alignment of the UITabBarItems.
bottomNavigationBar.selectedItem = videoItem
}
......
......@@ -30,7 +30,6 @@
96162BFB1CA6E89F00E3A235 /* MaterialPulseAnimation.swift in Headers */ = {isa = PBXBuildFile; fileRef = 968F17211C94B10B008CA3F6 /* MaterialPulseAnimation.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96162BFC1CA6E89F00E3A235 /* NavigationItem.swift in Headers */ = {isa = PBXBuildFile; fileRef = 967887861C9775900037F6C9 /* NavigationItem.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96162BFD1CA6E89F00E3A235 /* BottomNavigationBar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96A536641CA3A2C80069B3CC /* BottomNavigationBar.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96162BFE1CA6E89F00E3A235 /* BottomNavigationBarItem.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BAECE71CA3B4620048037C /* BottomNavigationBarItem.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96162BFF1CA6E89F00E3A235 /* BottomNavigationController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BAECE91CA3B8B90048037C /* BottomNavigationController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9626C2DE1C795017007CA8E0 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626C2DD1C795017007CA8E0 /* MenuViewController.swift */; };
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
......@@ -76,7 +75,6 @@
96A71F451C74ABCB00C0C4AE /* MaterialBorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F441C74ABCB00C0C4AE /* MaterialBorder.swift */; };
96A71FB31C764E3200C0C4AE /* StatusBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FB21C764E3200C0C4AE /* StatusBarView.swift */; };
96A71FB61C7651AA00C0C4AE /* ControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FB01C7649F800C0C4AE /* ControlView.swift */; };
96BAECE81CA3B4620048037C /* BottomNavigationBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BAECE71CA3B4620048037C /* BottomNavigationBarItem.swift */; };
96BAECEA1CA3B8B90048037C /* BottomNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BAECE91CA3B8B90048037C /* BottomNavigationController.swift */; };
96BE340F1C8E68EF007D02BE /* MaterialIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BE340E1C8E68EF007D02BE /* MaterialIcon.swift */; };
96CC08311C7CCB7C0034FF84 /* MaterialBorder.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96A71F441C74ABCB00C0C4AE /* MaterialBorder.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -209,7 +207,6 @@
96A71F441C74ABCB00C0C4AE /* MaterialBorder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialBorder.swift; sourceTree = "<group>"; };
96A71FB01C7649F800C0C4AE /* ControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlView.swift; sourceTree = "<group>"; };
96A71FB21C764E3200C0C4AE /* StatusBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarView.swift; sourceTree = "<group>"; };
96BAECE71CA3B4620048037C /* BottomNavigationBarItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomNavigationBarItem.swift; sourceTree = "<group>"; };
96BAECE91CA3B8B90048037C /* BottomNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomNavigationController.swift; sourceTree = "<group>"; };
96BE340E1C8E68EF007D02BE /* MaterialIcon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialIcon.swift; sourceTree = "<group>"; };
96CC083C1C7CF9D40034FF84 /* StatusBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarViewController.swift; sourceTree = "<group>"; };
......@@ -364,7 +361,6 @@
isa = PBXGroup;
children = (
96A536641CA3A2C80069B3CC /* BottomNavigationBar.swift */,
96BAECE71CA3B4620048037C /* BottomNavigationBarItem.swift */,
96BAECE91CA3B8B90048037C /* BottomNavigationController.swift */,
);
name = BottomNavigation;
......@@ -688,7 +684,6 @@
96162BFB1CA6E89F00E3A235 /* MaterialPulseAnimation.swift in Headers */,
96162BFC1CA6E89F00E3A235 /* NavigationItem.swift in Headers */,
96162BFD1CA6E89F00E3A235 /* BottomNavigationBar.swift in Headers */,
96162BFE1CA6E89F00E3A235 /* BottomNavigationBarItem.swift in Headers */,
96162BFF1CA6E89F00E3A235 /* BottomNavigationController.swift in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -799,7 +794,6 @@
files = (
96BAECEA1CA3B8B90048037C /* BottomNavigationController.swift in Sources */,
968F16F61C9260EC008CA3F6 /* Toolbar.swift in Sources */,
96BAECE81CA3B4620048037C /* BottomNavigationBarItem.swift in Sources */,
96D88C3D1C1328D800B91418 /* MaterialView.swift in Sources */,
960B23481C38480E00E96216 /* TextView.swift in Sources */,
96D88C291C1328D800B91418 /* MaterialBasicAnimation.swift in Sources */,
......
......@@ -359,8 +359,8 @@ Add a new dimension of interactivity with CaptureView. CaptureView is a fully fu
# Upcoming
* TabView
* TabViewController
* TabBar
* TabBarController
* Scrolling Techniques
* Snackbar
* Advanced Camera / Audio Toolset & Views
......
......@@ -30,8 +30,18 @@
import UIKit
public extension UITabBarItem {
/// Sets the color of the title color for a state.
public func setTitleColor(color: UIColor, forState state: UIControlState) {
setTitleTextAttributes([NSForegroundColorAttributeName: color], forState: state)
}
}
@IBDesignable
public class BottomNavigationBar : UITabBar {
/// Automatically aligns the BottomNavigationBar to the superview.
public var autoLayoutToSuperview: Bool = true
/**
This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. If an image is set using
......@@ -197,17 +207,35 @@ public class BottomNavigationBar : UITabBar {
super.layoutSubviews()
if let v: Array<UITabBarItem> = items {
for item in v {
if nil == item.title {
item.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0)
if .iPhone == MaterialDevice.type {
if nil == item.title {
let inset: CGFloat = 7
item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0)
} else {
let inset: CGFloat = 6
item.titlePositionAdjustment.vertical = -inset
}
} else {
item.titlePositionAdjustment.vertical = -5
if nil == item.title {
let inset: CGFloat = 9
item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0)
} else {
let inset: CGFloat = 3
item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0)
item.titlePositionAdjustment.vertical = -inset
}
}
}
}
if translatesAutoresizingMaskIntoConstraints {
}
public override func didMoveToSuperview() {
super.didMoveToSuperview()
if autoLayoutToSuperview && translatesAutoresizingMaskIntoConstraints {
if let v: UIView = superview {
let h: CGFloat = intrinsicContentSize().height
frame = CGRectMake(0, v.bounds.height - h, v.bounds.width, h)
translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottom(v, child: self)
MaterialLayout.alignToParentHorizontally(v, child: self)
}
}
}
......@@ -229,9 +257,9 @@ public class BottomNavigationBar : UITabBar {
}
/// A memory reference to the TabBarItem instance.
private var TabBarKey: UInt8 = 0
private var MaterialAssociatedObjectTabBarKey: UInt8 = 0
public class TabBar {
public class MaterialAssociatedObjectTabBar {
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
......@@ -246,14 +274,14 @@ public class TabBar {
public extension UITabBar {
/// TabBarItem reference.
public internal(set) var item: TabBar {
public internal(set) var item: MaterialAssociatedObjectTabBar {
get {
return MaterialAssociatedObject(self, key: &TabBarKey) {
return TabBar(depth: .None)
return MaterialAssociatedObject(self, key: &MaterialAssociatedObjectTabBarKey) {
return MaterialAssociatedObjectTabBar(depth: .None)
}
}
set(value) {
MaterialAssociateObject(self, key: &TabBarKey, value: value)
MaterialAssociateObject(self, key: &MaterialAssociatedObjectTabBarKey, value: value)
}
}
......
/*
* 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
public extension UITabBarItem {
/// Sets the color of the title color for a state.
public func setTitleColor(color: UIColor, forState state: UIControlState) {
setTitleTextAttributes([NSForegroundColorAttributeName: color], forState: state)
}
}
@IBDesignable
public class BottomNavigationBarItem : UITabBarItem {}
......@@ -93,10 +93,23 @@ public class BottomNavigationController : UITabBarController, UITabBarController
public func layoutSubviews() {
if let v: Array<UITabBarItem> = tabBar.items {
for item in v {
if nil == item.title {
item.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0)
if .iPhone == MaterialDevice.type {
if nil == item.title {
let inset: CGFloat = 7
item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0)
} else {
let inset: CGFloat = 6
item.titlePositionAdjustment.vertical = -inset
}
} else {
item.titlePositionAdjustment.vertical = -5
if nil == item.title {
let inset: CGFloat = 9
item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0)
} else {
let inset: CGFloat = 3
item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0)
item.titlePositionAdjustment.vertical = -inset
}
}
}
}
......
......@@ -31,9 +31,9 @@
import UIKit
/// A memory reference to the NavigationItem instance.
private var NavigationItemKey: UInt8 = 0
private var MaterialAssociatedObjectNavigationItemKey: UInt8 = 0
public class NavigationItem {
public class MaterialAssociatedObjectNavigationItem {
/// Portrait inset.
public var portraitInset: CGFloat
......@@ -63,14 +63,14 @@ public class NavigationItem {
public extension UINavigationItem {
/// NavigationItem reference.
public internal(set) var item: NavigationItem {
public internal(set) var item: MaterialAssociatedObjectNavigationItem {
get {
return MaterialAssociatedObject(self, key: &NavigationItemKey) {
return NavigationItem(portraitInset: .iPad == MaterialDevice.type || "iPhone 6s Plus" == MaterialDevice.model || "iPhone 6 Plus" == MaterialDevice.model ? -20 : -16, landscapeInset: -20)
return MaterialAssociatedObject(self, key: &MaterialAssociatedObjectNavigationItemKey) {
return MaterialAssociatedObjectNavigationItem(portraitInset: .iPad == MaterialDevice.type || "iPhone 6s Plus" == MaterialDevice.model || "iPhone 6 Plus" == MaterialDevice.model ? -20 : -16, landscapeInset: -20)
}
}
set(value) {
MaterialAssociateObject(self, key: &NavigationItemKey, value: value)
MaterialAssociateObject(self, key: &MaterialAssociatedObjectNavigationItemKey, value: value)
}
}
......
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