Commit 3898ce7f by Daniel Dahan

Merge branch 'storyboard-examples' into development

parents 163c8863 54b91588
......@@ -65,12 +65,12 @@ class ViewController: UIViewController {
private func prepareFavoriteButton() {
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.white)
favoriteButton.pulse.color = Color.white
favoriteButton.pulseColor = Color.white
}
private func prepareShareButton() {
shareButton = IconButton(image: Icon.cm.share, tintColor: Color.white)
shareButton.pulse.color = Color.white
shareButton.pulseColor = Color.white
}
private func prepareTitleLabel() {
......
......@@ -77,7 +77,7 @@ class ViewController: UIViewController {
private func prepareRaisedButton() {
let button = RaisedButton(title: "Raised Button", titleColor: Color.white)
button.pulse.color = Color.white
button.pulseColor = Color.white
button.backgroundColor = Color.blue.base
view.layout(button)
......
......@@ -77,7 +77,7 @@ class RootViewController: UIViewController {
private func prepareNextButton() {
nextButton = FlatButton()
nextButton.pulse.animation = .none
nextButton.pulseAnimation = .none
nextButton.addTarget(self, action: #selector(handleNextButton), for: .touchUpInside)
view.layout(nextButton).edges()
}
......
......@@ -51,7 +51,7 @@ class RootViewController: UIViewController {
private func prepareUndoButton() {
undoButton = FlatButton(title: "Undo", titleColor: Color.yellow.base)
undoButton.pulse.animation = .backing
undoButton.pulseAnimation = .backing
undoButton.titleLabel?.font = RobotoFont.regular(with: 14)
}
......
......@@ -48,15 +48,15 @@ class ViewController: UIViewController {
private func prepareButtons() {
let btn1 = FlatButton(title: "Library", titleColor: Color.blueGrey.base)
btn1.pulse.animation = .none
btn1.pulseAnimation = .none
buttons.append(btn1)
let btn2 = FlatButton(title: "Photo", titleColor: Color.blueGrey.base)
btn2.pulse.animation = .none
btn2.pulseAnimation = .none
buttons.append(btn2)
let btn3 = FlatButton(title: "Video", titleColor: Color.blueGrey.base)
btn3.pulse.animation = .none
btn3.pulseAnimation = .none
buttons.append(btn3)
}
......
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Button.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 CosmicMind 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: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
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 invalidate graphics rendering callbacks. 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 active 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" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"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="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</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="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</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"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Button" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="HIy-Yt-SER" customClass="FlatButton" customModule="Material">
<frame key="frameInset" minX="50.00%" minY="149" width="153" height="49"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Flat Button"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="title" value="Flat Button"/>
</userDefinedRuntimeAttributes>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="xu1-qa-63H" customClass="RaisedButton" customModule="Material">
<frame key="frameInset" minX="49.75%" minY="227" width="174" height="49"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.50196081400000003" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<state key="normal" title="Raised Button"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="3"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="shadowColor">
<color key="value" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="size" keyPath="shadowOffset">
<size key="value" width="1" height="1"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="backgroundColor">
<color key="value" red="0.0" green="0.50196081400000003" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="title" value="Raised Button"/>
</userDefinedRuntimeAttributes>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="IqT-sg-mjt" customClass="FabButton" customModule="Material">
<frame key="frameInset" minX="49.84%" minY="312" width="60" height="60"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="0.93803510270000001" colorSpace="calibratedRGB"/>
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<state key="normal" image="cm_pen_white"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="image" keyPath="image" value="cm_pen_white"/>
</userDefinedRuntimeAttributes>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="Aqc-uz-GVW" customClass="IconButton" customModule="Material">
<frame key="frameInset" minX="164" minY="398" height="40" maxX="171"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<state key="normal" image="cm_search_white"/>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<connections>
<outlet property="fabButton" destination="IqT-sg-mjt" id="DvE-hp-bo2"/>
<outlet property="iconButton" destination="Aqc-uz-GVW" id="Ba4-If-S9Z"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-377.5" y="-13.5"/>
</scene>
</scenes>
<resources>
<image name="cm_pen_white" width="24" height="24"/>
<image name="cm_search_white" width="24" height="24"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
</simulatedMetricsContainer>
</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>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>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</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 CosmicMind 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
import Material
class ViewController: UIViewController {
@IBOutlet weak var fabButton: FabButton!
@IBOutlet weak var iconButton: IconButton!
override func viewDidLoad() {
super.viewDidLoad()
prepareFabButton()
prepareIconButton()
}
func prepareFabButton() {
fabButton.image = Icon.cm.add
fabButton.pulseColor = Color.white
}
func prepareIconButton() {
iconButton.image = Icon.search
iconButton.pulseColor = Color.blue.base
}
}
......@@ -74,5 +74,12 @@
location = "group:Examples/Programmatic/View/View.xcodeproj">
</FileRef>
</Group>
<Group
location = "container:"
name = "Storyboards">
<FileRef
location = "group:Examples/Storyboards/Button/Button.xcodeproj">
</FileRef>
</Group>
</Group>
</Workspace>
......@@ -102,7 +102,39 @@ open class Bar: View {
}
/// Divider layer.
open internal(set) var divider: Divider!
internal lazy var divider: Divider = Divider(view: self)
/// Divider color.
@IBInspectable
open var dividerColor: UIColor? {
get {
return divider.color
}
set(value) {
divider.color = value
}
}
/// Divider animation.
open var dividerAlignment: DividerAlignment {
get {
return divider.alignment
}
set(value) {
divider.alignment = value
}
}
/// Divider height.
@IBInspectable
open var dividerHeight: CGFloat {
get {
return divider.height
}
set(value) {
divider.height = value
}
}
/// ContentView that holds the any desired subviews.
open private(set) lazy var contentView = View()
......@@ -233,16 +265,10 @@ open class Bar: View {
open override func prepare() {
super.prepare()
prepareContentView()
prepareDivider()
}
/// Prepares the contentView.
private func prepareContentView() {
contentView.backgroundColor = nil
}
/// Prepares the divider.
private func prepareDivider() {
divider = Divider(view: self)
}
}
......@@ -123,7 +123,7 @@ open class BottomTabBar: UITabBar {
*/
public func prepare() {
depthPreset = .depth1
divider.alignment = .top
dividerAlignment = .top
contentScaleFactor = Device.scale
backgroundColor = Color.white
let image = UIImage.imageWithColor(color: Color.clear, size: CGSize(width: 1, height: 1))
......@@ -137,7 +137,7 @@ private var TabBarKey: UInt8 = 0
extension UITabBar {
/// TabBarItem reference.
public internal(set) var divider: Divider! {
internal private(set) var divider: Divider! {
get {
return AssociatedObject(base: self, key: &TabBarKey) {
return Divider(view: self)
......@@ -147,5 +147,37 @@ extension UITabBar {
AssociateObject(base: self, key: &TabBarKey, value: value)
}
}
/// Divider color.
@IBInspectable
open var dividerColor: UIColor? {
get {
return divider.color
}
set(value) {
divider.color = value
}
}
/// Divider animation.
open var dividerAlignment: DividerAlignment {
get {
return divider.alignment
}
set(value) {
divider.alignment = value
}
}
/// Divider height.
@IBInspectable
open var dividerHeight: CGFloat {
get {
return divider.height
}
set(value) {
divider.height = value
}
}
}
......@@ -41,8 +41,39 @@ open class Button: UIButton {
open private(set) lazy var visualLayer = CAShapeLayer()
/// A Pulse reference.
internal private(set) lazy var pulse: Pulse = Pulse()
/// PulseAnimation value.
open var pulseAnimation: PulseAnimation {
get {
return pulse.animation
}
set(value) {
pulse.animation = value
}
}
/// PulseAnimation color.
@IBInspectable
open internal(set) lazy var pulse: Pulse = Pulse()
open var pulseColor: UIColor {
get {
return pulse.color
}
set(value) {
pulse.color = value
}
}
/// Pulse opacity.
@IBInspectable
open var pulseOpacity: CGFloat {
get {
return pulse.opacity
}
set(value) {
pulse.opacity = value
}
}
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
......
......@@ -180,7 +180,7 @@ open class Card: PulseView {
open override func prepare() {
super.prepare()
depthPreset = .depth1
pulse.animation = .none
pulseAnimation = .none
}
/**
......
......@@ -41,8 +41,39 @@ open class CollectionReusableView: UICollectionReusableView {
open private(set) lazy var visualLayer = CAShapeLayer()
/// A Pulse reference.
internal private(set) lazy var pulse: Pulse = Pulse()
/// PulseAnimation value.
open var pulseAnimation: PulseAnimation {
get {
return pulse.animation
}
set(value) {
pulse.animation = value
}
}
/// PulseAnimation color.
@IBInspectable
open internal(set) lazy var pulse: Pulse = Pulse()
open var pulseColor: UIColor {
get {
return pulse.color
}
set(value) {
pulse.color = value
}
}
/// Pulse opacity.
@IBInspectable
open var pulseOpacity: CGFloat {
get {
return pulse.opacity
}
set(value) {
pulse.opacity = value
}
}
/**
A property that manages an image for the visualLayer's contents
......
......@@ -32,8 +32,40 @@ import UIKit
@objc(CollectionViewCell)
open class CollectionViewCell: UICollectionViewCell {
/// A reference to the divider.
open internal(set) var divider: Divider!
/// Divider layer.
internal private(set) lazy var divider: Divider = Divider(view: self)
/// Divider color.
@IBInspectable
open var dividerColor: UIColor? {
get {
return divider.color
}
set(value) {
divider.color = value
}
}
/// Divider animation.
open var dividerAlignment: DividerAlignment {
get {
return divider.alignment
}
set(value) {
divider.alignment = value
}
}
/// Divider height.
@IBInspectable
open var dividerHeight: CGFloat {
get {
return divider.height
}
set(value) {
divider.height = value
}
}
/**
A CAShapeLayer used to manage elements that would be affected by
......@@ -44,8 +76,39 @@ open class CollectionViewCell: UICollectionViewCell {
open private(set) lazy var visualLayer = CAShapeLayer()
/// A Pulse reference.
internal private(set) lazy var pulse: Pulse = Pulse()
/// PulseAnimation value.
open var pulseAnimation: PulseAnimation {
get {
return pulse.animation
}
set(value) {
pulse.animation = value
}
}
/// PulseAnimation color.
@IBInspectable
open var pulseColor: UIColor {
get {
return pulse.color
}
set(value) {
pulse.color = value
}
}
/// Pulse opacity.
@IBInspectable
open internal(set) lazy var pulse: Pulse = Pulse()
open var pulseOpacity: CGFloat {
get {
return pulse.opacity
}
set(value) {
pulse.opacity = value
}
}
/**
A property that manages an image for the visualLayer's contents
......@@ -268,7 +331,6 @@ open class CollectionViewCell: UICollectionViewCell {
open func prepare() {
contentScaleFactor = Device.scale
prepareVisualLayer()
prepareDivider()
}
/// Prepares the visualLayer property.
......@@ -283,9 +345,4 @@ open class CollectionViewCell: UICollectionViewCell {
visualLayer.frame = bounds
visualLayer.cornerRadius = cornerRadius
}
/// Prepares the divider.
private func prepareDivider() {
divider = Divider(view: self)
}
}
......@@ -42,8 +42,8 @@ open class FabButton: Button {
super.prepare()
depthPreset = .depth1
shapePreset = .circle
pulse.animation = .centerWithBacking
pulse.color = Color.white
pulseAnimation = .centerWithBacking
pulseColor = Color.white
tintColor = Color.white
backgroundColor = Color.red.base
}
......
......@@ -40,6 +40,6 @@ open class IconButton: Button {
*/
open override func prepare() {
super.prepare()
pulse.animation = .center
pulseAnimation = .center
}
}
......@@ -39,8 +39,40 @@ public enum NavigationBarStyle: Int {
}
open class NavigationBar: UINavigationBar {
/// A reference to the divider.
open internal(set) var divider: Divider!
/// Divider layer.
internal private(set) lazy var divider: Divider = Divider(view: self)
/// Divider color.
@IBInspectable
open var dividerColor: UIColor? {
get {
return divider.color
}
set(value) {
divider.color = value
}
}
/// Divider animation.
open var dividerAlignment: DividerAlignment {
get {
return divider.alignment
}
set(value) {
divider.alignment = value
}
}
/// Divider height.
@IBInspectable
open var dividerHeight: CGFloat {
get {
return divider.height
}
set(value) {
divider.height = value
}
}
open override var intrinsicContentSize: CGSize {
switch navigationBarStyle {
......@@ -174,9 +206,7 @@ open class NavigationBar: UINavigationBar {
layoutNavigationItem(item: v)
}
if let v = divider {
v.reload()
}
divider.reload()
}
open override func pushItem(_ item: UINavigationItem, animated: Bool) {
......@@ -305,7 +335,6 @@ open class NavigationBar: UINavigationBar {
shadowImage = image
setBackgroundImage(image, for: .default)
backgroundColor = Color.white
prepareDivider()
}
/**
......@@ -327,9 +356,4 @@ open class NavigationBar: UINavigationBar {
}
item.titleView = UIView(frame: .zero)
}
/// Prepares the divider.
private func prepareDivider() {
divider = Divider(view: self)
}
}
......@@ -36,7 +36,7 @@ private var PageTabBarItemKey: UInt8 = 0
open class PageTabBarItem: FlatButton {
open override func prepare() {
super.prepare()
pulse.animation = .none
pulseAnimation = .none
}
}
......
......@@ -30,18 +30,16 @@
import UIKit
open class Pulse {
internal struct Pulse {
/// An Array of layers.
internal lazy var layers = [CAShapeLayer]()
/// A UIColor.
@IBInspectable
open var color = Color.grey.base
internal var color = Color.grey.base
/// A reference to the PulseAnimation.
open var animation = PulseAnimation.pointWithBacking
internal var animation = PulseAnimation.pointWithBacking
/// The opcaity value for the pulse animation.
@IBInspectable
open var opacity: CGFloat = 0.18
internal var opacity: CGFloat = 0.18
}
......@@ -32,8 +32,39 @@ import UIKit
open class PulseView: View {
/// A Pulse reference.
internal private(set) lazy var pulse: Pulse = Pulse()
/// PulseAnimation value.
open var pulseAnimation: PulseAnimation {
get {
return pulse.animation
}
set(value) {
pulse.animation = value
}
}
/// PulseAnimation color.
@IBInspectable
open internal(set) lazy var pulse: Pulse = Pulse()
open var pulseColor: UIColor {
get {
return pulse.color
}
set(value) {
pulse.color = value
}
}
/// Pulse opacity.
@IBInspectable
open var pulseOpacity: CGFloat {
get {
return pulse.opacity
}
set(value) {
pulse.opacity = value
}
}
/**
Triggers the pulse animation.
......
......@@ -413,7 +413,7 @@ open class Switch: UIControl {
/// Prepares the button.
private func prepareButton() {
button.pulse.animation = .none
button.pulseAnimation = .none
button.addTarget(self, action: #selector(handleTouchUpInside), for: .touchUpInside)
button.addTarget(self, action: #selector(handleTouchDragInside), for: .touchDragInside)
button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), for: .touchCancel)
......
......@@ -40,8 +40,39 @@ open class TableViewCell: UITableViewCell {
open private(set) lazy var visualLayer = CAShapeLayer()
/// A Pulse reference.
internal private(set) lazy var pulse: Pulse = Pulse()
/// PulseAnimation value.
open var pulseAnimation: PulseAnimation {
get {
return pulse.animation
}
set(value) {
pulse.animation = value
}
}
/// PulseAnimation color.
@IBInspectable
open internal(set) lazy var pulse: Pulse = Pulse()
open var pulseColor: UIColor {
get {
return pulse.color
}
set(value) {
pulse.color = value
}
}
/// Pulse opacity.
@IBInspectable
open var pulseOpacity: CGFloat {
get {
return pulse.opacity
}
set(value) {
pulse.opacity = value
}
}
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
......
......@@ -207,7 +207,7 @@ open class TextField: UITextField {
if nil == clearIconButton {
clearIconButton = IconButton(image: Icon.cm.clear, tintColor: placeholderColor)
clearIconButton!.contentEdgeInsets = .zero
clearIconButton!.pulse.animation = .center
clearIconButton!.pulseAnimation = .center
clearButtonMode = .never
rightViewMode = .whileEditing
rightView = clearIconButton
......@@ -242,7 +242,7 @@ open class TextField: UITextField {
if nil == visibilityIconButton {
visibilityIconButton = IconButton(image: Icon.visibility, tintColor: placeholderColor.withAlphaComponent(isSecureTextEntry ? 0.38 : 0.54))
visibilityIconButton!.contentEdgeInsets = .zero
visibilityIconButton!.pulse.animation = .center
visibilityIconButton!.pulseAnimation = .center
isSecureTextEntry = true
clearButtonMode = .never
rightViewMode = .whileEditing
......
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