Commit 4494ebad by Daniel Dahan

working SearchBarView and NavigationBarView with grid

parent 74fe8155
......@@ -89,6 +89,13 @@
</Group>
<Group
location = "container:"
name = "SearchBarView">
<FileRef
location = "group:Programmatic/SearchBarView/SearchBarView.xcodeproj">
</FileRef>
</Group>
<Group
location = "container:"
name = "SideNavigationViewController">
<FileRef
location = "group:Programmatic/SideNavigationViewController/SideNavigationViewController.xcodeproj">
......
......@@ -65,7 +65,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
......@@ -36,13 +36,9 @@ import UIKit
import Material
class ViewController: UIViewController, MaterialSwitchDelegate {
/// Reference for NavigationBarView.
private var searchBarView: SearchBarView = SearchBarView(frame: CGRectNull)
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareSearchBarView()
prepareSmallMaterialSwitch()
prepareNormalMaterialSwitch()
prepareLargeMaterialSwitch()
......@@ -57,56 +53,23 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
view.backgroundColor = MaterialColor.white
}
/// Prepare navigationBarView.
private func prepareSearchBarView() {
searchBarView.statusBarStyle = .LightContent
searchBarView.backgroundColor = MaterialColor.blue.base
var image = UIImage(named: "ic_close_white")
let clearButton: FlatButton = FlatButton()
clearButton.pulseColor = MaterialColor.white
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
searchBarView.clearButton = clearButton
image = UIImage(named: "ic_alarm_white")
let alarmButton: FlatButton = FlatButton()
alarmButton.pulseColor = MaterialColor.white
alarmButton.setImage(image, forState: .Normal)
alarmButton.setImage(image, forState: .Highlighted)
searchBarView.placeholder = "Search"
searchBarView.tintColor = MaterialColor.white
searchBarView.textColor = MaterialColor.white
searchBarView.placeholderTextColor = MaterialColor.white
searchBarView.rightControls = [alarmButton]
view.addSubview(searchBarView)
searchBarView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.height(view, child: searchBarView, height: 70)
MaterialLayout.alignFromTop(view, child: searchBarView)
MaterialLayout.alignToParentHorizontally(view, child: searchBarView)
}
/// Prepares the Small MaterialSwitch.
private func prepareSmallMaterialSwitch() {
let materialSwitch: MaterialSwitch = MaterialSwitch(state: .Off, style: .Light, size: .Small)
materialSwitch.center = view.center
materialSwitch.y -= 100
materialSwitch.delegate = self
searchBarView.leftControls = [materialSwitch]
view.addSubview(materialSwitch)
}
/// Prepares the Normal MaterialSwitch.
private func prepareNormalMaterialSwitch() {
let materialSwitch: MaterialSwitch = MaterialSwitch(state: .On, style: .Light, size: .Normal)
materialSwitch.center = view.center
materialSwitch.y -= 100
materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch)
materialSwitch.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.size(view, child: materialSwitch, width: materialSwitch.width + 100, height: materialSwitch.height + 100)
MaterialLayout.size(view, child: materialSwitch, width: materialSwitch.width, height: materialSwitch.height)
MaterialLayout.alignFromBottomRight(view, child: materialSwitch, bottom: 16, right: 16)
}
......@@ -119,7 +82,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.delegate = self
materialSwitch.button.setImage(image, forState: .Normal)
materialSwitch.button.setImage(image, forState: .Highlighted)
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch)
}
......@@ -129,7 +91,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.enabled = false
materialSwitch.center = view.center
materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch)
}
......@@ -140,7 +101,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.center = view.center
materialSwitch.y += 50
materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch)
}
......@@ -151,7 +111,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.center = view.center
materialSwitch.y += 100
materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch)
}
......@@ -162,7 +121,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.center = view.center
materialSwitch.y += 150
materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch)
}
......
......@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
96A71EF91C7182F100C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71EF81C7182F100C0C4AE /* Material.framework */; };
96A71EFA1C7182F100C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71EF81C7182F100C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96D88C831C132C1800B91418 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C821C132C1800B91418 /* AppDelegate.swift */; };
96D88C851C132C1800B91418 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C841C132C1800B91418 /* ViewController.swift */; };
96D88C8A1C132C1800B91418 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96D88C891C132C1800B91418 /* Assets.xcassets */; };
......@@ -20,6 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96A71EFA1C7182F100C0C4AE /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
96A71EF81C7182F100C0C4AE /* 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>"; };
96D88C7F1C132C1800B91418 /* NavigationBarView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationBarView.app; sourceTree = BUILT_PRODUCTS_DIR; };
96D88C821C132C1800B91418 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96D88C841C132C1800B91418 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
......@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96A71EF91C7182F100C0C4AE /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -49,6 +54,7 @@
96D88C761C132C1800B91418 = {
isa = PBXGroup;
children = (
96A71EF81C7182F100C0C4AE /* Material.framework */,
96D88C811C132C1800B91418 /* NavigationBarView */,
96D88C801C132C1800B91418 /* Products */,
);
......
......@@ -64,7 +64,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
......@@ -223,10 +223,10 @@ class ViewController: UIViewController {
btn3.setImage(img3, forState: .Highlighted)
// Add buttons to left side.
navigationBarView.leftButtons = [btn1]
navigationBarView.leftControls = [btn1]
// Add buttons to right side.
navigationBarView.rightButtons = [btn2, btn3]
navigationBarView.rightControls = [btn2, btn3]
// To support orientation changes, use MaterialLayout.
view.addSubview(navigationBarView)
......@@ -253,18 +253,16 @@ class ViewController: UIViewController {
titleLabel.text = "Material"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20)
titleLabel.font = RobotoFont.regularWithSize(22)
navigationBarView.titleLabel = titleLabel
navigationBarView.titleLabelInset.left = 64
// Detail label.
let detailLabel: UILabel = UILabel()
detailLabel.text = "Build Beautiful Software"
detailLabel.textAlignment = .Left
detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12)
navigationBarView.detailLabel = detailLabel
navigationBarView.detailLabelInset.left = 64
detailLabel.font = RobotoFont.regularWithSize(10)
// navigationBarView.detailLabel = detailLabel
// Menu button.
let img1: UIImage? = UIImage(named: "ic_menu_white")
......@@ -275,12 +273,7 @@ class ViewController: UIViewController {
btn1.setImage(img1, forState: .Highlighted)
// Star button.
let img2: UIImage? = UIImage(named: "ic_star_white")
let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.white
btn2.pulseScale = false
btn2.setImage(img2, forState: .Normal)
btn2.setImage(img2, forState: .Highlighted)
let materialSwitch: MaterialSwitch = MaterialSwitch(state: .On, style: .Light, size: .Normal)
// Search button.
let img3: UIImage? = UIImage(named: "ic_search_white")
......@@ -291,10 +284,10 @@ class ViewController: UIViewController {
btn3.setImage(img3, forState: .Highlighted)
// Add buttons to left side.
navigationBarView.leftButtons = [btn1]
navigationBarView.leftControls = [btn1]
// Add buttons to right side.
navigationBarView.rightButtons = [btn2, btn3]
navigationBarView.rightControls = [materialSwitch, btn3]
// To support orientation changes, use MaterialLayout.
view.addSubview(navigationBarView)
......
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:SearchBarView.xcodeproj">
</FileRef>
</Workspace>
/*
* 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
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = ViewController()
window!.makeKeyAndVisible()
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Material-Icon-29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Material-Icon-29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Material-Icon-40@2x-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Material-Icon-40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Material-Icon-60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Material-Icon-60@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Material-Icon-29.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Material-Icon-29@2x-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Material-Icon-40.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Material-Icon-40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Material-Icon-76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Material-Icon-76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Material-Icon-83.5@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -2,17 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "ic_alarm_white.png",
"filename" : "ic_menu_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_alarm_white_2x.png",
"filename" : "ic_menu_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_alarm_white_3x.png",
"filename" : "ic_menu_white@3x.png",
"scale" : "3x"
}
],
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_search_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_search_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_search_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
/*
* 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.
*/
/*
The following is an example of SearchBarView.
*/
import UIKit
import Material
class ViewController: UIViewController {
/// Reference for NavigationBarView.
private var searchBarView: SearchBarView = SearchBarView(frame: CGRectNull)
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareSearchBarView()
}
/// General preparation statements.
private func prepareView() {
view.backgroundColor = MaterialColor.white
}
/// Prepare navigationBarView.
private func prepareSearchBarView() {
searchBarView.statusBarStyle = .LightContent
searchBarView.backgroundColor = MaterialColor.blue.base
var image = UIImage(named: "ic_close_white")
let clearButton: FlatButton = FlatButton()
clearButton.pulseColor = MaterialColor.white
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
searchBarView.clearButton = clearButton
image = UIImage(named: "ic_menu_white")
let menuButton: FlatButton = FlatButton()
menuButton.pulseColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted)
let materialSwitch: MaterialSwitch = MaterialSwitch(state: .On, style: .Light, size: .Normal)
image = UIImage(named: "ic_search_white")
let searchButton: FlatButton = FlatButton()
searchButton.pulseColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted)
searchBarView.placeholder = "Search"
searchBarView.tintColor = MaterialColor.white
searchBarView.textColor = MaterialColor.white
searchBarView.placeholderTextColor = MaterialColor.white
searchBarView.leftControls = [menuButton]
searchBarView.rightControls = [materialSwitch, searchButton]
view.addSubview(searchBarView)
searchBarView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.height(view, child: searchBarView, height: 70)
MaterialLayout.alignFromTop(view, child: searchBarView)
MaterialLayout.alignToParentHorizontally(view, child: searchBarView)
}
}
......@@ -368,14 +368,6 @@ public class MaterialSwitch: UIControl {
}
}
/**
Handle the TouchDown event.
- Parameter sender: A UIButton.
*/
internal func handleTouchDown(sender: UIButton) {
}
/// Prepares the track.
private func prepareTrack() {
addSubview(track)
......@@ -384,7 +376,6 @@ public class MaterialSwitch: UIControl {
/// Prepares the button.
private func prepareButton() {
button.pulseColor = nil
button.addTarget(self, action: "handleTouchDown:", forControlEvents: .TouchDown)
button.addTarget(self, action: "handleTouchUpOutsideOrCanceled:event:", forControlEvents: .TouchUpOutside)
button.addTarget(self, action: "handleTouchUpInside", forControlEvents: .TouchUpInside)
button.addTarget(self, action: "handleTouchDragInside:event:", forControlEvents: .TouchDragInside)
......
......@@ -41,6 +41,15 @@ public class SearchBarView : MaterialView {
}
}
/**
:name: contentInsets
*/
public var contentInsetPreset: MaterialEdgeInset = .None {
didSet {
contentInset = MaterialEdgeInsetToValue(contentInsetPreset)
}
}
/// Wrapper around grid.contentInset.
public var contentInset: UIEdgeInsets = UIEdgeInsetsZero {
didSet {
......@@ -174,7 +183,7 @@ public class SearchBarView : MaterialView {
let g: CGFloat = width / CGFloat(0 < grid.columns ? grid.columns : 1)
grid.views = []
textField.grid.columns = grid.columns
textField.grid.columns = grid.axis.columns
// leftControls
if let v: Array<UIControl> = leftControls {
......@@ -215,6 +224,8 @@ public class SearchBarView : MaterialView {
v.frame = CGRectMake(0, 0, textField.height, textField.height)
}
textField.grid.columns -= textField.grid.offset.columns
grid.reloadLayout()
}
......@@ -223,12 +234,13 @@ public class SearchBarView : MaterialView {
*/
public override func prepareView() {
super.prepareView()
grid.columns = 10
grid.spacing = 8
grid.contentInset.top = 28
grid.contentInset.left = 8
grid.contentInset.bottom = 8
grid.contentInset.right = 8
grid.spacing = 10
grid.axis.columns = 8
grid.axis.inherited = false
grid.contentInset.top = 25
grid.contentInset.left = 10
grid.contentInset.bottom = 10
grid.contentInset.right = 10
depth = .Depth1
prepareTextField()
}
......
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