Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
51dbc2fa
Commit
51dbc2fa
authored
Aug 26, 2015
by
adamdahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New image text card + addition to Layout + small refactor to other cards
parent
493444cf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
5 deletions
+100
-5
MaterialKit.xcodeproj/project.pbxproj
+4
-0
Source/BasicCard.swift
+2
-2
Source/ImageCard.swift
+2
-2
Source/ImageTextCard.swift
+82
-0
Source/Layout.swift
+10
-1
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
51dbc2fa
...
...
@@ -31,6 +31,7 @@
963832851B89070E0015F710
/* CapturePreview.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9638325F1B88E5BF0015F710
/* CapturePreview.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
963832881B8908180015F710
/* Layout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832871B8908180015F710
/* Layout.swift */
;
};
963832891B89097D0015F710
/* Layout.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832871B8908180015F710
/* Layout.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A3A3B6A1B8E992F005F16BC
/* ImageTextCard.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A3A3B691B8E992F005F16BC
/* ImageTextCard.swift */
;
};
9A94D0F91B895C8C00F586A5
/* Roboto.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9AAC38531B89559900FE6B2D
/* Roboto.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A94D0FA1B895EA500F586A5
/* LICENSE in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832631B88E5BF0015F710
/* LICENSE */
;
};
9A94D0FB1B895EA500F586A5
/* Roboto-Regular.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9AAC38591B8956E300FE6B2D
/* Roboto-Regular.ttf */
;
};
...
...
@@ -73,6 +74,7 @@
963832671B88E5BF0015F710
/* TextStorage.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextStorage.swift
;
sourceTree
=
"<group>"
;
};
963832681B88E5BF0015F710
/* TextView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextView.swift
;
sourceTree
=
"<group>"
;
};
963832871B8908180015F710
/* Layout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layout.swift
;
sourceTree
=
"<group>"
;
};
9A3A3B691B8E992F005F16BC
/* ImageTextCard.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ImageTextCard.swift
;
sourceTree
=
"<group>"
;
};
9A94D1081B8A3F5100F586A5
/* MaterialPulseView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialPulseView.swift
;
sourceTree
=
"<group>"
;
};
9A94D10A1B8A485C00F586A5
/* ImageCard.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ImageCard.swift
;
sourceTree
=
"<group>"
;
};
9AAC384C1B89528900FE6B2D
/* BasicCard.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicCard.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -222,6 +224,7 @@
children
=
(
9AAC384C1B89528900FE6B2D
/* BasicCard.swift */
,
9A94D10A1B8A485C00F586A5
/* ImageCard.swift */
,
9A3A3B691B8E992F005F16BC
/* ImageTextCard.swift */
,
);
name
=
Card
;
sourceTree
=
"<group>"
;
...
...
@@ -362,6 +365,7 @@
9A94D10B1B8A485C00F586A5
/* ImageCard.swift in Sources */
,
9638326B1B88E5BF0015F710
/* FabButton.swift in Sources */
,
9A94D1091B8A3F5100F586A5
/* MaterialPulseView.swift in Sources */
,
9A3A3B6A1B8E992F005F16BC
/* ImageTextCard.swift in Sources */
,
65B965871B8BEEC60055B139
/* SideNavController.swift in Sources */
,
9638326C1B88E5BF0015F710
/* FlatButton.swift in Sources */
,
65B965751B8A60A00055B139
/* MaterialView.swift in Sources */
,
...
...
Source/BasicCard.swift
View file @
51dbc2fa
...
...
@@ -49,8 +49,8 @@ public class BasicCard : MaterialPulseView {
addConstraints
(
Layout
.
constraint
(
"H:|-(20)-[detailTextLabel]-(20)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
addConstraints
(
Layout
.
constraint
(
"H:|[horizontalSeparator]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
addConstraints
(
Layout
.
constraint
(
"H:|-(10)-[cancelButton(80)]-(10)-[otherButton(80)]"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
addConstraints
(
Layout
.
constraint
(
"V:|-(20)-[titleLabel(22)]-(10)-[detailTextLabel]-(20)-[
line
(1)]-(10)-[cancelButton]-(10)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
addConstraints
(
Layout
.
constraint
(
"V:|-(20)-[titleLabel(22)]-(10)-[detailTextLabel]-(20)-[
line
(1)]-(10)-[otherButton]-(10)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
addConstraints
(
Layout
.
constraint
(
"V:|-(20)-[titleLabel(22)]-(10)-[detailTextLabel]-(20)-[
horizontalSeparator
(1)]-(10)-[cancelButton]-(10)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
addConstraints
(
Layout
.
constraint
(
"V:|-(20)-[titleLabel(22)]-(10)-[detailTextLabel]-(20)-[
horizontalSeparator
(1)]-(10)-[otherButton]-(10)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
}
private
func
setupTitleLabel
()
{
...
...
Source/ImageCard.swift
View file @
51dbc2fa
...
...
@@ -30,7 +30,7 @@ public class ImageCard : MaterialPulseView {
}
internal
override
func
initialize
()
{
setup
ImageView
()
prepare
ImageView
()
super
.
initialize
()
}
...
...
@@ -40,7 +40,7 @@ public class ImageCard : MaterialPulseView {
addConstraints
(
Layout
.
constraint
(
"V:|[imageView]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
}
private
func
setup
ImageView
()
{
private
func
prepare
ImageView
()
{
imageView
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
imageView
.
contentMode
=
.
ScaleAspectFill
imageView
.
userInteractionEnabled
=
false
...
...
Source/ImageTextCard.swift
0 → 100644
View file @
51dbc2fa
//
// ImageTextCard.swift
// MaterialKit
//
// Created by Adam Dahan on 2015-08-26.
// Copyright (c) 2015 GraphKit Inc. All rights reserved.
//
import
UIKit
public
class
ImageTextCard
:
MaterialPulseView
{
public
lazy
var
imageView
:
UIImageView
=
UIImageView
()
public
lazy
var
titleLabel
:
UILabel
=
UILabel
()
public
lazy
var
descriptionContainerView
:
UIView
=
UIView
()
public
lazy
var
descriptionLabel
:
UILabel
=
UILabel
()
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
public
required
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
}
internal
override
func
initialize
()
{
prepareImageView
()
prepareTitleLabel
()
prepareDescriptionContainerView
()
prepareDescriptionLabel
()
super
.
initialize
()
}
internal
override
func
constrainSubviews
()
{
super
.
constrainSubviews
()
addConstraints
(
Layout
.
constraint
(
"H:|[imageView]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
imageView
.
addConstraints
(
Layout
.
constraint
(
"H:|-20-[titleLabel]-(20)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
imageView
.
addConstraints
(
Layout
.
constraint
(
"V:[titleLabel(45)]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
addConstraints
(
Layout
.
constraint
(
"H:|[descriptionContainerView]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
descriptionContainerView
.
addConstraints
(
Layout
.
constraint
(
"H:|-20-[descriptionLabel]-(20)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
descriptionContainerView
.
addConstraints
(
Layout
.
constraint
(
"V:|-(20)-[descriptionLabel]-(20)-|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
addConstraints
(
Layout
.
constraint
(
"V:|[imageView][descriptionContainerView(120)]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
}
private
func
prepareImageView
()
{
imageView
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
imageView
.
contentMode
=
.
ScaleAspectFill
imageView
.
userInteractionEnabled
=
false
imageView
.
clipsToBounds
=
true
addSubview
(
imageView
)
views
[
"imageView"
]
=
imageView
}
private
func
prepareTitleLabel
()
{
titleLabel
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
titleLabel
.
font
=
Roboto
.
mediumWithSize
(
18
)
titleLabel
.
textColor
=
.
whiteColor
()
titleLabel
.
text
=
"Card Title"
titleLabel
.
layer
.
shadowOffset
=
CGSizeMake
(
1
,
1
)
titleLabel
.
layer
.
shadowOpacity
=
0.4
titleLabel
.
layer
.
shadowRadius
=
5.0
imageView
.
addSubview
(
titleLabel
)
views
[
"titleLabel"
]
=
titleLabel
}
private
func
prepareDescriptionContainerView
()
{
descriptionContainerView
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
descriptionContainerView
.
backgroundColor
=
UIColor
.
whiteColor
()
addSubview
(
descriptionContainerView
)
views
[
"descriptionContainerView"
]
=
descriptionContainerView
}
private
func
prepareDescriptionLabel
()
{
descriptionLabel
.
setTranslatesAutoresizingMaskIntoConstraints
(
false
)
descriptionLabel
.
font
=
Roboto
.
lightWithSize
(
14
)
descriptionLabel
.
textColor
=
.
darkTextColor
()
descriptionLabel
.
numberOfLines
=
0
descriptionLabel
.
lineBreakMode
=
NSLineBreakMode
.
ByWordWrapping
descriptionLabel
.
text
=
"I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively."
descriptionContainerView
.
addSubview
(
descriptionLabel
)
views
[
"descriptionLabel"
]
=
descriptionLabel
}
}
Source/Layout.swift
View file @
51dbc2fa
...
...
@@ -84,7 +84,16 @@ public struct Layout {
parent
.
addConstraints
(
constraint
(
"H:[child]-(right)-|"
,
options
:
nil
,
metrics
:
metrics
,
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:[child]-(bottom)-|"
,
options
:
nil
,
metrics
:
metrics
,
views
:
views
))
}
/**
:name: alignAllSides
*/
public
static
func
alignAllSides
(
parent
:
UIView
,
child
:
UIView
)
{
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|[child]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:|[child]|"
,
options
:
nil
,
metrics
:
nil
,
views
:
views
))
}
/**
:name: constraint
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment