Commit bd7f50c5 by Daniel Dahan

added CardView with support for any view in the detailView area

parent e1e1abc3
......@@ -90,6 +90,9 @@
<FileRef
location = "group:Programmatic/CardView/CardView.xcodeproj">
</FileRef>
<FileRef
location = "group:Programmatic/TableCardView/TableCardView.xcodeproj">
</FileRef>
</Group>
<Group
location = "container:"
......
......@@ -39,10 +39,10 @@ class ViewController: UIViewController {
// Examples of using CardView.
// Uncomment different examples and read
// the comments below.
// prepareGeneralCardViewExample()
prepareGeneralCardViewExample()
// prepareCardViewWithoutPulseBackgroundImageExample()
// prepareCardViewWithPulseBackgroundImageExample()
prepareCardViewButtonBarExample()
// prepareCardViewButtonBarExample()
}
/**
......@@ -71,7 +71,7 @@ class ViewController: UIViewController {
let detailLabel: UILabel = UILabel()
detailLabel.text = "It’s been a while, have you read any new books lately?"
detailLabel.numberOfLines = 0
cardView.detailLabel = detailLabel
cardView.detailView = detailLabel
// Yes button.
let btn1: FlatButton = FlatButton()
......@@ -124,7 +124,7 @@ class ViewController: UIViewController {
detailLabel.text = "Beautiful Material Design"
detailLabel.textColor = MaterialColor.white
detailLabel.numberOfLines = 0
cardView.detailLabel = detailLabel
cardView.detailView = detailLabel
// Favorite button.
let img1: UIImage? = UIImage(named: "ic_favorite_white")
......@@ -169,7 +169,7 @@ class ViewController: UIViewController {
detailLabel.text = "Data-Driven Framework"
detailLabel.textColor = MaterialColor.white
detailLabel.numberOfLines = 0
cardView.detailLabel = detailLabel
cardView.detailView = detailLabel
// Favorite button.
let img1: UIImage? = UIImage(named: "ic_favorite_white")
......
......@@ -486,10 +486,10 @@ class ViewController: UIViewController {
alarmButton.grid.columns = 2
alarmButton.grid.offset.columns = 10
contentView.grid.spacing = 8
contentView.grid.axis.inherited = false
contentView.grid.axis.direction = .None
contentView.grid.contentInsetPreset = .Square3
contentView.grid.spacing = 8
contentView.grid.views = [
titleLabel,
moreButton,
......
......@@ -74,7 +74,7 @@ class ViewController: UIViewController {
let detailLabel: UILabel = UILabel()
detailLabel.text = "It’s been a while, have you read any new books lately?"
detailLabel.numberOfLines = 0
imageCardView.detailLabel = detailLabel
imageCardView.detailView = detailLabel
// Yes button.
let btn1: FlatButton = FlatButton()
......
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:TableCardView.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,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "GraphKit.png",
"filename" : "Profile1.jpg",
"scale" : "1x"
},
{
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile2.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile3.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile4.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile5.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile6.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile7.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile8.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "Profile9.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_settings.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_settings_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_settings_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" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</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>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>
</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 GraphKit 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 setting a UITableView as the detailView for a
CardView.
*/
import UIKit
import Material
private struct Item {
var text: String
var detail: String
var image: UIImage?
}
class ViewController: UIViewController {
/// A tableView used to display Bond entries.
private let tableView: UITableView = UITableView()
/// A list of all the Author Bond types.
private var items: Array<Item> = Array<Item>()
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareItems()
prepareTableView()
prepareCardView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
}
/// Prepares the items Array.
private func prepareItems() {
items.append(Item(text: "Summer BBQ", detail: "Wish I could come, but I am out of town this weekend.", image: UIImage(named: "Profile1")))
items.append(Item(text: "Birthday gift", detail: "Have any ideas about what we should get Heidi for her birthday?", image: UIImage(named: "Profile2")))
items.append(Item(text: "Brunch this weekend?", detail: "I'll be in your neighborhood doing errands this weekend.", image: UIImage(named: "Profile3")))
items.append(Item(text: "Giants game", detail: "Are we on this weekend for the game?", image: UIImage(named: "Profile4")))
items.append(Item(text: "Recipe to try", detail: "We should eat this: Squash, Corn and tomatillo Tacos.", image: UIImage(named: "Profile5")))
items.append(Item(text: "Interview", detail: "The candidate will be arriving at 11:30, are you free?", image: UIImage(named: "Profile6")))
items.append(Item(text: "Book recommendation", detail: "I found the book title, Surely You’re Joking, Mr. Feynman!", image: UIImage(named: "Profile7")))
items.append(Item(text: "Oui oui", detail: "Do you have Paris recommendations? Have you ever been?", image: UIImage(named: "Profile8")))
}
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
tableView.dataSource = self
tableView.delegate = self
}
/// Prepares the CardView.
func prepareCardView() {
let cardView: CardView = CardView()
cardView.pulseColor = nil
let titleLabel: UILabel = UILabel()
titleLabel.text = "Messages"
titleLabel.textAlignment = .Center
titleLabel.font = RobotoFont.mediumWithSize(24)
let v: UIView = UIView()
v.backgroundColor = MaterialColor.blue.accent1
let closeButton: FlatButton = FlatButton()
closeButton.setTitle("Close", forState: .Normal)
let image: UIImage? = UIImage(named: "ic_settings")?.imageWithRenderingMode(.AlwaysTemplate)
let settingButton: FlatButton = FlatButton()
settingButton.tintColor = MaterialColor.blue.accent3
settingButton.setImage(image, forState: .Normal)
settingButton.setImage(image, forState: .Highlighted)
// Use MaterialLayout to easily align the tableView.
cardView.titleLabel = titleLabel
cardView.detailView = tableView
cardView.detailViewInsetPreset = .None
cardView.dividerInset.top = 0
cardView.leftButtons = [closeButton]
cardView.rightButtons = [settingButton]
cardView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(cardView)
MaterialLayout.alignToParent(view, child: cardView, left: 10, right: 10, top: 100, bottom: 100)
}
}
/// TableViewDataSource methods.
extension ViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count;
}
/// Returns the number of sections.
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UITableViewCell = UITableViewCell(style: .Subtitle, reuseIdentifier: "Cell")
let item: Item = items[indexPath.row]
cell.selectionStyle = .None
cell.textLabel!.text = item.text
cell.textLabel!.font = RobotoFont.regular
cell.detailTextLabel!.text = item.detail
cell.detailTextLabel!.font = RobotoFont.regular
cell.detailTextLabel!.textColor = MaterialColor.grey.darken1
cell.imageView!.image = item.image?.resize(toWidth: 40)
cell.imageView!.layer.cornerRadius = 20
return cell
}
}
/// UITableViewDelegate methods.
extension ViewController: UITableViewDelegate {
/// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 80
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "Graph.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -68,7 +68,7 @@ class ViewController: UIViewController {
let detailLabel: UILabel = UILabel()
detailLabel.text = "It’s been a while, have you read any new books lately?"
detailLabel.numberOfLines = 0
cardView.detailLabel = detailLabel
cardView.detailView = detailLabel
// Yes button.
let btn1: FlatButton = FlatButton()
......@@ -95,16 +95,16 @@ class ViewController: UIViewController {
func prepareCardViewExampleTwo() {
secondCardView.dividerInset.left = 100
secondCardView.titleLabelInset.left = 100
secondCardView.detailLabelInset.left = 100
secondCardView.detailViewInset.left = 100
secondCardView.pulseColor = MaterialColor.teal.lighten4
// Image.
secondCardView.image = UIImage(named: "GraphKit")?.resize(toHeight: 100)
secondCardView.image = UIImage(named: "Graph")?.resize(toHeight: 100)
secondCardView.contentsGravity = .TopLeft
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.text = "GraphKit"
titleLabel.text = "Graph"
titleLabel.font = RobotoFont.mediumWithSize(24)
secondCardView.titleLabel = titleLabel
......@@ -112,14 +112,14 @@ class ViewController: UIViewController {
let detailLabel: UILabel = UILabel()
detailLabel.text = "Build scalable data-driven apps."
detailLabel.numberOfLines = 0
secondCardView.detailLabel = detailLabel
secondCardView.detailView = detailLabel
// LEARN MORE button.
let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.teal.lighten1
btn1.pulseColor = MaterialColor.blue.lighten1
btn1.pulseScale = false
btn1.setTitle("LEARN MORE", forState: .Normal)
btn1.setTitleColor(MaterialColor.teal.darken1, forState: .Normal)
btn1.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
// Add buttons to right side.
secondCardView.rightButtons = [btn1]
......
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '1.31.6'
s.version = '1.32.0'
s.license = 'BSD'
s.summary = 'Material is an animation and graphics framework in Swift.'
s.summary = 'Material is an animation and graphics framework for Google\'s Material Design and Apple\'s Flat UI in Swift.'
s.homepage = 'http://cosmicmind.io'
s.social_media_url = 'https://www.facebook.com/graphkit'
s.authors = { 'CosmicMind, Inc.' => 'support@cosmicmind.io' }
......
......@@ -2,7 +2,7 @@
# Welcome to Material
Material is an animation and graphics framework. It may be used for Google's Material Design and Apple's Flat UI. Material allows the creativity of others to easily be expressed.
Material is an animation and graphics framework for Google's Material Design and Apple's Flat UI in Swift. Material allows the creativity of others to easily be expressed.
## Features
......@@ -227,16 +227,20 @@ Right out of the box to a fully customizable configuration, CardView always stan
![MaterialCardView](http://www.cosmicmind.io/MK/MaterialCardView.gif)
[Learn More About CardView](https://github.com/CosmicMind/Material/wiki/CardView)
Easily remove the pulse animation and add a background image for an entirely new feel.
![MaterialCardViewFavorite](http://www.cosmicmind.io/MK/MaterialCardViewFavorite.gif)
Add any view as the detail to a CardView. For example, a UITableView.
![MaterialTableCardView](http://www.cosmicmind.io/MK/MaterialTableCardView.gif)
CardViews are so flexible they create entirely new components by removing all but certain elements. For example, bellow is a button bar by only setting the button values of the CardView.
![MaterialCardViewButtonBar](http://www.cosmicmind.io/MK/MaterialCardViewButtonBar.gif)
[Learn More About CardView](https://github.com/CosmicMind/Material/wiki/CardView)
<a name="imagecardview"></a>
## ImageCardView
......
......@@ -119,29 +119,29 @@ public class CardView : MaterialPulseView {
}
/**
:name: detailLabelInsets
:name: detailViewInsets
*/
public var detailLabelInsetPreset: MaterialEdgeInsetPreset = .None {
public var detailViewInsetPreset: MaterialEdgeInsetPreset = .None {
didSet {
detailLabelInset = MaterialEdgeInsetPresetToValue(detailLabelInsetPreset)
detailViewInset = MaterialEdgeInsetPresetToValue(detailViewInsetPreset)
}
}
/**
:name: detailLabelInset
:name: detailViewInset
*/
public var detailLabelInset: UIEdgeInsets = MaterialEdgeInsetPresetToValue(.Square2) {
public var detailViewInset: UIEdgeInsets = MaterialEdgeInsetPresetToValue(.Square2) {
didSet {
reloadView()
}
}
/**
:name: detailLabel
:name: detailView
*/
public var detailLabel: UILabel? {
public var detailView: UIView? {
didSet {
detailLabel?.translatesAutoresizingMaskIntoConstraints = false
detailView?.translatesAutoresizingMaskIntoConstraints = false
reloadView()
}
}
......@@ -234,9 +234,9 @@ public class CardView : MaterialPulseView {
/**
:name: init
*/
public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, detailLabel: UILabel? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) {
public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, detailView: UIView? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) {
self.init(frame: CGRectNull)
prepareProperties(image, titleLabel: titleLabel, detailLabel: detailLabel, leftButtons: leftButtons, rightButtons: rightButtons)
prepareProperties(image, titleLabel: titleLabel, detailView: detailView, leftButtons: leftButtons, rightButtons: rightButtons)
}
/**
......@@ -279,13 +279,13 @@ public class CardView : MaterialPulseView {
if nil != titleLabel {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + titleLabelInset.top
} else if nil != detailLabel {
} else if nil != detailView {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + detailLabelInset.top
metrics["insetTop"] = contentInset.top + detailViewInset.top
}
// title
if let v = titleLabel {
if let v: UILabel = titleLabel {
addSubview(v)
verticalFormat += "-[titleLabel]"
......@@ -295,24 +295,24 @@ public class CardView : MaterialPulseView {
}
// detail
if let v = detailLabel {
if let v: UIView = detailView {
addSubview(v)
if nil == titleLabel {
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailLabelInset.top
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailViewInset.top
} else {
verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInset.bottom + detailLabelInset.top
metrics["insetB"] = titleLabelInset.bottom + detailViewInset.top
}
verticalFormat += "-[detailLabel]"
views["detailLabel"] = v
verticalFormat += "-[detailView]"
views["detailView"] = v
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailLabelInset.left, right: contentInset.right + detailLabelInset.right)
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailViewInset.left, right: contentInset.right + detailViewInset.right)
}
// leftButtons
if let v = leftButtons {
if let v: Array<UIButton> = leftButtons {
if 0 < v.count {
var h: String = "H:|"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
......@@ -339,7 +339,7 @@ public class CardView : MaterialPulseView {
}
// rightButtons
if let v = rightButtons {
if let v: Array<UIButton> = rightButtons {
if 0 < v.count {
var h: String = "H:"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
......@@ -378,11 +378,11 @@ public class CardView : MaterialPulseView {
metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
}
if nil != detailLabel {
if nil != detailView {
if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInset.bottom + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetBottom"] = contentInset.bottom + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
}
} else if nil != titleLabel {
if nil == metrics["insetC"] {
......@@ -394,7 +394,6 @@ public class CardView : MaterialPulseView {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
}
if 0 < views.count {
verticalFormat += "-(insetBottom)-|"
addConstraints(MaterialLayout.constraint(verticalFormat, options: [], metrics: metrics, views: views))
......@@ -427,10 +426,10 @@ public class CardView : MaterialPulseView {
/**
:name: prepareProperties
*/
internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, detailLabel: UILabel?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) {
internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, detailView: UIView?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) {
self.image = image
self.titleLabel = titleLabel
self.detailLabel = detailLabel
self.detailView = detailView
self.leftButtons = leftButtons
self.rightButtons = rightButtons
}
......
......@@ -209,29 +209,29 @@ public class ImageCardView : MaterialPulseView {
}
/**
:name: detailLabelInsets
:name: detailViewInsets
*/
public var detailLabelInsetPreset: MaterialEdgeInsetPreset = .None {
public var detailViewInsetPreset: MaterialEdgeInsetPreset = .None {
didSet {
detailLabelInset = MaterialEdgeInsetPresetToValue(detailLabelInsetPreset)
detailViewInset = MaterialEdgeInsetPresetToValue(detailViewInsetPreset)
}
}
/**
:name: detailLabelInset
:name: detailViewInset
*/
public var detailLabelInset: UIEdgeInsets = MaterialEdgeInsetPresetToValue(.Square2) {
public var detailViewInset: UIEdgeInsets = MaterialEdgeInsetPresetToValue(.Square2) {
didSet {
reloadView()
}
}
/**
:name: detailLabel
:name: detailView
*/
public var detailLabel: UILabel? {
public var detailView: UIView? {
didSet {
detailLabel?.translatesAutoresizingMaskIntoConstraints = false
detailView?.translatesAutoresizingMaskIntoConstraints = false
reloadView()
}
}
......@@ -324,9 +324,9 @@ public class ImageCardView : MaterialPulseView {
/**
:name: init
*/
public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, detailLabel: UILabel? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) {
public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, detailView: UIView? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) {
self.init(frame: CGRectNull)
prepareProperties(image, titleLabel: titleLabel, detailLabel: detailLabel, leftButtons: leftButtons, rightButtons: rightButtons)
prepareProperties(image, titleLabel: titleLabel, detailView: detailView, leftButtons: leftButtons, rightButtons: rightButtons)
}
/**
......@@ -376,13 +376,13 @@ public class ImageCardView : MaterialPulseView {
} else if nil != titleLabel {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + titleLabelInset.top
} else if nil != detailLabel {
} else if nil != detailView {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInset.top + detailLabelInset.top
metrics["insetTop"] = contentInset.top + detailViewInset.top
}
// title
if let v = titleLabel {
if let v: UILabel = titleLabel {
addSubview(v)
if nil == imageLayer?.contents {
......@@ -395,24 +395,24 @@ public class ImageCardView : MaterialPulseView {
}
// detail
if let v = detailLabel {
if let v: UIView = detailView {
addSubview(v)
if nil == imageLayer?.contents && nil != titleLabel {
verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInset.bottom + detailLabelInset.top
metrics["insetB"] = titleLabelInset.bottom + detailViewInset.top
} else {
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailLabelInset.top
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailViewInset.top
}
verticalFormat += "-[detailLabel]"
views["detailLabel"] = v
verticalFormat += "-[detailView]"
views["detailView"] = v
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailLabelInset.left, right: contentInset.right + detailLabelInset.right)
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailViewInset.left, right: contentInset.right + detailViewInset.right)
}
// leftButtons
if let v = leftButtons {
if let v: Array<UIButton> = leftButtons {
if 0 < v.count {
var h: String = "H:|"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
......@@ -439,7 +439,7 @@ public class ImageCardView : MaterialPulseView {
}
// rightButtons
if let v = rightButtons {
if let v: Array<UIButton> = rightButtons {
if 0 < v.count {
var h: String = "H:"
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
......@@ -479,11 +479,11 @@ public class ImageCardView : MaterialPulseView {
metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
}
if nil != detailLabel {
if nil != detailView {
if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInset.bottom + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetBottom"] = contentInset.bottom + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
}
} else if nil != titleLabel {
if nil == metrics["insetC"] {
......@@ -494,7 +494,7 @@ public class ImageCardView : MaterialPulseView {
} else if nil != metrics["insetC"] {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
}
} else if nil != detailLabel {
} else if nil != detailView {
if 0 < leftButtons?.count {
verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0]
......@@ -508,9 +508,9 @@ public class ImageCardView : MaterialPulseView {
}
if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInset.bottom + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetBottom"] = contentInset.bottom + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
}
} else {
if 0 < leftButtons?.count {
......@@ -576,10 +576,10 @@ public class ImageCardView : MaterialPulseView {
/**
:name: prepareProperties
*/
internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, detailLabel: UILabel?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) {
internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, detailView: UIView?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) {
self.image = image
self.titleLabel = titleLabel
self.detailLabel = detailLabel
self.detailView = detailView
self.leftButtons = leftButtons
self.rightButtons = rightButtons
}
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.31.6</string>
<string>1.32.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
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