Commit 141e5838 by Daniel Dahan

development: added Card project with latest Card component

parent f714cc4c
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
96B5B02B1D936DBC00449DDD /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B5B02A1D936DBC00449DDD /* ViewController.swift */; }; 96B5B02B1D936DBC00449DDD /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B5B02A1D936DBC00449DDD /* ViewController.swift */; };
96B5B0301D936DBC00449DDD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96B5B02F1D936DBC00449DDD /* Assets.xcassets */; }; 96B5B0301D936DBC00449DDD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96B5B02F1D936DBC00449DDD /* Assets.xcassets */; };
96B5B0331D936DBC00449DDD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96B5B0311D936DBC00449DDD /* LaunchScreen.storyboard */; }; 96B5B0331D936DBC00449DDD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96B5B0311D936DBC00449DDD /* LaunchScreen.storyboard */; };
96B5B03B1D937E5400449DDD /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96B5B03A1D937E5400449DDD /* Material.framework */; };
96B5B03C1D937E5400449DDD /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96B5B03A1D937E5400449DDD /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96B5B03C1D937E5400449DDD /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -36,7 +33,6 @@ ...@@ -36,7 +33,6 @@
96B5B02F1D936DBC00449DDD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96B5B02F1D936DBC00449DDD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96B5B0321D936DBC00449DDD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 96B5B0321D936DBC00449DDD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96B5B0341D936DBC00449DDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 96B5B0341D936DBC00449DDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96B5B03A1D937E5400449DDD /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96B5B03B1D937E5400449DDD /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -54,7 +49,6 @@ ...@@ -54,7 +49,6 @@
96B5B01C1D936DBC00449DDD = { 96B5B01C1D936DBC00449DDD = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96B5B03A1D937E5400449DDD /* Material.framework */,
96B5B0271D936DBC00449DDD /* Card */, 96B5B0271D936DBC00449DDD /* Card */,
96B5B0261D936DBC00449DDD /* Products */, 96B5B0261D936DBC00449DDD /* Products */,
); );
......
...@@ -32,44 +32,55 @@ import UIKit ...@@ -32,44 +32,55 @@ import UIKit
import Material import Material
class ViewController: UIViewController { class ViewController: UIViewController {
private var titleBar: Toolbar!
private var contentView: UILabel!
private var bottomBar: Bar!
private var favoriteButton: IconButton! private var favoriteButton: IconButton!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = Color.grey.lighten5
prepareTitleBar()
prepareContentView()
prepareFavoriteButton() prepareFavoriteButton()
prepareBottomBar()
prepareCard() prepareCard()
} }
private func prepareTitleBar() {
titleBar = Toolbar()
titleBar.title = "Title"
titleBar.backgroundColor = nil
}
private func prepareContentView() {
contentView = UILabel()
contentView.numberOfLines = 0
contentView.text = "It’s been a while, have you read any new books lately?"
contentView.font = RobotoFont.regular(with: 14)
}
private func prepareFavoriteButton() { private func prepareFavoriteButton() {
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.white) favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.blue.base)
favoriteButton.pulseColor = Color.white favoriteButton.pulseColor = Color.blue.base
} }
private func prepareBottomBar() {
bottomBar = Bar()
bottomBar.backgroundColor = nil
bottomBar.leftViews = [favoriteButton]
}
private func prepareCard() { private func prepareCard() {
view.backgroundColor = Color.white let card = Card()
card.pulseAnimation = .pointWithBacking
let card = ContentCard()
card.depthPreset = .depth2
card.titleBar = Toolbar()
card.titleBar?.title = "Title"
card.titleBar?.backgroundColor = Color.red.base
card.contentView.backgroundColor = Color.grey.base
card.contentView.height = 300
card.bottomBar = Bar()
card.bottomBar?.backgroundColor = Color.blue.base
card.bottomBar?.contentEdgeInsetsPreset = .square1
card.bottomBar?.rightViews = [favoriteButton]
let button = FlatButton(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) card.titleBar = titleBar
card.contentView.addSubview(button) card.contentView = contentView
card.bottomBar = bottomBar
_ = view.layout(card).left(20).right(20).top(100) view.layout(card).top(100).left(20).right(20)
} }
} }
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
96264BE71D833D2800576F37 /* Reminders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96264BE61D833D2800576F37 /* Reminders.swift */; }; 96264BE71D833D2800576F37 /* Reminders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96264BE61D833D2800576F37 /* Reminders.swift */; };
96264BE91D833D3400576F37 /* RemindersController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96264BE81D833D3400576F37 /* RemindersController.swift */; }; 96264BE91D833D3400576F37 /* RemindersController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96264BE81D833D3400576F37 /* RemindersController.swift */; };
96264C0E1D84051900576F37 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96264C0D1D84051900576F37 /* Checkbox.swift */; }; 96264C0E1D84051900576F37 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96264C0D1D84051900576F37 /* Checkbox.swift */; };
96264C121D840B5F00576F37 /* ContentCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96264C111D840B5F00576F37 /* ContentCard.swift */; };
9628645A1D53FE3E00690B69 /* Material+UIWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864591D53FE3E00690B69 /* Material+UIWindow.swift */; }; 9628645A1D53FE3E00690B69 /* Material+UIWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864591D53FE3E00690B69 /* Material+UIWindow.swift */; };
9628645F1D540AF300690B69 /* DynamicFontType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9628645E1D540AF300690B69 /* DynamicFontType.swift */; }; 9628645F1D540AF300690B69 /* DynamicFontType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9628645E1D540AF300690B69 /* DynamicFontType.swift */; };
962864621D54111D00690B69 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864611D54111D00690B69 /* JSON.swift */; }; 962864621D54111D00690B69 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864611D54111D00690B69 /* JSON.swift */; };
...@@ -32,7 +31,6 @@ ...@@ -32,7 +31,6 @@
968C99471D377849000074FF /* Offset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968C99461D377849000074FF /* Offset.swift */; }; 968C99471D377849000074FF /* Offset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968C99461D377849000074FF /* Offset.swift */; };
9697F7B71D8F22A4004741EC /* MenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9697F7B61D8F22A4004741EC /* MenuItem.swift */; }; 9697F7B71D8F22A4004741EC /* MenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9697F7B61D8F22A4004741EC /* MenuItem.swift */; };
9697F7BC1D8F2572004741EC /* BasicAnimation.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96E3C39D1D3A1D0C0086A024 /* BasicAnimation.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9697F7BC1D8F2572004741EC /* BasicAnimation.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96E3C39D1D3A1D0C0086A024 /* BasicAnimation.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7BD1D8F2572004741EC /* ContentCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96264C111D840B5F00576F37 /* ContentCard.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7BE1D8F2572004741EC /* Checkbox.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96264C0D1D84051900576F37 /* Checkbox.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9697F7BE1D8F2572004741EC /* Checkbox.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96264C0D1D84051900576F37 /* Checkbox.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7BF1D8F2572004741EC /* Divider.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96230AB71D6A520C00AF47DC /* Divider.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9697F7BF1D8F2572004741EC /* Divider.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96230AB71D6A520C00AF47DC /* Divider.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7C01D8F2572004741EC /* Material+CALayer.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96F1DC871D654FDF0025F925 /* Material+CALayer.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9697F7C01D8F2572004741EC /* Material+CALayer.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96F1DC871D654FDF0025F925 /* Material+CALayer.swift */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -225,7 +223,6 @@ ...@@ -225,7 +223,6 @@
96264BE61D833D2800576F37 /* Reminders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reminders.swift; sourceTree = "<group>"; }; 96264BE61D833D2800576F37 /* Reminders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reminders.swift; sourceTree = "<group>"; };
96264BE81D833D3400576F37 /* RemindersController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemindersController.swift; sourceTree = "<group>"; }; 96264BE81D833D3400576F37 /* RemindersController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemindersController.swift; sourceTree = "<group>"; };
96264C0D1D84051900576F37 /* Checkbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = "<group>"; }; 96264C0D1D84051900576F37 /* Checkbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = "<group>"; };
96264C111D840B5F00576F37 /* ContentCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentCard.swift; sourceTree = "<group>"; };
962864591D53FE3E00690B69 /* Material+UIWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIWindow.swift"; sourceTree = "<group>"; }; 962864591D53FE3E00690B69 /* Material+UIWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIWindow.swift"; sourceTree = "<group>"; };
9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; }; 9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; };
962864611D54111D00690B69 /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; }; 962864611D54111D00690B69 /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; };
...@@ -630,7 +627,6 @@ ...@@ -630,7 +627,6 @@
96BCB8021CB40F3B00C806FE /* Card */ = { 96BCB8021CB40F3B00C806FE /* Card */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96264C111D840B5F00576F37 /* ContentCard.swift */,
96BCB75D1CB40DC500C806FE /* Card.swift */, 96BCB75D1CB40DC500C806FE /* Card.swift */,
96BCB7621CB40DC500C806FE /* ImageCard.swift */, 96BCB7621CB40DC500C806FE /* ImageCard.swift */,
); );
...@@ -871,7 +867,6 @@ ...@@ -871,7 +867,6 @@
96E3C39A1D3A1CC20086A024 /* ErrorTextField.swift in Headers */, 96E3C39A1D3A1CC20086A024 /* ErrorTextField.swift in Headers */,
96E3C39C1D3A1CC20086A024 /* Offset.swift in Headers */, 96E3C39C1D3A1CC20086A024 /* Offset.swift in Headers */,
9697F7BC1D8F2572004741EC /* BasicAnimation.swift in Headers */, 9697F7BC1D8F2572004741EC /* BasicAnimation.swift in Headers */,
9697F7BD1D8F2572004741EC /* ContentCard.swift in Headers */,
9697F7BE1D8F2572004741EC /* Checkbox.swift in Headers */, 9697F7BE1D8F2572004741EC /* Checkbox.swift in Headers */,
9697F7BF1D8F2572004741EC /* Divider.swift in Headers */, 9697F7BF1D8F2572004741EC /* Divider.swift in Headers */,
9697F7C01D8F2572004741EC /* Material+CALayer.swift in Headers */, 9697F7C01D8F2572004741EC /* Material+CALayer.swift in Headers */,
...@@ -1156,7 +1151,6 @@ ...@@ -1156,7 +1151,6 @@
96BCB7CD1CB40DC500C806FE /* PulseView.swift in Sources */, 96BCB7CD1CB40DC500C806FE /* PulseView.swift in Sources */,
96BCB7DA1CB40DC500C806FE /* NavigationController.swift in Sources */, 96BCB7DA1CB40DC500C806FE /* NavigationController.swift in Sources */,
96BCB7A81CB40DC500C806FE /* FabButton.swift in Sources */, 96BCB7A81CB40DC500C806FE /* FabButton.swift in Sources */,
96264C121D840B5F00576F37 /* ContentCard.swift in Sources */,
96BCB7E41CB40DC500C806FE /* Text.swift in Sources */, 96BCB7E41CB40DC500C806FE /* Text.swift in Sources */,
96BCB7AB1CB40DC500C806FE /* ImageCard.swift in Sources */, 96BCB7AB1CB40DC500C806FE /* ImageCard.swift in Sources */,
96BCB7CB1CB40DC500C806FE /* PulseAnimation.swift in Sources */, 96BCB7CB1CB40DC500C806FE /* PulseAnimation.swift in Sources */,
......
/*
* 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
open class ContentCard: PulseView {
/// Will render the view.
open var willLayout: Bool {
return 0 < width && nil != superview
}
/// A preset wrapper around contentInset.
open var contentEdgeInsetsPreset: EdgeInsetsPreset {
get {
return grid.contentEdgeInsetsPreset
}
set(value) {
grid.contentEdgeInsetsPreset = value
}
}
/// A wrapper around grid.contentInset.
@IBInspectable
open var contentEdgeInsets: EdgeInsets {
get {
return grid.contentEdgeInsets
}
set(value) {
grid.contentEdgeInsets = value
}
}
/// A preset wrapper around interimSpace.
open var interimSpacePreset = InterimSpacePreset.none {
didSet {
interimSpace = InterimSpacePresetToValue(preset: interimSpacePreset)
}
}
/// A wrapper around grid.interimSpace.
@IBInspectable
open var interimSpace: InterimSpace {
get {
return grid.interimSpace
}
set(value) {
grid.interimSpace = value
}
}
/// A reference to the titleBar.
open var titleBar: Toolbar? {
didSet {
layoutSubviews()
}
}
/// A reference to the contentView.
open var contentView = UIView() {
didSet {
layoutSubviews()
}
}
/// A reference to the bottomBar.
open var bottomBar: Bar? {
didSet {
layoutSubviews()
}
}
/// Grid cell factor.
@IBInspectable
open var gridFactor: CGFloat = 24 {
didSet {
assert(0 < gridFactor, "[Material Error: gridFactor must be greater than 0.]")
layoutSubviews()
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() {
super.prepare()
pulseAnimation = .none
}
open override func layoutSubviews() {
super.layoutSubviews()
guard willLayout else {
return
}
// clear constraints so new ones do not conflict
removeConstraints(constraints)
for v in subviews {
v.removeFromSuperview()
}
var views = [String: Any]()
var format = "V:|"
if let v = titleBar {
views["titleBar"] = v
format += "[titleBar]"
layout(v).horizontally()
}
views["contentView"] = contentView
format += "[contentView]"
layout(contentView).horizontally()
// if let v = bottomBar {
// views["bottomBar"] = v
// format += "[bottomBar]"
// layout(v).horizontally()
// }
addConstraints(Layout.constraint(format: "\(format)|", options: [], metrics: nil, views: views))
}
}
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