Commit 4494ebad by Daniel Dahan

working SearchBarView and NavigationBarView with grid

parent 74fe8155
...@@ -89,6 +89,13 @@ ...@@ -89,6 +89,13 @@
</Group> </Group>
<Group <Group
location = "container:" location = "container:"
name = "SearchBarView">
<FileRef
location = "group:Programmatic/SearchBarView/SearchBarView.xcodeproj">
</FileRef>
</Group>
<Group
location = "container:"
name = "SideNavigationViewController"> name = "SideNavigationViewController">
<FileRef <FileRef
location = "group:Programmatic/SideNavigationViewController/SideNavigationViewController.xcodeproj"> location = "group:Programmatic/SideNavigationViewController/SideNavigationViewController.xcodeproj">
......
...@@ -65,7 +65,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -65,7 +65,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationWillTerminate(application: UIApplication) { func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
} }
} }
...@@ -36,13 +36,9 @@ import UIKit ...@@ -36,13 +36,9 @@ import UIKit
import Material import Material
class ViewController: UIViewController, MaterialSwitchDelegate { class ViewController: UIViewController, MaterialSwitchDelegate {
/// Reference for NavigationBarView.
private var searchBarView: SearchBarView = SearchBarView(frame: CGRectNull)
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
prepareSearchBarView()
prepareSmallMaterialSwitch() prepareSmallMaterialSwitch()
prepareNormalMaterialSwitch() prepareNormalMaterialSwitch()
prepareLargeMaterialSwitch() prepareLargeMaterialSwitch()
...@@ -57,56 +53,23 @@ class ViewController: UIViewController, MaterialSwitchDelegate { ...@@ -57,56 +53,23 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
view.backgroundColor = MaterialColor.white 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. /// Prepares the Small MaterialSwitch.
private func prepareSmallMaterialSwitch() { private func prepareSmallMaterialSwitch() {
let materialSwitch: MaterialSwitch = MaterialSwitch(state: .Off, style: .Light, size: .Small) let materialSwitch: MaterialSwitch = MaterialSwitch(state: .Off, style: .Light, size: .Small)
materialSwitch.center = view.center
materialSwitch.y -= 100
materialSwitch.delegate = self materialSwitch.delegate = self
searchBarView.leftControls = [materialSwitch] view.addSubview(materialSwitch)
} }
/// Prepares the Normal MaterialSwitch. /// Prepares the Normal MaterialSwitch.
private func prepareNormalMaterialSwitch() { private func prepareNormalMaterialSwitch() {
let materialSwitch: MaterialSwitch = MaterialSwitch(state: .On, style: .Light, size: .Normal) let materialSwitch: MaterialSwitch = MaterialSwitch(state: .On, style: .Light, size: .Normal)
materialSwitch.center = view.center
materialSwitch.y -= 100
materialSwitch.delegate = self materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch) view.addSubview(materialSwitch)
materialSwitch.translatesAutoresizingMaskIntoConstraints = false 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) MaterialLayout.alignFromBottomRight(view, child: materialSwitch, bottom: 16, right: 16)
} }
...@@ -119,7 +82,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate { ...@@ -119,7 +82,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.delegate = self materialSwitch.delegate = self
materialSwitch.button.setImage(image, forState: .Normal) materialSwitch.button.setImage(image, forState: .Normal)
materialSwitch.button.setImage(image, forState: .Highlighted) materialSwitch.button.setImage(image, forState: .Highlighted)
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch) view.addSubview(materialSwitch)
} }
...@@ -129,7 +91,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate { ...@@ -129,7 +91,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.enabled = false materialSwitch.enabled = false
materialSwitch.center = view.center materialSwitch.center = view.center
materialSwitch.delegate = self materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch) view.addSubview(materialSwitch)
} }
...@@ -140,7 +101,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate { ...@@ -140,7 +101,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.center = view.center materialSwitch.center = view.center
materialSwitch.y += 50 materialSwitch.y += 50
materialSwitch.delegate = self materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch) view.addSubview(materialSwitch)
} }
...@@ -151,7 +111,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate { ...@@ -151,7 +111,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.center = view.center materialSwitch.center = view.center
materialSwitch.y += 100 materialSwitch.y += 100
materialSwitch.delegate = self materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch) view.addSubview(materialSwitch)
} }
...@@ -162,7 +121,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate { ...@@ -162,7 +121,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
materialSwitch.center = view.center materialSwitch.center = view.center
materialSwitch.y += 150 materialSwitch.y += 150
materialSwitch.delegate = self materialSwitch.delegate = self
materialSwitch.backgroundColor = MaterialColor.green.base
view.addSubview(materialSwitch) view.addSubview(materialSwitch)
} }
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* 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 */; }; 96D88C831C132C1800B91418 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C821C132C1800B91418 /* AppDelegate.swift */; };
96D88C851C132C1800B91418 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C841C132C1800B91418 /* ViewController.swift */; }; 96D88C851C132C1800B91418 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C841C132C1800B91418 /* ViewController.swift */; };
96D88C8A1C132C1800B91418 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96D88C891C132C1800B91418 /* Assets.xcassets */; }; 96D88C8A1C132C1800B91418 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96D88C891C132C1800B91418 /* Assets.xcassets */; };
...@@ -20,6 +22,7 @@ ...@@ -20,6 +22,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96A71EFA1C7182F100C0C4AE /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -27,6 +30,7 @@ ...@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference 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; }; 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>"; }; 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>"; }; 96D88C841C132C1800B91418 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96A71EF91C7182F100C0C4AE /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
96D88C761C132C1800B91418 = { 96D88C761C132C1800B91418 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96A71EF81C7182F100C0C4AE /* Material.framework */,
96D88C811C132C1800B91418 /* NavigationBarView */, 96D88C811C132C1800B91418 /* NavigationBarView */,
96D88C801C132C1800B91418 /* Products */, 96D88C801C132C1800B91418 /* Products */,
); );
......
...@@ -64,7 +64,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -64,7 +64,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationWillTerminate(application: UIApplication) { func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
} }
} }
...@@ -223,10 +223,10 @@ class ViewController: UIViewController { ...@@ -223,10 +223,10 @@ class ViewController: UIViewController {
btn3.setImage(img3, forState: .Highlighted) btn3.setImage(img3, forState: .Highlighted)
// Add buttons to left side. // Add buttons to left side.
navigationBarView.leftButtons = [btn1] navigationBarView.leftControls = [btn1]
// Add buttons to right side. // Add buttons to right side.
navigationBarView.rightButtons = [btn2, btn3] navigationBarView.rightControls = [btn2, btn3]
// To support orientation changes, use MaterialLayout. // To support orientation changes, use MaterialLayout.
view.addSubview(navigationBarView) view.addSubview(navigationBarView)
...@@ -253,18 +253,16 @@ class ViewController: UIViewController { ...@@ -253,18 +253,16 @@ class ViewController: UIViewController {
titleLabel.text = "Material" titleLabel.text = "Material"
titleLabel.textAlignment = .Left titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20) titleLabel.font = RobotoFont.regularWithSize(22)
navigationBarView.titleLabel = titleLabel navigationBarView.titleLabel = titleLabel
navigationBarView.titleLabelInset.left = 64
// Detail label. // Detail label.
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
detailLabel.text = "Build Beautiful Software" detailLabel.text = "Build Beautiful Software"
detailLabel.textAlignment = .Left detailLabel.textAlignment = .Left
detailLabel.textColor = MaterialColor.white detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12) detailLabel.font = RobotoFont.regularWithSize(10)
navigationBarView.detailLabel = detailLabel // navigationBarView.detailLabel = detailLabel
navigationBarView.detailLabelInset.left = 64
// Menu button. // Menu button.
let img1: UIImage? = UIImage(named: "ic_menu_white") let img1: UIImage? = UIImage(named: "ic_menu_white")
...@@ -275,12 +273,7 @@ class ViewController: UIViewController { ...@@ -275,12 +273,7 @@ class ViewController: UIViewController {
btn1.setImage(img1, forState: .Highlighted) btn1.setImage(img1, forState: .Highlighted)
// Star button. // Star button.
let img2: UIImage? = UIImage(named: "ic_star_white") let materialSwitch: MaterialSwitch = MaterialSwitch(state: .On, style: .Light, size: .Normal)
let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.white
btn2.pulseScale = false
btn2.setImage(img2, forState: .Normal)
btn2.setImage(img2, forState: .Highlighted)
// Search button. // Search button.
let img3: UIImage? = UIImage(named: "ic_search_white") let img3: UIImage? = UIImage(named: "ic_search_white")
...@@ -291,10 +284,10 @@ class ViewController: UIViewController { ...@@ -291,10 +284,10 @@ class ViewController: UIViewController {
btn3.setImage(img3, forState: .Highlighted) btn3.setImage(img3, forState: .Highlighted)
// Add buttons to left side. // Add buttons to left side.
navigationBarView.leftButtons = [btn1] navigationBarView.leftControls = [btn1]
// Add buttons to right side. // Add buttons to right side.
navigationBarView.rightButtons = [btn2, btn3] navigationBarView.rightControls = [materialSwitch, btn3]
// To support orientation changes, use MaterialLayout. // To support orientation changes, use MaterialLayout.
view.addSubview(navigationBarView) view.addSubview(navigationBarView)
......
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
96A71F081C718F8800C0C4AE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F071C718F8800C0C4AE /* AppDelegate.swift */; };
96A71F0A1C718F8800C0C4AE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F091C718F8800C0C4AE /* ViewController.swift */; };
96A71F0F1C718F8800C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71F0E1C718F8800C0C4AE /* Assets.xcassets */; };
96A71F121C718F8800C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71F101C718F8800C0C4AE /* LaunchScreen.storyboard */; };
96A71F1A1C71904400C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F191C71904400C0C4AE /* Material.framework */; };
96A71F1B1C71904400C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F191C71904400C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
96A71F1C1C71904400C0C4AE /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
96A71F1B1C71904400C0C4AE /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
96A71F041C718F8800C0C4AE /* SearchBarView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SearchBarView.app; sourceTree = BUILT_PRODUCTS_DIR; };
96A71F071C718F8800C0C4AE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96A71F091C718F8800C0C4AE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
96A71F0E1C718F8800C0C4AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96A71F111C718F8800C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96A71F131C718F8800C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96A71F191C71904400C0C4AE /* 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 */
/* Begin PBXFrameworksBuildPhase section */
96A71F011C718F8800C0C4AE /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96A71F1A1C71904400C0C4AE /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
96A71EFB1C718F8800C0C4AE = {
isa = PBXGroup;
children = (
96A71F191C71904400C0C4AE /* Material.framework */,
96A71F061C718F8800C0C4AE /* SearchBarView */,
96A71F051C718F8800C0C4AE /* Products */,
);
sourceTree = "<group>";
};
96A71F051C718F8800C0C4AE /* Products */ = {
isa = PBXGroup;
children = (
96A71F041C718F8800C0C4AE /* SearchBarView.app */,
);
name = Products;
sourceTree = "<group>";
};
96A71F061C718F8800C0C4AE /* SearchBarView */ = {
isa = PBXGroup;
children = (
96A71F071C718F8800C0C4AE /* AppDelegate.swift */,
96A71F091C718F8800C0C4AE /* ViewController.swift */,
96A71F0E1C718F8800C0C4AE /* Assets.xcassets */,
96A71F101C718F8800C0C4AE /* LaunchScreen.storyboard */,
96A71F131C718F8800C0C4AE /* Info.plist */,
);
path = SearchBarView;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
96A71F031C718F8800C0C4AE /* SearchBarView */ = {
isa = PBXNativeTarget;
buildConfigurationList = 96A71F161C718F8800C0C4AE /* Build configuration list for PBXNativeTarget "SearchBarView" */;
buildPhases = (
96A71F001C718F8800C0C4AE /* Sources */,
96A71F011C718F8800C0C4AE /* Frameworks */,
96A71F021C718F8800C0C4AE /* Resources */,
96A71F1C1C71904400C0C4AE /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = SearchBarView;
productName = SearchBarView;
productReference = 96A71F041C718F8800C0C4AE /* SearchBarView.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
96A71EFC1C718F8800C0C4AE /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
ORGANIZATIONNAME = "CosmicMind, Inc.";
TargetAttributes = {
96A71F031C718F8800C0C4AE = {
CreatedOnToolsVersion = 7.2;
};
};
};
buildConfigurationList = 96A71EFF1C718F8800C0C4AE /* Build configuration list for PBXProject "SearchBarView" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 96A71EFB1C718F8800C0C4AE;
productRefGroup = 96A71F051C718F8800C0C4AE /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
96A71F031C718F8800C0C4AE /* SearchBarView */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
96A71F021C718F8800C0C4AE /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
96A71F121C718F8800C0C4AE /* LaunchScreen.storyboard in Resources */,
96A71F0F1C718F8800C0C4AE /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
96A71F001C718F8800C0C4AE /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
96A71F0A1C718F8800C0C4AE /* ViewController.swift in Sources */,
96A71F081C718F8800C0C4AE /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
96A71F101C718F8800C0C4AE /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
96A71F111C718F8800C0C4AE /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
96A71F141C718F8800C0C4AE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
96A71F151C718F8800C0C4AE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
96A71F171C718F8800C0C4AE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = SearchBarView/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.SearchBarView;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
96A71F181C718F8800C0C4AE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = SearchBarView/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.SearchBarView;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
96A71EFF1C718F8800C0C4AE /* Build configuration list for PBXProject "SearchBarView" */ = {
isa = XCConfigurationList;
buildConfigurations = (
96A71F141C718F8800C0C4AE /* Debug */,
96A71F151C718F8800C0C4AE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
96A71F161C718F8800C0C4AE /* Build configuration list for PBXNativeTarget "SearchBarView" */ = {
isa = XCConfigurationList;
buildConfigurations = (
96A71F171C718F8800C0C4AE /* Debug */,
96A71F181C718F8800C0C4AE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 96A71EFC1C718F8800C0C4AE /* Project object */;
}
<?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 @@ ...@@ -2,17 +2,17 @@
"images" : [ "images" : [
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "ic_alarm_white.png", "filename" : "ic_menu_white.png",
"scale" : "1x" "scale" : "1x"
}, },
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "ic_alarm_white_2x.png", "filename" : "ic_menu_white@2x.png",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "ic_alarm_white_3x.png", "filename" : "ic_menu_white@3x.png",
"scale" : "3x" "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 { ...@@ -368,14 +368,6 @@ public class MaterialSwitch: UIControl {
} }
} }
/**
Handle the TouchDown event.
- Parameter sender: A UIButton.
*/
internal func handleTouchDown(sender: UIButton) {
}
/// Prepares the track. /// Prepares the track.
private func prepareTrack() { private func prepareTrack() {
addSubview(track) addSubview(track)
...@@ -384,7 +376,6 @@ public class MaterialSwitch: UIControl { ...@@ -384,7 +376,6 @@ public class MaterialSwitch: UIControl {
/// Prepares the button. /// Prepares the button.
private func prepareButton() { private func prepareButton() {
button.pulseColor = nil button.pulseColor = nil
button.addTarget(self, action: "handleTouchDown:", forControlEvents: .TouchDown)
button.addTarget(self, action: "handleTouchUpOutsideOrCanceled:event:", forControlEvents: .TouchUpOutside) button.addTarget(self, action: "handleTouchUpOutsideOrCanceled:event:", forControlEvents: .TouchUpOutside)
button.addTarget(self, action: "handleTouchUpInside", forControlEvents: .TouchUpInside) button.addTarget(self, action: "handleTouchUpInside", forControlEvents: .TouchUpInside)
button.addTarget(self, action: "handleTouchDragInside:event:", forControlEvents: .TouchDragInside) button.addTarget(self, action: "handleTouchDragInside:event:", forControlEvents: .TouchDragInside)
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
import UIKit import UIKit
public class NavigationBarView : MaterialView { public class NavigationBarView : MaterialView {
/// TitleView that holds the titleLabel and detailLabel.
public private(set) lazy var titleView: MaterialView = MaterialView()
/** /**
:name: statusBarStyle :name: statusBarStyle
*/ */
...@@ -59,47 +62,14 @@ public class NavigationBarView : MaterialView { ...@@ -59,47 +62,14 @@ public class NavigationBarView : MaterialView {
} }
/** /**
:name: titleLabelInsets
*/
public var titleLabelInsetPreset: MaterialEdgeInset = .None {
didSet {
titleLabelInset = MaterialEdgeInsetToValue(titleLabelInsetPreset)
}
}
/**
:name: titleLabelInset
*/
public var titleLabelInset: UIEdgeInsets = UIEdgeInsets(top: 12, left: 0, bottom: 0, right: 0) {
didSet {
reloadView()
}
}
/**
:name: titleLabel :name: titleLabel
*/ */
public var titleLabel: UILabel? { public var titleLabel: UILabel? {
didSet { didSet {
titleLabel?.translatesAutoresizingMaskIntoConstraints = false if let v: UILabel = titleLabel {
reloadView() v.grid.rows = nil == detailLabel ? 3 : 2
} titleView.addSubview(v)
} }
/**
:name: detailLabelInsets
*/
public var detailLabelInsetPreset: MaterialEdgeInset = .None {
didSet {
detailLabelInset = MaterialEdgeInsetToValue(detailLabelInsetPreset)
}
}
/**
:name: detailLabelInset
*/
public var detailLabelInset: UIEdgeInsets = MaterialEdgeInsetToValue(.None) {
didSet {
reloadView() reloadView()
} }
} }
...@@ -109,71 +79,31 @@ public class NavigationBarView : MaterialView { ...@@ -109,71 +79,31 @@ public class NavigationBarView : MaterialView {
*/ */
public var detailLabel: UILabel? { public var detailLabel: UILabel? {
didSet { didSet {
detailLabel?.translatesAutoresizingMaskIntoConstraints = false if let v: UILabel = detailLabel {
reloadView() v.grid.rows = 1
} titleView.addSubview(v)
} titleLabel?.grid.rows = 2
} else {
/** titleLabel?.grid.rows = 3
:name: leftButtonsInsets
*/
public var leftButtonsInsetPreset: MaterialEdgeInset = .None {
didSet {
leftButtonsInset = MaterialEdgeInsetToValue(leftButtonsInsetPreset)
}
}
/**
:name: leftButtonsInset
*/
public var leftButtonsInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) {
didSet {
reloadView()
}
}
/**
:name: leftButtons
*/
public var leftButtons: Array<UIButton>? {
didSet {
if let v = leftButtons {
for b in v {
b.translatesAutoresizingMaskIntoConstraints = false
}
} }
reloadView() reloadView()
} }
} }
/** /**
:name: rightButtonsInsets :name: leftControls
*/ */
public var rightButtonsInsetPreset: MaterialEdgeInset = .None { public var leftControls: Array<UIControl>? {
didSet {
rightButtonsInset = MaterialEdgeInsetToValue(rightButtonsInsetPreset)
}
}
/**
:name: rightButtonsInset
*/
public var rightButtonsInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) {
didSet { didSet {
reloadView() reloadView()
} }
} }
/** /**
:name: rightButtons :name: rightControls
*/ */
public var rightButtons: Array<UIButton>? { public var rightControls: Array<UIControl>? {
didSet { didSet {
if let v = rightButtons {
for b in v {
b.translatesAutoresizingMaskIntoConstraints = false
}
}
reloadView() reloadView()
} }
} }
...@@ -202,129 +132,87 @@ public class NavigationBarView : MaterialView { ...@@ -202,129 +132,87 @@ public class NavigationBarView : MaterialView {
/** /**
:name: init :name: init
*/ */
public convenience init?(titleLabel: UILabel? = nil, detailLabel: UILabel? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) { public convenience init?(titleLabel: UILabel? = nil, detailLabel: UILabel? = nil, leftControls: Array<UIControl>? = nil, rightControls: Array<UIControl>? = nil) {
self.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, 70)) self.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, 70))
prepareProperties(titleLabel, detailLabel: detailLabel, leftButtons: leftButtons, rightButtons: rightButtons) prepareProperties(titleLabel, detailLabel: detailLabel, leftControls: leftControls, rightControls: rightControls)
}
public override func layoutSubviews() {
super.layoutSubviews()
reloadView()
}
public override func didMoveToSuperview() {
super.didMoveToSuperview()
reloadView()
} }
/** /**
:name: reloadView :name: reloadView
*/ */
public func reloadView() { public func reloadView() {
layoutIfNeeded()
// clear constraints so new ones do not conflict // clear constraints so new ones do not conflict
removeConstraints(constraints) removeConstraints(constraints)
for v in subviews { for v in subviews {
v.removeFromSuperview() if v != titleView {
v.removeFromSuperview()
}
} }
var verticalFormat: String = "V:|" // Size of single grid column.
var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() let g: CGFloat = width / CGFloat(0 < grid.columns ? grid.columns : 1)
var metrics: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
if nil != titleLabel {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + titleLabelInset.top
} else if nil != detailLabel {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + detailLabelInset.top
}
// title grid.views = []
if let v = titleLabel { titleView.grid.columns = grid.axis.columns
verticalFormat += "-[titleLabel]"
views["titleLabel"] = v
addSubview(v)
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + titleLabelInset.left, right: contentInset.right + titleLabelInset.right)
}
// detail // leftControls
if let v = detailLabel { if let v: Array<UIControl> = leftControls {
if nil != titleLabel { for c in v {
verticalFormat += "-(insetB)" let w: CGFloat = c.intrinsicContentSize().width
metrics["insetB"] = titleLabelInset.bottom + detailLabelInset.top if let b: UIButton = c as? UIButton {
} b.contentEdgeInsets = UIEdgeInsetsZero
verticalFormat += "-[detailLabel]"
views["detailLabel"] = v
addSubview(v)
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailLabelInset.left, right: contentInset.right + detailLabelInset.right)
}
// leftButtons
if let v = leftButtons {
if 0 < v.count {
var h: String = "H:|"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var i: Int = 0
for b in v {
let k: String = "b\(i)"
d[k] = b
if 0 == i++ {
h += "-(left)-"
} else {
h += "-(left_right)-"
}
h += "[\(k)]"
addSubview(b)
MaterialLayout.alignFromBottom(self, child: b, bottom: contentInset.bottom + leftButtonsInset.bottom)
} }
addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : contentInset.left + leftButtonsInset.left, "left_right" : leftButtonsInset.left + leftButtonsInset.right], views: d)) c.grid.columns = 0 == g ? 1 : Int(ceil(w / g))
titleView.grid.columns -= c.grid.columns
addSubview(c)
grid.views?.append(c)
} }
} }
// rightButtons grid.views?.append(titleView)
if let v = rightButtons {
if 0 < v.count { // rightControls
var h: String = "H:" if let v: Array<UIControl> = rightControls {
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() for c in v {
var i: Int = v.count - 1 let w: CGFloat = c.intrinsicContentSize().width
if let b: UIButton = c as? UIButton {
for b in v { b.contentEdgeInsets = UIEdgeInsetsZero
let k: String = "b\(i)"
d[k] = b
h += "[\(k)]"
if 0 == i-- {
h += "-(right)-"
} else {
h += "-(right_left)-"
}
addSubview(b)
MaterialLayout.alignFromBottom(self, child: b, bottom: contentInset.bottom + rightButtonsInset.bottom)
} }
addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : contentInset.right + rightButtonsInset.right, "right_left" : rightButtonsInset.right + rightButtonsInset.left], views: d)) c.grid.columns = 0 == g ? 1 : Int(ceil(w / g))
titleView.grid.columns -= c.grid.columns
addSubview(c)
grid.views?.append(c)
} }
} }
if nil != detailLabel { titleView.grid.columns -= titleView.grid.offset.columns
if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInset.bottom + detailLabelInset.bottom
} else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInset.bottom
}
} else if nil != titleLabel {
if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInset.bottom + titleLabelInset.bottom
} else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + titleLabelInset.bottom
}
}
if 0 < views.count { grid.reloadLayout()
verticalFormat += "-(insetBottom)-|"
addConstraints(MaterialLayout.constraint(verticalFormat, options: [], metrics: metrics, views: views)) titleView.grid.views = []
if let v: UILabel = titleLabel {
titleView.grid.views?.append(v)
}
if let v: UILabel = detailLabel {
titleView.grid.views?.append(v)
} }
titleView.grid.reloadLayout()
} }
/** /**
...@@ -332,16 +220,34 @@ public class NavigationBarView : MaterialView { ...@@ -332,16 +220,34 @@ public class NavigationBarView : MaterialView {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
super.prepareView()
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 depth = .Depth1
prepareTextView()
}
public func prepareTextView() {
titleView.backgroundColor = nil
titleView.grid.spacing = 4
titleView.grid.axis.rows = 3
titleView.grid.axis.inherited = false
titleView.grid.axis.direction = .Vertical
addSubview(titleView)
} }
/** /**
:name: prepareProperties :name: prepareProperties
*/ */
internal func prepareProperties(titleLabel: UILabel?, detailLabel: UILabel?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) { internal func prepareProperties(titleLabel: UILabel?, detailLabel: UILabel?, leftControls: Array<UIControl>?, rightControls: Array<UIControl>?) {
self.titleLabel = titleLabel self.titleLabel = titleLabel
self.detailLabel = detailLabel self.detailLabel = detailLabel
self.leftButtons = leftButtons self.leftControls = leftControls
self.rightButtons = rightButtons self.rightControls = rightControls
} }
} }
...@@ -41,6 +41,15 @@ public class SearchBarView : MaterialView { ...@@ -41,6 +41,15 @@ public class SearchBarView : MaterialView {
} }
} }
/**
:name: contentInsets
*/
public var contentInsetPreset: MaterialEdgeInset = .None {
didSet {
contentInset = MaterialEdgeInsetToValue(contentInsetPreset)
}
}
/// Wrapper around grid.contentInset. /// Wrapper around grid.contentInset.
public var contentInset: UIEdgeInsets = UIEdgeInsetsZero { public var contentInset: UIEdgeInsets = UIEdgeInsetsZero {
didSet { didSet {
...@@ -174,7 +183,7 @@ public class SearchBarView : MaterialView { ...@@ -174,7 +183,7 @@ public class SearchBarView : MaterialView {
let g: CGFloat = width / CGFloat(0 < grid.columns ? grid.columns : 1) let g: CGFloat = width / CGFloat(0 < grid.columns ? grid.columns : 1)
grid.views = [] grid.views = []
textField.grid.columns = grid.columns textField.grid.columns = grid.axis.columns
// leftControls // leftControls
if let v: Array<UIControl> = leftControls { if let v: Array<UIControl> = leftControls {
...@@ -215,6 +224,8 @@ public class SearchBarView : MaterialView { ...@@ -215,6 +224,8 @@ public class SearchBarView : MaterialView {
v.frame = CGRectMake(0, 0, textField.height, textField.height) v.frame = CGRectMake(0, 0, textField.height, textField.height)
} }
textField.grid.columns -= textField.grid.offset.columns
grid.reloadLayout() grid.reloadLayout()
} }
...@@ -223,12 +234,13 @@ public class SearchBarView : MaterialView { ...@@ -223,12 +234,13 @@ public class SearchBarView : MaterialView {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
grid.columns = 10 grid.spacing = 10
grid.spacing = 8 grid.axis.columns = 8
grid.contentInset.top = 28 grid.axis.inherited = false
grid.contentInset.left = 8 grid.contentInset.top = 25
grid.contentInset.bottom = 8 grid.contentInset.left = 10
grid.contentInset.right = 8 grid.contentInset.bottom = 10
grid.contentInset.right = 10
depth = .Depth1 depth = .Depth1
prepareTextField() 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