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
33b548eb
Commit
33b548eb
authored
Aug 17, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: applying updates to issue-491, second pass
parent
973206a0
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
474 additions
and
497 deletions
+474
-497
Material.xcodeproj/project.pbxproj
+10
-6
Sources/iOS/BottomNavigationController.swift
+7
-7
Sources/iOS/CollectionView.swift
+0
-0
Sources/iOS/CollectionViewCell.swift
+16
-8
Sources/iOS/Depth.swift
+0
-23
Sources/iOS/DynamicFontType.swift
+1
-1
Sources/iOS/Grid.swift
+1
-1
Sources/iOS/JSON.swift
+17
-17
Sources/iOS/Label.swift
+16
-12
Sources/iOS/Layer.swift
+15
-198
Sources/iOS/Material+CALayer.swift
+316
-0
Sources/iOS/Material+UIView.swift
+37
-146
Sources/iOS/MaterialTextLayer.swift
+1
-49
Sources/iOS/NavigationController.swift
+7
-7
Sources/iOS/RootController.swift
+8
-7
Sources/iOS/SearchBarController.swift
+4
-4
Sources/iOS/ToolbarController.swift
+4
-4
Sources/iOS/View.swift
+14
-7
No files found.
Material.xcodeproj/project.pbxproj
View file @
33b548eb
...
@@ -55,7 +55,7 @@
...
@@ -55,7 +55,7 @@
96BCB7C51CB40DC500C806FE
/* MaterialGravity.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
;
};
96BCB7C51CB40DC500C806FE
/* MaterialGravity.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
;
};
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
};
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
};
96BCB7C71CB40DC500C806FE
/* KeyframeAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77E1CB40DC500C806FE
/* KeyframeAnimation.swift */
;
};
96BCB7C71CB40DC500C806FE
/* KeyframeAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77E1CB40DC500C806FE
/* KeyframeAnimation.swift */
;
};
96BCB7C81CB40DC500C806FE
/*
MaterialLabel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/* Material
Label.swift */
;
};
96BCB7C81CB40DC500C806FE
/*
Label.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/*
Label.swift */
;
};
96BCB7C91CB40DC500C806FE
/* Layer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7801CB40DC500C806FE
/* Layer.swift */
;
};
96BCB7C91CB40DC500C806FE
/* Layer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7801CB40DC500C806FE
/* Layer.swift */
;
};
96BCB7CA1CB40DC500C806FE
/* Layout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7811CB40DC500C806FE
/* Layout.swift */
;
};
96BCB7CA1CB40DC500C806FE
/* Layout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7811CB40DC500C806FE
/* Layout.swift */
;
};
96BCB7CB1CB40DC500C806FE
/* PulseAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7821CB40DC500C806FE
/* PulseAnimation.swift */
;
};
96BCB7CB1CB40DC500C806FE
/* PulseAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7821CB40DC500C806FE
/* PulseAnimation.swift */
;
};
...
@@ -159,7 +159,7 @@
...
@@ -159,7 +159,7 @@
96BCB8511CB4115200C806FE
/* MaterialGravity.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8511CB4115200C806FE
/* MaterialGravity.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8521CB4115200C806FE
/* CornerRadius.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7851CB40DC500C806FE
/* CornerRadius.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8521CB4115200C806FE
/* CornerRadius.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7851CB40DC500C806FE
/* CornerRadius.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8531CB4115200C806FE
/* Shape.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7861CB40DC500C806FE
/* Shape.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8531CB4115200C806FE
/* Shape.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7861CB40DC500C806FE
/* Shape.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8541CB4115200C806FE
/*
MaterialLabel.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/* Material
Label.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8541CB4115200C806FE
/*
Label.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77F1CB40DC500C806FE
/*
Label.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8551CB4115200C806FE
/* PulseView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7841CB40DC500C806FE
/* PulseView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8551CB4115200C806FE
/* PulseView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7841CB40DC500C806FE
/* PulseView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8561CB4115200C806FE
/* Switch.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7881CB40DC500C806FE
/* Switch.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8561CB4115200C806FE
/* Switch.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7881CB40DC500C806FE
/* Switch.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8571CB4115200C806FE
/* View.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB78C1CB40DC500C806FE
/* View.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8571CB4115200C806FE
/* View.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB78C1CB40DC500C806FE
/* View.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
@@ -177,6 +177,7 @@
...
@@ -177,6 +177,7 @@
96E3C39E1D3A1D0C0086A024
/* BasicAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E3C39D1D3A1D0C0086A024
/* BasicAnimation.swift */
;
};
96E3C39E1D3A1D0C0086A024
/* BasicAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96E3C39D1D3A1D0C0086A024
/* BasicAnimation.swift */
;
};
96EA9A431D4E68F80052C74D
/* PhotoLibrary.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96EA9A421D4E68F80052C74D
/* PhotoLibrary.swift */
;
};
96EA9A431D4E68F80052C74D
/* PhotoLibrary.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96EA9A421D4E68F80052C74D
/* PhotoLibrary.swift */
;
};
96EA9A4B1D4E7A430052C74D
/* PhotoLibraryController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96EA9A4A1D4E7A430052C74D
/* PhotoLibraryController.swift */
;
};
96EA9A4B1D4E7A430052C74D
/* PhotoLibraryController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96EA9A4A1D4E7A430052C74D
/* PhotoLibraryController.swift */
;
};
96F1DC881D654FDF0025F925
/* Material+CALayer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96F1DC871D654FDF0025F925
/* Material+CALayer.swift */
;
};
/* End PBXBuildFile section */
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
/* Begin PBXContainerItemProxy section */
...
@@ -246,7 +247,7 @@
...
@@ -246,7 +247,7 @@
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialGravity.swift
;
sourceTree
=
"<group>"
;
};
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialGravity.swift
;
sourceTree
=
"<group>"
;
};
96BCB77D1CB40DC500C806FE
/* Icon.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Icon.swift
;
sourceTree
=
"<group>"
;
};
96BCB77D1CB40DC500C806FE
/* Icon.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Icon.swift
;
sourceTree
=
"<group>"
;
};
96BCB77E1CB40DC500C806FE
/* KeyframeAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
KeyframeAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB77E1CB40DC500C806FE
/* KeyframeAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
KeyframeAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB77F1CB40DC500C806FE
/*
MaterialLabel.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Material
Label.swift
;
sourceTree
=
"<group>"
;
};
96BCB77F1CB40DC500C806FE
/*
Label.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Label.swift
;
sourceTree
=
"<group>"
;
};
96BCB7801CB40DC500C806FE
/* Layer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layer.swift
;
sourceTree
=
"<group>"
;
};
96BCB7801CB40DC500C806FE
/* Layer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layer.swift
;
sourceTree
=
"<group>"
;
};
96BCB7811CB40DC500C806FE
/* Layout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layout.swift
;
sourceTree
=
"<group>"
;
};
96BCB7811CB40DC500C806FE
/* Layout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Layout.swift
;
sourceTree
=
"<group>"
;
};
96BCB7821CB40DC500C806FE
/* PulseAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PulseAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB7821CB40DC500C806FE
/* PulseAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PulseAnimation.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -292,6 +293,7 @@
...
@@ -292,6 +293,7 @@
96E3C39D1D3A1D0C0086A024
/* BasicAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicAnimation.swift
;
sourceTree
=
"<group>"
;
};
96E3C39D1D3A1D0C0086A024
/* BasicAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicAnimation.swift
;
sourceTree
=
"<group>"
;
};
96EA9A421D4E68F80052C74D
/* PhotoLibrary.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoLibrary.swift
;
sourceTree
=
"<group>"
;
};
96EA9A421D4E68F80052C74D
/* PhotoLibrary.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoLibrary.swift
;
sourceTree
=
"<group>"
;
};
96EA9A4A1D4E7A430052C74D
/* PhotoLibraryController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoLibraryController.swift
;
sourceTree
=
"<group>"
;
};
96EA9A4A1D4E7A430052C74D
/* PhotoLibraryController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoLibraryController.swift
;
sourceTree
=
"<group>"
;
};
96F1DC871D654FDF0025F925
/* Material+CALayer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+CALayer.swift"
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
/* Begin PBXFrameworksBuildPhase section */
...
@@ -416,7 +418,7 @@
...
@@ -416,7 +418,7 @@
968C99431D36ECBB000074FF
/* Label */
=
{
968C99431D36ECBB000074FF
/* Label */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
96BCB77F1CB40DC500C806FE
/*
Material
Label.swift */
,
96BCB77F1CB40DC500C806FE
/* Label.swift */
,
);
);
name
=
Label
;
name
=
Label
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -607,6 +609,7 @@
...
@@ -607,6 +609,7 @@
children
=
(
children
=
(
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
,
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
,
96E3C3931D397AE90086A024
/* Material+UIView.swift */
,
96E3C3931D397AE90086A024
/* Material+UIView.swift */
,
96F1DC871D654FDF0025F925
/* Material+CALayer.swift */
,
96BCB7641CB40DC500C806FE
/* Material+String.swift */
,
96BCB7641CB40DC500C806FE
/* Material+String.swift */
,
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
,
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
,
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
,
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
,
...
@@ -746,7 +749,7 @@
...
@@ -746,7 +749,7 @@
96BCB8511CB4115200C806FE
/* MaterialGravity.swift in Headers */
,
96BCB8511CB4115200C806FE
/* MaterialGravity.swift in Headers */
,
96BCB8521CB4115200C806FE
/* CornerRadius.swift in Headers */
,
96BCB8521CB4115200C806FE
/* CornerRadius.swift in Headers */
,
96BCB8531CB4115200C806FE
/* Shape.swift in Headers */
,
96BCB8531CB4115200C806FE
/* Shape.swift in Headers */
,
96BCB8541CB4115200C806FE
/*
Material
Label.swift in Headers */
,
96BCB8541CB4115200C806FE
/* Label.swift in Headers */
,
96BCB8551CB4115200C806FE
/* PulseView.swift in Headers */
,
96BCB8551CB4115200C806FE
/* PulseView.swift in Headers */
,
96BCB8561CB4115200C806FE
/* Switch.swift in Headers */
,
96BCB8561CB4115200C806FE
/* Switch.swift in Headers */
,
96BCB8571CB4115200C806FE
/* View.swift in Headers */
,
96BCB8571CB4115200C806FE
/* View.swift in Headers */
,
...
@@ -975,7 +978,7 @@
...
@@ -975,7 +978,7 @@
96EA9A431D4E68F80052C74D
/* PhotoLibrary.swift in Sources */
,
96EA9A431D4E68F80052C74D
/* PhotoLibrary.swift in Sources */
,
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
,
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
,
96BCB7E91CB40DC500C806FE
/* ToolbarController.swift in Sources */
,
96BCB7E91CB40DC500C806FE
/* ToolbarController.swift in Sources */
,
96BCB7C81CB40DC500C806FE
/*
Material
Label.swift in Sources */
,
96BCB7C81CB40DC500C806FE
/* Label.swift in Sources */
,
96BCB7A21CB40DC500C806FE
/* BottomTabBar.swift in Sources */
,
96BCB7A21CB40DC500C806FE
/* BottomTabBar.swift in Sources */
,
96BCB7BD1CB40DC500C806FE
/* CollectionViewDelegate.swift in Sources */
,
96BCB7BD1CB40DC500C806FE
/* CollectionViewDelegate.swift in Sources */
,
961F18E81CD93E3E008927C5
/* ErrorTextField.swift in Sources */
,
961F18E81CD93E3E008927C5
/* ErrorTextField.swift in Sources */
,
...
@@ -1009,6 +1012,7 @@
...
@@ -1009,6 +1012,7 @@
966ECF2A1CF4C20100BB0BDF
/* CollectionReusableView.swift in Sources */
,
966ECF2A1CF4C20100BB0BDF
/* CollectionReusableView.swift in Sources */
,
96BCB7E51CB40DC500C806FE
/* TextField.swift in Sources */
,
96BCB7E51CB40DC500C806FE
/* TextField.swift in Sources */
,
96BCB7D21CB40DC500C806FE
/* MaterialTableViewCell.swift in Sources */
,
96BCB7D21CB40DC500C806FE
/* MaterialTableViewCell.swift in Sources */
,
96F1DC881D654FDF0025F925
/* Material+CALayer.swift in Sources */
,
96BCB7B61CB40DC500C806FE
/* Animation.swift in Sources */
,
96BCB7B61CB40DC500C806FE
/* Animation.swift in Sources */
,
96BCB7A71CB40DC500C806FE
/* ControlView.swift in Sources */
,
96BCB7A71CB40DC500C806FE
/* ControlView.swift in Sources */
,
96BCB7DB1CB40DC500C806FE
/* NavigationItem.swift in Sources */
,
96BCB7DB1CB40DC500C806FE
/* NavigationItem.swift in Sources */
,
...
...
Sources/iOS/BottomNavigationController.swift
View file @
33b548eb
...
@@ -60,9 +60,9 @@ public enum BottomNavigationTransitionAnimation: Int {
...
@@ -60,9 +60,9 @@ public enum BottomNavigationTransitionAnimation: Int {
}
}
@IBDesignable
@IBDesignable
public
class
BottomNavigationController
:
UITabBarController
,
UITabBarControllerDelegate
{
open
class
BottomNavigationController
:
UITabBarController
,
UITabBarControllerDelegate
{
/// The transition animation to use when selecting a new tab.
/// The transition animation to use when selecting a new tab.
public
var
transitionAnimation
:
BottomNavigationTransitionAnimation
=
.
fade
open
var
transitionAnimation
:
BottomNavigationTransitionAnimation
=
.
fade
/**
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
...
@@ -85,17 +85,17 @@ public class BottomNavigationController : UITabBarController, UITabBarController
...
@@ -85,17 +85,17 @@ public class BottomNavigationController : UITabBarController, UITabBarController
super
.
init
(
nibName
:
nil
,
bundle
:
nil
)
super
.
init
(
nibName
:
nil
,
bundle
:
nil
)
}
}
public
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
prepareView
()
prepareView
()
}
}
public
override
func
viewWillLayoutSubviews
()
{
open
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
super
.
viewWillLayoutSubviews
()
layoutSubviews
()
layoutSubviews
()
}
}
public
func
layoutSubviews
()
{
open
func
layoutSubviews
()
{
if
let
v
:
Array
<
UITabBarItem
>
=
tabBar
.
items
{
if
let
v
:
Array
<
UITabBarItem
>
=
tabBar
.
items
{
for
item
in
v
{
for
item
in
v
{
if
.
phone
==
Device
.
userInterfaceIdiom
{
if
.
phone
==
Device
.
userInterfaceIdiom
{
...
@@ -127,7 +127,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController
...
@@ -127,7 +127,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController
The super.prepareView method should always be called immediately
The super.prepareView method should always be called immediately
when subclassing.
when subclassing.
*/
*/
public
func
prepareView
()
{
open
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
Device
.
scale
view
.
contentScaleFactor
=
Device
.
scale
delegate
=
self
delegate
=
self
...
@@ -135,7 +135,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController
...
@@ -135,7 +135,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController
}
}
/// Handles transitions when tabBarItems are pressed.
/// Handles transitions when tabBarItems are pressed.
public
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
animationControllerForTransitionFrom
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
open
func
tabBarController
(
_
tabBarController
:
UITabBarController
,
animationControllerForTransitionFrom
fromVC
:
UIViewController
,
to
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
let
fVC
:
UIViewController
?
=
fromVC
let
fVC
:
UIViewController
?
=
fromVC
let
tVC
:
UIViewController
?
=
toVC
let
tVC
:
UIViewController
?
=
toVC
if
nil
==
fVC
||
nil
==
tVC
{
if
nil
==
fVC
||
nil
==
tVC
{
...
...
Sources/iOS/CollectionView.swift
View file @
33b548eb
Sources/iOS/CollectionViewCell.swift
View file @
33b548eb
...
@@ -63,7 +63,8 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -63,7 +63,8 @@ open class CollectionViewCell: UICollectionViewCell {
property. Images should not be set to the backing layer's contents
property. Images should not be set to the backing layer's contents
property to avoid conflicts when using clipsToBounds.
property to avoid conflicts when using clipsToBounds.
*/
*/
@IBInspectable
open
var
image
:
UIImage
?
{
@IBInspectable
open
var
image
:
UIImage
?
{
didSet
{
didSet
{
visualLayer
.
contents
=
image
?
.
cgImage
visualLayer
.
contents
=
image
?
.
cgImage
}
}
...
@@ -75,7 +76,8 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -75,7 +76,8 @@ open class CollectionViewCell: UICollectionViewCell {
much greater flexibility than the contentsGravity property in
much greater flexibility than the contentsGravity property in
terms of how the image is cropped and stretched.
terms of how the image is cropped and stretched.
*/
*/
@IBInspectable
open
var
contentsRect
:
CGRect
{
@IBInspectable
open
var
contentsRect
:
CGRect
{
get
{
get
{
return
visualLayer
.
contentsRect
return
visualLayer
.
contentsRect
}
}
...
@@ -88,7 +90,8 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -88,7 +90,8 @@ open class CollectionViewCell: UICollectionViewCell {
A CGRect that defines a stretchable region inside the visualLayer
A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
with a fixed border around the edge.
*/
*/
@IBInspectable
open
var
contentsCenter
:
CGRect
{
@IBInspectable
open
var
contentsCenter
:
CGRect
{
get
{
get
{
return
visualLayer
.
contentsCenter
return
visualLayer
.
contentsCenter
}
}
...
@@ -102,7 +105,8 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -102,7 +105,8 @@ open class CollectionViewCell: UICollectionViewCell {
dimensions of the visualLayer's contents property and the size
dimensions of the visualLayer's contents property and the size
of the view. By default, this value is set to the Device.scale.
of the view. By default, this value is set to the Device.scale.
*/
*/
@IBInspectable
open
var
contentsScale
:
CGFloat
{
@IBInspectable
open
var
contentsScale
:
CGFloat
{
get
{
get
{
return
visualLayer
.
contentsScale
return
visualLayer
.
contentsScale
}
}
...
@@ -119,7 +123,8 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -119,7 +123,8 @@ open class CollectionViewCell: UICollectionViewCell {
}
}
/// Determines how content should be aligned within the visualLayer's bounds.
/// Determines how content should be aligned within the visualLayer's bounds.
@IBInspectable
open
var
contentsGravity
:
String
{
@IBInspectable
open
var
contentsGravity
:
String
{
get
{
get
{
return
visualLayer
.
contentsGravity
return
visualLayer
.
contentsGravity
}
}
...
@@ -139,7 +144,8 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -139,7 +144,8 @@ open class CollectionViewCell: UICollectionViewCell {
}
}
/// A wrapper around grid.contentInset.
/// A wrapper around grid.contentInset.
@IBInspectable
open
var
contentInset
:
EdgeInsets
{
@IBInspectable
open
var
contentInset
:
EdgeInsets
{
get
{
get
{
return
contentView
.
grid
.
contentEdgeInsets
return
contentView
.
grid
.
contentEdgeInsets
}
}
...
@@ -156,7 +162,8 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -156,7 +162,8 @@ open class CollectionViewCell: UICollectionViewCell {
}
}
/// A wrapper around grid.interimSpace.
/// A wrapper around grid.interimSpace.
@IBInspectable
open
var
interimSpace
:
InterimSpace
{
@IBInspectable
open
var
interimSpace
:
InterimSpace
{
get
{
get
{
return
contentView
.
grid
.
interimSpace
return
contentView
.
grid
.
interimSpace
}
}
...
@@ -166,7 +173,8 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -166,7 +173,8 @@ open class CollectionViewCell: UICollectionViewCell {
}
}
/// A property that accesses the backing layer's backgroundColor.
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
}
}
...
...
Sources/iOS/Depth.swift
View file @
33b548eb
...
@@ -107,26 +107,3 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
...
@@ -107,26 +107,3 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
5
),
opacity
:
0.3
,
radius
:
5
)
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
5
),
opacity
:
0.3
,
radius
:
5
)
}
}
}
}
/// Grid extension for UIView.
extension
UIView
{
/// A preset value for Depth.
public
var
depthPreset
:
DepthPreset
{
get
{
return
material
.
depthPreset
}
set
(
value
)
{
material
.
depthPreset
=
value
}
}
/// Grid reference.
public
var
depth
:
Depth
{
get
{
return
material
.
depth
}
set
(
value
)
{
material
.
depth
=
value
}
}
}
Sources/iOS/DynamicFontType.swift
View file @
33b548eb
...
@@ -41,7 +41,7 @@ public protocol DynamicFontTypeDelegate {
...
@@ -41,7 +41,7 @@ public protocol DynamicFontTypeDelegate {
}
}
@objc(DynamicFontType)
@objc(DynamicFontType)
public
class
DynamicFontType
:
NSObject
{
open
class
DynamicFontType
:
NSObject
{
/// A weak reference to a DynamicFontTypeDelegate.
/// A weak reference to a DynamicFontTypeDelegate.
public
weak
var
delegate
:
DynamicFontTypeDelegate
?
public
weak
var
delegate
:
DynamicFontTypeDelegate
?
...
...
Sources/iOS/Grid.swift
View file @
33b548eb
...
@@ -42,7 +42,7 @@ public class GridAxis {
...
@@ -42,7 +42,7 @@ public class GridAxis {
unowned
var
grid
:
Grid
unowned
var
grid
:
Grid
/// The direction the grid lays its views out.
/// The direction the grid lays its views out.
public
var
direction
:
GridAxisDirection
=
.
horizontal
{
open
var
direction
:
GridAxisDirection
=
.
horizontal
{
didSet
{
didSet
{
grid
.
reload
()
grid
.
reload
()
}
}
...
...
Sources/iOS/JSON.swift
View file @
33b548eb
...
@@ -30,79 +30,79 @@
...
@@ -30,79 +30,79 @@
import
Foundation
import
Foundation
public
class
JSON
:
Equatable
,
CustomStringConvertible
{
open
class
JSON
:
Equatable
,
CustomStringConvertible
{
/**
/**
:name: description
:name: description
*/
*/
public
var
description
:
String
{
open
var
description
:
String
{
return
JSON
.
stringify
(
object
)
??
"{}"
return
JSON
.
stringify
(
object
)
??
"{}"
}
}
/**
/**
:name: object
:name: object
*/
*/
public
private(set)
var
object
:
Any
open
private(set)
var
object
:
Any
/**
/**
:name: asArray
:name: asArray
*/
*/
public
var
asArray
:
[
Any
]?
{
open
var
asArray
:
[
Any
]?
{
return
object
as?
[
Any
]
return
object
as?
[
Any
]
}
}
/**
/**
:name: asDictionary
:name: asDictionary
*/
*/
public
var
asDictionary
:
[
String
:
Any
]?
{
open
var
asDictionary
:
[
String
:
Any
]?
{
return
object
as?
[
String
:
Any
]
return
object
as?
[
String
:
Any
]
}
}
/**
/**
:name: asString
:name: asString
*/
*/
public
var
asString
:
String
?
{
open
var
asString
:
String
?
{
return
object
as?
String
return
object
as?
String
}
}
/**
/**
:name: asInt
:name: asInt
*/
*/
public
var
asInt
:
Int
?
{
open
var
asInt
:
Int
?
{
return
object
as?
Int
return
object
as?
Int
}
}
/**
/**
:name: asDouble
:name: asDouble
*/
*/
public
var
asDouble
:
Double
?
{
open
var
asDouble
:
Double
?
{
return
object
as?
Double
return
object
as?
Double
}
}
/**
/**
:name: asFloat
:name: asFloat
*/
*/
public
var
asFloat
:
Float
?
{
open
var
asFloat
:
Float
?
{
return
object
as?
Float
return
object
as?
Float
}
}
/**
/**
:name: asBool
:name: asBool
*/
*/
public
var
asBool
:
Bool
?
{
open
var
asBool
:
Bool
?
{
return
object
as?
Bool
return
object
as?
Bool
}
}
/**
/**
:name: asNSData
:name: asNSData
*/
*/
public
var
asNSData
:
Data
?
{
open
var
asNSData
:
Data
?
{
return
JSON
.
serialize
(
object
:
object
)
return
JSON
.
serialize
(
object
:
object
)
}
}
/**
/**
:name: parse
:name: parse
*/
*/
public
class
func
parse
(
_
data
:
Data
,
options
:
JSONSerialization
.
ReadingOptions
=
.
allowFragments
)
->
JSON
?
{
open
class
func
parse
(
_
data
:
Data
,
options
:
JSONSerialization
.
ReadingOptions
=
.
allowFragments
)
->
JSON
?
{
if
let
object
=
try
?
JSONSerialization
.
jsonObject
(
with
:
data
,
options
:
options
)
{
if
let
object
=
try
?
JSONSerialization
.
jsonObject
(
with
:
data
,
options
:
options
)
{
return
JSON
(
object
)
return
JSON
(
object
)
}
}
...
@@ -112,7 +112,7 @@ public class JSON: Equatable, CustomStringConvertible {
...
@@ -112,7 +112,7 @@ public class JSON: Equatable, CustomStringConvertible {
/**
/**
:name: parse
:name: parse
*/
*/
public
class
func
parse
(
_
json
:
String
)
->
JSON
?
{
open
class
func
parse
(
_
json
:
String
)
->
JSON
?
{
guard
let
data
=
json
.
data
(
using
:
String
.
Encoding
.
utf8
)
else
{
guard
let
data
=
json
.
data
(
using
:
String
.
Encoding
.
utf8
)
else
{
return
nil
return
nil
}
}
...
@@ -122,14 +122,14 @@ public class JSON: Equatable, CustomStringConvertible {
...
@@ -122,14 +122,14 @@ public class JSON: Equatable, CustomStringConvertible {
/**
/**
:name: serialize
:name: serialize
*/
*/
public
class
func
serialize
(
object
:
Any
)
->
Data
?
{
open
class
func
serialize
(
object
:
Any
)
->
Data
?
{
return
try
?
JSONSerialization
.
data
(
withJSONObject
:
object
,
options
:
[])
return
try
?
JSONSerialization
.
data
(
withJSONObject
:
object
,
options
:
[])
}
}
/**
/**
:name: stringify
:name: stringify
*/
*/
public
class
func
stringify
(
_
object
:
Any
)
->
String
?
{
open
class
func
stringify
(
_
object
:
Any
)
->
String
?
{
if
let
o
=
object
as?
JSON
{
if
let
o
=
object
as?
JSON
{
return
stringify
(
o
.
object
)
return
stringify
(
o
.
object
)
}
else
if
let
data
=
JSON
.
serialize
(
object
:
object
)
{
}
else
if
let
data
=
JSON
.
serialize
(
object
:
object
)
{
...
@@ -154,7 +154,7 @@ public class JSON: Equatable, CustomStringConvertible {
...
@@ -154,7 +154,7 @@ public class JSON: Equatable, CustomStringConvertible {
/**
/**
:name: operator [0...count - 1]
:name: operator [0...count - 1]
*/
*/
public
subscript
(
index
:
Int
)
->
JSON
?
{
open
subscript
(
index
:
Int
)
->
JSON
?
{
if
let
item
=
asArray
{
if
let
item
=
asArray
{
return
JSON
(
item
[
index
])
return
JSON
(
item
[
index
])
}
}
...
@@ -164,7 +164,7 @@ public class JSON: Equatable, CustomStringConvertible {
...
@@ -164,7 +164,7 @@ public class JSON: Equatable, CustomStringConvertible {
/**
/**
:name: operator [key 1...key n]
:name: operator [key 1...key n]
*/
*/
public
subscript
(
key
:
String
)
->
JSON
?
{
open
subscript
(
key
:
String
)
->
JSON
?
{
if
let
item
=
asDictionary
{
if
let
item
=
asDictionary
{
if
nil
!=
item
[
key
]
{
if
nil
!=
item
[
key
]
{
return
JSON
(
item
[
key
]
!
)
return
JSON
(
item
[
key
]
!
)
...
...
Sources/iOS/
Material
Label.swift
→
Sources/iOS/Label.swift
View file @
33b548eb
...
@@ -31,25 +31,26 @@
...
@@ -31,25 +31,26 @@
import
UIKit
import
UIKit
@IBDesignable
@IBDesignable
public
class
MaterialLabel
:
UILabel
{
open
class
Label
:
UILabel
{
/**
/**
:name: layerClass
:name: layerClass
*/
*/
public
override
class
var
layerClass
:
AnyClass
{
open
override
class
var
layerClass
:
AnyClass
{
return
MaterialTextLayer
.
self
return
MaterialTextLayer
.
self
}
}
/**
/**
:name: textLayer
:name: textLayer
*/
*/
public
var
textLayer
:
MaterialTextLayer
{
open
var
textLayer
:
MaterialTextLayer
{
return
layer
as!
MaterialTextLayer
return
layer
as!
MaterialTextLayer
}
}
/**
/**
:name: text
:name: text
*/
*/
@IBInspectable
public
override
var
text
:
String
?
{
@IBInspectable
open
override
var
text
:
String
?
{
didSet
{
didSet
{
textLayer
.
text
=
text
textLayer
.
text
=
text
}
}
...
@@ -58,7 +59,8 @@ public class MaterialLabel : UILabel {
...
@@ -58,7 +59,8 @@ public class MaterialLabel : UILabel {
/**
/**
:name: textColor
:name: textColor
*/
*/
@IBInspectable
public
override
var
textColor
:
UIColor
?
{
@IBInspectable
open
override
var
textColor
:
UIColor
?
{
didSet
{
didSet
{
textLayer
.
textColor
=
textColor
textLayer
.
textColor
=
textColor
}
}
...
@@ -67,7 +69,7 @@ public class MaterialLabel : UILabel {
...
@@ -67,7 +69,7 @@ public class MaterialLabel : UILabel {
/**
/**
:name: font
:name: font
*/
*/
public
override
var
font
:
UIFont
!
{
open
override
var
font
:
UIFont
!
{
didSet
{
didSet
{
textLayer
.
fontType
=
font
textLayer
.
fontType
=
font
}
}
...
@@ -76,7 +78,7 @@ public class MaterialLabel : UILabel {
...
@@ -76,7 +78,7 @@ public class MaterialLabel : UILabel {
/**
/**
:name: textAlignment
:name: textAlignment
*/
*/
public
override
var
textAlignment
:
NSTextAlignment
{
open
override
var
textAlignment
:
NSTextAlignment
{
didSet
{
didSet
{
textLayer
.
textAlignment
=
textAlignment
textLayer
.
textAlignment
=
textAlignment
}
}
...
@@ -85,7 +87,8 @@ public class MaterialLabel : UILabel {
...
@@ -85,7 +87,8 @@ public class MaterialLabel : UILabel {
/**
/**
:name: wrapped
:name: wrapped
*/
*/
@IBInspectable
public
var
wrapped
:
Bool
{
@IBInspectable
open
var
wrapped
:
Bool
{
didSet
{
didSet
{
textLayer
.
isWrapped
=
wrapped
textLayer
.
isWrapped
=
wrapped
}
}
...
@@ -94,7 +97,8 @@ public class MaterialLabel : UILabel {
...
@@ -94,7 +97,8 @@ public class MaterialLabel : UILabel {
/**
/**
:name: contentsScale
:name: contentsScale
*/
*/
@IBInspectable
public
var
contentsScale
:
CGFloat
{
@IBInspectable
open
var
contentsScale
:
CGFloat
{
didSet
{
didSet
{
textLayer
.
contentsScale
=
contentsScale
textLayer
.
contentsScale
=
contentsScale
}
}
...
@@ -103,7 +107,7 @@ public class MaterialLabel : UILabel {
...
@@ -103,7 +107,7 @@ public class MaterialLabel : UILabel {
/**
/**
:name: lineBreakMode
:name: lineBreakMode
*/
*/
public
override
var
lineBreakMode
:
NSLineBreakMode
{
open
override
var
lineBreakMode
:
NSLineBreakMode
{
didSet
{
didSet
{
textLayer
.
lineBreakMode
=
lineBreakMode
textLayer
.
lineBreakMode
=
lineBreakMode
}
}
...
@@ -139,14 +143,14 @@ public class MaterialLabel : UILabel {
...
@@ -139,14 +143,14 @@ public class MaterialLabel : UILabel {
/**
/**
:name: stringSize
:name: stringSize
*/
*/
public
func
stringSize
(
constrainedToWidth
width
:
Double
)
->
CGSize
{
open
func
stringSize
(
constrainedToWidth
width
:
Double
)
->
CGSize
{
return
textLayer
.
stringSize
(
constrainedToWidth
:
width
)
return
textLayer
.
stringSize
(
constrainedToWidth
:
width
)
}
}
/**
/**
:name: prepareView
:name: prepareView
*/
*/
public
func
prepareView
()
{
open
func
prepareView
()
{
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
textAlignment
=
.
left
textAlignment
=
.
left
}
}
...
...
Sources/iOS/Layer.swift
View file @
33b548eb
...
@@ -34,77 +34,22 @@ import UIKit
...
@@ -34,77 +34,22 @@ import UIKit
public
protocol
MaterialDelegate
{}
public
protocol
MaterialDelegate
{}
@objc(Layer)
@objc(Layer)
public
class
Layer
:
CAShapeLayer
{
open
class
Layer
:
CAShapeLayer
{
/**
/**
A CAShapeLayer used to manage elements that would be affected by
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
the clipToBounds property of the backing layer. For example, this
allows the dropshadow effect on the backing layer, while clipping
allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer.
the image to a desired shape within the visualLayer.
*/
*/
public
private(set)
var
visualLayer
:
CAShapeLayer
!
open
private(set)
var
visualLayer
:
CAShapeLayer
!
/// A property that accesses the layer.frame.origin.x property.
@IBInspectable
public
var
x
:
CGFloat
{
get
{
return
frame
.
origin
.
x
}
set
(
value
)
{
frame
.
origin
.
x
=
value
}
}
/// A property that accesses the layer.frame.origin.y property.
@IBInspectable
public
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
}
}
/**
A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a
value that is not .none, the height will be adjusted to maintain the correct
shape.
*/
@IBInspectable
public
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
height
=
value
}
}
}
/**
A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a
value that is not .none, the width will be adjusted to maintain the correct
shape.
*/
@IBInspectable
public
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
width
=
value
}
}
}
/**
/**
A property that manages an image for the visualLayer's contents
A property that manages an image for the visualLayer's contents
property. Images should not be set to the backing layer's contents
property. Images should not be set to the backing layer's contents
property to avoid conflicts when using clipsToBounds.
property to avoid conflicts when using clipsToBounds.
*/
*/
@IBInspectable
public
var
image
:
UIImage
?
{
@IBInspectable
open
var
image
:
UIImage
?
{
didSet
{
didSet
{
visualLayer
.
contents
=
image
?
.
cgImage
visualLayer
.
contents
=
image
?
.
cgImage
}
}
...
@@ -116,7 +61,7 @@ public class Layer: CAShapeLayer {
...
@@ -116,7 +61,7 @@ public class Layer: CAShapeLayer {
much greater flexibility than the contentsGravity property in
much greater flexibility than the contentsGravity property in
terms of how the image is cropped and stretched.
terms of how the image is cropped and stretched.
*/
*/
public
override
var
contentsRect
:
CGRect
{
open
override
var
contentsRect
:
CGRect
{
didSet
{
didSet
{
visualLayer
.
contentsRect
=
contentsRect
visualLayer
.
contentsRect
=
contentsRect
}
}
...
@@ -126,7 +71,7 @@ public class Layer: CAShapeLayer {
...
@@ -126,7 +71,7 @@ public class Layer: CAShapeLayer {
A CGRect that defines a stretchable region inside the visualLayer
A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
with a fixed border around the edge.
*/
*/
public
override
var
contentsCenter
:
CGRect
{
open
override
var
contentsCenter
:
CGRect
{
didSet
{
didSet
{
visualLayer
.
contentsCenter
=
contentsCenter
visualLayer
.
contentsCenter
=
contentsCenter
}
}
...
@@ -137,21 +82,23 @@ public class Layer: CAShapeLayer {
...
@@ -137,21 +82,23 @@ public class Layer: CAShapeLayer {
dimensions of the visualLayer's contents property and the size
dimensions of the visualLayer's contents property and the size
of the layer. By default, this value is set to the Device.scale.
of the layer. By default, this value is set to the Device.scale.
*/
*/
@IBInspectable
public
override
var
contentsScale
:
CGFloat
{
@IBInspectable
open
override
var
contentsScale
:
CGFloat
{
didSet
{
didSet
{
visualLayer
.
contentsScale
=
contentsScale
visualLayer
.
contentsScale
=
contentsScale
}
}
}
}
/// A Preset for the contentsGravity property.
/// A Preset for the contentsGravity property.
public
var
contentsGravityPreset
:
MaterialGravity
{
open
var
contentsGravityPreset
:
MaterialGravity
{
didSet
{
didSet
{
contentsGravity
=
MaterialGravityToValue
(
gravity
:
contentsGravityPreset
)
contentsGravity
=
MaterialGravityToValue
(
gravity
:
contentsGravityPreset
)
}
}
}
}
/// Determines how content should be aligned within the visualLayer's bounds.
/// Determines how content should be aligned within the visualLayer's bounds.
@IBInspectable
public
override
var
contentsGravity
:
String
{
@IBInspectable
open
override
var
contentsGravity
:
String
{
get
{
get
{
return
visualLayer
.
contentsGravity
return
visualLayer
.
contentsGravity
}
}
...
@@ -160,52 +107,13 @@ public class Layer: CAShapeLayer {
...
@@ -160,52 +107,13 @@ public class Layer: CAShapeLayer {
}
}
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable
public
var
isShadowPathAutoSizing
:
Bool
=
true
{
didSet
{
if
isShadowPathAutoSizing
{
layoutShadowPath
()
}
}
}
/// A preset value for Depth.
public
var
depthPreset
:
DepthPreset
=
.
none
{
didSet
{
depth
=
DepthPresetToValue
(
preset
:
depthPreset
)
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer.
*/
public
var
depth
=
Depth
.
zero
{
didSet
{
shadowOffset
=
depth
.
offset
.
asSize
shadowOpacity
=
depth
.
opacity
shadowRadius
=
depth
.
radius
layoutShadowPath
()
}
}
/**
/**
A property that sets the cornerRadius of the backing layer. If the shape
A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .circle when the cornerRadius is set, it will
property has a value of .circle when the cornerRadius is set, it will
become .none, as it no longer maintains its circle shape.
become .none, as it no longer maintains its circle shape.
*/
*/
public
var
cornerRadiusPreset
:
CornerRadiusPreset
=
.
none
{
@IBInspectable
didSet
{
open
override
var
cornerRadius
:
CGFloat
{
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
cornerRadiusPreset
)
}
}
/**
A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .circle when the cornerRadius is set, it will
become .none, as it no longer maintains its circle shape.
*/
@IBInspectable
public
override
var
cornerRadius
:
CGFloat
{
didSet
{
didSet
{
layoutShadowPath
()
layoutShadowPath
()
if
.
circle
==
shapePreset
{
if
.
circle
==
shapePreset
{
...
@@ -215,31 +123,6 @@ public class Layer: CAShapeLayer {
...
@@ -215,31 +123,6 @@ public class Layer: CAShapeLayer {
}
}
/**
/**
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
public
var
shapePreset
:
ShapePreset
=
.
none
{
didSet
{
if
.
none
!=
shapePreset
{
if
width
<
height
{
frame
.
size
.
width
=
height
}
else
{
frame
.
size
.
height
=
width
}
layoutShadowPath
()
}
}
}
/// A preset property to set the borderWidth.
public
var
borderWidthPreset
:
BorderWidthPreset
=
.
none
{
didSet
{
borderWidth
=
BorderWidthPresetToValue
(
preset
:
borderWidthPreset
)
}
}
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
- Parameter aDecoder: A NSCoder instance.
*/
*/
...
@@ -276,58 +159,15 @@ public class Layer: CAShapeLayer {
...
@@ -276,58 +159,15 @@ public class Layer: CAShapeLayer {
self
.
frame
=
frame
self
.
frame
=
frame
}
}
public
override
func
layoutSublayers
()
{
open
override
func
layoutSublayers
()
{
super
.
layoutSublayers
()
super
.
layoutSublayers
()
layoutShape
()
layoutShape
()
layoutVisualLayer
()
layoutVisualLayer
()
layoutShadowPath
()
layoutShadowPath
()
}
}
/**
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
public
func
animate
(
animation
:
CAAnimation
)
{
if
let
a
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
nil
==
presentation
()
?
self
:
presentation
()
!
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
}
if
let
a
=
animation
as?
CAPropertyAnimation
{
add
(
a
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
add
(
a
,
forKey
:
nil
)
}
else
if
let
a
=
animation
as?
CATransition
{
add
(
a
,
forKey
:
kCATransition
)
}
}
/**
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter animation: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
public
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
=
animation
as?
CAPropertyAnimation
{
if
let
b
=
a
as?
CABasicAnimation
{
if
let
v
=
b
.
toValue
{
if
let
k
=
b
.
keyPath
{
setValue
(
v
,
forKeyPath
:
k
)
removeAnimation
(
forKey
:
k
)
}
}
}
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
}
/// Prepares the visualLayer property.
/// Prepares the visualLayer property.
public
func
prepareVisualLayer
()
{
open
func
prepareVisualLayer
()
{
visualLayer
=
CAShapeLayer
()
visualLayer
=
CAShapeLayer
()
visualLayer
.
zPosition
=
0
visualLayer
.
zPosition
=
0
visualLayer
.
masksToBounds
=
true
visualLayer
.
masksToBounds
=
true
...
@@ -339,27 +179,4 @@ public class Layer: CAShapeLayer {
...
@@ -339,27 +179,4 @@ public class Layer: CAShapeLayer {
visualLayer
.
frame
=
bounds
visualLayer
.
frame
=
bounds
visualLayer
.
cornerRadius
=
cornerRadius
visualLayer
.
cornerRadius
=
cornerRadius
}
}
/// Manages the layout for the shape of the layer instance.
internal
func
layoutShape
()
{
if
.
circle
==
shapePreset
{
let
w
=
width
/
2
if
w
!=
cornerRadius
{
cornerRadius
=
w
}
}
}
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
isShadowPathAutoSizing
{
if
.
none
==
depthPreset
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
animate
(
animation
:
Animation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
}
}
}
}
}
Sources/iOS/Material+CALayer.swift
0 → 100644
View file @
33b548eb
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
open
class
MaterialLayer
{
/// A reference to the UIView.
internal
weak
var
layer
:
CALayer
?
/**
Initializer that takes in a UIView.
- Parameter view: A UIView reference.
*/
internal
init
(
layer
:
CALayer
?)
{
self
.
layer
=
layer
}
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
=
.
none
{
didSet
{
guard
let
v
=
layer
else
{
return
}
v
.
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
cornerRadiusPreset
)
}
}
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
=
.
none
{
didSet
{
guard
let
v
=
layer
else
{
return
}
v
.
borderWidth
=
BorderWidthPresetToValue
(
preset
:
borderWidthPreset
)
}
}
/// A preset property to set the shape.
open
var
shapePreset
:
ShapePreset
=
.
none
/// A preset value for Depth.
open
var
depthPreset
:
DepthPreset
{
get
{
return
depth
.
preset
}
set
(
value
)
{
depth
.
preset
=
value
}
}
/// Grid reference.
open
var
depth
=
Depth
.
zero
{
didSet
{
guard
let
v
=
layer
else
{
return
}
v
.
shadowOffset
=
depth
.
offset
.
asSize
v
.
shadowOpacity
=
depth
.
opacity
v
.
shadowRadius
=
depth
.
radius
v
.
layoutShadowPath
()
}
}
/// Enables automatic shadowPath sizing.
open
var
isShadowPathAutoSizing
=
false
{
didSet
{
if
isShadowPathAutoSizing
{
layer
?
.
layoutShadowPath
()
}
}
}
}
/// A memory reference to the MaterialLayer instance for CALayer extensions.
private
var
MaterialLayerKey
:
UInt8
=
0
/// Grid extension for UIView.
extension
CALayer
{
/// MaterialLayer Reference.
internal
var
material
:
MaterialLayer
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialLayerKey
)
{
return
MaterialLayer
(
layer
:
self
)
}
}
set
(
value
)
{
AssociateObject
(
base
:
self
,
key
:
&
MaterialLayerKey
,
value
:
value
)
}
}
/// A property that accesses the frame.origin.x property.
@IBInspectable
open
var
x
:
CGFloat
{
get
{
return
frame
.
origin
.
x
}
set
(
value
)
{
frame
.
origin
.
x
=
value
layoutShadowPath
()
}
}
/// A property that accesses the frame.origin.y property.
@IBInspectable
open
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
layoutShadowPath
()
}
}
/// A property that accesses the frame.size.width property.
@IBInspectable
open
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
height
=
value
layoutShape
()
}
layoutShadowPath
()
}
}
/// A property that accesses the frame.size.height property.
@IBInspectable
open
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
width
=
value
layoutShape
()
}
layoutShadowPath
()
}
}
/**
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
open
var
shapePreset
:
ShapePreset
{
get
{
return
material
.
shapePreset
}
set
(
value
)
{
material
.
shapePreset
=
value
}
}
/// A preset value for Depth.
open
var
depthPreset
:
DepthPreset
{
get
{
return
depth
.
preset
}
set
(
value
)
{
depth
.
preset
=
value
}
}
/// Grid reference.
open
var
depth
:
Depth
{
get
{
return
material
.
depth
}
set
(
value
)
{
material
.
depth
=
value
}
}
/// Enables automatic shadowPath sizing.
@IBInspectable
open
var
isShadowPathAutoSizing
:
Bool
{
get
{
return
material
.
isShadowPathAutoSizing
}
set
(
value
)
{
material
.
isShadowPathAutoSizing
=
value
}
}
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
{
get
{
return
material
.
cornerRadiusPreset
}
set
(
value
)
{
material
.
cornerRadiusPreset
=
value
}
}
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
{
get
{
return
material
.
borderWidthPreset
}
set
(
value
)
{
material
.
borderWidthPreset
=
value
}
}
/**
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
open
func
animate
(
animation
:
CAAnimation
)
{
if
let
a
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
nil
==
presentation
()
?
self
:
presentation
()
!
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
}
if
let
a
=
animation
as?
CAPropertyAnimation
{
add
(
a
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
add
(
a
,
forKey
:
nil
)
}
else
if
let
a
=
animation
as?
CATransition
{
add
(
a
,
forKey
:
kCATransition
)
}
}
/**
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter animation: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
open
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
=
animation
as?
CAPropertyAnimation
{
if
let
b
=
a
as?
CABasicAnimation
{
if
let
v
=
b
.
toValue
{
if
let
k
=
b
.
keyPath
{
setValue
(
v
,
forKeyPath
:
k
)
removeAnimation
(
forKey
:
k
)
}
}
}
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
}
/// Manages the layout for the shape of the view instance.
open
func
layoutShape
()
{
if
.
none
!=
shapePreset
{
if
width
<
height
{
frame
.
size
.
width
=
height
}
else
if
width
>
height
{
frame
.
size
.
height
=
width
}
}
if
.
circle
==
shapePreset
{
cornerRadius
=
width
/
2
}
}
/// Sets the shadow path.
open
func
layoutShadowPath
()
{
if
isShadowPathAutoSizing
{
if
.
none
==
depthPreset
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
animate
(
animation
:
Animation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
}
}
}
}
Sources/iOS/Material+UIView.swift
View file @
33b548eb
...
@@ -30,102 +30,16 @@
...
@@ -30,102 +30,16 @@
import
UIKit
import
UIKit
open
class
Material
{
/// A reference to the UIView.
internal
weak
var
view
:
UIView
?
/**
Initializer that takes in a UIView.
- Parameter view: A UIView reference.
*/
internal
init
(
view
:
UIView
?)
{
self
.
view
=
view
}
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
=
.
none
{
didSet
{
guard
let
v
=
view
else
{
return
}
v
.
cornerRadius
=
CornerRadiusPresetToValue
(
preset
:
cornerRadiusPreset
)
}
}
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
=
.
none
{
didSet
{
guard
let
v
=
view
else
{
return
}
v
.
borderWidth
=
BorderWidthPresetToValue
(
preset
:
borderWidthPreset
)
}
}
/// A preset property to set the shape.
open
var
shapePreset
:
ShapePreset
=
.
none
/// A preset value for Depth.
open
var
depthPreset
:
DepthPreset
{
get
{
return
depth
.
preset
}
set
(
value
)
{
depth
.
preset
=
value
}
}
/// Grid reference.
open
var
depth
=
Depth
.
zero
{
didSet
{
guard
let
v
=
view
else
{
return
}
v
.
layer
.
shadowOffset
=
depth
.
offset
.
asSize
v
.
layer
.
shadowOpacity
=
depth
.
opacity
v
.
layer
.
shadowRadius
=
depth
.
radius
v
.
layoutShadowPath
()
}
}
/// Enables automatic shadowPath sizing.
open
var
isShadowPathAutoSizing
=
false
{
didSet
{
if
isShadowPathAutoSizing
{
view
?
.
layoutShadowPath
()
}
}
}
}
/// A memory reference to the Depth instance for UIView extensions.
private
var
MaterialKey
:
UInt8
=
0
/// Grid extension for UIView.
/// Grid extension for UIView.
extension
UIView
{
extension
UIView
{
/// Material Reference.
internal
var
material
:
Material
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialKey
)
{
return
Material
(
view
:
self
)
}
}
set
(
value
)
{
AssociateObject
(
base
:
self
,
key
:
&
MaterialKey
,
value
:
value
)
}
}
/// A property that accesses the frame.origin.x property.
/// A property that accesses the frame.origin.x property.
@IBInspectable
@IBInspectable
open
var
x
:
CGFloat
{
open
var
x
:
CGFloat
{
get
{
get
{
return
frame
.
origin
.
x
return
layer
.
x
}
}
set
(
value
)
{
set
(
value
)
{
frame
.
origin
.
x
=
value
layer
.
x
=
value
layoutShadowPath
()
}
}
}
}
...
@@ -133,12 +47,10 @@ extension UIView {
...
@@ -133,12 +47,10 @@ extension UIView {
@IBInspectable
@IBInspectable
open
var
y
:
CGFloat
{
open
var
y
:
CGFloat
{
get
{
get
{
return
frame
.
origin
.
y
return
layer
.
y
}
}
set
(
value
)
{
set
(
value
)
{
frame
.
origin
.
y
=
value
layer
.
y
=
value
layoutShadowPath
()
}
}
}
}
...
@@ -146,17 +58,10 @@ extension UIView {
...
@@ -146,17 +58,10 @@ extension UIView {
@IBInspectable
@IBInspectable
open
var
width
:
CGFloat
{
open
var
width
:
CGFloat
{
get
{
get
{
return
frame
.
size
.
width
return
layer
.
width
}
}
set
(
value
)
{
set
(
value
)
{
frame
.
size
.
width
=
value
layer
.
width
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
height
=
value
layoutShape
()
}
layoutShadowPath
()
}
}
}
}
...
@@ -164,17 +69,10 @@ extension UIView {
...
@@ -164,17 +69,10 @@ extension UIView {
@IBInspectable
@IBInspectable
open
var
height
:
CGFloat
{
open
var
height
:
CGFloat
{
get
{
get
{
return
frame
.
size
.
height
return
layer
.
height
}
}
set
(
value
)
{
set
(
value
)
{
frame
.
size
.
height
=
value
layer
.
height
=
value
if
.
none
!=
shapePreset
{
frame
.
size
.
width
=
value
layoutShape
()
}
layoutShadowPath
()
}
}
}
}
...
@@ -185,13 +83,30 @@ extension UIView {
...
@@ -185,13 +83,30 @@ extension UIView {
*/
*/
open
var
shapePreset
:
ShapePreset
{
open
var
shapePreset
:
ShapePreset
{
get
{
get
{
return
material
.
shapePreset
return
layer
.
shapePreset
}
}
set
(
value
)
{
set
(
value
)
{
material
.
shapePreset
=
value
layer
.
shapePreset
=
value
}
}
layoutShape
()
/// A preset value for Depth.
layoutShadowPath
()
open
var
depthPreset
:
DepthPreset
{
get
{
return
layer
.
depthPreset
}
set
(
value
)
{
layer
.
depthPreset
=
value
}
}
/// Grid reference.
open
var
depth
:
Depth
{
get
{
return
layer
.
depth
}
set
(
value
)
{
layer
.
depth
=
value
}
}
}
}
...
@@ -258,20 +173,20 @@ extension UIView {
...
@@ -258,20 +173,20 @@ extension UIView {
@IBInspectable
@IBInspectable
open
var
isShadowPathAutoSizing
:
Bool
{
open
var
isShadowPathAutoSizing
:
Bool
{
get
{
get
{
return
material
.
isShadowPathAutoSizing
return
layer
.
isShadowPathAutoSizing
}
}
set
(
value
)
{
set
(
value
)
{
material
.
isShadowPathAutoSizing
=
value
layer
.
isShadowPathAutoSizing
=
value
}
}
}
}
/// A property that sets the cornerRadius of the backing layer.
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
{
open
var
cornerRadiusPreset
:
CornerRadiusPreset
{
get
{
get
{
return
material
.
cornerRadiusPreset
return
layer
.
cornerRadiusPreset
}
}
set
(
value
)
{
set
(
value
)
{
material
.
cornerRadiusPreset
=
value
layer
.
cornerRadiusPreset
=
value
}
}
}
}
...
@@ -283,22 +198,16 @@ extension UIView {
...
@@ -283,22 +198,16 @@ extension UIView {
}
}
set
(
value
)
{
set
(
value
)
{
layer
.
cornerRadius
=
value
layer
.
cornerRadius
=
value
if
.
circle
==
shapePreset
{
shapePreset
=
.
none
}
else
{
layoutShadowPath
()
}
}
}
}
}
/// A preset property to set the borderWidth.
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
{
open
var
borderWidthPreset
:
BorderWidthPreset
{
get
{
get
{
return
material
.
borderWidthPreset
return
layer
.
borderWidthPreset
}
}
set
(
value
)
{
set
(
value
)
{
material
.
borderWidthPreset
=
value
layer
.
borderWidthPreset
=
value
}
}
}
}
...
@@ -394,29 +303,11 @@ extension UIView {
...
@@ -394,29 +303,11 @@ extension UIView {
/// Manages the layout for the shape of the view instance.
/// Manages the layout for the shape of the view instance.
open
func
layoutShape
()
{
open
func
layoutShape
()
{
if
.
none
!=
shapePreset
{
layer
.
layoutShape
()
if
width
<
height
{
frame
.
size
.
width
=
height
}
else
if
width
>
height
{
frame
.
size
.
height
=
width
}
}
if
.
circle
==
shapePreset
{
layer
.
cornerRadius
=
width
/
2
}
}
}
/// Sets the shadow path.
/// Sets the shadow path.
open
func
layoutShadowPath
()
{
open
func
layoutShadowPath
()
{
if
isShadowPathAutoSizing
{
layer
.
layoutShadowPath
()
if
.
none
==
depthPreset
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
animate
(
animation
:
Animation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
}
}
}
}
}
}
Sources/iOS/MaterialTextLayer.swift
View file @
33b548eb
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
import
UIKit
import
UIKit
public
class
MaterialTextLayer
:
CATextLayer
{
public
class
MaterialTextLayer
:
CATextLayer
{
/**
/**
:name: fontType
:name: fontType
*/
*/
...
@@ -113,54 +113,6 @@ public class MaterialTextLayer : CATextLayer {
...
@@ -113,54 +113,6 @@ public class MaterialTextLayer : CATextLayer {
}
}
/**
/**
:name: x
*/
@IBInspectable
public
var
x
:
CGFloat
{
get
{
return
frame
.
origin
.
x
}
set
(
value
)
{
frame
.
origin
.
x
=
value
}
}
/**
:name: y
*/
@IBInspectable
public
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
}
}
/**
:name: width
*/
@IBInspectable
public
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
}
}
/**
:name: height
*/
@IBInspectable
public
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
}
}
/**
:name: init
:name: init
*/
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
...
...
Sources/iOS/NavigationController.swift
View file @
33b548eb
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
import
UIKit
import
UIKit
@IBDesignable
@IBDesignable
public
class
NavigationController
:
UINavigationController
,
UIGestureRecognizerDelegate
{
open
class
NavigationController
:
UINavigationController
,
UIGestureRecognizerDelegate
{
/**
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
- Parameter aDecoder: A NSCoder instance.
...
@@ -58,7 +58,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -58,7 +58,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
setViewControllers
([
rootViewController
],
animated
:
false
)
setViewControllers
([
rootViewController
],
animated
:
false
)
}
}
public
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
open
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
super
.
viewWillAppear
(
animated
)
if
let
v
=
interactivePopGestureRecognizer
{
if
let
v
=
interactivePopGestureRecognizer
{
if
let
x
=
navigationDrawerController
{
if
let
x
=
navigationDrawerController
{
...
@@ -72,12 +72,12 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -72,12 +72,12 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
}
}
}
}
public
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
prepareView
()
prepareView
()
}
}
public
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
open
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
super
.
viewDidAppear
(
animated
)
super
.
viewDidAppear
(
animated
)
// Load the initial topItem.
// Load the initial topItem.
if
let
v
=
navigationBar
as?
NavigationBar
{
if
let
v
=
navigationBar
as?
NavigationBar
{
...
@@ -94,7 +94,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -94,7 +94,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
- Parameter touch: The UITouch event.
- Parameter touch: The UITouch event.
- Returns: A Boolean of whether to continue the gesture or not, true yes, false no.
- Returns: A Boolean of whether to continue the gesture or not, true yes, false no.
*/
*/
public
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
open
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
return
interactivePopGestureRecognizer
==
gestureRecognizer
&&
nil
!=
navigationBar
.
backItem
return
interactivePopGestureRecognizer
==
gestureRecognizer
&&
nil
!=
navigationBar
.
backItem
}
}
...
@@ -106,7 +106,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -106,7 +106,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
- Returns: A Boolean value that indicates whether to push the item on to the stack or not.
- Returns: A Boolean value that indicates whether to push the item on to the stack or not.
True is yes, false is no.
True is yes, false is no.
*/
*/
public
func
navigationBar
(
navigationBar
:
UINavigationBar
,
shouldPushItem
item
:
UINavigationItem
)
->
Bool
{
open
func
navigationBar
(
navigationBar
:
UINavigationBar
,
shouldPushItem
item
:
UINavigationItem
)
->
Bool
{
if
let
v
=
navigationBar
as?
NavigationBar
{
if
let
v
=
navigationBar
as?
NavigationBar
{
let
backButton
=
IconButton
()
let
backButton
=
IconButton
()
backButton
.
pulseColor
=
Color
.
white
backButton
.
pulseColor
=
Color
.
white
...
@@ -139,7 +139,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -139,7 +139,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
The super.prepareView method should always be called immediately
The super.prepareView method should always be called immediately
when subclassing.
when subclassing.
*/
*/
public
func
prepareView
()
{
open
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
Device
.
scale
view
.
contentScaleFactor
=
Device
.
scale
...
...
Sources/iOS/RootController.swift
View file @
33b548eb
...
@@ -31,9 +31,9 @@
...
@@ -31,9 +31,9 @@
import
UIKit
import
UIKit
@IBDesignable
@IBDesignable
public
class
RootController
:
UIViewController
{
open
class
RootController
:
UIViewController
{
/// Device status bar style.
/// Device status bar style.
public
var
statusBarStyle
:
UIStatusBarStyle
{
open
var
statusBarStyle
:
UIStatusBarStyle
{
get
{
get
{
return
Device
.
statusBarStyle
return
Device
.
statusBarStyle
}
}
...
@@ -46,7 +46,8 @@ public class RootController: UIViewController {
...
@@ -46,7 +46,8 @@ public class RootController: UIViewController {
A Boolean property used to enable and disable interactivity
A Boolean property used to enable and disable interactivity
with the rootViewController.
with the rootViewController.
*/
*/
@IBInspectable
public
var
isUserInteractionEnabled
:
Bool
{
@IBInspectable
open
var
isUserInteractionEnabled
:
Bool
{
get
{
get
{
return
rootViewController
.
view
.
isUserInteractionEnabled
return
rootViewController
.
view
.
isUserInteractionEnabled
}
}
...
@@ -92,7 +93,7 @@ public class RootController: UIViewController {
...
@@ -92,7 +93,7 @@ public class RootController: UIViewController {
prepareView
()
prepareView
()
}
}
public
override
func
viewWillLayoutSubviews
()
{
open
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
super
.
viewWillLayoutSubviews
()
layoutSubviews
()
layoutSubviews
()
}
}
...
@@ -113,7 +114,7 @@ public class RootController: UIViewController {
...
@@ -113,7 +114,7 @@ public class RootController: UIViewController {
the transition animation from the active rootViewController
the transition animation from the active rootViewController
to the toViewController has completed.
to the toViewController has completed.
*/
*/
public
func
transitionFromRootViewController
(
toViewController
:
UIViewController
,
duration
:
TimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
open
func
transitionFromRootViewController
(
toViewController
:
UIViewController
,
duration
:
TimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
rootViewController
.
willMove
(
toParentViewController
:
nil
)
rootViewController
.
willMove
(
toParentViewController
:
nil
)
addChildViewController
(
toViewController
)
addChildViewController
(
toViewController
)
toViewController
.
view
.
frame
=
rootViewController
.
view
.
frame
toViewController
.
view
.
frame
=
rootViewController
.
view
.
frame
...
@@ -140,7 +141,7 @@ public class RootController: UIViewController {
...
@@ -140,7 +141,7 @@ public class RootController: UIViewController {
method. LayoutSubviews should be called immediately, unless you
method. LayoutSubviews should be called immediately, unless you
have a certain need.
have a certain need.
*/
*/
public
func
layoutSubviews
()
{}
open
func
layoutSubviews
()
{}
/**
/**
Prepares the view instance when intialized. When subclassing,
Prepares the view instance when intialized. When subclassing,
...
@@ -149,7 +150,7 @@ public class RootController: UIViewController {
...
@@ -149,7 +150,7 @@ public class RootController: UIViewController {
The super.prepareView method should always be called immediately
The super.prepareView method should always be called immediately
when subclassing.
when subclassing.
*/
*/
public
func
prepareView
()
{
open
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
Device
.
scale
view
.
contentScaleFactor
=
Device
.
scale
prepareRootViewController
()
prepareRootViewController
()
...
...
Sources/iOS/SearchBarController.swift
View file @
33b548eb
...
@@ -48,16 +48,16 @@ extension UIViewController {
...
@@ -48,16 +48,16 @@ extension UIViewController {
}
}
}
}
public
class
SearchBarController
:
RootController
{
open
class
SearchBarController
:
RootController
{
/// Reference to the SearchBar.
/// Reference to the SearchBar.
public
private(set)
var
searchBar
:
SearchBar
!
open
private(set)
var
searchBar
:
SearchBar
!
/**
/**
To execute in the order of the layout chain, override this
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
method. LayoutSubviews should be called immediately, unless you
have a certain need.
have a certain need.
*/
*/
public
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
if
let
v
:
SearchBar
=
searchBar
{
if
let
v
:
SearchBar
=
searchBar
{
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
...
@@ -81,7 +81,7 @@ public class SearchBarController: RootController {
...
@@ -81,7 +81,7 @@ public class SearchBarController: RootController {
The super.prepareView method should always be called immediately
The super.prepareView method should always be called immediately
when subclassing.
when subclassing.
*/
*/
public
override
func
prepareView
()
{
open
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
prepareSearchBar
()
prepareSearchBar
()
}
}
...
...
Sources/iOS/ToolbarController.swift
View file @
33b548eb
...
@@ -68,7 +68,7 @@ public protocol ToolbarControllerDelegate : MaterialDelegate {
...
@@ -68,7 +68,7 @@ public protocol ToolbarControllerDelegate : MaterialDelegate {
}
}
@objc(ToolbarController)
@objc(ToolbarController)
public
class
ToolbarController
:
RootController
{
open
class
ToolbarController
:
RootController
{
/// Internal reference to the floatingViewController.
/// Internal reference to the floatingViewController.
private
var
internalFloatingViewController
:
UIViewController
?
private
var
internalFloatingViewController
:
UIViewController
?
...
@@ -79,7 +79,7 @@ public class ToolbarController: RootController {
...
@@ -79,7 +79,7 @@ public class ToolbarController: RootController {
public
weak
var
delegate
:
ToolbarControllerDelegate
?
public
weak
var
delegate
:
ToolbarControllerDelegate
?
/// A floating UIViewController.
/// A floating UIViewController.
public
var
floatingViewController
:
UIViewController
?
{
open
var
floatingViewController
:
UIViewController
?
{
get
{
get
{
return
internalFloatingViewController
return
internalFloatingViewController
}
}
...
@@ -160,7 +160,7 @@ public class ToolbarController: RootController {
...
@@ -160,7 +160,7 @@ public class ToolbarController: RootController {
method. LayoutSubviews should be called immediately, unless you
method. LayoutSubviews should be called immediately, unless you
have a certain need.
have a certain need.
*/
*/
public
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
if
let
v
:
Toolbar
=
toolbar
{
if
let
v
:
Toolbar
=
toolbar
{
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
...
@@ -184,7 +184,7 @@ public class ToolbarController: RootController {
...
@@ -184,7 +184,7 @@ public class ToolbarController: RootController {
The super.prepareView method should always be called immediately
The super.prepareView method should always be called immediately
when subclassing.
when subclassing.
*/
*/
public
override
func
prepareView
()
{
open
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
prepareToolbar
()
prepareToolbar
()
}
}
...
...
Sources/iOS/View.swift
View file @
33b548eb
...
@@ -49,7 +49,8 @@ open class View: UIView {
...
@@ -49,7 +49,8 @@ open class View: UIView {
property. Images should not be set to the backing layer's contents
property. Images should not be set to the backing layer's contents
property to avoid conflicts when using clipsToBounds.
property to avoid conflicts when using clipsToBounds.
*/
*/
@IBInspectable
open
var
image
:
UIImage
?
{
@IBInspectable
open
var
image
:
UIImage
?
{
didSet
{
didSet
{
visualLayer
.
contents
=
image
?
.
cgImage
visualLayer
.
contents
=
image
?
.
cgImage
}
}
...
@@ -61,7 +62,8 @@ open class View: UIView {
...
@@ -61,7 +62,8 @@ open class View: UIView {
much greater flexibility than the contentsGravity property in
much greater flexibility than the contentsGravity property in
terms of how the image is cropped and stretched.
terms of how the image is cropped and stretched.
*/
*/
@IBInspectable
open
var
contentsRect
:
CGRect
{
@IBInspectable
open
var
contentsRect
:
CGRect
{
get
{
get
{
return
visualLayer
.
contentsRect
return
visualLayer
.
contentsRect
}
}
...
@@ -74,7 +76,8 @@ open class View: UIView {
...
@@ -74,7 +76,8 @@ open class View: UIView {
A CGRect that defines a stretchable region inside the visualLayer
A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
with a fixed border around the edge.
*/
*/
@IBInspectable
open
var
contentsCenter
:
CGRect
{
@IBInspectable
open
var
contentsCenter
:
CGRect
{
get
{
get
{
return
visualLayer
.
contentsCenter
return
visualLayer
.
contentsCenter
}
}
...
@@ -88,7 +91,8 @@ open class View: UIView {
...
@@ -88,7 +91,8 @@ open class View: UIView {
dimensions of the visualLayer's contents property and the size
dimensions of the visualLayer's contents property and the size
of the view. By default, this value is set to the Device.scale.
of the view. By default, this value is set to the Device.scale.
*/
*/
@IBInspectable
open
var
contentsScale
:
CGFloat
{
@IBInspectable
open
var
contentsScale
:
CGFloat
{
get
{
get
{
return
visualLayer
.
contentsScale
return
visualLayer
.
contentsScale
}
}
...
@@ -98,14 +102,16 @@ open class View: UIView {
...
@@ -98,14 +102,16 @@ open class View: UIView {
}
}
/// A Preset for the contentsGravity property.
/// A Preset for the contentsGravity property.
@IBInspectable
open
var
contentsGravityPreset
:
MaterialGravity
{
@IBInspectable
open
var
contentsGravityPreset
:
MaterialGravity
{
didSet
{
didSet
{
contentsGravity
=
MaterialGravityToValue
(
gravity
:
contentsGravityPreset
)
contentsGravity
=
MaterialGravityToValue
(
gravity
:
contentsGravityPreset
)
}
}
}
}
/// Determines how content should be aligned within the visualLayer's bounds.
/// Determines how content should be aligned within the visualLayer's bounds.
@IBInspectable
open
var
contentsGravity
:
String
{
@IBInspectable
open
var
contentsGravity
:
String
{
get
{
get
{
return
visualLayer
.
contentsGravity
return
visualLayer
.
contentsGravity
}
}
...
@@ -115,7 +121,8 @@ open class View: UIView {
...
@@ -115,7 +121,8 @@ open class View: UIView {
}
}
/// A property that accesses the backing layer's backgroundColor.
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
}
}
...
...
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