Commit 1dc511ca by Daniel Dahan

issue-304: Added example with two CardViews.

parent a317e8dc
...@@ -25,16 +25,27 @@ ...@@ -25,16 +25,27 @@
<constraint firstAttribute="height" constant="200" id="fB1-Lj-ku6"/> <constraint firstAttribute="height" constant="200" id="fB1-Lj-ku6"/>
</constraints> </constraints>
</view> </view>
<view contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ylj-hn-p8r" customClass="CardView" customModule="Material">
<rect key="frame" x="20" y="361" width="560" height="185"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="200" id="RUo-o3-zj2"/>
</constraints>
</view>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstItem="ylj-hn-p8r" firstAttribute="leading" secondItem="dkT-RV-hy3" secondAttribute="leading" id="5w9-za-1gm"/>
<constraint firstItem="dkT-RV-hy3" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="88" id="6OV-Jx-9WC"/> <constraint firstItem="dkT-RV-hy3" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="88" id="6OV-Jx-9WC"/>
<constraint firstAttribute="trailingMargin" secondItem="dkT-RV-hy3" secondAttribute="trailing" id="ETS-RI-4Ow"/> <constraint firstAttribute="trailingMargin" secondItem="dkT-RV-hy3" secondAttribute="trailing" id="ETS-RI-4Ow"/>
<constraint firstItem="dkT-RV-hy3" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="JyX-Ka-Od1"/> <constraint firstItem="dkT-RV-hy3" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="JyX-Ka-Od1"/>
<constraint firstItem="ylj-hn-p8r" firstAttribute="trailing" secondItem="dkT-RV-hy3" secondAttribute="trailing" id="aQK-5e-qe2"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="ylj-hn-p8r" secondAttribute="bottom" constant="54" id="piH-oh-PBB"/>
</constraints> </constraints>
</view> </view>
<connections> <connections>
<outlet property="cardView" destination="dkT-RV-hy3" id="2UC-zJ-Eh4"/> <outlet property="bottomCardView" destination="ylj-hn-p8r" id="Nd1-xc-hkc"/>
<outlet property="topCardView" destination="dkT-RV-hy3" id="1mM-nh-GoH"/>
</connections> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
......
...@@ -33,9 +33,6 @@ ...@@ -33,9 +33,6 @@
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array> </array>
</dict> </dict>
</plist> </plist>
...@@ -32,12 +32,14 @@ import UIKit ...@@ -32,12 +32,14 @@ import UIKit
import Material import Material
class ViewController: UIViewController { class ViewController: UIViewController {
@IBOutlet weak var cardView: CardView! @IBOutlet weak var topCardView: CardView!
@IBOutlet weak var bottomCardView: CardView!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
prepareCardView() prepareTopCardView()
prepareBottomCardView()
} }
/// Prepares the view. /// Prepares the view.
...@@ -45,20 +47,20 @@ class ViewController: UIViewController { ...@@ -45,20 +47,20 @@ class ViewController: UIViewController {
view.backgroundColor = MaterialColor.white view.backgroundColor = MaterialColor.white
} }
/// Prepares the cardView. /// Prepares the topCardView.
func prepareCardView() { func prepareTopCardView() {
// Title label. // Title label.
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
titleLabel.text = "Welcome Back!" titleLabel.text = "Welcome Back!"
titleLabel.textColor = MaterialColor.blue.darken1 titleLabel.textColor = MaterialColor.blue.darken1
titleLabel.font = RobotoFont.mediumWithSize(20) titleLabel.font = RobotoFont.mediumWithSize(20)
cardView.titleLabel = titleLabel topCardView.titleLabel = titleLabel
// Detail label. // Detail label.
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
detailLabel.text = "It’s been a while, have you read any new books lately?" detailLabel.text = "It’s been a while, have you read any new books lately?"
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
cardView.detailView = detailLabel topCardView.detailView = detailLabel
// Yes button. // Yes button.
let btn1: FlatButton = FlatButton() let btn1: FlatButton = FlatButton()
...@@ -75,7 +77,40 @@ class ViewController: UIViewController { ...@@ -75,7 +77,40 @@ class ViewController: UIViewController {
btn2.setTitleColor(MaterialColor.blue.darken1, forState: .Normal) btn2.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
// Add buttons to left side. // Add buttons to left side.
cardView.leftButtons = [btn1, btn2] topCardView.leftButtons = [btn1, btn2]
}
/// Prepares the bottomCardView.
func prepareBottomCardView() {
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.text = "Welcome Back!"
titleLabel.textColor = MaterialColor.blue.darken1
titleLabel.font = RobotoFont.mediumWithSize(20)
bottomCardView.titleLabel = titleLabel
// Detail label.
let detailLabel: UILabel = UILabel()
detailLabel.text = "It’s been a while, have you read any new books lately?"
detailLabel.numberOfLines = 0
bottomCardView.detailView = detailLabel
// Yes button.
let btn1: FlatButton = FlatButton()
btn1.pulseColor = MaterialColor.blue.lighten1
btn1.pulseScale = false
btn1.setTitle("YES", forState: .Normal)
btn1.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
// No button.
let btn2: FlatButton = FlatButton()
btn2.pulseColor = MaterialColor.blue.lighten1
btn2.pulseScale = false
btn2.setTitle("NO", forState: .Normal)
btn2.setTitleColor(MaterialColor.blue.darken1, forState: .Normal)
// Add buttons to left side.
bottomCardView.leftButtons = [btn1, btn2]
} }
} }
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Material' s.name = 'Material'
s.version = '1.39.8' s.version = '1.39.9'
s.license = 'BSD' s.license = 'BSD'
s.summary = 'Express your creativity with Material, an animation and graphics framework for Google\'s Material Design and Apple\'s Flat UI in Swift.' s.summary = 'Express your creativity with Material, an animation and graphics framework for Google\'s Material Design and Apple\'s Flat UI in Swift.'
s.homepage = 'http://cosmicmind.io' s.homepage = 'http://cosmicmind.io'
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.39.8</string> <string>1.39.9</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <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