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
68e44743
Commit
68e44743
authored
Sep 14, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue-845: removed name collisions. Closes #845.
parent
6598bb5b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
227 additions
and
389 deletions
+227
-389
Sources/iOS/Bar.swift
+7
-7
Sources/iOS/Button.swift
+1
-1
Sources/iOS/Card.swift
+14
-11
Sources/iOS/ChipBar.swift
+11
-11
Sources/iOS/ChipBarController.swift
+13
-13
Sources/iOS/CollectionReusableView.swift
+1
-1
Sources/iOS/CollectionViewCell.swift
+1
-1
Sources/iOS/Divider.swift
+5
-5
Sources/iOS/FABMenu.swift
+5
-5
Sources/iOS/FABMenuController.swift
+3
-3
Sources/iOS/Grid.swift
+13
-13
Sources/iOS/ImageCard.swift
+2
-2
Sources/iOS/Material+UIView.swift
+20
-185
Sources/iOS/NavigationBar.swift
+13
-13
Sources/iOS/NavigationController.swift
+1
-1
Sources/iOS/NavigationDrawerController.swift
+0
-0
Sources/iOS/PresenterCard.swift
+1
-1
Sources/iOS/SearchBarController.swift
+11
-11
Sources/iOS/Snackbar.swift
+1
-1
Sources/iOS/SnackbarController.swift
+5
-5
Sources/iOS/SpringAnimation.swift
+11
-11
Sources/iOS/StatusBarController.swift
+7
-7
Sources/iOS/Switch.swift
+15
-15
Sources/iOS/TabBar.swift
+17
-17
Sources/iOS/TableViewCell.swift
+1
-1
Sources/iOS/TabsController.swift
+10
-10
Sources/iOS/TextField.swift
+19
-19
Sources/iOS/Toolbar.swift
+6
-6
Sources/iOS/ToolbarController.swift
+11
-11
Sources/iOS/View.swift
+2
-2
No files found.
Sources/iOS/Bar.swift
View file @
68e44743
...
...
@@ -39,11 +39,11 @@ public enum ContentViewAlignment: Int {
open
class
Bar
:
View
{
/// Will layout the view.
open
var
willLayout
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
&&
!
grid
.
deferred
return
0
<
bounds
.
width
&&
0
<
bounds
.
height
&&
nil
!=
superview
&&
!
grid
.
deferred
}
open
override
var
intrinsicContentSize
:
CGSize
{
return
CGSize
(
width
:
width
,
height
:
height
)
return
bounds
.
size
}
/// Should center the contentView.
...
...
@@ -195,9 +195,9 @@ open class Bar: View {
b
.
titleEdgeInsets
=
.
zero
}
v
.
width
=
v
.
intrinsicContentSize
.
width
v
.
frame
.
size
.
width
=
v
.
intrinsicContentSize
.
width
v
.
sizeToFit
()
v
.
grid
.
columns
=
Int
(
ceil
(
v
.
width
/
gridFactor
))
+
2
v
.
grid
.
columns
=
Int
(
ceil
(
v
.
bounds
.
width
/
gridFactor
))
+
2
lc
+=
v
.
grid
.
columns
...
...
@@ -212,9 +212,9 @@ open class Bar: View {
b
.
titleEdgeInsets
=
.
zero
}
v
.
width
=
v
.
intrinsicContentSize
.
width
v
.
frame
.
size
.
width
=
v
.
intrinsicContentSize
.
width
v
.
sizeToFit
()
v
.
grid
.
columns
=
Int
(
ceil
(
v
.
width
/
gridFactor
))
+
2
v
.
grid
.
columns
=
Int
(
ceil
(
v
.
bounds
.
width
/
gridFactor
))
+
2
rc
+=
v
.
grid
.
columns
...
...
@@ -237,7 +237,7 @@ open class Bar: View {
}
}
let
p
=
width
-
l
-
r
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
let
p
=
bounds
.
width
-
l
-
r
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
let
columns
=
Int
(
ceil
(
p
/
gridFactor
))
if
.
center
==
contentViewAlignment
{
...
...
Sources/iOS/Button.swift
View file @
68e44743
...
...
@@ -291,6 +291,6 @@ extension Button {
/// Manages the layout for the visualLayer property.
fileprivate
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
cornerRadius
=
cornerRadius
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
Sources/iOS/Card.swift
View file @
68e44743
...
...
@@ -42,9 +42,12 @@ open class Card: PulseView {
}
@IBInspectable
open
override
var
cornerRadius
:
CGFloat
{
didSet
{
container
.
cornerRadius
=
cornerRadius
open
var
cornerRadius
:
CGFloat
{
get
{
return
container
.
layer
.
cornerRadius
}
set
(
value
)
{
container
.
layer
.
cornerRadius
=
value
}
}
...
...
@@ -177,7 +180,7 @@ open class Card: PulseView {
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
container
.
width
=
width
container
.
frame
.
size
.
width
=
bounds
.
width
reload
()
}
...
...
@@ -197,7 +200,7 @@ open class Card: PulseView {
h
=
prepare
(
view
:
v
,
with
:
bottomBarEdgeInsets
,
from
:
h
)
}
container
.
height
=
h
container
.
frame
.
size
.
height
=
h
bounds
.
size
.
height
=
h
}
...
...
@@ -220,19 +223,19 @@ open class Card: PulseView {
open
func
prepare
(
view
:
UIView
,
with
insets
:
EdgeInsets
,
from
top
:
CGFloat
)
->
CGFloat
{
let
y
=
insets
.
top
+
top
view
.
y
=
y
view
.
x
=
insets
.
left
view
.
frame
.
origin
.
y
=
y
view
.
frame
.
origin
.
x
=
insets
.
left
let
w
=
container
.
width
-
insets
.
left
-
insets
.
right
var
h
=
view
.
height
let
w
=
container
.
bounds
.
width
-
insets
.
left
-
insets
.
right
var
h
=
view
.
bounds
.
height
if
0
==
h
||
nil
!=
view
as?
UILabel
{
(
view
as?
UILabel
)?
.
sizeToFit
()
h
=
view
.
sizeThatFits
(
CGSize
(
width
:
w
,
height
:
.
greatestFiniteMagnitude
))
.
height
}
view
.
width
=
w
view
.
height
=
h
view
.
frame
.
size
.
width
=
w
view
.
frame
.
size
.
height
=
h
return
y
+
h
+
insets
.
bottom
}
...
...
Sources/iOS/ChipBar.swift
View file @
68e44743
...
...
@@ -62,7 +62,7 @@ fileprivate extension ChipItem {
/// Lays out the chipItem based on its style.
func
layoutChipItemStyle
()
{
if
.
pill
==
chipItemStyle
{
cornerRadius
=
height
/
2
layer
.
cornerRadius
=
bounds
.
height
/
2
}
}
}
...
...
@@ -125,7 +125,7 @@ open class ChipBar: Bar {
let
p
=
q
+
chipItemsInterimSpace
for
v
in
chipItems
{
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
bounds
.
height
))
.
width
w
+=
x
w
+=
p
}
...
...
@@ -251,7 +251,7 @@ fileprivate extension ChipBar {
func
prepareChipItems
()
{
for
v
in
chipItems
{
v
.
grid
.
columns
=
0
v
.
cornerRadius
=
0
v
.
layer
.
cornerRadius
=
0
v
.
contentEdgeInsets
=
.
zero
v
.
removeTarget
(
self
,
action
:
#selector(
handle(chipItem:)
)
,
for
:
.
touchUpInside
)
...
...
@@ -261,7 +261,7 @@ fileprivate extension ChipBar {
/// Prepares the contentView.
func
prepareContentView
()
{
contentView
.
zPosition
=
6000
contentView
.
layer
.
zPosition
=
6000
}
/// Prepares the scroll view.
...
...
@@ -277,16 +277,16 @@ fileprivate extension ChipBar {
func
layoutScrollView
()
{
contentView
.
grid
.
reload
()
if
.
scrollable
==
chipBarStyle
||
(
.
auto
==
chipBarStyle
&&
chipItemsTotalWidth
>
scrollView
.
width
)
{
if
.
scrollable
==
chipBarStyle
||
(
.
auto
==
chipBarStyle
&&
chipItemsTotalWidth
>
scrollView
.
bounds
.
width
)
{
var
w
:
CGFloat
=
0
let
q
=
2
*
chipItemsInterimSpace
let
p
=
q
+
chipItemsInterimSpace
for
v
in
chipItems
{
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
v
.
height
=
scrollView
.
height
v
.
width
=
x
+
q
v
.
x
=
w
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
bounds
.
height
))
.
width
v
.
frame
.
size
.
height
=
scrollView
.
bounds
.
height
v
.
frame
.
size
.
width
=
x
+
q
v
.
frame
.
origin
.
x
=
w
w
+=
x
w
+=
p
...
...
@@ -298,7 +298,7 @@ fileprivate extension ChipBar {
w
-=
chipItemsInterimSpace
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
scrollView
.
height
)
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
scrollView
.
bounds
.
height
)
}
else
{
scrollView
.
grid
.
begin
()
...
...
@@ -370,7 +370,7 @@ fileprivate extension ChipBar {
}
if
!
scrollView
.
bounds
.
contains
(
v
.
frame
)
{
let
contentOffsetX
=
(
v
.
x
<
scrollView
.
bounds
.
minX
)
?
v
.
x
:
v
.
frame
.
maxX
-
scrollView
.
bounds
.
width
let
contentOffsetX
=
(
v
.
frame
.
origin
.
x
<
scrollView
.
bounds
.
minX
)
?
v
.
frame
.
origin
.
x
:
v
.
frame
.
maxX
-
scrollView
.
bounds
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
bounds
.
width
)
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
true
)
}
...
...
Sources/iOS/ChipBarController.swift
View file @
68e44743
...
...
@@ -97,26 +97,26 @@ fileprivate extension ChipBarController {
fileprivate
extension
ChipBarController
{
/// Layout the container.
func
layoutContainer
()
{
chipBar
.
width
=
view
.
width
chipBar
.
frame
.
size
.
width
=
view
.
bounds
.
width
switch
displayStyle
{
case
.
partial
:
let
p
=
chipBar
.
height
let
y
=
view
.
height
-
p
let
p
=
chipBar
.
bounds
.
height
let
y
=
view
.
bounds
.
height
-
p
switch
chipBarAlignment
{
case
.
top
:
container
.
y
=
p
container
.
height
=
y
container
.
frame
.
origin
.
y
=
p
container
.
frame
.
size
.
height
=
y
case
.
bottom
:
container
.
y
=
0
container
.
height
=
y
container
.
frame
.
origin
.
y
=
0
container
.
frame
.
size
.
height
=
y
case
.
hidden
:
container
.
y
=
0
container
.
height
=
view
.
height
container
.
frame
.
origin
.
y
=
0
container
.
frame
.
size
.
height
=
view
.
bounds
.
height
}
container
.
width
=
view
.
width
container
.
frame
.
size
.
width
=
view
.
bounds
.
width
case
.
full
:
container
.
frame
=
view
.
bounds
...
...
@@ -125,15 +125,15 @@ fileprivate extension ChipBarController {
/// Layout the chipBar.
func
layoutChipBar
()
{
chipBar
.
width
=
view
.
width
chipBar
.
frame
.
size
.
width
=
view
.
bounds
.
width
switch
chipBarAlignment
{
case
.
top
:
chipBar
.
isHidden
=
false
chipBar
.
y
=
0
chipBar
.
frame
.
origin
.
y
=
0
case
.
bottom
:
chipBar
.
isHidden
=
false
chipBar
.
y
=
view
.
height
-
chipBar
.
height
chipBar
.
frame
.
origin
.
y
=
view
.
bounds
.
height
-
chipBar
.
bounds
.
height
case
.
hidden
:
chipBar
.
isHidden
=
true
}
...
...
Sources/iOS/CollectionReusableView.swift
View file @
68e44743
...
...
@@ -317,6 +317,6 @@ extension CollectionReusableView {
/// Manages the layout for the visualLayer property.
fileprivate
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
cornerRadius
=
cornerRadius
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
Sources/iOS/CollectionViewCell.swift
View file @
68e44743
...
...
@@ -276,6 +276,6 @@ extension CollectionViewCell {
/// Manages the layout for the visualLayer property.
fileprivate
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
cornerRadius
=
cornerRadius
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
Sources/iOS/Divider.swift
View file @
68e44743
...
...
@@ -79,7 +79,7 @@ public struct Divider {
}
if
nil
==
line
{
line
=
UIView
()
line
?
.
zPosition
=
5000
line
?
.
layer
.
zPosition
=
5000
view
?
.
addSubview
(
line
!
)
reload
()
}
...
...
@@ -123,13 +123,13 @@ public struct Divider {
switch
alignment
{
case
.
top
:
l
.
frame
=
CGRect
(
x
:
c
.
left
,
y
:
c
.
top
,
width
:
v
.
width
-
c
.
left
-
c
.
right
,
height
:
thickness
)
l
.
frame
=
CGRect
(
x
:
c
.
left
,
y
:
c
.
top
,
width
:
v
.
bounds
.
width
-
c
.
left
-
c
.
right
,
height
:
thickness
)
case
.
bottom
:
l
.
frame
=
CGRect
(
x
:
c
.
left
,
y
:
v
.
height
-
thickness
-
c
.
bottom
,
width
:
v
.
width
-
c
.
left
-
c
.
right
,
height
:
thickness
)
l
.
frame
=
CGRect
(
x
:
c
.
left
,
y
:
v
.
bounds
.
height
-
thickness
-
c
.
bottom
,
width
:
v
.
bounds
.
width
-
c
.
left
-
c
.
right
,
height
:
thickness
)
case
.
left
:
l
.
frame
=
CGRect
(
x
:
c
.
left
,
y
:
c
.
top
,
width
:
thickness
,
height
:
v
.
height
-
c
.
top
-
c
.
bottom
)
l
.
frame
=
CGRect
(
x
:
c
.
left
,
y
:
c
.
top
,
width
:
thickness
,
height
:
v
.
bounds
.
height
-
c
.
top
-
c
.
bottom
)
case
.
right
:
l
.
frame
=
CGRect
(
x
:
v
.
width
-
thickness
-
c
.
right
,
y
:
c
.
top
,
width
:
thickness
,
height
:
v
.
height
-
c
.
top
-
c
.
bottom
)
l
.
frame
=
CGRect
(
x
:
v
.
bounds
.
width
-
thickness
-
c
.
right
,
y
:
c
.
top
,
width
:
thickness
,
height
:
v
.
bounds
.
height
-
c
.
top
-
c
.
bottom
)
}
}
}
...
...
Sources/iOS/FABMenu.swift
View file @
68e44743
...
...
@@ -92,15 +92,15 @@ extension FABMenuItem {
let
interimSpace
=
InterimSpacePresetToValue
(
preset
:
.
interimSpace6
)
titleLabel
.
sizeToFit
()
titleLabel
.
width
+=
1.5
*
interimSpace
titleLabel
.
height
+=
interimSpace
/
2
titleLabel
.
y
=
(
height
-
titleLabel
.
height
)
/
2
titleLabel
.
frame
.
size
.
width
+=
1.5
*
interimSpace
titleLabel
.
frame
.
size
.
height
+=
interimSpace
/
2
titleLabel
.
frame
.
origin
.
y
=
(
bounds
.
height
-
titleLabel
.
bounds
.
height
)
/
2
switch
titleLabelPosition
{
case
.
left
:
titleLabel
.
x
=
-
titleLabel
.
width
-
interimSpace
titleLabel
.
frame
.
origin
.
x
=
-
titleLabel
.
bounds
.
width
-
interimSpace
case
.
right
:
titleLabel
.
x
=
frame
.
width
+
interimSpace
titleLabel
.
frame
.
origin
.
x
=
frame
.
bounds
.
width
+
interimSpace
}
titleLabel
.
alpha
=
0
...
...
Sources/iOS/FABMenuController.swift
View file @
68e44743
...
...
@@ -74,11 +74,11 @@ open class FABMenuController: TransitionController {
extension
FABMenuController
:
FABMenuDelegate
{}
extension
FABMenuController
{
fileprivate
extension
FABMenuController
{
/// Prepares the fabMenu.
f
ileprivate
f
unc
prepareFABMenu
()
{
func
prepareFABMenu
()
{
fabMenu
.
delegate
=
self
fabMenu
.
zPosition
=
1000
fabMenu
.
layer
.
zPosition
=
1000
fabMenu
.
handleFABButtonCallback
=
{
[
weak
self
]
in
self
?
.
handleFABButtonCallback
(
button
:
$0
)
...
...
Sources/iOS/Grid.swift
View file @
68e44743
...
...
@@ -210,7 +210,7 @@ public struct Grid {
return
}
guard
0
<
canvas
.
width
&&
0
<
canva
s
.
height
else
{
guard
0
<
canvas
.
bounds
.
width
&&
0
<
canvas
.
bound
s
.
height
else
{
return
}
...
...
@@ -227,10 +227,10 @@ public struct Grid {
let
co
=
v
.
grid
.
offset
.
columns
let
w
=
(
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
v
.
x
=
CGFloat
(
i
+
n
+
co
)
*
w
+
contentEdgeInsets
.
left
+
layoutEdgeInsets
.
left
v
.
y
=
contentEdgeInsets
.
top
+
layoutEdgeInsets
.
top
v
.
width
=
w
*
CGFloat
(
c
)
-
interimSpace
v
.
height
=
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
v
.
frame
.
origin
.
x
=
CGFloat
(
i
+
n
+
co
)
*
w
+
contentEdgeInsets
.
left
+
layoutEdgeInsets
.
left
v
.
frame
.
origin
.
y
=
contentEdgeInsets
.
top
+
layoutEdgeInsets
.
top
v
.
frame
.
size
.
width
=
w
*
CGFloat
(
c
)
-
interimSpace
v
.
frame
.
size
.
height
=
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
n
+=
c
+
co
-
1
...
...
@@ -239,10 +239,10 @@ public struct Grid {
let
ro
=
v
.
grid
.
offset
.
rows
let
h
=
(
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
v
.
x
=
contentEdgeInsets
.
left
+
layoutEdgeInsets
.
left
v
.
y
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
contentEdgeInsets
.
top
+
layoutEdgeInsets
.
top
v
.
width
=
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
v
.
height
=
h
*
CGFloat
(
r
)
-
interimSpace
v
.
frame
.
origin
.
x
=
contentEdgeInsets
.
left
+
layoutEdgeInsets
.
left
v
.
frame
.
origin
.
y
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
contentEdgeInsets
.
top
+
layoutEdgeInsets
.
top
v
.
frame
.
size
.
width
=
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
v
.
frame
.
size
.
height
=
h
*
CGFloat
(
r
)
-
interimSpace
n
+=
r
+
ro
-
1
...
...
@@ -254,10 +254,10 @@ public struct Grid {
let
w
=
(
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
let
h
=
(
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
v
.
x
=
CGFloat
(
co
)
*
w
+
contentEdgeInsets
.
left
+
layoutEdgeInsets
.
left
v
.
y
=
CGFloat
(
ro
)
*
h
+
contentEdgeInsets
.
top
+
layoutEdgeInsets
.
top
v
.
width
=
w
*
CGFloat
(
c
)
-
interimSpace
v
.
height
=
h
*
CGFloat
(
r
)
-
interimSpace
v
.
frame
.
origin
.
x
=
CGFloat
(
co
)
*
w
+
contentEdgeInsets
.
left
+
layoutEdgeInsets
.
left
v
.
frame
.
origin
.
y
=
CGFloat
(
ro
)
*
h
+
contentEdgeInsets
.
top
+
layoutEdgeInsets
.
top
v
.
frame
.
size
.
width
=
w
*
CGFloat
(
c
)
-
interimSpace
v
.
frame
.
size
.
height
=
h
*
CGFloat
(
r
)
-
interimSpace
}
i
+=
1
...
...
Sources/iOS/ImageCard.swift
View file @
68e44743
...
...
@@ -87,7 +87,7 @@ open class ImageCard: Card {
if
let
v
=
toolbar
{
prepare
(
view
:
v
,
with
:
toolbarEdgeInsets
,
from
:
h
)
v
.
y
=
.
top
==
toolbarAlignment
?
toolbarEdgeInsets
.
top
:
h
-
v
.
height
-
toolbarEdgeInsets
.
bottom
v
.
frame
.
origin
.
y
=
.
top
==
toolbarAlignment
?
toolbarEdgeInsets
.
top
:
h
-
v
.
bounds
.
height
-
toolbarEdgeInsets
.
bottom
container
.
bringSubview
(
toFront
:
v
)
}
...
...
@@ -99,7 +99,7 @@ open class ImageCard: Card {
h
=
prepare
(
view
:
v
,
with
:
bottomBarEdgeInsets
,
from
:
h
)
}
container
.
height
=
h
container
.
frame
.
size
.
height
=
h
bounds
.
size
.
height
=
h
}
}
Sources/iOS/Material+UIView.swift
View file @
68e44743
...
...
@@ -31,80 +31,30 @@
import
UIKit
extension
UIView
{
/// A property that accesses the backing layer's masksToBounds.
@IBInspectable
open
var
masksToBounds
:
Bool
{
get
{
return
layer
.
masksToBounds
}
set
(
value
)
{
layer
.
masksToBounds
=
value
}
}
/// A property that accesses the backing layer's opacity.
@IBInspectable
open
var
opacity
:
Float
{
get
{
return
layer
.
opacity
}
set
(
value
)
{
layer
.
opacity
=
value
}
}
/// A property that accesses the backing layer's anchorPoint.
@IBInspectable
open
var
anchorPoint
:
CGPoint
{
get
{
return
layer
.
anchorPoint
}
set
(
value
)
{
layer
.
anchorPoint
=
value
}
}
/// A property that accesses the frame.origin.x property.
@IBInspectable
open
var
x
:
CGFloat
{
get
{
return
layer
.
x
}
set
(
value
)
{
layer
.
x
=
value
}
}
/// A property that accesses the frame.origin.y property.
@IBInspectable
open
var
y
:
CGFloat
{
get
{
return
layer
.
y
}
set
(
value
)
{
layer
.
y
=
value
}
}
/// A property that accesses the frame.size.width property.
@IBInspectable
open
var
width
:
CGFloat
{
/// A property that accesses the backing layer's shadow
open
var
shadowColor
:
UIColor
?
{
get
{
return
layer
.
width
guard
let
v
=
layer
.
shadowColor
else
{
return
nil
}
return
UIColor
(
cgColor
:
v
)
}
set
(
value
)
{
layer
.
width
=
value
layer
.
shadowColor
=
value
?
.
cgColor
}
}
/// A property that accesses the frame.size.height property.
@IBInspectable
open
var
height
:
CGFloat
{
/// A property that accesses the layer.borderColor property.
open
var
borderColor
:
UIColor
?
{
get
{
return
layer
.
height
guard
let
v
=
layer
.
borderColor
else
{
return
nil
}
return
UIColor
(
cgColor
:
v
)
}
set
(
value
)
{
layer
.
height
=
value
layer
.
borderColor
=
value
?
.
cgColor
}
}
...
...
@@ -153,65 +103,6 @@ extension UIView {
}
}
/// A property that accesses the backing layer's shadow
@IBInspectable
open
var
shadowColor
:
UIColor
?
{
get
{
guard
let
v
=
layer
.
shadowColor
else
{
return
nil
}
return
UIColor
(
cgColor
:
v
)
}
set
(
value
)
{
layer
.
shadowColor
=
value
?
.
cgColor
}
}
/// A property that accesses the backing layer's shadowOffset.
@IBInspectable
open
var
shadowOffset
:
CGSize
{
get
{
return
layer
.
shadowOffset
}
set
(
value
)
{
layer
.
shadowOffset
=
value
}
}
/// A property that accesses the backing layer's shadowOpacity.
@IBInspectable
open
var
shadowOpacity
:
Float
{
get
{
return
layer
.
shadowOpacity
}
set
(
value
)
{
layer
.
shadowOpacity
=
value
}
}
/// A property that accesses the backing layer's shadowRadius.
@IBInspectable
open
var
shadowRadius
:
CGFloat
{
get
{
return
layer
.
shadowRadius
}
set
(
value
)
{
layer
.
shadowRadius
=
value
}
}
/// A property that accesses the backing layer's shadowPath.
@IBInspectable
open
var
shadowPath
:
CGPath
?
{
get
{
return
layer
.
shadowPath
}
set
(
value
)
{
layer
.
shadowPath
=
value
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable
open
var
isShadowPathAutoSizing
:
Bool
{
...
...
@@ -234,17 +125,6 @@ extension UIView {
}
}
/// A property that accesses the layer.cornerRadius.
@IBInspectable
open
var
cornerRadius
:
CGFloat
{
get
{
return
layer
.
cornerRadius
}
set
(
value
)
{
layer
.
cornerRadius
=
value
}
}
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
{
get
{
...
...
@@ -254,61 +134,16 @@ extension UIView {
layer
.
borderWidthPreset
=
value
}
}
/// A property that accesses the layer.borderWith.
@IBInspectable
open
var
borderWidth
:
CGFloat
{
get
{
return
layer
.
borderWidth
}
set
(
value
)
{
layer
.
borderWidth
=
value
}
}
/// A property that accesses the layer.borderColor property.
@IBInspectable
open
var
borderColor
:
UIColor
?
{
get
{
guard
let
v
=
layer
.
borderColor
else
{
return
nil
}
return
UIColor
(
cgColor
:
v
)
}
set
(
value
)
{
layer
.
borderColor
=
value
?
.
cgColor
}
}
/// A property that accesses the layer.position property.
@IBInspectable
open
var
position
:
CGPoint
{
get
{
return
layer
.
position
}
set
(
value
)
{
layer
.
position
=
value
}
}
/// A property that accesses the layer.zPosition property.
@IBInspectable
open
var
zPosition
:
CGFloat
{
get
{
return
layer
.
zPosition
}
set
(
value
)
{
layer
.
zPosition
=
value
}
}
}
extension
UIView
{
/// Manages the layout for the shape of the view instance.
open
func
layoutShape
()
{
internal
func
layoutShape
()
{
layer
.
layoutShape
()
}
/// Sets the shadow path.
open
func
layoutShadowPath
()
{
internal
func
layoutShadowPath
()
{
layer
.
layoutShadowPath
()
}
}
Sources/iOS/NavigationBar.swift
View file @
68e44743
...
...
@@ -33,11 +33,11 @@ import UIKit
open
class
NavigationBar
:
UINavigationBar
{
/// Will layout the view.
open
var
willLayout
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
return
0
<
bounds
.
width
&&
0
<
bounds
.
height
&&
nil
!=
superview
}
open
override
var
intrinsicContentSize
:
CGSize
{
return
CGSize
(
width
:
width
,
height
:
height
)
return
CGSize
(
width
:
bounds
.
width
,
height
:
bounds
.
height
)
}
/// A preset wrapper around contentEdgeInsets.
...
...
@@ -183,9 +183,9 @@ open class NavigationBar: UINavigationBar {
b
.
titleEdgeInsets
=
.
zero
}
v
.
width
=
v
.
intrinsicContentSize
.
width
v
.
frame
.
size
.
width
=
v
.
intrinsicContentSize
.
width
v
.
sizeToFit
()
v
.
grid
.
columns
=
Int
(
ceil
(
v
.
width
/
gridFactor
))
+
2
v
.
grid
.
columns
=
Int
(
ceil
(
v
.
bounds
.
width
/
gridFactor
))
+
2
lc
+=
v
.
grid
.
columns
...
...
@@ -200,9 +200,9 @@ open class NavigationBar: UINavigationBar {
b
.
titleEdgeInsets
=
.
zero
}
v
.
width
=
v
.
intrinsicContentSize
.
width
v
.
frame
.
size
.
width
=
v
.
intrinsicContentSize
.
width
v
.
sizeToFit
()
v
.
grid
.
columns
=
Int
(
ceil
(
v
.
width
/
gridFactor
))
+
2
v
.
grid
.
columns
=
Int
(
ceil
(
v
.
bounds
.
width
/
gridFactor
))
+
2
rc
+=
v
.
grid
.
columns
...
...
@@ -225,7 +225,7 @@ open class NavigationBar: UINavigationBar {
}
}
let
p
=
width
-
l
-
r
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
let
p
=
bounds
.
width
-
l
-
r
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
let
columns
=
Int
(
ceil
(
p
/
gridFactor
))
if
.
center
==
item
.
contentViewAlignment
{
...
...
@@ -267,14 +267,14 @@ open class NavigationBar: UINavigationBar {
item
.
titleLabel
.
sizeToFit
()
item
.
detailLabel
.
sizeToFit
()
let
diff
=
(
item
.
contentView
.
height
-
item
.
titleLabel
.
height
-
item
.
detailLabel
.
height
)
/
2
let
diff
=
(
item
.
contentView
.
bounds
.
height
-
item
.
titleLabel
.
bounds
.
height
-
item
.
detailLabel
.
bounds
.
height
)
/
2
item
.
titleLabel
.
height
+=
diff
item
.
titleLabel
.
width
=
item
.
contentView
.
width
item
.
titleLabel
.
frame
.
size
.
height
+=
diff
item
.
titleLabel
.
frame
.
size
.
width
=
item
.
contentView
.
bounds
.
width
item
.
detailLabel
.
height
+=
diff
item
.
detailLabel
.
width
=
item
.
contentView
.
width
item
.
detailLabel
.
y
=
item
.
titleLabel
.
height
item
.
detailLabel
.
frame
.
size
.
height
+=
diff
item
.
detailLabel
.
frame
.
size
.
width
=
item
.
contentView
.
bounds
.
width
item
.
detailLabel
.
frame
.
origin
.
y
=
item
.
titleLabel
.
bounds
.
height
}
}
else
{
item
.
detailLabel
.
removeFromSuperview
()
...
...
Sources/iOS/NavigationController.swift
View file @
68e44743
...
...
@@ -120,7 +120,7 @@ open class NavigationController: UINavigationController {
*/
open
func
prepare
()
{
navigationBar
.
heightPreset
=
.
normal
navigationBar
.
width
=
view
.
width
navigationBar
.
frame
.
size
.
width
=
view
.
bounds
.
width
view
.
clipsToBounds
=
true
view
.
backgroundColor
=
.
white
...
...
Sources/iOS/NavigationDrawerController.swift
View file @
68e44743
This diff is collapsed.
Click to expand it.
Sources/iOS/PresenterCard.swift
View file @
68e44743
...
...
@@ -78,7 +78,7 @@ open class PresenterCard: Card {
h
=
prepare
(
view
:
v
,
with
:
bottomBarEdgeInsets
,
from
:
h
)
}
container
.
height
=
h
container
.
frame
.
size
.
height
=
h
bounds
.
size
.
height
=
h
}
}
Sources/iOS/SearchBarController.swift
View file @
68e44743
...
...
@@ -77,7 +77,7 @@ open class SearchBarController: StatusBarController {
fileprivate
extension
SearchBarController
{
/// Prepares the searchBar.
func
prepareSearchBar
()
{
searchBar
.
zPosition
=
1000
searchBar
.
layer
.
zPosition
=
1000
searchBar
.
depthPreset
=
.
depth1
view
.
addSubview
(
searchBar
)
}
...
...
@@ -88,20 +88,20 @@ fileprivate extension SearchBarController {
func
layoutContainer
()
{
switch
displayStyle
{
case
.
partial
:
let
p
=
searchBar
.
height
let
p
=
searchBar
.
bounds
.
height
let
q
=
statusBarOffsetAdjustment
let
h
=
view
.
height
-
p
-
q
let
h
=
view
.
bounds
.
height
-
p
-
q
switch
searchBarAlignment
{
case
.
top
:
container
.
y
=
q
+
p
container
.
height
=
h
container
.
frame
.
origin
.
y
=
q
+
p
container
.
frame
.
size
.
height
=
h
case
.
bottom
:
container
.
y
=
q
container
.
height
=
h
container
.
frame
.
origin
.
y
=
q
container
.
frame
.
size
.
height
=
h
}
container
.
width
=
view
.
width
container
.
frame
.
size
.
width
=
view
.
bounds
.
width
case
.
full
:
container
.
frame
=
view
.
bounds
...
...
@@ -110,9 +110,9 @@ fileprivate extension SearchBarController {
/// Layout the searchBar.
func
layoutSearchBar
()
{
searchBar
.
x
=
0
searchBar
.
y
=
.
top
==
searchBarAlignment
?
statusBarOffsetAdjustment
:
view
.
height
-
searchBar
.
height
searchBar
.
width
=
view
.
width
searchBar
.
frame
.
origin
.
x
=
0
searchBar
.
frame
.
origin
.
y
=
.
top
==
searchBarAlignment
?
statusBarOffsetAdjustment
:
view
.
bounds
.
height
-
searchBar
.
bounds
.
height
searchBar
.
frame
.
size
.
width
=
view
.
bounds
.
width
}
/// Layout the rootViewController.
...
...
Sources/iOS/Snackbar.swift
View file @
68e44743
...
...
@@ -64,7 +64,7 @@ open class Snackbar: Bar {
open
let
textLabel
=
UILabel
()
open
override
var
intrinsicContentSize
:
CGSize
{
return
CGSize
(
width
:
width
,
height
:
49
)
return
CGSize
(
width
:
bounds
.
width
,
height
:
49
)
}
/// The status of the snackbar.
...
...
Sources/iOS/SnackbarController.swift
View file @
68e44743
...
...
@@ -175,8 +175,8 @@ open class SnackbarController: TransitionController {
/// Reloads the view.
open
func
reload
()
{
snackbar
.
x
=
snackbarEdgeInsets
.
left
snackbar
.
width
=
view
.
width
-
snackbarEdgeInsets
.
left
-
snackbarEdgeInsets
.
right
snackbar
.
frame
.
origin
.
x
=
snackbarEdgeInsets
.
left
snackbar
.
frame
.
size
.
width
=
view
.
bounds
.
width
-
snackbarEdgeInsets
.
left
-
snackbarEdgeInsets
.
right
rootViewController
.
view
.
frame
=
view
.
bounds
layoutSnackbar
(
status
:
snackbar
.
status
)
}
...
...
@@ -188,7 +188,7 @@ open class SnackbarController: TransitionController {
/// Prepares the snackbar.
private
func
prepareSnackbar
()
{
snackbar
.
zPosition
=
10000
snackbar
.
layer
.
zPosition
=
10000
view
.
addSubview
(
snackbar
)
}
...
...
@@ -198,9 +198,9 @@ open class SnackbarController: TransitionController {
*/
private
func
layoutSnackbar
(
status
:
SnackbarStatus
)
{
if
.
bottom
==
snackbarAlignment
{
snackbar
.
y
=
.
visible
==
status
?
view
.
height
-
snackbar
.
height
-
snackbarEdgeInsets
.
bottom
:
view
.
height
snackbar
.
frame
.
origin
.
y
=
.
visible
==
status
?
view
.
bounds
.
height
-
snackbar
.
bounds
.
height
-
snackbarEdgeInsets
.
bottom
:
view
.
bounds
.
height
}
else
{
snackbar
.
y
=
.
visible
==
status
?
snackbarEdgeInsets
.
top
:
-
snackbar
.
height
snackbar
.
frame
.
origin
.
y
=
.
visible
==
status
?
snackbarEdgeInsets
.
top
:
-
snackbar
.
bounds
.
height
}
}
}
Sources/iOS/SpringAnimation.swift
View file @
68e44743
...
...
@@ -92,9 +92,9 @@ open class SpringAnimation {
v
.
alpha
=
0
v
.
isHidden
=
true
v
.
frame
.
size
=
itemSize
v
.
x
=
(
baseSize
.
width
-
itemSize
.
width
)
/
2
v
.
y
=
(
baseSize
.
height
-
itemSize
.
height
)
/
2
v
.
zPosition
=
CGFloat
(
10000
-
views
.
count
-
i
)
v
.
frame
.
origin
.
x
=
(
baseSize
.
width
-
itemSize
.
width
)
/
2
v
.
frame
.
origin
.
y
=
(
baseSize
.
height
-
itemSize
.
height
)
/
2
v
.
layer
.
zPosition
=
CGFloat
(
10000
-
views
.
count
-
i
)
}
}
}
...
...
@@ -238,7 +238,7 @@ extension SpringAnimation {
options
:
options
,
animations
:
{
[
s
=
interimSpace
,
m
=
CGFloat
(
i
+
1
),
v
=
v
]
in
v
.
alpha
=
1
v
.
y
=
-
m
*
(
v
.
height
+
s
)
v
.
frame
.
origin
.
y
=
-
m
*
(
v
.
bounds
.
height
+
s
)
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
self
?
.
handleOpenCompletion
(
view
:
v
,
completion
:
completion
)
...
...
@@ -267,7 +267,7 @@ extension SpringAnimation {
options
:
options
,
animations
:
{
[
v
=
v
]
in
v
.
alpha
=
0
v
.
y
=
0
v
.
frame
.
origin
.
y
=
0
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
self
?
.
handleCloseCompletion
(
view
:
v
,
completion
:
completion
)
...
...
@@ -298,7 +298,7 @@ extension SpringAnimation {
options
:
options
,
animations
:
{
[
s
=
interimSpace
,
m
=
CGFloat
(
i
+
1
),
v
=
v
]
in
v
.
alpha
=
1
v
.
y
=
m
*
(
v
.
height
+
s
)
v
.
frame
.
origin
.
y
=
m
*
(
v
.
bounds
.
height
+
s
)
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
...
...
@@ -332,7 +332,7 @@ extension SpringAnimation {
options
:
options
,
animations
:
{
[
first
=
first
,
v
=
v
]
in
v
.
alpha
=
0
v
.
y
=
first
.
y
v
.
frame
.
origin
.
y
=
first
.
frame
.
origin
.
y
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
...
...
@@ -364,7 +364,7 @@ extension SpringAnimation {
options
:
options
,
animations
:
{
[
s
=
interimSpace
,
m
=
CGFloat
(
i
+
1
),
v
=
v
]
in
v
.
alpha
=
1
v
.
x
=
-
m
*
(
v
.
width
+
s
)
v
.
frame
.
origin
.
x
=
-
m
*
(
v
.
bounds
.
width
+
s
)
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
...
...
@@ -398,7 +398,7 @@ extension SpringAnimation {
options
:
options
,
animations
:
{
[
first
=
first
,
v
=
v
]
in
v
.
alpha
=
0
v
.
x
=
first
.
x
v
.
frame
.
origin
.
x
=
first
.
frame
.
origin
.
x
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
...
...
@@ -430,7 +430,7 @@ extension SpringAnimation {
options
:
options
,
animations
:
{
[
s
=
interimSpace
,
m
=
CGFloat
(
i
+
1
),
v
=
v
]
in
v
.
alpha
=
1
v
.
x
=
m
*
(
v
.
width
+
s
)
v
.
frame
.
origin
.
x
=
m
*
(
v
.
bounds
.
width
+
s
)
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
...
...
@@ -466,7 +466,7 @@ extension SpringAnimation {
options
:
options
,
animations
:
{
[
first
=
first
,
v
=
v
]
in
v
.
alpha
=
0
v
.
x
=
first
.
x
+
w
v
.
frame
.
origin
.
x
=
first
.
frame
.
origin
.
x
+
w
animations
?(
v
)
})
{
[
weak
self
,
v
=
v
]
_
in
...
...
Sources/iOS/StatusBarController.swift
View file @
68e44743
...
...
@@ -76,7 +76,7 @@ open class StatusBarController: TransitionController {
/// An adjustment based on the rules for displaying the statusBar.
open
var
statusBarOffsetAdjustment
:
CGFloat
{
return
Application
.
shouldStatusBarBeHidden
||
statusBar
.
isHidden
?
0
:
statusBar
.
height
return
Application
.
shouldStatusBarBeHidden
||
statusBar
.
isHidden
?
0
:
statusBar
.
bounds
.
height
}
/// A boolean that indicates to hide the statusBar on rotation.
...
...
@@ -92,20 +92,20 @@ open class StatusBarController: TransitionController {
statusBar
.
isHidden
=
Application
.
shouldStatusBarBeHidden
}
statusBar
.
width
=
view
.
width
statusBar
.
frame
.
size
.
width
=
view
.
bounds
.
width
switch
displayStyle
{
case
.
partial
:
let
h
=
statusBar
.
height
container
.
y
=
h
container
.
height
=
view
.
height
-
h
let
h
=
statusBar
.
bounds
.
height
container
.
frame
.
origin
.
y
=
h
container
.
frame
.
size
.
height
=
view
.
bounds
.
height
-
h
case
.
full
:
container
.
frame
=
view
.
bounds
}
rootViewController
.
view
.
frame
=
container
.
bounds
container
.
zPosition
=
statusBa
r
.
zPosition
+
(
Application
.
shouldStatusBarBeHidden
?
1
:
-
1
)
container
.
layer
.
zPosition
=
statusBar
.
laye
r
.
zPosition
+
(
Application
.
shouldStatusBarBeHidden
?
1
:
-
1
)
}
open
override
func
prepare
()
{
...
...
@@ -121,7 +121,7 @@ fileprivate extension StatusBarController {
statusBar
.
backgroundColor
=
.
white
}
statusBar
.
height
=
20
statusBar
.
frame
.
size
.
height
=
20
view
.
addSubview
(
statusBar
)
}
}
Sources/iOS/Switch.swift
View file @
68e44743
...
...
@@ -62,7 +62,7 @@ public protocol SwitchDelegate {
open
class
Switch
:
UIControl
{
/// Will layout the view.
open
var
willLayout
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
return
0
<
bounds
.
width
&&
0
<
bounds
.
height
&&
nil
!=
superview
}
/// An internal reference to the switchState public property.
...
...
@@ -309,17 +309,17 @@ open class Switch: UIControl {
/// Reloads the view.
open
func
reload
()
{
let
w
:
CGFloat
=
intrinsicContentSize
.
width
let
px
:
CGFloat
=
(
width
-
w
)
/
2
let
px
:
CGFloat
=
(
bounds
.
width
-
w
)
/
2
track
.
frame
=
CGRect
(
x
:
px
,
y
:
(
height
-
trackThickness
)
/
2
,
width
:
w
,
height
:
trackThickness
)
track
.
cornerRadius
=
min
(
w
,
trackThickness
)
/
2
track
.
frame
=
CGRect
(
x
:
px
,
y
:
(
bounds
.
height
-
trackThickness
)
/
2
,
width
:
w
,
height
:
trackThickness
)
track
.
layer
.
cornerRadius
=
min
(
w
,
trackThickness
)
/
2
button
.
frame
=
CGRect
(
x
:
px
,
y
:
(
height
-
buttonDiameter
)
/
2
,
width
:
buttonDiameter
,
height
:
buttonDiameter
)
onPosition
=
width
-
px
-
buttonDiameter
button
.
frame
=
CGRect
(
x
:
px
,
y
:
(
bounds
.
height
-
buttonDiameter
)
/
2
,
width
:
buttonDiameter
,
height
:
buttonDiameter
)
onPosition
=
bounds
.
width
-
px
-
buttonDiameter
offPosition
=
px
if
.
on
==
internalSwitchState
{
button
.
x
=
onPosition
button
.
frame
.
origin
.
x
=
onPosition
}
}
...
...
@@ -402,7 +402,7 @@ extension Switch {
s
.
delegate
?
.
switchDidChangeState
(
control
:
s
,
state
:
s
.
internalSwitchState
)
}
}
else
{
button
.
x
=
.
on
==
state
?
self
.
onPosition
:
self
.
offPosition
button
.
frame
.
origin
.
x
=
.
on
==
state
?
self
.
onPosition
:
self
.
offPosition
styleForState
(
state
:
state
)
guard
isTriggeredByUserInteraction
else
{
...
...
@@ -474,7 +474,7 @@ extension Switch {
return
}
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
+
s
.
bounceOffset
:
s
.
offPosition
-
s
.
bounceOffset
s
.
button
.
frame
.
origin
.
x
=
.
on
==
state
?
s
.
onPosition
+
s
.
bounceOffset
:
s
.
offPosition
-
s
.
bounceOffset
s
.
styleForState
(
state
:
state
)
})
{
[
weak
self
]
_
in
UIView
.
animate
(
withDuration
:
0.15
,
...
...
@@ -483,7 +483,7 @@ extension Switch {
return
}
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
:
s
.
offPosition
s
.
button
.
frame
.
origin
.
x
=
.
on
==
state
?
s
.
onPosition
:
s
.
offPosition
})
{
[
weak
self
]
_
in
guard
let
s
=
self
else
{
return
...
...
@@ -508,8 +508,8 @@ extension Switch {
return
}
let
q
:
CGFloat
=
sender
.
x
+
v
.
location
(
in
:
sender
)
.
x
-
v
.
previousLocation
(
in
:
sender
)
.
x
updateSwitchState
(
state
:
q
>
(
width
-
button
.
width
)
/
2
?
.
on
:
.
off
,
animated
:
true
,
isTriggeredByUserInteraction
:
true
)
let
q
:
CGFloat
=
sender
.
frame
.
origin
.
x
+
v
.
location
(
in
:
sender
)
.
x
-
v
.
previousLocation
(
in
:
sender
)
.
x
updateSwitchState
(
state
:
q
>
(
bounds
.
width
-
button
.
bounds
.
width
)
/
2
?
.
on
:
.
off
,
animated
:
true
,
isTriggeredByUserInteraction
:
true
)
}
/// Handles the TouchUpInside event.
...
...
@@ -529,13 +529,13 @@ extension Switch {
return
}
let
q
:
CGFloat
=
max
(
min
(
sender
.
x
+
v
.
location
(
in
:
sender
)
.
x
-
v
.
previousLocation
(
in
:
sender
)
.
x
,
onPosition
),
offPosition
)
let
q
:
CGFloat
=
max
(
min
(
sender
.
frame
.
origin
.
x
+
v
.
location
(
in
:
sender
)
.
x
-
v
.
previousLocation
(
in
:
sender
)
.
x
,
onPosition
),
offPosition
)
guard
q
!=
sender
.
x
else
{
guard
q
!=
sender
.
frame
.
origin
.
x
else
{
return
}
sender
.
x
=
q
sender
.
frame
.
origin
.
x
=
q
}
}
...
...
Sources/iOS/TabBar.swift
View file @
68e44743
...
...
@@ -92,7 +92,7 @@ open class TabBar: Bar {
let
p
=
q
+
tabItemsInterimSpace
for
v
in
tabItems
{
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
bounds
.
height
))
.
width
w
+=
x
w
+=
p
}
...
...
@@ -205,10 +205,10 @@ open class TabBar: Bar {
/// The line height.
open
var
lineHeight
:
CGFloat
{
get
{
return
line
.
height
return
line
.
bounds
.
height
}
set
(
value
)
{
line
.
height
=
value
line
.
frame
.
size
.
height
=
value
}
}
...
...
@@ -240,7 +240,7 @@ open class TabBar: Bar {
fileprivate
extension
TabBar
{
// Prepares the line.
func
prepareLine
()
{
line
.
zPosition
=
10000
line
.
layer
.
zPosition
=
10000
lineColor
=
Color
.
blue
.
base
lineHeight
=
3
scrollView
.
addSubview
(
line
)
...
...
@@ -277,7 +277,7 @@ fileprivate extension TabBar {
/// Prepares the contentView.
func
prepareContentView
()
{
contentView
.
zPosition
=
6000
contentView
.
layer
.
zPosition
=
6000
}
/// Prepares the scroll view.
...
...
@@ -293,16 +293,16 @@ fileprivate extension TabBar {
func
layoutScrollView
()
{
contentView
.
grid
.
reload
()
if
.
scrollable
==
tabBarStyle
||
(
.
auto
==
tabBarStyle
&&
tabItemsTotalWidth
>
scrollView
.
width
)
{
if
.
scrollable
==
tabBarStyle
||
(
.
auto
==
tabBarStyle
&&
tabItemsTotalWidth
>
scrollView
.
bounds
.
width
)
{
var
w
:
CGFloat
=
0
let
q
=
2
*
tabItemsInterimSpace
let
p
=
q
+
tabItemsInterimSpace
for
v
in
tabItems
{
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
v
.
height
=
scrollView
.
height
v
.
width
=
x
+
q
v
.
x
=
w
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
bounds
.
height
))
.
width
v
.
frame
.
size
.
height
=
scrollView
.
bounds
.
height
v
.
frame
.
size
.
width
=
x
+
q
v
.
frame
.
origin
.
x
=
w
w
+=
x
w
+=
p
...
...
@@ -314,7 +314,7 @@ fileprivate extension TabBar {
w
-=
tabItemsInterimSpace
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
scrollView
.
height
)
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
scrollView
.
bounds
.
height
)
}
else
{
scrollView
.
grid
.
begin
()
...
...
@@ -335,12 +335,12 @@ fileprivate extension TabBar {
guard
shouldNotAnimateLineView
else
{
line
.
animate
(
.
duration
(
0
),
.
size
(
CGSize
(
width
:
v
.
width
,
height
:
lineHeight
)
),
.
position
(
CGPoint
(
x
:
v
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
/
2
:
lineHeight
/
2
)
))
.
size
(
width
:
v
.
bounds
.
width
,
height
:
lineHeight
),
.
position
(
x
:
v
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
bounds
.
height
-
lineHeight
/
2
:
lineHeight
/
2
))
return
}
line
.
frame
=
CGRect
(
x
:
v
.
x
,
y
:
.
bottom
==
lineAlignment
?
scrollView
.
height
-
lineHeight
:
0
,
width
:
v
.
width
,
height
:
lineHeight
)
line
.
frame
=
CGRect
(
x
:
v
.
frame
.
origin
.
x
,
y
:
.
bottom
==
lineAlignment
?
scrollView
.
bounds
.
height
-
lineHeight
:
0
,
width
:
v
.
bounds
.
width
,
height
:
lineHeight
)
shouldNotAnimateLineView
=
false
}
...
...
@@ -408,8 +408,8 @@ fileprivate extension TabBar {
selectedTabItem
=
tabItem
line
.
animate
(
.
duration
(
0.25
),
.
size
(
width
:
tabItem
.
width
,
height
:
lineHeight
),
.
position
(
x
:
tabItem
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
/
2
:
lineHeight
/
2
),
.
size
(
width
:
tabItem
.
bounds
.
width
,
height
:
lineHeight
),
.
position
(
x
:
tabItem
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
bounds
.
height
-
lineHeight
/
2
:
lineHeight
/
2
),
.
completion
({
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
tabItem
=
tabItem
,
completion
=
completion
]
in
guard
let
s
=
self
else
{
return
...
...
@@ -434,7 +434,7 @@ fileprivate extension TabBar {
}
if
!
scrollView
.
bounds
.
contains
(
v
.
frame
)
{
let
contentOffsetX
=
(
v
.
x
<
scrollView
.
bounds
.
minX
)
?
v
.
x
:
v
.
frame
.
maxX
-
scrollView
.
bounds
.
width
let
contentOffsetX
=
(
v
.
frame
.
origin
.
x
<
scrollView
.
bounds
.
minX
)
?
v
.
frame
.
origin
.
x
:
v
.
frame
.
maxX
-
scrollView
.
bounds
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
bounds
.
width
)
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
true
)
}
...
...
Sources/iOS/TableViewCell.swift
View file @
68e44743
...
...
@@ -196,6 +196,6 @@ extension TableViewCell {
/// Manages the layout for the visualLayer property.
fileprivate
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
cornerRadius
=
cornerRadius
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
Sources/iOS/TabsController.swift
View file @
68e44743
...
...
@@ -306,19 +306,19 @@ fileprivate extension TabsController {
func
layoutContainer
()
{
switch
displayStyle
{
case
.
partial
:
let
p
=
tabBar
.
height
let
y
=
view
.
height
-
p
let
p
=
tabBar
.
bounds
.
height
let
y
=
view
.
bounds
.
height
-
p
switch
tabBarAlignment
{
case
.
top
:
container
.
y
=
p
container
.
height
=
y
container
.
frame
.
origin
.
y
=
p
container
.
frame
.
size
.
height
=
y
case
.
bottom
:
container
.
y
=
0
container
.
height
=
y
container
.
frame
.
origin
.
y
=
0
container
.
frame
.
size
.
height
=
y
}
container
.
width
=
view
.
width
container
.
frame
.
size
.
width
=
view
.
bounds
.
width
case
.
full
:
container
.
frame
=
view
.
bounds
...
...
@@ -327,9 +327,9 @@ fileprivate extension TabsController {
/// Layout the tabBar.
func
layoutTabBar
()
{
tabBar
.
x
=
0
tabBar
.
y
=
.
top
==
tabBarAlignment
?
0
:
view
.
height
-
tabBar
.
height
tabBar
.
width
=
view
.
width
tabBar
.
frame
.
origin
.
x
=
0
tabBar
.
frame
.
origin
.
y
=
.
top
==
tabBarAlignment
?
0
:
view
.
bounds
.
height
-
tabBar
.
bounds
.
height
tabBar
.
frame
.
size
.
width
=
view
.
bounds
.
width
}
/// Layout the rootViewController.
...
...
Sources/iOS/TextField.swift
View file @
68e44743
...
...
@@ -66,7 +66,7 @@ public protocol TextFieldDelegate: UITextFieldDelegate {
open
class
TextField
:
UITextField
{
/// Default size when using AutoLayout.
open
override
var
intrinsicContentSize
:
CGSize
{
return
CGSize
(
width
:
width
,
height
:
32
)
return
CGSize
(
width
:
bounds
.
width
,
height
:
32
)
}
/// A Boolean that indicates if the placeholder label is animated.
...
...
@@ -109,7 +109,7 @@ open class TextField: UITextField {
return
0
}
return
leftViewOffset
+
height
return
leftViewOffset
+
bounds
.
height
}
/// The leftView offset value.
...
...
@@ -550,41 +550,41 @@ fileprivate extension TextField {
/// Layout the placeholderLabel.
func
layoutPlaceholderLabel
()
{
let
w
=
leftViewWidth
+
textInset
let
h
=
0
==
height
?
intrinsicContentSize
.
height
:
height
let
h
=
0
==
bounds
.
height
?
intrinsicContentSize
.
height
:
bounds
.
height
placeholderLabel
.
transform
=
CGAffineTransform
.
identity
guard
isEditing
||
!
isEmpty
||
!
isPlaceholderAnimated
else
{
placeholderLabel
.
frame
=
CGRect
(
x
:
w
,
y
:
0
,
width
:
width
-
leftViewWidth
-
2
*
textInset
,
height
:
h
)
placeholderLabel
.
frame
=
CGRect
(
x
:
w
,
y
:
0
,
width
:
bounds
.
width
-
leftViewWidth
-
2
*
textInset
,
height
:
h
)
return
}
placeholderLabel
.
frame
=
CGRect
(
x
:
w
,
y
:
0
,
width
:
width
-
leftViewWidth
-
2
*
textInset
,
height
:
h
)
placeholderLabel
.
frame
=
CGRect
(
x
:
w
,
y
:
0
,
width
:
bounds
.
width
-
leftViewWidth
-
2
*
textInset
,
height
:
h
)
placeholderLabel
.
transform
=
CGAffineTransform
(
scaleX
:
placeholderActiveScale
,
y
:
placeholderActiveScale
)
switch
textAlignment
{
case
.
left
,
.
natural
:
placeholderLabel
.
x
=
w
+
placeholderHorizontalOffset
placeholderLabel
.
frame
.
origin
.
x
=
w
+
placeholderHorizontalOffset
case
.
right
:
placeholderLabel
.
x
=
width
-
placeholderLabel
.
width
-
textInset
+
placeholderHorizontalOffset
placeholderLabel
.
frame
.
origin
.
x
=
bounds
.
width
-
placeholderLabel
.
bounds
.
width
-
textInset
+
placeholderHorizontalOffset
default
:
break
}
placeholderLabel
.
y
=
-
placeholderLabel
.
height
+
placeholderVerticalOffset
placeholderLabel
.
frame
.
origin
.
y
=
-
placeholderLabel
.
bounds
.
height
+
placeholderVerticalOffset
}
/// Layout the detailLabel.
func
layoutDetailLabel
()
{
let
c
=
dividerContentEdgeInsets
detailLabel
.
height
=
detailLabel
.
sizeThatFits
(
CGSize
(
width
:
width
,
height
:
.
greatestFiniteMagnitude
))
.
height
detailLabel
.
x
=
c
.
left
detailLabel
.
y
=
height
+
detailVerticalOffset
detailLabel
.
width
=
width
-
c
.
left
-
c
.
right
detailLabel
.
frame
.
size
.
height
=
detailLabel
.
sizeThatFits
(
CGSize
(
width
:
bounds
.
width
,
height
:
.
greatestFiniteMagnitude
))
.
height
detailLabel
.
frame
.
origin
.
x
=
c
.
left
detailLabel
.
frame
.
origin
.
y
=
bounds
.
height
+
detailVerticalOffset
detailLabel
.
frame
.
size
.
width
=
bounds
.
width
-
c
.
left
-
c
.
right
}
/// Layout the a button.
func
layoutButton
(
button
:
UIButton
?)
{
button
?
.
frame
=
CGRect
(
x
:
width
-
height
,
y
:
0
,
width
:
height
,
height
:
height
)
button
?
.
frame
=
CGRect
(
x
:
bounds
.
width
-
bounds
.
height
,
y
:
0
,
width
:
bounds
.
height
,
height
:
bounds
.
height
)
}
/// Layout the leftView.
...
...
@@ -594,7 +594,7 @@ fileprivate extension TextField {
}
let
w
=
leftViewWidth
v
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
w
,
height
:
height
)
v
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
w
,
height
:
bounds
.
height
)
dividerContentEdgeInsets
.
left
=
w
}
}
...
...
@@ -705,13 +705,13 @@ extension TextField {
switch
s
.
textAlignment
{
case
.
left
,
.
natural
:
s
.
placeholderLabel
.
x
=
s
.
leftViewWidth
+
s
.
textInset
+
s
.
placeholderHorizontalOffset
s
.
placeholderLabel
.
frame
.
origin
.
x
=
s
.
leftViewWidth
+
s
.
textInset
+
s
.
placeholderHorizontalOffset
case
.
right
:
s
.
placeholderLabel
.
x
=
s
.
width
-
s
.
placeholderLabel
.
width
-
s
.
textInset
+
s
.
placeholderHorizontalOffset
s
.
placeholderLabel
.
frame
.
origin
.
x
=
s
.
bounds
.
width
-
s
.
placeholderLabel
.
bounds
.
width
-
s
.
textInset
+
s
.
placeholderHorizontalOffset
default
:
break
}
s
.
placeholderLabel
.
y
=
-
s
.
placeholderLabel
.
height
+
s
.
placeholderVerticalOffset
s
.
placeholderLabel
.
frame
.
origin
.
y
=
-
s
.
placeholderLabel
.
bounds
.
height
+
s
.
placeholderVerticalOffset
})
}
...
...
@@ -739,8 +739,8 @@ extension TextField {
}
s
.
placeholderLabel
.
transform
=
CGAffineTransform
.
identity
s
.
placeholderLabel
.
x
=
s
.
leftViewWidth
+
s
.
textInset
s
.
placeholderLabel
.
y
=
0
s
.
placeholderLabel
.
frame
.
origin
.
x
=
s
.
leftViewWidth
+
s
.
textInset
s
.
placeholderLabel
.
frame
.
origin
.
y
=
0
})
}
}
Sources/iOS/Toolbar.swift
View file @
68e44743
...
...
@@ -97,14 +97,14 @@ open class Toolbar: Bar {
titleLabel
.
sizeToFit
()
detailLabel
.
sizeToFit
()
let
diff
:
CGFloat
=
(
contentView
.
height
-
titleLabel
.
height
-
detailLabel
.
height
)
/
2
let
diff
:
CGFloat
=
(
contentView
.
bounds
.
height
-
titleLabel
.
bounds
.
height
-
detailLabel
.
bounds
.
height
)
/
2
titleLabel
.
height
+=
diff
titleLabel
.
width
=
contentView
.
width
titleLabel
.
frame
.
size
.
height
+=
diff
titleLabel
.
frame
.
size
.
width
=
contentView
.
bounds
.
width
detailLabel
.
height
+=
diff
detailLabel
.
width
=
contentView
.
width
detailLabel
.
y
=
titleLabel
.
height
detailLabel
.
frame
.
size
.
height
+=
diff
detailLabel
.
frame
.
size
.
width
=
contentView
.
bounds
.
width
detailLabel
.
frame
.
origin
.
y
=
titleLabel
.
bounds
.
height
}
}
else
{
detailLabel
.
removeFromSuperview
()
...
...
Sources/iOS/ToolbarController.swift
View file @
68e44743
...
...
@@ -78,7 +78,7 @@ open class ToolbarController: StatusBarController {
fileprivate
extension
ToolbarController
{
/// Prepares the toolbar.
func
prepareToolbar
()
{
toolbar
.
zPosition
=
1000
toolbar
.
layer
.
zPosition
=
1000
toolbar
.
depthPreset
=
.
depth1
view
.
addSubview
(
toolbar
)
}
...
...
@@ -89,20 +89,20 @@ fileprivate extension ToolbarController {
func
layoutContainer
()
{
switch
displayStyle
{
case
.
partial
:
let
p
=
toolbar
.
height
let
p
=
toolbar
.
bounds
.
height
let
q
=
statusBarOffsetAdjustment
let
h
=
view
.
height
-
p
-
q
let
h
=
view
.
bounds
.
height
-
p
-
q
switch
toolbarAlignment
{
case
.
top
:
container
.
y
=
q
+
p
container
.
height
=
h
container
.
frame
.
origin
.
y
=
q
+
p
container
.
frame
.
size
.
height
=
h
case
.
bottom
:
container
.
y
=
q
container
.
height
=
h
container
.
frame
.
origin
.
y
=
q
container
.
frame
.
size
.
height
=
h
}
container
.
width
=
view
.
width
container
.
frame
.
size
.
width
=
view
.
bounds
.
width
case
.
full
:
container
.
frame
=
view
.
bounds
...
...
@@ -111,9 +111,9 @@ fileprivate extension ToolbarController {
/// Layout the toolbar.
func
layoutToolbar
()
{
toolbar
.
x
=
0
toolbar
.
y
=
.
top
==
toolbarAlignment
?
statusBarOffsetAdjustment
:
view
.
height
-
toolbar
.
height
toolbar
.
width
=
view
.
width
toolbar
.
frame
.
origin
.
x
=
0
toolbar
.
frame
.
origin
.
y
=
.
top
==
toolbarAlignment
?
statusBarOffsetAdjustment
:
view
.
bounds
.
height
-
toolbar
.
bounds
.
height
toolbar
.
frame
.
size
.
width
=
view
.
bounds
.
width
}
/// Layout the rootViewController.
...
...
Sources/iOS/View.swift
View file @
68e44743
...
...
@@ -32,7 +32,7 @@ import UIKit
open
class
View
:
UIView
{
open
override
var
intrinsicContentSize
:
CGSize
{
return
CGSize
(
width
:
width
,
height
:
height
)
return
bounds
.
size
}
/**
...
...
@@ -196,6 +196,6 @@ extension View {
/// Manages the layout for the visualLayer property.
fileprivate
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
cornerRadius
=
cornerRadius
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
}
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