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
6c813dcf
Commit
6c813dcf
authored
Aug 16, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: Updated to Xcode Beta 6
parent
d2aa614b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
358 additions
and
365 deletions
+358
-365
Sources/iOS/Animation.swift
+5
-5
Sources/iOS/BottomNavigationController.swift
+2
-2
Sources/iOS/CaptureSession.swift
+0
-0
Sources/iOS/Card.swift
+65
-69
Sources/iOS/CollectionViewLayout.swift
+1
-1
Sources/iOS/ControlView.swift
+51
-52
Sources/iOS/DataSourceItem.swift
+3
-3
Sources/iOS/Font.swift
+2
-2
Sources/iOS/ImageCard.swift
+73
-77
Sources/iOS/JSON.swift
+9
-9
Sources/iOS/Layer.swift
+3
-5
Sources/iOS/Layout.swift
+3
-3
Sources/iOS/Material+Obj-C.swift
+2
-2
Sources/iOS/Material+String.swift
+1
-1
Sources/iOS/Material+UIImage.swift
+5
-5
Sources/iOS/Material+UIView.swift
+2
-8
Sources/iOS/MaterialTextLayer.swift
+6
-8
Sources/iOS/NavigationBar.swift
+78
-79
Sources/iOS/NavigationDrawerController.swift
+5
-5
Sources/iOS/PhotoLibrary.swift
+0
-0
Sources/iOS/Switch.swift
+7
-7
Sources/iOS/TabBar.swift
+4
-4
Sources/iOS/TextStorage.swift
+2
-2
Sources/iOS/TextView.swift
+29
-16
No files found.
Sources/iOS/Animation.swift
View file @
6c813dcf
...
...
@@ -56,13 +56,13 @@ public func AnimationFillModeToValue(mode: AnimationFillMode) -> AnimationFillMo
}
}
public
typealias
AnimationDelayCancelBlock
=
(
cancel
:
Bool
)
->
Void
public
typealias
AnimationDelayCancelBlock
=
(
Bool
)
->
Void
public
struct
Animation
{
/// Delay helper method.
public
static
func
delay
(
time
:
TimeInterval
,
completion
:
()
->
Void
)
->
AnimationDelayCancelBlock
?
{
public
static
func
delay
(
time
:
TimeInterval
,
completion
:
@escaping
()
->
Void
)
->
AnimationDelayCancelBlock
?
{
func
dispatch_later
(
completion
:
()
->
Void
)
{
func
dispatch_later
(
completion
:
@escaping
()
->
Void
)
{
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
DispatchTime
.
now
()
+
time
,
execute
:
completion
)
}
...
...
@@ -78,7 +78,7 @@ public struct Animation {
cancelable
=
delayed
dispatch_later
{
cancelable
?(
cancel
:
false
)
cancelable
?(
false
)
}
return
cancelable
;
...
...
@@ -88,7 +88,7 @@ public struct Animation {
:name: delayCancel
*/
public
static
func
delayCancel
(
completion
:
AnimationDelayCancelBlock
?)
{
completion
?(
cancel
:
true
)
completion
?(
true
)
}
...
...
Sources/iOS/BottomNavigationController.swift
View file @
6c813dcf
...
...
@@ -32,8 +32,8 @@ import UIKit
public
class
BottomNavigationFadeAnimatedTransitioning
:
NSObject
,
UIViewControllerAnimatedTransitioning
{
public
func
animateTransition
(
using
transitionContext
:
UIViewControllerContextTransitioning
)
{
let
fromView
:
UIView
=
transitionContext
.
view
(
forKey
:
UITransitionContext
FromViewKey
)
!
let
toView
:
UIView
=
transitionContext
.
view
(
forKey
:
UITransitionContext
ToViewKey
)
!
let
fromView
:
UIView
=
transitionContext
.
view
(
forKey
:
UITransitionContext
ViewKey
.
from
)
!
let
toView
:
UIView
=
transitionContext
.
view
(
forKey
:
UITransitionContext
ViewKey
.
to
)
!
toView
.
alpha
=
0
transitionContext
.
containerView
.
addSubview
(
fromView
)
...
...
Sources/iOS/CaptureSession.swift
View file @
6c813dcf
This diff is collapsed.
Click to expand it.
Sources/iOS/Card.swift
View file @
6c813dcf
...
...
@@ -165,7 +165,7 @@ public class Card: PulseView {
/**
:name: leftButtons
*/
public
var
leftButtons
:
Array
<
UIButton
>
?
{
public
var
leftButtons
=
[
UIButton
]()
{
didSet
{
reloadView
()
}
...
...
@@ -192,7 +192,7 @@ public class Card: PulseView {
/**
:name: rightButtons
*/
public
var
rightButtons
:
Array
<
UIButton
>
?
{
public
var
rightButtons
=
[
UIButton
]()
{
didSet
{
reloadView
()
}
...
...
@@ -222,7 +222,7 @@ public class Card: PulseView {
/**
:name: init
*/
public
convenience
init
?(
image
:
UIImage
?
=
nil
,
titleLabel
:
UILabel
?
=
nil
,
contentView
:
UIView
?
=
nil
,
leftButtons
:
Array
<
UIButton
>
?
=
nil
,
rightButtons
:
Array
<
UIButton
>
?
=
nil
)
{
public
convenience
init
?(
image
:
UIImage
?
=
nil
,
titleLabel
:
UILabel
?
=
nil
,
contentView
:
UIView
?
=
nil
,
leftButtons
:
[
UIButton
]?
=
nil
,
rightButtons
:
[
UIButton
]
?
=
nil
)
{
self
.
init
(
frame
:
CGRect
.
zero
)
prepareProperties
(
image
:
image
,
titleLabel
:
titleLabel
,
contentView
:
contentView
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
}
...
...
@@ -235,10 +235,10 @@ public class Card: PulseView {
if
self
.
layer
==
layer
{
if
divider
{
var
y
:
CGFloat
=
contentInset
.
bottom
+
dividerInset
.
bottom
if
0
<
leftButtons
?
.
count
{
y
+=
leftButtonsInset
.
top
+
leftButtonsInset
.
bottom
+
leftButtons
!
[
0
]
.
frame
.
height
}
else
if
0
<
rightButtons
?
.
count
{
y
+=
rightButtonsInset
.
top
+
rightButtonsInset
.
bottom
+
rightButtons
!
[
0
]
.
frame
.
height
if
0
<
leftButtons
.
count
{
y
+=
leftButtonsInset
.
top
+
leftButtonsInset
.
bottom
+
leftButtons
[
0
]
.
frame
.
height
}
else
if
0
<
rightButtons
.
count
{
y
+=
rightButtonsInset
.
top
+
rightButtonsInset
.
bottom
+
rightButtons
[
0
]
.
frame
.
height
}
if
0
<
y
{
prepareDivider
(
y
:
bounds
.
height
-
y
-
0.5
,
width
:
bounds
.
width
)
...
...
@@ -261,8 +261,8 @@ public class Card: PulseView {
}
var
verticalFormat
:
String
=
"V:|"
var
views
:
Dictionary
<
String
,
Any
Object
>
=
Dictionary
<
String
,
AnyObject
>
()
var
metrics
:
Dictionary
<
String
,
Any
Object
>
=
Dictionary
<
String
,
AnyObject
>
()
var
views
:
Dictionary
<
String
,
Any
>
=
Dictionary
<
String
,
Any
>
()
var
metrics
:
Dictionary
<
String
,
Any
>
=
Dictionary
<
String
,
Any
>
()
if
nil
!=
titleLabel
{
verticalFormat
+=
"-(insetTop)"
...
...
@@ -296,70 +296,66 @@ public class Card: PulseView {
}
// leftButtons
if
let
v
:
Array
<
UIButton
>
=
leftButtons
{
if
0
<
v
.
count
{
var
h
:
String
=
"H:|"
var
d
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
i
:
Int
=
0
for
b
in
v
{
let
k
:
String
=
"b
\(
i
)
"
d
[
k
]
=
b
if
0
==
i
{
h
+=
"-(left)-"
}
else
{
h
+=
"-(left_right)-"
}
h
+=
"[
\(
k
)
]"
_
=
layout
(
b
)
.
bottom
(
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
i
+=
1
}
addConstraints
(
Layout
.
constraint
(
format
:
h
,
options
:
[],
metrics
:
[
"left"
:
contentInset
.
left
+
leftButtonsInset
.
left
,
"left_right"
:
leftButtonsInset
.
left
+
leftButtonsInset
.
right
],
views
:
d
))
}
}
if
0
<
leftButtons
.
count
{
var
h
=
"H:|"
var
d
=
Dictionary
<
String
,
Any
>
()
var
i
=
0
for
b
in
leftButtons
{
let
k
:
String
=
"b
\(
i
)
"
d
[
k
]
=
b
if
0
==
i
{
h
+=
"-(left)-"
}
else
{
h
+=
"-(left_right)-"
}
h
+=
"[
\(
k
)
]"
_
=
layout
(
b
)
.
bottom
(
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
i
+=
1
}
addConstraints
(
Layout
.
constraint
(
format
:
h
,
options
:
[],
metrics
:
[
"left"
:
contentInset
.
left
+
leftButtonsInset
.
left
,
"left_right"
:
leftButtonsInset
.
left
+
leftButtonsInset
.
right
],
views
:
d
))
}
// rightButtons
if
let
v
:
Array
<
UIButton
>
=
rightButtons
{
if
0
<
v
.
count
{
var
h
:
String
=
"H:"
var
d
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
i
:
Int
=
v
.
count
-
1
for
b
in
v
{
let
k
:
String
=
"b
\(
i
)
"
d
[
k
]
=
b
h
+=
"[
\(
k
)
]"
if
0
==
i
{
h
+=
"-(right)-"
}
else
{
h
+=
"-(right_left)-"
}
_
=
layout
(
b
)
.
bottom
(
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
i
-=
1
}
addConstraints
(
Layout
.
constraint
(
format
:
h
+
"|"
,
options
:
[],
metrics
:
[
"right"
:
contentInset
.
right
+
rightButtonsInset
.
right
,
"right_left"
:
rightButtonsInset
.
right
+
rightButtonsInset
.
left
],
views
:
d
))
}
}
if
0
<
rightButtons
.
count
{
var
h
=
"H:"
var
d
=
Dictionary
<
String
,
Any
>
()
var
i
=
rightButtons
.
count
-
1
for
b
in
rightButtons
{
let
k
:
String
=
"b
\(
i
)
"
d
[
k
]
=
b
h
+=
"[
\(
k
)
]"
if
0
==
i
{
h
+=
"-(right)-"
}
else
{
h
+=
"-(right_left)-"
}
_
=
layout
(
b
)
.
bottom
(
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
i
-=
1
}
addConstraints
(
Layout
.
constraint
(
format
:
h
+
"|"
,
options
:
[],
metrics
:
[
"right"
:
contentInset
.
right
+
rightButtonsInset
.
right
,
"right_left"
:
rightButtonsInset
.
right
+
rightButtonsInset
.
left
],
views
:
d
))
}
if
0
<
leftButtons
?
.
count
{
if
0
<
leftButtons
.
count
{
verticalFormat
+=
"-(insetC)-[button]"
views
[
"button"
]
=
leftButtons
!
[
0
]
views
[
"button"
]
=
leftButtons
[
0
]
metrics
[
"insetC"
]
=
leftButtonsInset
.
top
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
leftButtonsInset
.
bottom
}
else
if
0
<
rightButtons
?
.
count
{
}
else
if
0
<
rightButtons
.
count
{
verticalFormat
+=
"-(insetC)-[button]"
views
[
"button"
]
=
rightButtons
!
[
0
]
views
[
"button"
]
=
rightButtons
[
0
]
metrics
[
"insetC"
]
=
rightButtonsInset
.
top
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
rightButtonsInset
.
bottom
}
...
...
@@ -412,11 +408,11 @@ public class Card: PulseView {
/**
:name: prepareProperties
*/
internal
func
prepareProperties
(
image
:
UIImage
?,
titleLabel
:
UILabel
?,
contentView
:
UIView
?,
leftButtons
:
Array
<
UIButton
>
?,
rightButtons
:
Array
<
UIButton
>
?)
{
internal
func
prepareProperties
(
image
:
UIImage
?,
titleLabel
:
UILabel
?,
contentView
:
UIView
?,
leftButtons
:
[
UIButton
]?,
rightButtons
:
[
UIButton
]
?)
{
self
.
image
=
image
self
.
titleLabel
=
titleLabel
self
.
contentView
=
contentView
self
.
leftButtons
=
leftButtons
self
.
rightButtons
=
rightButtons
self
.
leftButtons
=
leftButtons
??
[]
self
.
rightButtons
=
rightButtons
??
[]
}
}
Sources/iOS/CollectionViewLayout.swift
View file @
6c813dcf
...
...
@@ -137,7 +137,7 @@ public class CollectionViewLayout: UICollectionViewLayout {
for
i
in
0
..<
dataSourceItems
.
count
{
let
item
:
DataSourceItem
=
dataSourceItems
[
i
]
let
indexPath
=
IndexPath
(
item
:
i
,
section
:
0
)
layoutItems
.
append
((
layoutAttributesForItem
(
at
:
indexPath
)
!
,
indexPath
))
layoutItems
.
append
((
layoutAttributesForItem
(
at
:
indexPath
)
!
,
indexPath
as
NSIndexPath
))
offset
.
x
+=
interimSpace
offset
.
x
+=
nil
==
item
.
width
?
itemSize
.
width
:
item
.
width
!
...
...
Sources/iOS/ControlView.swift
View file @
6c813dcf
...
...
@@ -164,58 +164,57 @@ public class ControlView: View {
if
willRenderView
{
layoutIfNeeded
()
if
let
g
:
Int
=
Int
(
width
/
gridFactor
)
{
let
columns
:
Int
=
g
+
1
grid
.
views
=
[]
grid
.
axis
.
columns
=
columns
contentView
.
grid
.
columns
=
columns
// leftControls
if
let
v
=
leftControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
addSubview
(
c
)
grid
.
views
.
append
(
c
)
}
}
addSubview
(
contentView
)
grid
.
views
.
append
(
contentView
)
// rightControls
if
let
v
=
rightControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
addSubview
(
c
)
grid
.
views
.
append
(
c
)
}
}
grid
.
contentEdgeInsets
=
contentInset
grid
.
interimSpace
=
interimSpace
grid
.
reload
()
contentView
.
grid
.
reload
()
}
}
}
let
g
=
Int
(
width
/
gridFactor
)
let
columns
=
g
+
1
grid
.
views
=
[]
grid
.
axis
.
columns
=
columns
contentView
.
grid
.
columns
=
columns
// leftControls
if
let
v
=
leftControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
addSubview
(
c
)
grid
.
views
.
append
(
c
)
}
}
addSubview
(
contentView
)
grid
.
views
.
append
(
contentView
)
// rightControls
if
let
v
=
rightControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
addSubview
(
c
)
grid
.
views
.
append
(
c
)
}
}
grid
.
contentEdgeInsets
=
contentInset
grid
.
interimSpace
=
interimSpace
grid
.
reload
()
contentView
.
grid
.
reload
()
}
}
/**
Prepares the view instance when intialized. When subclassing,
...
...
Sources/iOS/DataSourceItem.swift
View file @
6c813dcf
...
...
@@ -32,7 +32,7 @@ import UIKit
public
struct
DataSourceItem
{
/// Stores an the data for the item.
public
var
data
:
Any
Object
?
public
var
data
:
Any
?
/// Width for horizontal scroll direction.
public
var
width
:
CGFloat
?
...
...
@@ -42,12 +42,12 @@ public struct DataSourceItem {
/**
Initializer.
- Parameter data: A reference to an Any
Object
that is associated
- Parameter data: A reference to an Any that is associated
with a width or height.
- Parameter width: The width for the horizontal scroll direction.
- Parameter height: The height for the vertical scroll direction.
*/
public
init
(
data
:
Any
Object
?
=
nil
,
width
:
CGFloat
?
=
nil
,
height
:
CGFloat
?
=
nil
)
{
public
init
(
data
:
Any
?
=
nil
,
width
:
CGFloat
?
=
nil
,
height
:
CGFloat
?
=
nil
)
{
self
.
data
=
data
self
.
width
=
width
self
.
height
=
height
...
...
Sources/iOS/Font.swift
View file @
6c813dcf
...
...
@@ -96,8 +96,8 @@ private class FontLoader {
var
error
:
Unmanaged
<
CFError
>
?
if
!
CTFontManagerRegisterGraphicsFont
(
font
,
&
error
)
{
let
errorDescription
=
CFErrorCopyDescription
(
error
!.
takeUnretainedValue
())
let
nsError
=
error
!.
takeUnretainedValue
()
as
Any
Object
as!
Error
NSException
(
name
:
.
internalInconsistencyException
,
reason
:
errorDescription
as?
String
,
userInfo
:
[
NSUnderlyingErrorKey
:
nsError
as
Any
Object
])
.
raise
()
let
nsError
=
error
!.
takeUnretainedValue
()
as
Any
as!
Error
NSException
(
name
:
.
internalInconsistencyException
,
reason
:
errorDescription
as?
String
,
userInfo
:
[
NSUnderlyingErrorKey
:
nsError
as
Any
])
.
raise
()
}
}
}
...
...
Sources/iOS/ImageCard.swift
View file @
6c813dcf
...
...
@@ -258,7 +258,7 @@ public class ImageCard: PulseView {
/**
:name: leftButtons
*/
public
var
leftButtons
:
Array
<
UIButton
>
?
{
public
var
leftButtons
=
[
UIButton
]()
{
didSet
{
reloadView
()
}
...
...
@@ -285,7 +285,7 @@ public class ImageCard: PulseView {
/**
:name: rightButtons
*/
public
var
rightButtons
:
Array
<
UIButton
>
?
{
public
var
rightButtons
=
[
UIButton
]()
{
didSet
{
reloadView
()
}
...
...
@@ -315,7 +315,7 @@ public class ImageCard: PulseView {
/**
:name: init
*/
public
convenience
init
?(
image
:
UIImage
?
=
nil
,
titleLabel
:
UILabel
?
=
nil
,
contentView
:
UIView
?
=
nil
,
leftButtons
:
Array
<
UIButton
>
?
=
nil
,
rightButtons
:
Array
<
UIButton
>
?
=
nil
)
{
public
convenience
init
?(
image
:
UIImage
?
=
nil
,
titleLabel
:
UILabel
?
=
nil
,
contentView
:
UIView
?
=
nil
,
leftButtons
:
[
UIButton
]?
=
nil
,
rightButtons
:
[
UIButton
]
?
=
nil
)
{
self
.
init
(
frame
:
CGRect
.
zero
)
prepareProperties
(
image
:
image
,
titleLabel
:
titleLabel
,
contentView
:
contentView
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
}
...
...
@@ -332,10 +332,10 @@ public class ImageCard: PulseView {
// divider
if
divider
{
var
y
:
CGFloat
=
contentInset
.
bottom
+
dividerInset
.
bottom
if
0
<
leftButtons
?
.
count
{
y
+=
leftButtonsInset
.
top
+
leftButtonsInset
.
bottom
+
leftButtons
!
[
0
]
.
frame
.
height
}
else
if
0
<
rightButtons
?
.
count
{
y
+=
rightButtonsInset
.
top
+
rightButtonsInset
.
bottom
+
rightButtons
!
[
0
]
.
frame
.
height
if
0
<
leftButtons
.
count
{
y
+=
leftButtonsInset
.
top
+
leftButtonsInset
.
bottom
+
leftButtons
[
0
]
.
frame
.
height
}
else
if
0
<
rightButtons
.
count
{
y
+=
rightButtonsInset
.
top
+
rightButtonsInset
.
bottom
+
rightButtons
[
0
]
.
frame
.
height
}
if
0
<
y
{
prepareDivider
(
y
:
bounds
.
height
-
y
-
0.5
,
width
:
bounds
.
width
)
...
...
@@ -358,8 +358,8 @@ public class ImageCard: PulseView {
}
var
verticalFormat
:
String
=
"V:|"
var
views
:
Dictionary
<
String
,
Any
Object
>
=
Dictionary
<
String
,
AnyObject
>
()
var
metrics
:
Dictionary
<
String
,
Any
Object
>
=
Dictionary
<
String
,
AnyObject
>
()
var
views
:
Dictionary
<
String
,
Any
>
=
Dictionary
<
String
,
Any
>
()
var
metrics
:
Dictionary
<
String
,
Any
>
=
Dictionary
<
String
,
Any
>
()
if
nil
!=
imageLayer
?
.
contents
{
verticalFormat
+=
"-(insetTop)"
...
...
@@ -399,71 +399,67 @@ public class ImageCard: PulseView {
}
// leftButtons
if
let
v
:
Array
<
UIButton
>
=
leftButtons
{
if
0
<
v
.
count
{
var
h
:
String
=
"H:|"
var
d
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
i
:
Int
=
0
for
b
in
v
{
let
k
:
String
=
"b
\(
i
)
"
d
[
k
]
=
b
if
0
==
i
{
h
+=
"-(left)-"
}
else
{
h
+=
"-(left_right)-"
}
h
+=
"[
\(
k
)
]"
_
=
layout
(
b
)
.
bottom
(
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
i
+=
1
}
addConstraints
(
Layout
.
constraint
(
format
:
h
,
options
:
[],
metrics
:
[
"left"
:
contentInset
.
left
+
leftButtonsInset
.
left
,
"left_right"
:
leftButtonsInset
.
left
+
leftButtonsInset
.
right
],
views
:
d
))
}
}
if
0
<
leftButtons
.
count
{
var
h
:
String
=
"H:|"
var
d
:
Dictionary
<
String
,
Any
>
=
Dictionary
<
String
,
Any
>
()
var
i
:
Int
=
0
for
b
in
leftButtons
{
let
k
:
String
=
"b
\(
i
)
"
d
[
k
]
=
b
if
0
==
i
{
h
+=
"-(left)-"
}
else
{
h
+=
"-(left_right)-"
}
h
+=
"[
\(
k
)
]"
_
=
layout
(
b
)
.
bottom
(
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
i
+=
1
}
addConstraints
(
Layout
.
constraint
(
format
:
h
,
options
:
[],
metrics
:
[
"left"
:
contentInset
.
left
+
leftButtonsInset
.
left
,
"left_right"
:
leftButtonsInset
.
left
+
leftButtonsInset
.
right
],
views
:
d
))
}
// rightButtons
if
let
v
:
Array
<
UIButton
>
=
rightButtons
{
if
0
<
v
.
count
{
var
h
:
String
=
"H:"
var
d
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
var
i
:
Int
=
v
.
count
-
1
for
b
in
v
{
let
k
:
String
=
"b
\(
i
)
"
d
[
k
]
=
b
h
+=
"[
\(
k
)
]"
if
0
==
i
{
h
+=
"-(right)-"
}
else
{
h
+=
"-(right_left)-"
}
_
=
layout
(
b
)
.
bottom
(
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
i
-=
1
}
addConstraints
(
Layout
.
constraint
(
format
:
h
+
"|"
,
options
:
[],
metrics
:
[
"right"
:
contentInset
.
right
+
rightButtonsInset
.
right
,
"right_left"
:
rightButtonsInset
.
right
+
rightButtonsInset
.
left
],
views
:
d
))
}
}
if
0
<
rightButtons
.
count
{
var
h
:
String
=
"H:"
var
d
:
Dictionary
<
String
,
Any
>
=
Dictionary
<
String
,
Any
>
()
var
i
:
Int
=
rightButtons
.
count
-
1
for
b
in
rightButtons
{
let
k
:
String
=
"b
\(
i
)
"
d
[
k
]
=
b
h
+=
"[
\(
k
)
]"
if
0
==
i
{
h
+=
"-(right)-"
}
else
{
h
+=
"-(right_left)-"
}
_
=
layout
(
b
)
.
bottom
(
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
i
-=
1
}
addConstraints
(
Layout
.
constraint
(
format
:
h
+
"|"
,
options
:
[],
metrics
:
[
"right"
:
contentInset
.
right
+
rightButtonsInset
.
right
,
"right_left"
:
rightButtonsInset
.
right
+
rightButtonsInset
.
left
],
views
:
d
))
}
if
nil
==
imageLayer
?
.
contents
{
if
0
<
leftButtons
?
.
count
{
if
0
<
leftButtons
.
count
{
verticalFormat
+=
"-(insetC)-[button]"
views
[
"button"
]
=
leftButtons
!
[
0
]
views
[
"button"
]
=
leftButtons
[
0
]
metrics
[
"insetC"
]
=
leftButtonsInset
.
top
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
leftButtonsInset
.
bottom
}
else
if
0
<
rightButtons
?
.
count
{
}
else
if
0
<
rightButtons
.
count
{
verticalFormat
+=
"-(insetC)-[button]"
views
[
"button"
]
=
rightButtons
!
[
0
]
views
[
"button"
]
=
rightButtons
[
0
]
metrics
[
"insetC"
]
=
rightButtonsInset
.
top
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
rightButtonsInset
.
bottom
}
...
...
@@ -484,14 +480,14 @@ public class ImageCard: PulseView {
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
contentInset
.
top
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
}
}
else
if
nil
!=
contentView
{
if
0
<
leftButtons
?
.
count
{
if
0
<
leftButtons
.
count
{
verticalFormat
+=
"-(insetC)-[button]"
views
[
"button"
]
=
leftButtons
!
[
0
]
views
[
"button"
]
=
leftButtons
[
0
]
metrics
[
"insetC"
]
=
leftButtonsInset
.
top
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
leftButtonsInset
.
bottom
}
else
if
0
<
rightButtons
?
.
count
{
}
else
if
0
<
rightButtons
.
count
{
verticalFormat
+=
"-(insetC)-[button]"
views
[
"button"
]
=
rightButtons
!
[
0
]
views
[
"button"
]
=
rightButtons
[
0
]
metrics
[
"insetC"
]
=
rightButtonsInset
.
top
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
rightButtonsInset
.
bottom
}
...
...
@@ -502,14 +498,14 @@ public class ImageCard: PulseView {
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
contentViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
}
}
else
{
if
0
<
leftButtons
?
.
count
{
if
0
<
leftButtons
.
count
{
verticalFormat
+=
"-[button]"
views
[
"button"
]
=
leftButtons
!
[
0
]
views
[
"button"
]
=
leftButtons
[
0
]
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
contentInset
.
top
+
leftButtonsInset
.
top
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
leftButtonsInset
.
bottom
}
else
if
0
<
rightButtons
?
.
count
{
}
else
if
0
<
rightButtons
.
count
{
verticalFormat
+=
"-[button]"
views
[
"button"
]
=
rightButtons
!
[
0
]
views
[
"button"
]
=
rightButtons
[
0
]
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
contentInset
.
top
+
rightButtonsInset
.
top
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
rightButtonsInset
.
bottom
}
else
{
...
...
@@ -565,11 +561,11 @@ public class ImageCard: PulseView {
/**
:name: prepareProperties
*/
internal
func
prepareProperties
(
image
:
UIImage
?,
titleLabel
:
UILabel
?,
contentView
:
UIView
?,
leftButtons
:
Array
<
UIButton
>
?,
rightButtons
:
Array
<
UIButton
>
?)
{
internal
func
prepareProperties
(
image
:
UIImage
?,
titleLabel
:
UILabel
?,
contentView
:
UIView
?,
leftButtons
:
[
UIButton
]?,
rightButtons
:
[
UIButton
]
?)
{
self
.
image
=
image
self
.
titleLabel
=
titleLabel
self
.
contentView
=
contentView
self
.
leftButtons
=
leftButtons
self
.
rightButtons
=
rightButtons
self
.
leftButtons
=
leftButtons
??
[]
self
.
rightButtons
=
rightButtons
??
[]
}
}
Sources/iOS/JSON.swift
View file @
6c813dcf
...
...
@@ -41,20 +41,20 @@ public class JSON: Equatable, CustomStringConvertible {
/**
:name: object
*/
public
private(set)
var
object
:
Any
Object
public
private(set)
var
object
:
Any
/**
:name: asArray
*/
public
var
asArray
:
[
Any
Object
]?
{
return
object
as?
[
Any
Object
]
public
var
asArray
:
[
Any
]?
{
return
object
as?
[
Any
]
}
/**
:name: asDictionary
*/
public
var
asDictionary
:
[
String
:
Any
Object
]?
{
return
object
as?
[
String
:
Any
Object
]
public
var
asDictionary
:
[
String
:
Any
]?
{
return
object
as?
[
String
:
Any
]
}
/**
...
...
@@ -95,7 +95,7 @@ public class JSON: Equatable, CustomStringConvertible {
/**
:name: asNSData
*/
public
var
asNSData
:
NS
Data
?
{
public
var
asNSData
:
Data
?
{
return
JSON
.
serialize
(
object
:
object
)
}
...
...
@@ -122,14 +122,14 @@ public class JSON: Equatable, CustomStringConvertible {
/**
:name: serialize
*/
public
class
func
serialize
(
object
:
Any
Object
)
->
Data
?
{
public
class
func
serialize
(
object
:
Any
)
->
Data
?
{
return
try
?
JSONSerialization
.
data
(
withJSONObject
:
object
,
options
:
[])
}
/**
:name: stringify
*/
public
class
func
stringify
(
_
object
:
Any
Object
)
->
String
?
{
public
class
func
stringify
(
_
object
:
Any
)
->
String
?
{
if
let
o
=
object
as?
JSON
{
return
stringify
(
o
.
object
)
}
else
if
let
data
=
JSON
.
serialize
(
object
:
object
)
{
...
...
@@ -143,7 +143,7 @@ public class JSON: Equatable, CustomStringConvertible {
/**
:name: init
*/
public
required
init
(
_
object
:
Any
Object
)
{
public
required
init
(
_
object
:
Any
)
{
if
let
o
=
object
as?
JSON
{
self
.
object
=
o
.
object
}
else
{
...
...
Sources/iOS/Layer.swift
View file @
6c813dcf
...
...
@@ -196,9 +196,7 @@ public class Layer: CAShapeLayer {
*/
public
var
cornerRadiusPreset
:
CornerRadiusPreset
=
.
none
{
didSet
{
if
let
v
:
CornerRadiusPreset
=
cornerRadiusPreset
{
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
v
)
}
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
cornerRadiusPreset
)
}
}
...
...
@@ -254,9 +252,9 @@ public class Layer: CAShapeLayer {
/**
An initializer the same as init(). The layer parameter is ignored
to avoid crashes on certain architectures.
- Parameter layer: Any
Object
.
- Parameter layer: Any.
*/
public
override
init
(
layer
:
Any
Object
)
{
public
override
init
(
layer
:
Any
)
{
contentsGravityPreset
=
.
ResizeAspectFill
super
.
init
()
prepareVisualLayer
()
...
...
Sources/iOS/Layout.swift
View file @
6c813dcf
...
...
@@ -850,11 +850,11 @@ extension Layout {
Creats an Array with a NSLayoutConstraint value.
- Parameter format: The VFL format string.
- Parameter options: Additional NSLayoutFormatOptions.
- Parameter metrics: An optional Dictionary<String, Any
Object
> of metric key / value pairs.
- Parameter views: A Dictionary<String, Any
Object
> of view key / value pairs.
- Parameter metrics: An optional Dictionary<String, Any> of metric key / value pairs.
- Parameter views: A Dictionary<String, Any> of view key / value pairs.
- Returns: The Array<NSLayoutConstraint> instance.
*/
public
class
func
constraint
(
format
:
String
,
options
:
NSLayoutFormatOptions
,
metrics
:
Dictionary
<
String
,
Any
Object
>
?,
views
:
Dictionary
<
String
,
AnyObject
>
)
->
Array
<
NSLayoutConstraint
>
{
public
class
func
constraint
(
format
:
String
,
options
:
NSLayoutFormatOptions
,
metrics
:
Dictionary
<
String
,
Any
>
?,
views
:
Dictionary
<
String
,
Any
>
)
->
Array
<
NSLayoutConstraint
>
{
for
(
_
,
a
)
in
views
{
if
let
v
=
a
as?
UIView
{
v
.
translatesAutoresizingMaskIntoConstraints
=
false
...
...
Sources/iOS/Material+Obj-C.swift
View file @
6c813dcf
...
...
@@ -35,7 +35,7 @@
- Parameter initializer: Object initializer.
- Returns: The associated reference for the initializer object.
*/
internal
func
AssociatedObject
<
T
:
Any
Object
>
(
base
:
AnyObject
,
key
:
UnsafePointer
<
UInt8
>
,
initializer
:
()
->
T
)
->
T
{
internal
func
AssociatedObject
<
T
:
Any
>
(
base
:
Any
,
key
:
UnsafePointer
<
UInt8
>
,
initializer
:
()
->
T
)
->
T
{
if
let
v
:
T
=
objc_getAssociatedObject
(
base
,
key
)
as?
T
{
return
v
}
...
...
@@ -52,6 +52,6 @@ internal func AssociatedObject<T: AnyObject>(base: AnyObject, key: UnsafePointer
- Parameter value: The object instance to set for the associated object.
- Returns: The associated reference for the initializer object.
*/
internal
func
AssociateObject
<
T
:
Any
Object
>
(
base
:
AnyObject
,
key
:
UnsafePointer
<
UInt8
>
,
value
:
T
)
{
internal
func
AssociateObject
<
T
:
Any
>
(
base
:
Any
,
key
:
UnsafePointer
<
UInt8
>
,
value
:
T
)
{
objc_setAssociatedObject
(
base
,
key
,
value
,
.
OBJC_ASSOCIATION_RETAIN
)
}
Sources/iOS/Material+String.swift
View file @
6c813dcf
...
...
@@ -63,7 +63,7 @@ extension String {
:name: replacePunctuationCharacters
*/
public
func
replacePunctuationCharacters
(
separator
:
String
=
""
)
->
String
{
return
components
(
separatedBy
:
CharacterSet
.
punctuation
)
.
joined
(
separator
:
separator
)
.
trim
()
return
components
(
separatedBy
:
CharacterSet
.
punctuation
Characters
)
.
joined
(
separator
:
separator
)
.
trim
()
}
/**
...
...
Sources/iOS/Material+UIImage.swift
View file @
6c813dcf
...
...
@@ -185,13 +185,13 @@ extension UIImage {
- Parameter completion: A completion block that is executed once the image
has been retrieved.
*/
public
class
func
contentsOfURL
(
url
:
URL
,
completion
:
((
image
:
UIImage
?,
error
:
Error
?)
->
Void
))
{
public
class
func
contentsOfURL
(
url
:
URL
,
completion
:
((
UIImage
?,
Error
?)
->
Void
))
{
URLSession
.
shared
.
dataTask
(
with
:
URLRequest
(
url
:
url
))
{
(
data
:
Data
?,
response
:
URLResponse
?,
error
:
Error
?)
in
DispatchQueue
.
main
.
async
{
if
let
v
=
error
{
completion
(
image
:
nil
,
error
:
v
)
completion
(
nil
,
v
)
}
else
if
let
v
=
data
{
completion
(
image
:
UIImage
(
data
:
v
),
error
:
nil
)
completion
(
UIImage
(
data
:
v
),
nil
)
}
}
}
.
resume
()
...
...
@@ -246,9 +246,9 @@ extension UIImage {
switch
imageOrientation
{
case
.
left
,
.
leftMirrored
,
.
right
,
.
rightMirrored
:
context
.
draw
(
in
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
size
.
height
,
height
:
size
.
width
),
image
:
cgImage
!
)
context
.
draw
(
cgImage
!
,
in
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
size
.
height
,
height
:
size
.
width
)
)
default
:
context
.
draw
(
in
:
CGRect
(
origin
:
.
zero
,
size
:
size
),
image
:
cgImage
!
)
context
.
draw
(
cgImage
!
,
in
:
CGRect
(
origin
:
.
zero
,
size
:
size
)
)
}
guard
let
cgImage
=
context
.
makeImage
()
else
{
...
...
Sources/iOS/Material+UIView.swift
View file @
6c813dcf
...
...
@@ -48,10 +48,7 @@ public class Material {
guard
let
v
=
view
else
{
return
}
if
let
preset
:
CornerRadiusPreset
=
cornerRadiusPreset
{
v
.
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
preset
)
}
v
.
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
cornerRadiusPreset
)
}
}
...
...
@@ -61,10 +58,7 @@ public class Material {
guard
let
v
=
view
else
{
return
}
if
let
preset
:
BorderWidthPreset
=
borderWidthPreset
{
v
.
borderWidth
=
BorderWidthPresetToValue
(
preset
:
preset
)
}
v
.
borderWidth
=
BorderWidthPresetToValue
(
preset
:
borderWidthPreset
)
}
}
...
...
Sources/iOS/MaterialTextLayer.swift
View file @
6c813dcf
...
...
@@ -48,7 +48,7 @@ public class MaterialTextLayer : CATextLayer {
*/
@IBInspectable
public
var
text
:
String
?
{
didSet
{
string
=
text
as
?
AnyObject
string
=
text
as
Any
}
}
...
...
@@ -171,7 +171,7 @@ public class MaterialTextLayer : CATextLayer {
/**
:name: init
*/
public
override
init
(
layer
:
Any
Object
)
{
public
override
init
(
layer
:
Any
)
{
super
.
init
()
prepareLayer
()
}
...
...
@@ -196,12 +196,10 @@ public class MaterialTextLayer : CATextLayer {
:name: stringSize
*/
public
func
stringSize
(
constrainedToWidth
width
:
Double
)
->
CGSize
{
if
let
v
=
fontType
{
if
0
<
text
?
.
utf16
.
count
{
return
v
.
stringSize
(
string
:
text
!
,
constrainedToWidth
:
width
)
}
}
return
CGSize
.
zero
guard
let
v
=
fontType
,
let
t
=
text
,
0
<
t
.
utf16
.
count
else
{
return
CGSize
.
zero
}
return
v
.
stringSize
(
string
:
text
!
,
constrainedToWidth
:
width
)
}
/**
...
...
Sources/iOS/NavigationBar.swift
View file @
6c813dcf
...
...
@@ -196,93 +196,92 @@ public class NavigationBar: UINavigationBar {
let
titleView
=
prepareTitleView
(
item
:
item
)
let
contentView
=
prepareContentView
(
item
:
item
)
if
let
g
:
Int
=
Int
(
width
/
gridFactor
)
{
let
columns
:
Int
=
g
+
1
let
g
=
Int
(
width
/
gridFactor
)
let
columns
=
g
+
1
titleView
.
frame
.
origin
=
CGPoint
.
zero
titleView
.
frame
.
size
=
intrinsicContentSize
titleView
.
grid
.
views
=
[]
titleView
.
grid
.
axis
.
columns
=
columns
contentView
.
grid
.
columns
=
columns
// leftControls
if
let
v
:
Array
<
UIControl
>
=
item
.
leftControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
titleView
.
addSubview
(
c
)
titleView
.
grid
.
views
.
append
(
c
)
}
titleView
.
frame
.
origin
=
CGPoint
.
zero
titleView
.
frame
.
size
=
intrinsicContentSize
titleView
.
grid
.
views
=
[]
titleView
.
grid
.
axis
.
columns
=
columns
contentView
.
grid
.
columns
=
columns
// leftControls
if
let
v
:
Array
<
UIControl
>
=
item
.
leftControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
titleView
.
addSubview
(
c
)
titleView
.
grid
.
views
.
append
(
c
)
}
titleView
.
addSubview
(
contentView
)
titleView
.
grid
.
views
.
append
(
contentView
)
// rightControls
if
let
v
:
Array
<
UIControl
>
=
item
.
rightControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
titleView
.
addSubview
(
c
)
titleView
.
grid
.
views
.
append
(
c
)
}
}
titleView
.
addSubview
(
contentView
)
titleView
.
grid
.
views
.
append
(
contentView
)
// rightControls
if
let
v
:
Array
<
UIControl
>
=
item
.
rightControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
titleView
.
addSubview
(
c
)
titleView
.
grid
.
views
.
append
(
c
)
}
titleView
.
grid
.
contentEdgeInsets
=
contentInset
titleView
.
grid
.
interimSpace
=
interimSpace
titleView
.
grid
.
reload
()
// contentView alignment.
if
nil
!=
item
.
title
&&
""
!=
item
.
title
{
if
nil
==
item
.
titleLabel
.
superview
{
contentView
.
addSubview
(
item
.
titleLabel
)
}
item
.
titleLabel
.
frame
=
contentView
.
bounds
}
else
{
item
.
titleLabel
.
removeFromSuperview
()
}
titleView
.
grid
.
contentEdgeInsets
=
contentInset
titleView
.
grid
.
interimSpace
=
interimSpace
titleView
.
grid
.
reload
()
// contentView alignment.
if
nil
!=
item
.
title
&&
""
!=
item
.
title
{
if
nil
==
item
.
titleLabel
.
superview
{
contentView
.
addSubview
(
item
.
titleLabel
)
}
item
.
titleLabel
.
frame
=
contentView
.
bounds
}
else
{
item
.
titleLabel
.
removeFromSuperview
()
}
if
nil
!=
item
.
detail
&&
""
!=
item
.
detail
{
if
nil
==
item
.
detailLabel
.
superview
{
contentView
.
addSubview
(
item
.
detailLabel
)
}
if
nil
!=
item
.
detail
&&
""
!=
item
.
detail
{
if
nil
==
item
.
detailLabel
.
superview
{
contentView
.
addSubview
(
item
.
detailLabel
)
}
if
nil
==
item
.
titleLabel
.
superview
{
item
.
detailLabel
.
frame
=
contentView
.
bounds
}
else
{
item
.
titleLabel
.
sizeToFit
()
item
.
detailLabel
.
sizeToFit
()
let
diff
:
CGFloat
=
(
contentView
.
frame
.
height
-
item
.
titleLabel
.
frame
.
height
-
item
.
detailLabel
.
frame
.
height
)
/
2
item
.
titleLabel
.
frame
.
size
.
height
+=
diff
item
.
titleLabel
.
frame
.
size
.
width
=
contentView
.
frame
.
width
item
.
detailLabel
.
frame
.
size
.
height
+=
diff
item
.
detailLabel
.
frame
.
size
.
width
=
contentView
.
frame
.
width
item
.
detailLabel
.
frame
.
origin
.
y
=
item
.
titleLabel
.
frame
.
height
}
if
nil
==
item
.
titleLabel
.
superview
{
item
.
detailLabel
.
frame
=
contentView
.
bounds
}
else
{
item
.
detailLabel
.
removeFromSuperview
()
item
.
titleLabel
.
sizeToFit
()
item
.
detailLabel
.
sizeToFit
()
let
diff
:
CGFloat
=
(
contentView
.
frame
.
height
-
item
.
titleLabel
.
frame
.
height
-
item
.
detailLabel
.
frame
.
height
)
/
2
item
.
titleLabel
.
frame
.
size
.
height
+=
diff
item
.
titleLabel
.
frame
.
size
.
width
=
contentView
.
frame
.
width
item
.
detailLabel
.
frame
.
size
.
height
+=
diff
item
.
detailLabel
.
frame
.
size
.
width
=
contentView
.
frame
.
width
item
.
detailLabel
.
frame
.
origin
.
y
=
item
.
titleLabel
.
frame
.
height
}
contentView
.
grid
.
reload
()
}
else
{
item
.
detailLabel
.
removeFromSuperview
()
}
contentView
.
grid
.
reload
()
}
}
...
...
Sources/iOS/NavigationDrawerController.swift
View file @
6c813dcf
...
...
@@ -185,7 +185,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
A CGFloat property that sets the animation duration of the
leftView when closing and opening. Defaults to 0.25.
*/
@IBInspectable
public
var
animationDuration
:
CGFloat
=
0.25
@IBInspectable
public
var
animationDuration
:
TimeInterval
=
0.25
/**
A Boolean property that enables and disables the leftView from
...
...
@@ -619,7 +619,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
showView
(
container
:
v
)
isUserInteractionEnabled
=
false
delegate
?
.
navigationDrawerWillOpen
?(
navigationDrawerController
:
self
,
position
:
.
left
)
UIView
.
animate
(
withDuration
:
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
TimeInterval
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
v
.
position
.
x
=
v
.
width
/
2
self
.
rootViewController
.
view
.
alpha
=
0.5
...
...
@@ -645,7 +645,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
showView
(
container
:
v
)
isUserInteractionEnabled
=
false
delegate
?
.
navigationDrawerWillOpen
?(
navigationDrawerController
:
self
,
position
:
.
right
)
UIView
.
animate
(
withDuration
:
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
TimeInterval
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
[
weak
self
]
in
if
let
s
=
self
{
v
.
position
.
x
=
s
.
view
.
bounds
.
width
-
v
.
width
/
2
...
...
@@ -671,7 +671,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
if
let
v
:
View
=
leftView
{
isUserInteractionEnabled
=
true
delegate
?
.
navigationDrawerWillClose
?(
navigationDrawerController
:
self
,
position
:
.
left
)
UIView
.
animate
(
withDuration
:
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
TimeInterval
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
[
weak
self
]
in
if
let
s
=
self
{
v
.
position
.
x
=
-
v
.
width
/
2
...
...
@@ -699,7 +699,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
if
let
v
:
View
=
rightView
{
isUserInteractionEnabled
=
true
delegate
?
.
navigationDrawerWillClose
?(
navigationDrawerController
:
self
,
position
:
.
right
)
UIView
.
animate
(
withDuration
:
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
TimeInterval
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
[
weak
self
]
in
if
let
s
=
self
{
v
.
position
.
x
=
s
.
view
.
bounds
.
width
+
v
.
width
/
2
...
...
Sources/iOS/PhotoLibrary.swift
View file @
6c813dcf
This diff is collapsed.
Click to expand it.
Sources/iOS/Switch.swift
View file @
6c813dcf
...
...
@@ -315,7 +315,7 @@ public class Switch: UIControl {
Toggle the Switch state, if On will be Off, and if Off will be On.
- Parameter completion: An Optional completion block.
*/
public
func
toggle
(
completion
:
((
control
:
Switch
)
->
Void
)?
=
nil
)
{
public
func
toggle
(
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
setSwitchState
(
state
:
.
on
==
internalSwitchState
?
.
off
:
.
on
,
animated
:
true
,
completion
:
completion
)
}
...
...
@@ -324,7 +324,7 @@ public class Switch: UIControl {
- Parameter on: A bool of whether the switch should be in the on state or not.
- Parameter animated: A Boolean indicating to set the animation or not.
*/
public
func
setOn
(
on
:
Bool
,
animated
:
Bool
,
completion
:
((
control
:
Switch
)
->
Void
)?
=
nil
)
{
public
func
setOn
(
on
:
Bool
,
animated
:
Bool
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
setSwitchState
(
state
:
on
?
.
on
:
.
off
,
animated
:
animated
,
completion
:
completion
)
}
...
...
@@ -334,14 +334,14 @@ public class Switch: UIControl {
- Parameter animated: A Boolean indicating to set the animation or not.
- Parameter completion: An Optional completion block.
*/
public
func
setSwitchState
(
state
:
SwitchState
,
animated
:
Bool
=
true
,
completion
:
((
control
:
Switch
)
->
Void
)?
=
nil
)
{
public
func
setSwitchState
(
state
:
SwitchState
,
animated
:
Bool
=
true
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
if
isEnabled
&&
internalSwitchState
!=
state
{
internalSwitchState
=
state
if
animated
{
animateToState
(
state
:
state
)
{
[
weak
self
]
_
in
if
let
s
:
Switch
=
self
{
s
.
sendActions
(
for
:
.
valueChanged
)
completion
?(
control
:
s
)
completion
?(
s
)
s
.
delegate
?
.
switchStateChanged
(
control
:
s
)
}
}
...
...
@@ -349,7 +349,7 @@ public class Switch: UIControl {
button
.
x
=
.
on
==
state
?
self
.
onPosition
:
self
.
offPosition
styleForState
(
state
:
state
)
sendActions
(
for
:
.
valueChanged
)
completion
?(
control
:
self
)
completion
?(
self
)
delegate
?
.
switchStateChanged
(
control
:
self
)
}
}
...
...
@@ -508,7 +508,7 @@ public class Switch: UIControl {
- Parameter state: The SwitchState to set.
- Parameter completion: An Optional completion block.
*/
private
func
animateToState
(
state
:
SwitchState
,
completion
:
((
control
:
Switch
)
->
Void
)?
=
nil
)
{
private
func
animateToState
(
state
:
SwitchState
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
isUserInteractionEnabled
=
false
UIView
.
animate
(
withDuration
:
0.15
,
delay
:
0.05
,
...
...
@@ -527,7 +527,7 @@ public class Switch: UIControl {
})
{
[
weak
self
]
_
in
if
let
s
:
Switch
=
self
{
s
.
isUserInteractionEnabled
=
true
completion
?(
control
:
s
)
completion
?(
s
)
}
}
}
...
...
Sources/iOS/TabBar.swift
View file @
6c813dcf
...
...
@@ -53,15 +53,15 @@ public class TabBar: View {
}
/// Buttons.
public
var
buttons
:
Array
<
UIButton
>
?
{
public
var
buttons
:
[
UIButton
]
?
{
didSet
{
if
let
v
:
Array
<
UIButton
>
=
oldValue
{
if
let
v
:
[
UIButton
]
=
oldValue
{
for
b
in
v
{
b
.
removeFromSuperview
()
}
}
if
let
v
:
Array
<
UIButton
>
=
buttons
{
if
let
v
:
[
UIButton
]
=
buttons
{
for
b
in
v
{
addSubview
(
b
)
}
...
...
@@ -73,7 +73,7 @@ public class TabBar: View {
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
willRenderView
{
if
let
v
:
Array
<
UIButton
>
=
buttons
{
if
let
v
:
[
UIButton
]
=
buttons
{
if
0
<
v
.
count
{
let
columns
:
Int
=
grid
.
axis
.
columns
/
v
.
count
for
b
in
v
{
...
...
Sources/iOS/TextStorage.swift
View file @
6c813dcf
...
...
@@ -85,7 +85,7 @@ public class TextStorage: NSTextStorage {
If you don't need this value, pass NULL.
- Returns: The attributes for the character at index.
*/
public
override
func
attributes
(
at
location
:
Int
,
effectiveRange
range
:
NSRangePointer
?)
->
[
String
:
Any
Object
]
{
public
override
func
attributes
(
at
location
:
Int
,
effectiveRange
range
:
NSRangePointer
?)
->
[
String
:
Any
]
{
return
store
.
attributes
(
at
:
location
,
effectiveRange
:
range
)
}
...
...
@@ -106,7 +106,7 @@ public class TextStorage: NSTextStorage {
- Parameter range: A range of characters that will have their
attributes updated.
*/
public
override
func
setAttributes
(
_
attrs
:
[
String
:
Any
Object
]?,
range
:
NSRange
)
{
public
override
func
setAttributes
(
_
attrs
:
[
String
:
Any
]?,
range
:
NSRange
)
{
store
.
setAttributes
(
attrs
,
range
:
range
)
edited
(
NSTextStorageEditActions
.
editedAttributes
,
range
:
range
,
changeInLength
:
0
)
}
...
...
Sources/iOS/TextView.swift
View file @
6c813dcf
...
...
@@ -181,21 +181,32 @@ public class TextView: UITextView {
p
.
isHidden
=
!
(
true
==
text
?
.
isEmpty
)
}
if
0
<
text
?
.
utf16
.
count
{
showTitleLabel
()
}
else
if
0
==
text
?
.
utf16
.
count
{
hideTitleLabel
()
}
guard
let
t
=
text
else
{
hideTitleLabel
()
return
}
if
0
<
t
.
utf16
.
count
{
showTitleLabel
()
}
else
{
hideTitleLabel
()
}
}
/// Notification handler for when text editing ended.
internal
func
handleTextViewTextDidEnd
()
{
if
0
<
text
?
.
utf16
.
count
{
showTitleLabel
()
}
else
if
0
==
text
?
.
utf16
.
count
{
hideTitleLabel
()
}
titleLabel
?
.
textColor
=
titleLabelColor
guard
let
t
=
text
else
{
hideTitleLabel
()
return
}
if
0
<
t
.
utf16
.
count
{
showTitleLabel
()
}
else
{
hideTitleLabel
()
}
titleLabel
?
.
textColor
=
titleLabelColor
}
/**
...
...
@@ -233,11 +244,13 @@ public class TextView: UITextView {
if
let
v
:
UILabel
=
titleLabel
{
v
.
isHidden
=
true
addSubview
(
v
)
if
0
<
text
?
.
utf16
.
count
{
showTitleLabel
()
}
else
{
v
.
alpha
=
0
}
guard
let
t
=
text
,
0
==
t
.
utf16
.
count
else
{
v
.
alpha
=
0
return
}
showTitleLabel
()
}
}
...
...
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