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
b1f97f5c
Unverified
Commit
b1f97f5c
authored
Oct 14, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: reworking internals for Cards
parent
71b92d5c
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
161 additions
and
142 deletions
+161
-142
Examples/Programmatic/Card/Card/ViewController.swift
+1
-0
Examples/Programmatic/ImageCard/ImageCard/Assets.xcassets/frontier.imageset/frontier.jpg
+0
-0
Examples/Programmatic/ImageCard/ImageCard/ViewController.swift
+48
-67
Examples/Programmatic/Layer/Layer/ViewController.swift
+1
-1
Examples/Programmatic/TabBar/TabBar/ViewController.swift
+24
-0
Sources/iOS/Bar.swift
+7
-8
Sources/iOS/Button.swift
+13
-1
Sources/iOS/CapturePreview.swift
+1
-1
Sources/iOS/Card.swift
+4
-7
Sources/iOS/CollectionReusableView.swift
+1
-1
Sources/iOS/CollectionViewCell.swift
+1
-1
Sources/iOS/Font.swift
+7
-7
Sources/iOS/ImageCard.swift
+9
-12
Sources/iOS/Material+CALayer.swift
+0
-10
Sources/iOS/NavigationBar.swift
+2
-0
Sources/iOS/NavigationItem.swift
+11
-5
Sources/iOS/PresenterCard.swift
+5
-7
Sources/iOS/PulseAnimation.swift
+3
-1
Sources/iOS/RobotoFont.swift
+20
-10
Sources/iOS/TableViewCell.swift
+1
-1
Sources/iOS/TextView.swift
+1
-1
Sources/iOS/View.swift
+1
-1
No files found.
Examples/Programmatic/Card/Card/ViewController.swift
View file @
b1f97f5c
...
@@ -68,6 +68,7 @@ class ViewController: UIViewController {
...
@@ -68,6 +68,7 @@ class ViewController: UIViewController {
dateFormatter
.
dateStyle
=
.
medium
dateFormatter
.
dateStyle
=
.
medium
dateFormatter
.
timeStyle
=
.
none
dateFormatter
.
timeStyle
=
.
none
}
}
private
func
prepareDateLabel
()
{
private
func
prepareDateLabel
()
{
dateLabel
=
UILabel
()
dateLabel
=
UILabel
()
dateLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
dateLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
...
...
Examples/Programmatic/ImageCard/ImageCard/Assets.xcassets/frontier.imageset/frontier.jpg
View file @
b1f97f5c
This image diff could not be displayed because it is too large. You can
view the blob
instead.
Examples/Programmatic/ImageCard/ImageCard/ViewController.swift
View file @
b1f97f5c
...
@@ -32,95 +32,76 @@ import UIKit
...
@@ -32,95 +32,76 @@ import UIKit
import
Material
import
Material
class
ViewController
:
UIViewController
{
class
ViewController
:
UIViewController
{
private
var
card
:
ImageCard
!
/// View.
internal
var
imageCard
:
ImageCard
!
/// Conent area.
private
var
imageView
:
UIImageView
!
private
var
contentView
:
UILabel
!
/// Bottom Bar views.
private
var
bottomBar
:
Bar
!
private
var
favoriteButton
:
FlatButton
!
private
var
shareButton
:
FlatButton
!
private
var
starButton
:
FlatButton
!
/// Toolbar views.
private
var
toolbar
:
Toolbar
!
private
var
moreButton
:
IconButton
!
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
Color
.
grey
.
lighten5
prepareImageView
()
// Prepare view.
prepareFavoriteButton
()
prepareImageCard
()
prepareShareButton
()
}
prepareStarButton
()
}
prepareMoreButton
()
/// ImageCard.
extension
ViewController
{
internal
func
prepareImageCard
()
{
imageCard
=
ImageCard
()
view
.
layout
(
imageCard
)
.
horizontally
(
left
:
20
,
right
:
20
)
.
center
()
prepareToolbar
()
prepareToolbar
()
prepareImageView
()
prepareContentView
()
prepareContentView
()
prepareBottomBar
()
prepareBottomBar
()
prepareImageCard
()
}
private
func
prepareImageView
()
{
imageView
=
UIImageView
()
imageView
.
image
=
UIImage
(
named
:
"frontier.jpg"
)?
.
resize
(
toWidth
:
view
.
width
)
imageView
.
contentMode
=
.
scaleAspectFill
}
private
func
prepareFavoriteButton
()
{
favoriteButton
=
FlatButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
blueGrey
.
base
)
}
private
func
prepareShareButton
()
{
shareButton
=
FlatButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
Color
.
blueGrey
.
base
)
}
private
func
prepareStarButton
()
{
starButton
=
FlatButton
(
image
:
Icon
.
cm
.
star
,
tintColor
:
Color
.
blueGrey
.
base
)
}
private
func
prepareMoreButton
()
{
moreButton
=
IconButton
(
image
:
Icon
.
cm
.
moreHorizontal
,
tintColor
:
.
white
)
}
}
private
func
prepareToolbar
()
{
private
func
prepareToolbar
()
{
toolbar
=
Toolbar
()
imageCard
.
toolbar
=
Toolbar
()
toolbar
.
backgroundColor
=
nil
imageCard
.
toolbar
?
.
backgroundColor
=
.
clear
imageCard
.
toolbarEdgeInsetsPreset
=
.
square3
toolbar
.
title
=
"CosmicMind"
// Use the property subscript to access the model data.
toolbar
.
titleLabel
.
textColor
=
.
white
imageCard
.
toolbar
?
.
title
=
"Graph"
imageCard
.
toolbar
?
.
titleLabel
.
textColor
=
.
white
toolbar
.
detail
=
"Build Beautiful
Software"
imageCard
.
toolbar
?
.
detail
=
"Build Data-Driven
Software"
toolbar
.
detailLabel
.
textColor
=
.
white
imageCard
.
toolbar
?
.
detailLabel
.
textColor
=
.
white
}
}
private
func
prepareContentView
()
{
private
func
prepareImageView
()
{
contentView
=
UILabel
()
imageCard
.
imageView
=
UIImageView
()
contentView
.
numberOfLines
=
0
imageCard
.
imageView
?
.
image
=
UIImage
(
named
:
"frontier.jpg"
)?
.
resize
(
toWidth
:
view
.
width
)
contentView
.
text
=
"Build beautiful applications that are intelligently driven using Material, Graph, and Algorithm."
contentView
.
font
=
RobotoFont
.
regular
(
with
:
14
)
}
}
private
func
prepareBottomBar
()
{
private
func
prepareContentView
()
{
bottomBar
=
Bar
(
centerViews
:
[
favoriteButton
,
shareButton
,
starButton
])
let
label
=
UILabel
()
label
.
numberOfLines
=
0
label
.
text
=
"Graph is a semantic database that is used to create data-driven applications."
label
.
font
=
RobotoFont
.
regular
(
with
:
14
)
imageCard
.
contentView
=
label
imageCard
.
contentViewEdgeInsetsPreset
=
.
square3
}
}
private
func
prepareImageCard
()
{
private
func
prepareBottomBar
()
{
card
=
ImageCard
()
let
shareButton
=
IconButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
Color
.
blueGrey
.
base
)
let
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
red
.
base
)
card
.
imageView
=
imageView
card
.
toolbar
=
toolbar
card
.
toolbarEdgeInsetsPreset
=
.
square3
card
.
contentView
=
contentView
let
label
=
UILabel
()
card
.
contentViewEdgeInsetsPreset
=
.
square3
label
.
text
=
"CosmicMind"
label
.
textAlignment
=
.
center
label
.
textColor
=
Color
.
blueGrey
.
base
label
.
font
=
RobotoFont
.
regular
(
with
:
12
)
card
.
bottomBar
=
bottomBar
imageCard
.
bottomBar
=
Bar
()
imageCard
.
bottomBarEdgeInsetsPreset
=
.
wideRectangle2
imageCard
.
bottomBarEdgeInsets
.
top
=
0
imageCard
.
bottomBar
?
.
contentViewAlignment
=
.
center
view
.
layout
(
card
)
.
horizontally
(
left
:
20
,
right
:
20
)
.
center
()
imageCard
.
bottomBar
?
.
leftViews
=
[
favoriteButton
]
imageCard
.
bottomBar
?
.
centerViews
=
[
label
]
imageCard
.
bottomBar
?
.
rightViews
=
[
shareButton
]
}
}
}
}
Examples/Programmatic/Layer/Layer/ViewController.swift
View file @
b1f97f5c
...
@@ -49,7 +49,7 @@ class ViewController: UIViewController {
...
@@ -49,7 +49,7 @@ class ViewController: UIViewController {
layer
=
Layer
(
frame
:
CGRect
(
x
:
(
w
-
d
)
/
2
,
y
:
(
h
-
d
)
/
2
,
width
:
d
,
height
:
d
))
layer
=
Layer
(
frame
:
CGRect
(
x
:
(
w
-
d
)
/
2
,
y
:
(
h
-
d
)
/
2
,
width
:
d
,
height
:
d
))
layer
.
depthPreset
=
.
depth3
layer
.
depthPreset
=
.
depth3
layer
.
shapePreset
=
.
circle
layer
.
shapePreset
=
.
circle
layer
.
b
gColor
=
.
white
layer
.
b
ackgroundColor
=
Color
.
white
.
cgColor
layer
.
image
=
UIImage
(
named
:
"CosmicMind"
)
layer
.
image
=
UIImage
(
named
:
"CosmicMind"
)
view
.
layer
.
addSublayer
(
layer
)
view
.
layer
.
addSublayer
(
layer
)
...
...
Examples/Programmatic/TabBar/TabBar/ViewController.swift
View file @
b1f97f5c
...
@@ -55,6 +55,30 @@ class ViewController: UIViewController {
...
@@ -55,6 +55,30 @@ class ViewController: UIViewController {
let
btn3
=
FlatButton
(
title
:
"Video"
,
titleColor
:
Color
.
blueGrey
.
base
)
let
btn3
=
FlatButton
(
title
:
"Video"
,
titleColor
:
Color
.
blueGrey
.
base
)
btn3
.
pulseAnimation
=
.
none
btn3
.
pulseAnimation
=
.
none
buttons
.
append
(
btn3
)
buttons
.
append
(
btn3
)
let
btn4
=
FlatButton
(
title
:
"Video"
,
titleColor
:
Color
.
blueGrey
.
base
)
btn4
.
pulseAnimation
=
.
none
buttons
.
append
(
btn4
)
let
btn5
=
FlatButton
(
title
:
"Video 1"
,
titleColor
:
Color
.
blueGrey
.
base
)
btn5
.
pulseAnimation
=
.
none
buttons
.
append
(
btn5
)
//
// let btn6 = FlatButton(title: "Video 2", titleColor: Color.blueGrey.base)
// btn6.pulseAnimation = .none
// buttons.append(btn6)
//
// let btn7 = FlatButton(title: "Video 3", titleColor: Color.blueGrey.base)
// btn7.pulseAnimation = .none
// buttons.append(btn7)
//
// let btn8 = FlatButton(title: "Video 4", titleColor: Color.blueGrey.base)
// btn8.pulseAnimation = .none
// buttons.append(btn8)
//
// let btn9 = FlatButton(title: "Video 5", titleColor: Color.blueGrey.base)
// btn9.pulseAnimation = .none
// buttons.append(btn9)
}
}
private
func
prepareTabBar
()
{
private
func
prepareTabBar
()
{
...
...
Sources/iOS/Bar.swift
View file @
b1f97f5c
...
@@ -125,15 +125,12 @@ open class Bar: View {
...
@@ -125,15 +125,12 @@ open class Bar: View {
}
}
/// Center UIViews.
/// Center UIViews.
open
var
centerViews
:
[
UIView
]
{
open
var
centerViews
=
[
UIView
]()
{
get
{
didSet
{
return
contentView
.
grid
.
views
for
v
in
oldValue
{
}
set
(
value
)
{
for
v
in
contentView
.
grid
.
views
{
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
}
}
contentView
.
grid
.
views
=
value
layoutSubviews
()
}
}
}
}
...
@@ -168,12 +165,13 @@ open class Bar: View {
...
@@ -168,12 +165,13 @@ open class Bar: View {
- Parameter centerViews: An Array of UIViews that go in the center.
- Parameter centerViews: An Array of UIViews that go in the center.
*/
*/
public
init
(
leftViews
:
[
UIView
]?
=
nil
,
rightViews
:
[
UIView
]?
=
nil
,
centerViews
:
[
UIView
]?
=
nil
)
{
public
init
(
leftViews
:
[
UIView
]?
=
nil
,
rightViews
:
[
UIView
]?
=
nil
,
centerViews
:
[
UIView
]?
=
nil
)
{
super
.
init
(
frame
:
.
zero
)
self
.
leftViews
=
leftViews
??
[]
self
.
leftViews
=
leftViews
??
[]
self
.
rightViews
=
rightViews
??
[]
self
.
rightViews
=
rightViews
??
[]
super
.
init
(
frame
:
.
zero
)
self
.
centerViews
=
centerViews
??
[]
self
.
centerViews
=
centerViews
??
[]
frame
.
size
=
intrinsicContentSize
frame
.
size
=
intrinsicContentSize
}
}
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
guard
willLayout
else
{
guard
willLayout
else
{
...
@@ -224,6 +222,7 @@ open class Bar: View {
...
@@ -224,6 +222,7 @@ open class Bar: View {
}
}
contentView
.
grid
.
begin
()
contentView
.
grid
.
begin
()
contentView
.
grid
.
views
=
centerViews
if
.
center
==
contentViewAlignment
{
if
.
center
==
contentViewAlignment
{
if
lc
<
rc
{
if
lc
<
rc
{
...
...
Sources/iOS/Button.swift
View file @
b1f97f5c
...
@@ -79,7 +79,7 @@ open class Button: UIButton {
...
@@ -79,7 +79,7 @@ open class Button: UIButton {
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
b
gColor
=
background
Color
layer
.
b
ackgroundColor
=
backgroundColor
?
.
cg
Color
}
}
}
}
...
@@ -192,6 +192,8 @@ open class Button: UIButton {
...
@@ -192,6 +192,8 @@ open class Button: UIButton {
}
}
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
:
&
s
.
pulse
)
Animation
.
pulseContractAnimation
(
layer
:
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulse
:
&
s
.
pulse
)
}
}
bringImageViewToFront
()
}
}
/**
/**
...
@@ -203,6 +205,8 @@ open class Button: UIButton {
...
@@ -203,6 +205,8 @@ open class Button: UIButton {
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
with
:
event
)
super
.
touchesBegan
(
touches
,
with
:
event
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
point
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
Animation
.
pulseExpandAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
point
:
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
),
width
:
width
,
height
:
height
,
pulse
:
&
pulse
)
bringImageViewToFront
()
}
}
/**
/**
...
@@ -227,6 +231,14 @@ open class Button: UIButton {
...
@@ -227,6 +231,14 @@ open class Button: UIButton {
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
Animation
.
pulseContractAnimation
(
layer
:
layer
,
visualLayer
:
visualLayer
,
pulse
:
&
pulse
)
}
}
open
func
bringImageViewToFront
()
{
guard
let
v
=
imageView
else
{
return
}
bringSubview
(
toFront
:
v
)
}
/**
/**
Prepares the view instance when intialized. When subclassing,
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
it is recommended to override the prepare method
...
...
Sources/iOS/CapturePreview.swift
View file @
b1f97f5c
...
@@ -70,7 +70,7 @@ open class CapturePreview: View {
...
@@ -70,7 +70,7 @@ open class CapturePreview: View {
/// Prepares the previewLayer.
/// Prepares the previewLayer.
private
func
preparePreviewLayer
()
{
private
func
preparePreviewLayer
()
{
layer
.
b
gColor
=
.
black
layer
.
b
ackgroundColor
=
Color
.
black
.
cgColor
layer
.
masksToBounds
=
true
layer
.
masksToBounds
=
true
(
layer
as!
AVCaptureVideoPreviewLayer
)
.
videoGravity
=
AVLayerVideoGravityResizeAspectFill
(
layer
as!
AVCaptureVideoPreviewLayer
)
.
videoGravity
=
AVLayerVideoGravityResizeAspectFill
}
}
...
...
Sources/iOS/Card.swift
View file @
b1f97f5c
...
@@ -178,7 +178,7 @@ open class Card: PulseView {
...
@@ -178,7 +178,7 @@ open class Card: PulseView {
/// Reloads the layout.
/// Reloads the layout.
open
func
reload
()
{
open
func
reload
()
{
// Clear constraints so new ones do not conflict.
// Clear constraints so new ones do not conflict.
container
.
removeConstraints
(
constraints
)
container
.
removeConstraints
(
con
tainer
.
con
straints
)
for
v
in
container
.
subviews
{
for
v
in
container
.
subviews
{
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
}
}
...
@@ -193,9 +193,7 @@ open class Card: PulseView {
...
@@ -193,9 +193,7 @@ open class Card: PulseView {
format
+=
"-(toolbarTop)-[toolbar]-(toolbarBottom)"
format
+=
"-(toolbarTop)-[toolbar]-(toolbarBottom)"
views
[
"toolbar"
]
=
v
views
[
"toolbar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
}
if
let
v
=
contentView
{
if
let
v
=
contentView
{
...
@@ -211,6 +209,7 @@ open class Card: PulseView {
...
@@ -211,6 +209,7 @@ open class Card: PulseView {
views
[
"contentView"
]
=
v
views
[
"contentView"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
grid
.
reload
()
v
.
divider
.
reload
()
v
.
divider
.
reload
()
}
}
...
@@ -230,9 +229,7 @@ open class Card: PulseView {
...
@@ -230,9 +229,7 @@ open class Card: PulseView {
}
}
views
[
"bottomBar"
]
=
v
views
[
"bottomBar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
}
guard
0
<
views
.
count
else
{
guard
0
<
views
.
count
else
{
...
...
Sources/iOS/CollectionReusableView.swift
View file @
b1f97f5c
...
@@ -186,7 +186,7 @@ open class CollectionReusableView: UICollectionReusableView {
...
@@ -186,7 +186,7 @@ open class CollectionReusableView: UICollectionReusableView {
/// A property that accesses the backing layer's background
/// A property that accesses the backing layer's background
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
b
gColor
=
background
Color
layer
.
b
ackgroundColor
=
backgroundColor
?
.
cg
Color
}
}
}
}
...
...
Sources/iOS/CollectionViewCell.swift
View file @
b1f97f5c
...
@@ -193,7 +193,7 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -193,7 +193,7 @@ open class CollectionViewCell: UICollectionViewCell {
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
b
gColor
=
background
Color
layer
.
b
ackgroundColor
=
backgroundColor
?
.
cg
Color
}
}
}
}
...
...
Sources/iOS/Font.swift
View file @
b1f97f5c
...
@@ -32,31 +32,31 @@ import UIKit
...
@@ -32,31 +32,31 @@ import UIKit
public
protocol
FontType
{}
public
protocol
FontType
{}
public
struct
Font
:
FontType
{
public
struct
Font
{
/// Size of font.
/// Size of font.
public
static
let
pointSize
:
CGFloat
=
16
public
static
let
pointSize
:
CGFloat
=
16
/**
/**
Retrieves the system font with a specified size.
Retrieves the system font with a specified size.
- Parameter
fontName: A String font name
.
- Parameter
ofSize size: A CGFloat
.
*/
*/
public
static
func
systemFont
WithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
systemFont
(
ofSize
size
:
CGFloat
)
->
UIFont
{
return
UIFont
.
systemFont
(
ofSize
:
size
)
return
UIFont
.
systemFont
(
ofSize
:
size
)
}
}
/**
/**
Retrieves the bold system font with a specified size..
Retrieves the bold system font with a specified size..
- Parameter
fontName: A String font name
.
- Parameter
ofSize size: A CGFloat
.
*/
*/
public
static
func
boldSystemFont
WithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
boldSystemFont
(
ofSize
size
:
CGFloat
)
->
UIFont
{
return
UIFont
.
boldSystemFont
(
ofSize
:
size
)
return
UIFont
.
boldSystemFont
(
ofSize
:
size
)
}
}
/**
/**
Retrieves the italic system font with a specified size.
Retrieves the italic system font with a specified size.
- Parameter
fontName: A String font name
.
- Parameter
ofSize size: A CGFloat
.
*/
*/
public
static
func
italicSystemFont
WithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
italicSystemFont
(
ofSize
size
:
CGFloat
)
->
UIFont
{
return
UIFont
.
italicSystemFont
(
ofSize
:
size
)
return
UIFont
.
italicSystemFont
(
ofSize
:
size
)
}
}
...
...
Sources/iOS/ImageCard.swift
View file @
b1f97f5c
...
@@ -74,7 +74,7 @@ open class ImageCard: Card {
...
@@ -74,7 +74,7 @@ open class ImageCard: Card {
}
}
// Clear constraints so new ones do not conflict.
// Clear constraints so new ones do not conflict.
container
.
removeConstraints
(
constraints
)
container
.
removeConstraints
(
con
tainer
.
con
straints
)
for
v
in
container
.
subviews
{
for
v
in
container
.
subviews
{
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
}
}
...
@@ -89,18 +89,16 @@ open class ImageCard: Card {
...
@@ -89,18 +89,16 @@ open class ImageCard: Card {
format
+=
"-(imageViewTop)-[imageView]-(imageViewBottom)"
format
+=
"-(imageViewTop)-[imageView]-(imageViewBottom)"
views
[
"imageView"
]
=
iv
views
[
"imageView"
]
=
iv
container
.
layout
(
iv
)
.
horizontally
(
left
:
imageViewEdgeInsets
.
left
,
right
:
imageViewEdgeInsets
.
right
)
container
.
layout
(
iv
)
.
horizontally
(
left
:
imageViewEdgeInsets
.
left
,
right
:
imageViewEdgeInsets
.
right
)
iv
.
grid
.
reload
()
iv
.
divider
.
reload
()
iv
.
divider
.
reload
()
if
let
v
=
toolbar
{
if
let
v
=
toolbar
{
iv
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
.
height
(
v
.
height
)
iv
.
layout
IfNeeded
(
)
if
.
top
==
toolbarAlignment
{
container
.
layout
(
v
)
iv
.
layout
(
v
)
.
top
(
toolbarEdgeInsets
.
top
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
}
else
{
.
top
(
.
top
==
toolbarAlignment
?
toolbarEdgeInsets
.
top
:
iv
.
height
-
v
.
height
-
toolbarEdgeInsets
.
bottom
)
iv
.
layout
(
v
)
.
bottom
(
toolbarEdgeInsets
.
bottom
)
}
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
}
if
let
v
=
contentView
{
if
let
v
=
contentView
{
...
@@ -110,6 +108,7 @@ open class ImageCard: Card {
...
@@ -110,6 +108,7 @@ open class ImageCard: Card {
format
+=
"-[contentView]-(contentViewBottom)"
format
+=
"-[contentView]-(contentViewBottom)"
views
[
"contentView"
]
=
v
views
[
"contentView"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
grid
.
reload
()
v
.
divider
.
reload
()
v
.
divider
.
reload
()
}
}
...
@@ -126,9 +125,7 @@ open class ImageCard: Card {
...
@@ -126,9 +125,7 @@ open class ImageCard: Card {
}
}
views
[
"bottomBar"
]
=
v
views
[
"bottomBar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
}
guard
0
<
views
.
count
else
{
guard
0
<
views
.
count
else
{
...
...
Sources/iOS/Material+CALayer.swift
View file @
b1f97f5c
...
@@ -248,16 +248,6 @@ extension CALayer {
...
@@ -248,16 +248,6 @@ extension CALayer {
}
}
}
}
/// A UIColor reference to the `backgroundColor`.
open
var
bgColor
:
UIColor
?
{
get
{
return
nil
==
backgroundColor
?
nil
:
UIColor
(
cgColor
:
backgroundColor
!
)
}
set
(
value
)
{
backgroundColor
=
bgColor
?
.
cgColor
}
}
/**
/**
A method that accepts CAAnimation objects and executes them on the
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
view's backing layer.
...
...
Sources/iOS/NavigationBar.swift
View file @
b1f97f5c
...
@@ -220,6 +220,8 @@ open class NavigationBar: UINavigationBar {
...
@@ -220,6 +220,8 @@ open class NavigationBar: UINavigationBar {
}
}
item
.
contentView
.
grid
.
begin
()
item
.
contentView
.
grid
.
begin
()
item
.
contentView
.
grid
.
views
=
item
.
centerViews
if
.
center
==
item
.
contentViewAlignment
{
if
.
center
==
item
.
contentViewAlignment
{
if
lc
<
rc
{
if
lc
<
rc
{
item
.
contentView
.
grid
.
columns
=
columns
-
2
*
rc
item
.
contentView
.
grid
.
columns
=
columns
-
2
*
rc
...
...
Sources/iOS/NavigationItem.swift
View file @
b1f97f5c
...
@@ -57,6 +57,9 @@ public class NavigationItem: NSObject {
...
@@ -57,6 +57,9 @@ public class NavigationItem: NSObject {
/// Left items.
/// Left items.
public
var
leftViews
=
[
UIView
]()
{
public
var
leftViews
=
[
UIView
]()
{
didSet
{
didSet
{
for
v
in
oldValue
{
v
.
removeFromSuperview
()
}
navigationBar
?
.
layoutSubviews
()
navigationBar
?
.
layoutSubviews
()
}
}
}
}
...
@@ -64,6 +67,9 @@ public class NavigationItem: NSObject {
...
@@ -64,6 +67,9 @@ public class NavigationItem: NSObject {
/// Right items.
/// Right items.
public
var
rightViews
=
[
UIView
]()
{
public
var
rightViews
=
[
UIView
]()
{
didSet
{
didSet
{
for
v
in
oldValue
{
v
.
removeFromSuperview
()
}
navigationBar
?
.
layoutSubviews
()
navigationBar
?
.
layoutSubviews
()
}
}
}
}
...
@@ -71,6 +77,9 @@ public class NavigationItem: NSObject {
...
@@ -71,6 +77,9 @@ public class NavigationItem: NSObject {
/// Center items.
/// Center items.
public
var
centerViews
=
[
UIView
]()
{
public
var
centerViews
=
[
UIView
]()
{
didSet
{
didSet
{
for
v
in
oldValue
{
v
.
removeFromSuperview
()
}
navigationBar
?
.
layoutSubviews
()
navigationBar
?
.
layoutSubviews
()
}
}
}
}
...
@@ -205,13 +214,10 @@ extension UINavigationItem {
...
@@ -205,13 +214,10 @@ extension UINavigationItem {
/// Center UIViews.
/// Center UIViews.
open
var
centerViews
:
[
UIView
]
{
open
var
centerViews
:
[
UIView
]
{
get
{
get
{
return
navigationItem
.
c
ontentView
.
grid
.
v
iews
return
navigationItem
.
c
enterV
iews
}
}
set
(
value
)
{
set
(
value
)
{
for
v
in
navigationItem
.
contentView
.
grid
.
views
{
navigationItem
.
centerViews
=
value
v
.
removeFromSuperview
()
}
navigationItem
.
contentView
.
grid
.
views
=
value
}
}
}
}
}
}
Sources/iOS/PresenterCard.swift
View file @
b1f97f5c
...
@@ -56,7 +56,7 @@ open class PresenterCard: Card {
...
@@ -56,7 +56,7 @@ open class PresenterCard: Card {
open
override
func
reload
()
{
open
override
func
reload
()
{
// Clear constraints so new ones do not conflict.
// Clear constraints so new ones do not conflict.
container
.
removeConstraints
(
constraints
)
container
.
removeConstraints
(
con
tainer
.
con
straints
)
for
v
in
container
.
subviews
{
for
v
in
container
.
subviews
{
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
}
}
...
@@ -71,9 +71,7 @@ open class PresenterCard: Card {
...
@@ -71,9 +71,7 @@ open class PresenterCard: Card {
format
+=
"-(toolbarTop)-[toolbar]-(toolbarBottom)"
format
+=
"-(toolbarTop)-[toolbar]-(toolbarBottom)"
views
[
"toolbar"
]
=
v
views
[
"toolbar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
}
if
let
v
=
presenterView
{
if
let
v
=
presenterView
{
...
@@ -89,6 +87,7 @@ open class PresenterCard: Card {
...
@@ -89,6 +87,7 @@ open class PresenterCard: Card {
views
[
"presenterView"
]
=
v
views
[
"presenterView"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
presenterViewEdgeInsets
.
left
,
right
:
presenterViewEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
presenterViewEdgeInsets
.
left
,
right
:
presenterViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
grid
.
reload
()
v
.
divider
.
reload
()
v
.
divider
.
reload
()
}
}
...
@@ -109,6 +108,7 @@ open class PresenterCard: Card {
...
@@ -109,6 +108,7 @@ open class PresenterCard: Card {
views
[
"contentView"
]
=
v
views
[
"contentView"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
grid
.
reload
()
v
.
divider
.
reload
()
v
.
divider
.
reload
()
}
}
...
@@ -131,9 +131,7 @@ open class PresenterCard: Card {
...
@@ -131,9 +131,7 @@ open class PresenterCard: Card {
}
}
views
[
"bottomBar"
]
=
v
views
[
"bottomBar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
}
guard
0
<
views
.
count
else
{
guard
0
<
views
.
count
else
{
...
...
Sources/iOS/PulseAnimation.swift
View file @
b1f97f5c
...
@@ -66,6 +66,8 @@ internal extension Animation {
...
@@ -66,6 +66,8 @@ internal extension Animation {
bLayer
.
addSublayer
(
pLayer
)
bLayer
.
addSublayer
(
pLayer
)
pulse
.
layers
.
insert
(
bLayer
,
at
:
0
)
pulse
.
layers
.
insert
(
bLayer
,
at
:
0
)
visualLayer
.
addSublayer
(
bLayer
)
visualLayer
.
addSublayer
(
bLayer
)
bLayer
.
zPosition
=
0
pLayer
.
zPosition
=
0
visualLayer
.
masksToBounds
=
!
(
.
centerRadialBeyondBounds
==
pulse
.
animation
||
.
radialBeyondBounds
==
pulse
.
animation
)
visualLayer
.
masksToBounds
=
!
(
.
centerRadialBeyondBounds
==
pulse
.
animation
||
.
radialBeyondBounds
==
pulse
.
animation
)
...
@@ -81,7 +83,7 @@ internal extension Animation {
...
@@ -81,7 +83,7 @@ internal extension Animation {
}
}
pLayer
.
cornerRadius
=
n
/
2
pLayer
.
cornerRadius
=
n
/
2
pLayer
.
b
gColor
=
pulse
.
color
.
withAlphaComponent
(
pulse
.
opacity
)
pLayer
.
b
ackgroundColor
=
pulse
.
color
.
withAlphaComponent
(
pulse
.
opacity
)
.
cgColor
pLayer
.
transform
=
CATransform3DMakeAffineTransform
(
CGAffineTransform
(
scaleX
:
0
,
y
:
0
))
pLayer
.
transform
=
CATransform3DMakeAffineTransform
(
CGAffineTransform
(
scaleX
:
0
,
y
:
0
))
})
})
...
...
Sources/iOS/RobotoFont.swift
View file @
b1f97f5c
...
@@ -68,10 +68,12 @@ public struct RobotoFont: FontType {
...
@@ -68,10 +68,12 @@ public struct RobotoFont: FontType {
*/
*/
public
static
func
thin
(
with
size
:
CGFloat
)
->
UIFont
{
public
static
func
thin
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Thin"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Thin"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Thin"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Thin"
,
size
:
size
)
{
return
f
return
f
}
}
return
Font
.
systemFontWithSize
(
size
:
size
)
return
Font
.
systemFont
(
ofSize
:
size
)
}
}
/**
/**
...
@@ -81,10 +83,12 @@ public struct RobotoFont: FontType {
...
@@ -81,10 +83,12 @@ public struct RobotoFont: FontType {
*/
*/
public
static
func
light
(
with
size
:
CGFloat
)
->
UIFont
{
public
static
func
light
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Light"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Light"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
return
f
return
f
}
}
return
Font
.
systemFontWithSize
(
size
:
size
)
return
Font
.
systemFont
(
ofSize
:
size
)
}
}
/**
/**
...
@@ -94,10 +98,12 @@ public struct RobotoFont: FontType {
...
@@ -94,10 +98,12 @@ public struct RobotoFont: FontType {
*/
*/
public
static
func
regular
(
with
size
:
CGFloat
)
->
UIFont
{
public
static
func
regular
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Regular"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Regular"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
return
f
return
f
}
}
return
Font
.
systemFontWithSize
(
size
:
size
)
return
Font
.
systemFont
(
ofSize
:
size
)
}
}
/**
/**
...
@@ -107,10 +113,12 @@ public struct RobotoFont: FontType {
...
@@ -107,10 +113,12 @@ public struct RobotoFont: FontType {
*/
*/
public
static
func
medium
(
with
size
:
CGFloat
)
->
UIFont
{
public
static
func
medium
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Medium"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Medium"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
return
f
return
f
}
}
return
Font
.
boldSystemFontWithSize
(
size
:
size
)
return
Font
.
boldSystemFont
(
ofSize
:
size
)
}
}
/**
/**
...
@@ -120,9 +128,11 @@ public struct RobotoFont: FontType {
...
@@ -120,9 +128,11 @@ public struct RobotoFont: FontType {
*/
*/
public
static
func
bold
(
with
size
:
CGFloat
)
->
UIFont
{
public
static
func
bold
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Bold"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Bold"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Bold"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Bold"
,
size
:
size
)
{
return
f
return
f
}
}
return
Font
.
boldSystemFontWithSize
(
size
:
size
)
return
Font
.
boldSystemFont
(
ofSize
:
size
)
}
}
}
}
Sources/iOS/TableViewCell.swift
View file @
b1f97f5c
...
@@ -78,7 +78,7 @@ open class TableViewCell: UITableViewCell {
...
@@ -78,7 +78,7 @@ open class TableViewCell: UITableViewCell {
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
b
gColor
=
background
Color
layer
.
b
ackgroundColor
=
backgroundColor
?
.
cg
Color
}
}
}
}
...
...
Sources/iOS/TextView.swift
View file @
b1f97f5c
...
@@ -38,7 +38,7 @@ public class TextView: UITextView {
...
@@ -38,7 +38,7 @@ public class TextView: UITextView {
/// A property that accesses the backing layer's background
/// A property that accesses the backing layer's background
@IBInspectable
public
override
var
backgroundColor
:
UIColor
?
{
@IBInspectable
public
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
b
gColor
=
background
Color
layer
.
b
ackgroundColor
=
backgroundColor
?
.
cg
Color
}
}
}
}
...
...
Sources/iOS/View.swift
View file @
b1f97f5c
...
@@ -120,7 +120,7 @@ open class View: UIView {
...
@@ -120,7 +120,7 @@ open class View: UIView {
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
b
gColor
=
background
Color
layer
.
b
ackgroundColor
=
backgroundColor
?
.
cg
Color
}
}
}
}
...
...
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