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
9a90a7d5
Commit
9a90a7d5
authored
Jul 16, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup and removal of duplicate code
parent
e15b9fff
Show whitespace changes
Inline
Side-by-side
Showing
47 changed files
with
825 additions
and
971 deletions
+825
-971
Material.xcodeproj/project.pbxproj
+0
-40
Sources/iOS/Animation.swift
+1
-1
Sources/iOS/BarView.swift
+1
-1
Sources/iOS/BottomNavigationController.swift
+15
-15
Sources/iOS/BottomTabBar.swift
+5
-0
Sources/iOS/Button.swift
+1
-1
Sources/iOS/ControlView.swift
+5
-5
Sources/iOS/Depth.swift
+2
-1
Sources/iOS/ErrorTextField.swift
+1
-1
Sources/iOS/Grid.swift
+1
-1
Sources/iOS/Icon.swift
+10
-7
Sources/iOS/Layer.swift
+14
-23
Sources/iOS/Material+String.swift
+75
-75
Sources/iOS/Material+UIFont.swift
+2
-2
Sources/iOS/Material+UIImage+Blank.swift
+0
-44
Sources/iOS/Material+UIImage+Color.swift
+0
-49
Sources/iOS/Material+UIImage+Crop.swift
+0
-54
Sources/iOS/Material+UIImage+FilterBlur.swift
+155
-155
Sources/iOS/Material+UIImage+Network.swift
+0
-51
Sources/iOS/Material+UIImage+Resize.swift
+2
-2
Sources/iOS/Material+UIImage+Size.swift
+0
-48
Sources/iOS/Material+UIImage.swift
+147
-3
Sources/iOS/Material.swift
+4
-4
Sources/iOS/MaterialCollectionReusableView.swift
+0
-4
Sources/iOS/MaterialCollectionViewCell.swift
+0
-2
Sources/iOS/MaterialCollectionViewLayout.swift
+21
-23
Sources/iOS/MaterialLabel.swift
+2
-2
Sources/iOS/MaterialTableViewCell.swift
+2
-2
Sources/iOS/MaterialTextLayer.swift
+19
-19
Sources/iOS/MenuController.swift
+3
-3
Sources/iOS/MenuView.swift
+9
-8
Sources/iOS/NavigationBar.swift
+20
-21
Sources/iOS/NavigationController.swift
+12
-13
Sources/iOS/NavigationDrawerController.swift
+126
-113
Sources/iOS/NavigationItem.swift
+6
-6
Sources/iOS/RootController.swift
+8
-8
Sources/iOS/SearchBar.swift
+10
-11
Sources/iOS/SearchBarController.swift
+1
-1
Sources/iOS/StatusBarController.swift
+2
-2
Sources/iOS/TabBar.swift
+10
-9
Sources/iOS/Text.swift
+7
-5
Sources/iOS/TextField.swift
+74
-76
Sources/iOS/TextStorage.swift
+11
-11
Sources/iOS/TextView.swift
+16
-14
Sources/iOS/Toolbar.swift
+4
-4
Sources/iOS/ToolbarController.swift
+21
-17
Sources/iOS/View.swift
+0
-14
No files found.
Material.xcodeproj/project.pbxproj
View file @
9a90a7d5
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
9660161D1CB2ED6C00AAB661
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966016131CB2ED6C00AAB661
/* Material.framework */
;
};
9660161D1CB2ED6C00AAB661
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966016131CB2ED6C00AAB661
/* Material.framework */
;
};
9660162A1CB2F04E00AAB661
/* Material.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88C091C1328D800B91418
/* Material.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9660162A1CB2F04E00AAB661
/* Material.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88C091C1328D800B91418
/* Material.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
966ECF2A1CF4C20100BB0BDF
/* MaterialCollectionReusableView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966ECF291CF4C20100BB0BDF
/* MaterialCollectionReusableView.swift */
;
};
966ECF2A1CF4C20100BB0BDF
/* MaterialCollectionReusableView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966ECF291CF4C20100BB0BDF
/* MaterialCollectionReusableView.swift */
;
};
9679CEAB1CC69E080021685B
/* Material+UIImage+TintColor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9679CEAA1CC69E080021685B
/* Material+UIImage+TintColor.swift */
;
};
967A48191D0F425A00B8CEB7
/* StatusBarController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967A48181D0F425A00B8CEB7
/* StatusBarController.swift */
;
};
967A48191D0F425A00B8CEB7
/* StatusBarController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967A48181D0F425A00B8CEB7
/* StatusBarController.swift */
;
};
96815B381CA07BA20006CBE2
/* MaterialViewTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967887881C9777CB0037F6C9
/* MaterialViewTests.swift */
;
};
96815B381CA07BA20006CBE2
/* MaterialViewTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967887881C9777CB0037F6C9
/* MaterialViewTests.swift */
;
};
968C99451D37730B000074FF
/* Direction.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
968C99441D37730B000074FF
/* Direction.swift */
;
};
968C99451D37730B000074FF
/* Direction.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
968C99441D37730B000074FF
/* Direction.swift */
;
};
...
@@ -34,12 +33,6 @@
...
@@ -34,12 +33,6 @@
96BCB7AC1CB40DC500C806FE
/* Material+Obj-C.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
;
};
96BCB7AC1CB40DC500C806FE
/* Material+Obj-C.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
;
};
96BCB7AD1CB40DC500C806FE
/* Material+String.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7641CB40DC500C806FE
/* Material+String.swift */
;
};
96BCB7AD1CB40DC500C806FE
/* Material+String.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7641CB40DC500C806FE
/* Material+String.swift */
;
};
96BCB7AE1CB40DC500C806FE
/* Material+UIFont.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
;
};
96BCB7AE1CB40DC500C806FE
/* Material+UIFont.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
;
};
96BCB7AF1CB40DC500C806FE
/* Material+UIImage+Blank.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7661CB40DC500C806FE
/* Material+UIImage+Blank.swift */
;
};
96BCB7B01CB40DC500C806FE
/* Material+UIImage+Color.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7671CB40DC500C806FE
/* Material+UIImage+Color.swift */
;
};
96BCB7B11CB40DC500C806FE
/* Material+UIImage+Crop.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7681CB40DC500C806FE
/* Material+UIImage+Crop.swift */
;
};
96BCB7B21CB40DC500C806FE
/* Material+UIImage+Network.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7691CB40DC500C806FE
/* Material+UIImage+Network.swift */
;
};
96BCB7B31CB40DC500C806FE
/* Material+UIImage+Resize.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76A1CB40DC500C806FE
/* Material+UIImage+Resize.swift */
;
};
96BCB7B41CB40DC500C806FE
/* Material+UIImage+Size.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76B1CB40DC500C806FE
/* Material+UIImage+Size.swift */
;
};
96BCB7B51CB40DC500C806FE
/* Material+UIImage.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
;
};
96BCB7B51CB40DC500C806FE
/* Material+UIImage.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
;
};
96BCB7B61CB40DC500C806FE
/* Animation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76D1CB40DC500C806FE
/* Animation.swift */
;
};
96BCB7B61CB40DC500C806FE
/* Animation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76D1CB40DC500C806FE
/* Animation.swift */
;
};
96BCB7B71CB40DC500C806FE
/* BasicAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76E1CB40DC500C806FE
/* BasicAnimation.swift */
;
};
96BCB7B71CB40DC500C806FE
/* BasicAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76E1CB40DC500C806FE
/* BasicAnimation.swift */
;
};
...
@@ -129,12 +122,6 @@
...
@@ -129,12 +122,6 @@
96BCB8271CB4115200C806FE
/* Material+Obj-C.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8271CB4115200C806FE
/* Material+Obj-C.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8281CB4115200C806FE
/* Material+String.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7641CB40DC500C806FE
/* Material+String.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8281CB4115200C806FE
/* Material+String.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7641CB40DC500C806FE
/* Material+String.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8291CB4115200C806FE
/* Material+UIFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8291CB4115200C806FE
/* Material+UIFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB82A1CB4115200C806FE
/* Material+UIImage+Blank.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7661CB40DC500C806FE
/* Material+UIImage+Blank.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB82B1CB4115200C806FE
/* Material+UIImage+Color.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7671CB40DC500C806FE
/* Material+UIImage+Color.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB82C1CB4115200C806FE
/* Material+UIImage+Crop.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7681CB40DC500C806FE
/* Material+UIImage+Crop.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB82D1CB4115200C806FE
/* Material+UIImage+Network.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7691CB40DC500C806FE
/* Material+UIImage+Network.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB82E1CB4115200C806FE
/* Material+UIImage+Resize.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76A1CB40DC500C806FE
/* Material+UIImage+Resize.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB82F1CB4115200C806FE
/* Material+UIImage+Size.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76B1CB40DC500C806FE
/* Material+UIImage+Size.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8301CB4115200C806FE
/* Material+UIImage.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8301CB4115200C806FE
/* Material+UIImage.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8311CB4115200C806FE
/* Font.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77B1CB40DC500C806FE
/* Font.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8311CB4115200C806FE
/* Font.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77B1CB40DC500C806FE
/* Font.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7941CB40DC500C806FE
/* RobotoFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7941CB40DC500C806FE
/* RobotoFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
@@ -209,7 +196,6 @@
...
@@ -209,7 +196,6 @@
9660161C1CB2ED6C00AAB661
/* Material OSX Tests.xctest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.cfbundle
;
includeInIndex
=
0
;
path
=
"Material OSX Tests.xctest"
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
9660161C1CB2ED6C00AAB661
/* Material OSX Tests.xctest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.cfbundle
;
includeInIndex
=
0
;
path
=
"Material OSX Tests.xctest"
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
966ECF291CF4C20100BB0BDF
/* MaterialCollectionReusableView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialCollectionReusableView.swift
;
sourceTree
=
"<group>"
;
};
966ECF291CF4C20100BB0BDF
/* MaterialCollectionReusableView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialCollectionReusableView.swift
;
sourceTree
=
"<group>"
;
};
967887881C9777CB0037F6C9
/* MaterialViewTests.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialViewTests.swift
;
sourceTree
=
"<group>"
;
};
967887881C9777CB0037F6C9
/* MaterialViewTests.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialViewTests.swift
;
sourceTree
=
"<group>"
;
};
9679CEAA1CC69E080021685B
/* Material+UIImage+TintColor.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+TintColor.swift"
;
sourceTree
=
"<group>"
;
};
967A48181D0F425A00B8CEB7
/* StatusBarController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
StatusBarController.swift
;
sourceTree
=
"<group>"
;
};
967A48181D0F425A00B8CEB7
/* StatusBarController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
StatusBarController.swift
;
sourceTree
=
"<group>"
;
};
968C99441D37730B000074FF
/* Direction.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Direction.swift
;
sourceTree
=
"<group>"
;
};
968C99441D37730B000074FF
/* Direction.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Direction.swift
;
sourceTree
=
"<group>"
;
};
968C99461D377849000074FF
/* Offset.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Offset.swift
;
sourceTree
=
"<group>"
;
};
968C99461D377849000074FF
/* Offset.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Offset.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -228,12 +214,6 @@
...
@@ -228,12 +214,6 @@
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+Obj-C.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+Obj-C.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7641CB40DC500C806FE
/* Material+String.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+String.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7641CB40DC500C806FE
/* Material+String.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+String.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIFont.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIFont.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7661CB40DC500C806FE
/* Material+UIImage+Blank.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Blank.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7671CB40DC500C806FE
/* Material+UIImage+Color.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Color.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7681CB40DC500C806FE
/* Material+UIImage+Crop.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Crop.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7691CB40DC500C806FE
/* Material+UIImage+Network.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Network.swift"
;
sourceTree
=
"<group>"
;
};
96BCB76A1CB40DC500C806FE
/* Material+UIImage+Resize.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Resize.swift"
;
sourceTree
=
"<group>"
;
};
96BCB76B1CB40DC500C806FE
/* Material+UIImage+Size.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Size.swift"
;
sourceTree
=
"<group>"
;
};
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage.swift"
;
sourceTree
=
"<group>"
;
};
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage.swift"
;
sourceTree
=
"<group>"
;
};
96BCB76D1CB40DC500C806FE
/* Animation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Animation.swift
;
sourceTree
=
"<group>"
;
};
96BCB76D1CB40DC500C806FE
/* Animation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Animation.swift
;
sourceTree
=
"<group>"
;
};
96BCB76E1CB40DC500C806FE
/* BasicAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB76E1CB40DC500C806FE
/* BasicAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BasicAnimation.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -586,15 +566,8 @@
...
@@ -586,15 +566,8 @@
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
,
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
,
96BCB7641CB40DC500C806FE
/* Material+String.swift */
,
96BCB7641CB40DC500C806FE
/* Material+String.swift */
,
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
,
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
,
96BCB7661CB40DC500C806FE
/* Material+UIImage+Blank.swift */
,
96BCB7671CB40DC500C806FE
/* Material+UIImage+Color.swift */
,
96BCB7681CB40DC500C806FE
/* Material+UIImage+Crop.swift */
,
96BCB7691CB40DC500C806FE
/* Material+UIImage+Network.swift */
,
96BCB76A1CB40DC500C806FE
/* Material+UIImage+Resize.swift */
,
96BCB76B1CB40DC500C806FE
/* Material+UIImage+Size.swift */
,
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
,
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
,
96977DA51CBB2E49000BEFC4
/* Material+UIImage+FilterBlur.swift */
,
96977DA51CBB2E49000BEFC4
/* Material+UIImage+FilterBlur.swift */
,
9679CEAA1CC69E080021685B
/* Material+UIImage+TintColor.swift */
,
);
);
name
=
Extension
;
name
=
Extension
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -693,12 +666,6 @@
...
@@ -693,12 +666,6 @@
96BCB8271CB4115200C806FE
/* Material+Obj-C.swift in Headers */
,
96BCB8271CB4115200C806FE
/* Material+Obj-C.swift in Headers */
,
96BCB8281CB4115200C806FE
/* Material+String.swift in Headers */
,
96BCB8281CB4115200C806FE
/* Material+String.swift in Headers */
,
96BCB8291CB4115200C806FE
/* Material+UIFont.swift in Headers */
,
96BCB8291CB4115200C806FE
/* Material+UIFont.swift in Headers */
,
96BCB82A1CB4115200C806FE
/* Material+UIImage+Blank.swift in Headers */
,
96BCB82B1CB4115200C806FE
/* Material+UIImage+Color.swift in Headers */
,
96BCB82C1CB4115200C806FE
/* Material+UIImage+Crop.swift in Headers */
,
96BCB82D1CB4115200C806FE
/* Material+UIImage+Network.swift in Headers */
,
96BCB82E1CB4115200C806FE
/* Material+UIImage+Resize.swift in Headers */
,
96BCB82F1CB4115200C806FE
/* Material+UIImage+Size.swift in Headers */
,
96BCB8301CB4115200C806FE
/* Material+UIImage.swift in Headers */
,
96BCB8301CB4115200C806FE
/* Material+UIImage.swift in Headers */
,
96BCB8311CB4115200C806FE
/* Font.swift in Headers */
,
96BCB8311CB4115200C806FE
/* Font.swift in Headers */
,
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
,
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
,
...
@@ -923,7 +890,6 @@
...
@@ -923,7 +890,6 @@
files
=
(
files
=
(
96BCB7C01CB40DC500C806FE
/* MaterialDataSourceItem.swift in Sources */
,
96BCB7C01CB40DC500C806FE
/* MaterialDataSourceItem.swift in Sources */
,
96BCB7AC1CB40DC500C806FE
/* Material+Obj-C.swift in Sources */
,
96BCB7AC1CB40DC500C806FE
/* Material+Obj-C.swift in Sources */
,
9679CEAB1CC69E080021685B
/* Material+UIImage+TintColor.swift in Sources */
,
9658F2171CD6FA4700B902C1
/* IconButton.swift in Sources */
,
9658F2171CD6FA4700B902C1
/* IconButton.swift in Sources */
,
96BCB7BB1CB40DC500C806FE
/* MaterialCollectionViewCell.swift in Sources */
,
96BCB7BB1CB40DC500C806FE
/* MaterialCollectionViewCell.swift in Sources */
,
96BCB7CF1CB40DC500C806FE
/* Shape.swift in Sources */
,
96BCB7CF1CB40DC500C806FE
/* Shape.swift in Sources */
,
...
@@ -933,7 +899,6 @@
...
@@ -933,7 +899,6 @@
96BCB7D61CB40DC500C806FE
/* Menu.swift in Sources */
,
96BCB7D61CB40DC500C806FE
/* Menu.swift in Sources */
,
96BCB7E61CB40DC500C806FE
/* TextStorage.swift in Sources */
,
96BCB7E61CB40DC500C806FE
/* TextStorage.swift in Sources */
,
968C99451D37730B000074FF
/* Direction.swift in Sources */
,
968C99451D37730B000074FF
/* Direction.swift in Sources */
,
96BCB7B21CB40DC500C806FE
/* Material+UIImage+Network.swift in Sources */
,
96BCB7A91CB40DC500C806FE
/* FlatButton.swift in Sources */
,
96BCB7A91CB40DC500C806FE
/* FlatButton.swift in Sources */
,
96BCB7CA1CB40DC500C806FE
/* Layout.swift in Sources */
,
96BCB7CA1CB40DC500C806FE
/* Layout.swift in Sources */
,
96BCB7D11CB40DC500C806FE
/* Switch.swift in Sources */
,
96BCB7D11CB40DC500C806FE
/* Switch.swift in Sources */
,
...
@@ -950,12 +915,9 @@
...
@@ -950,12 +915,9 @@
96BCB7A21CB40DC500C806FE
/* BottomTabBar.swift in Sources */
,
96BCB7A21CB40DC500C806FE
/* BottomTabBar.swift in Sources */
,
96BCB7BD1CB40DC500C806FE
/* MaterialCollectionViewDelegate.swift in Sources */
,
96BCB7BD1CB40DC500C806FE
/* MaterialCollectionViewDelegate.swift in Sources */
,
961F18E81CD93E3E008927C5
/* ErrorTextField.swift in Sources */
,
961F18E81CD93E3E008927C5
/* ErrorTextField.swift in Sources */
,
96BCB7AF1CB40DC500C806FE
/* Material+UIImage+Blank.swift in Sources */
,
96BCB7D01CB40DC500C806FE
/* InterimSpace.swift in Sources */
,
96BCB7D01CB40DC500C806FE
/* InterimSpace.swift in Sources */
,
96BCB7B31CB40DC500C806FE
/* Material+UIImage+Resize.swift in Sources */
,
96BCB7E81CB40DC500C806FE
/* Toolbar.swift in Sources */
,
96BCB7E81CB40DC500C806FE
/* Toolbar.swift in Sources */
,
96BCB7C41CB40DC500C806FE
/* Font.swift in Sources */
,
96BCB7C41CB40DC500C806FE
/* Font.swift in Sources */
,
96BCB7B41CB40DC500C806FE
/* Material+UIImage+Size.swift in Sources */
,
96BCB7AA1CB40DC500C806FE
/* Grid.swift in Sources */
,
96BCB7AA1CB40DC500C806FE
/* Grid.swift in Sources */
,
96BCB7E71CB40DC500C806FE
/* TextView.swift in Sources */
,
96BCB7E71CB40DC500C806FE
/* TextView.swift in Sources */
,
96BCB7C31CB40DC500C806FE
/* EdgeInsets.swift in Sources */
,
96BCB7C31CB40DC500C806FE
/* EdgeInsets.swift in Sources */
,
...
@@ -971,7 +933,6 @@
...
@@ -971,7 +933,6 @@
968C99471D377849000074FF
/* Offset.swift in Sources */
,
968C99471D377849000074FF
/* Offset.swift in Sources */
,
96BCB7D51CB40DC500C806FE
/* View.swift in Sources */
,
96BCB7D51CB40DC500C806FE
/* View.swift in Sources */
,
96BCB7DE1CB40DC500C806FE
/* SearchBar.swift in Sources */
,
96BCB7DE1CB40DC500C806FE
/* SearchBar.swift in Sources */
,
96BCB7B11CB40DC500C806FE
/* Material+UIImage+Crop.swift in Sources */
,
96BCB7B81CB40DC500C806FE
/* Border.swift in Sources */
,
96BCB7B81CB40DC500C806FE
/* Border.swift in Sources */
,
96BCB7A61CB40DC500C806FE
/* Card.swift in Sources */
,
96BCB7A61CB40DC500C806FE
/* Card.swift in Sources */
,
96BCB7C91CB40DC500C806FE
/* Layer.swift in Sources */
,
96BCB7C91CB40DC500C806FE
/* Layer.swift in Sources */
,
...
@@ -988,7 +949,6 @@
...
@@ -988,7 +949,6 @@
96BCB7E01CB40DC500C806FE
/* NavigationDrawerController.swift in Sources */
,
96BCB7E01CB40DC500C806FE
/* NavigationDrawerController.swift in Sources */
,
96BCB7AD1CB40DC500C806FE
/* Material+String.swift in Sources */
,
96BCB7AD1CB40DC500C806FE
/* Material+String.swift in Sources */
,
96BCB7A51CB40DC500C806FE
/* Capture.swift in Sources */
,
96BCB7A51CB40DC500C806FE
/* Capture.swift in Sources */
,
96BCB7B01CB40DC500C806FE
/* Material+UIImage+Color.swift in Sources */
,
96BCB7B91CB40DC500C806FE
/* Button.swift in Sources */
,
96BCB7B91CB40DC500C806FE
/* Button.swift in Sources */
,
96BCB7B51CB40DC500C806FE
/* Material+UIImage.swift in Sources */
,
96BCB7B51CB40DC500C806FE
/* Material+UIImage.swift in Sources */
,
96BCB7E31CB40DC500C806FE
/* TabBar.swift in Sources */
,
96BCB7E31CB40DC500C806FE
/* TabBar.swift in Sources */
,
...
...
Sources/iOS/Animation.swift
View file @
9a90a7d5
...
@@ -69,7 +69,7 @@ public struct Animation {
...
@@ -69,7 +69,7 @@ public struct Animation {
let
delayed
:
AnimationDelayCancelBlock
=
{
(
cancel
:
Bool
)
in
let
delayed
:
AnimationDelayCancelBlock
=
{
(
cancel
:
Bool
)
in
if
!
cancel
{
if
!
cancel
{
DispatchQueue
.
main
.
async
hronously
(
execute
:
completion
)
DispatchQueue
.
main
.
async
(
execute
:
completion
)
}
}
cancelable
=
nil
cancelable
=
nil
}
}
...
...
Sources/iOS/BarView.swift
View file @
9a90a7d5
...
@@ -67,6 +67,6 @@ public class BarView : ControlView {
...
@@ -67,6 +67,6 @@ public class BarView : ControlView {
*/
*/
public
override
func
prepareView
()
{
public
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
depth
=
.
depth1
depth
Preset
=
.
depth1
}
}
}
}
Sources/iOS/BottomNavigationController.swift
View file @
9a90a7d5
...
@@ -31,15 +31,15 @@
...
@@ -31,15 +31,15 @@
import
UIKit
import
UIKit
public
class
BottomNavigationFadeAnimatedTransitioning
:
NSObject
,
UIViewControllerAnimatedTransitioning
{
public
class
BottomNavigationFadeAnimatedTransitioning
:
NSObject
,
UIViewControllerAnimatedTransitioning
{
public
func
animateTransition
(
transitionContext
:
UIViewControllerContextTransitioning
)
{
public
func
animateTransition
(
_
transitionContext
:
UIViewControllerContextTransitioning
)
{
let
fromView
:
UIView
=
transitionContext
.
view
ForKey
(
UITransitionContextFromViewKey
)
!
let
fromView
:
UIView
=
transitionContext
.
view
(
forKey
:
UITransitionContextFromViewKey
)
!
let
toView
:
UIView
=
transitionContext
.
view
ForKey
(
UITransitionContextToViewKey
)
!
let
toView
:
UIView
=
transitionContext
.
view
(
forKey
:
UITransitionContextToViewKey
)
!
toView
.
alpha
=
0
toView
.
alpha
=
0
transitionContext
.
containerView
()
!
.
addSubview
(
fromView
)
transitionContext
.
containerView
()
.
addSubview
(
fromView
)
transitionContext
.
containerView
()
!
.
addSubview
(
toView
)
transitionContext
.
containerView
()
.
addSubview
(
toView
)
UIView
.
animate
WithDuration
(
transitionDuration
(
transitionContext
),
UIView
.
animate
(
withDuration
:
transitionDuration
(
transitionContext
),
animations
:
{
_
in
animations
:
{
_
in
toView
.
alpha
=
1
toView
.
alpha
=
1
fromView
.
alpha
=
0
fromView
.
alpha
=
0
...
@@ -48,20 +48,20 @@ public class BottomNavigationFadeAnimatedTransitioning : NSObject, UIViewControl
...
@@ -48,20 +48,20 @@ public class BottomNavigationFadeAnimatedTransitioning : NSObject, UIViewControl
}
}
}
}
public
func
transitionDuration
(
transitionContext
:
UIViewControllerContextTransitioning
?)
->
TimeInterval
{
public
func
transitionDuration
(
_
transitionContext
:
UIViewControllerContextTransitioning
?)
->
TimeInterval
{
return
0.35
return
0.35
}
}
}
}
public
enum
BottomNavigationTransitionAnimation
{
public
enum
BottomNavigationTransitionAnimation
{
case
N
one
case
n
one
case
F
ade
case
f
ade
}
}
@IBDesignable
@IBDesignable
public
class
BottomNavigationController
:
UITabBarController
,
UITabBarControllerDelegate
{
public
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
=
.
F
ade
public
var
transitionAnimation
:
BottomNavigationTransitionAnimation
=
.
f
ade
/**
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
...
@@ -76,7 +76,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController
...
@@ -76,7 +76,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
*/
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
NS
Bundle
?)
{
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
}
}
...
@@ -134,19 +134,19 @@ public class BottomNavigationController : UITabBarController, UITabBarController
...
@@ -134,19 +134,19 @@ public class BottomNavigationController : UITabBarController, UITabBarController
}
}
/// Handles transitions when tabBarItems are pressed.
/// Handles transitions when tabBarItems are pressed.
public
func
tabBarController
(
tabBarController
:
UITabBarController
,
animationControllerForTransitionFromViewController
fromVC
:
UIViewController
,
toViewController
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
public
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
{
return
nil
return
nil
}
}
return
.
F
ade
==
transitionAnimation
?
BottomNavigationFadeAnimatedTransitioning
()
:
nil
return
.
f
ade
==
transitionAnimation
?
BottomNavigationFadeAnimatedTransitioning
()
:
nil
}
}
/// Prepares the tabBar.
/// Prepares the tabBar.
private
func
prepareTabBar
()
{
private
func
prepareTabBar
()
{
tabBar
.
depth
=
.
depth1
tabBar
.
depth
Preset
=
.
depth1
let
image
:
UIImage
?
=
UIImage
.
imageWithColor
(
Color
.
clear
,
size
:
CGSizeMake
(
1
,
1
))
let
image
=
UIImage
.
imageWithColor
(
color
:
Color
.
clear
,
size
:
CGSize
(
width
:
1
,
height
:
1
))
tabBar
.
shadowImage
=
image
tabBar
.
shadowImage
=
image
tabBar
.
backgroundImage
=
image
tabBar
.
backgroundImage
=
image
tabBar
.
backgroundColor
=
Color
.
white
tabBar
.
backgroundColor
=
Color
.
white
...
...
Sources/iOS/BottomTabBar.swift
View file @
9a90a7d5
...
@@ -115,6 +115,11 @@ public class BottomTabBar: UITabBar {
...
@@ -115,6 +115,11 @@ public class BottomTabBar: UITabBar {
self
.
init
(
frame
:
CGRect
.
zero
)
self
.
init
(
frame
:
CGRect
.
zero
)
}
}
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
public
override
func
layoutSubviews
()
{
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
if
let
v
:
Array
<
UITabBarItem
>
=
items
{
if
let
v
:
Array
<
UITabBarItem
>
=
items
{
...
...
Sources/iOS/Button.swift
View file @
9a90a7d5
...
@@ -164,7 +164,7 @@ public class Button: UIButton {
...
@@ -164,7 +164,7 @@ public class Button: UIButton {
*/
*/
@IBInspectable
public
var
contentInset
=
EdgeInsets
.
zero
{
@IBInspectable
public
var
contentInset
=
EdgeInsets
.
zero
{
didSet
{
didSet
{
contentEdgeInsets
=
contentInset
.
asEdgeInsets
contentEdgeInsets
=
contentInset
}
}
}
}
...
...
Sources/iOS/ControlView.swift
View file @
9a90a7d5
...
@@ -47,7 +47,7 @@ public class ControlView : View {
...
@@ -47,7 +47,7 @@ public class ControlView : View {
}
}
/// A wrapper around grid.contentInset.
/// A wrapper around grid.contentInset.
@IBInspectable
public
var
contentInset
:
Inset
{
@IBInspectable
public
var
contentInset
:
EdgeInsets
{
get
{
get
{
return
grid
.
contentInset
return
grid
.
contentInset
}
}
...
@@ -152,7 +152,7 @@ public class ControlView : View {
...
@@ -152,7 +152,7 @@ public class ControlView : View {
public
init
(
leftControls
:
Array
<
UIControl
>
?
=
nil
,
rightControls
:
Array
<
UIControl
>
?
=
nil
)
{
public
init
(
leftControls
:
Array
<
UIControl
>
?
=
nil
,
rightControls
:
Array
<
UIControl
>
?
=
nil
)
{
super
.
init
(
frame
:
CGRect
.
zero
)
super
.
init
(
frame
:
CGRect
.
zero
)
frame
.
size
=
intrinsicContentSize
()
frame
.
size
=
intrinsicContentSize
()
prepareProperties
(
leftControls
,
rightControls
:
rightControls
)
prepareProperties
(
leftControls
:
leftControls
,
rightControls
:
rightControls
)
}
}
public
override
func
layoutSubviews
()
{
public
override
func
layoutSubviews
()
{
...
@@ -214,7 +214,7 @@ public class ControlView : View {
...
@@ -214,7 +214,7 @@ public class ControlView : View {
}
}
public
override
func
intrinsicContentSize
()
->
CGSize
{
public
override
func
intrinsicContentSize
()
->
CGSize
{
return
CGSizeMake
(
width
,
44
)
return
CGSize
(
width
:
width
,
height
:
44
)
}
}
/**
/**
...
@@ -227,8 +227,8 @@ public class ControlView : View {
...
@@ -227,8 +227,8 @@ public class ControlView : View {
public
override
func
prepareView
()
{
public
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
interimSpacePreset
=
.
interimSpace1
interimSpacePreset
=
.
interimSpace1
contentEdgeInsetsPreset
=
.
S
quare1
contentEdgeInsetsPreset
=
.
s
quare1
autoresizingMask
=
.
F
lexibleWidth
autoresizingMask
=
.
f
lexibleWidth
shadowPathAutoSizeEnabled
=
false
shadowPathAutoSizeEnabled
=
false
prepareContentView
()
prepareContentView
()
}
}
...
...
Sources/iOS/Depth.swift
View file @
9a90a7d5
...
@@ -50,7 +50,7 @@ public struct Depth {
...
@@ -50,7 +50,7 @@ public struct Depth {
public
var
radius
:
CGFloat
public
var
radius
:
CGFloat
/// Preset.
/// Preset.
public
var
preset
:
DepthPreset
{
public
var
preset
:
DepthPreset
=
.
none
{
didSet
{
didSet
{
let
depth
=
DepthPresetToValue
(
preset
:
preset
)
let
depth
=
DepthPresetToValue
(
preset
:
preset
)
offset
=
depth
.
offset
offset
=
depth
.
offset
...
@@ -76,6 +76,7 @@ public struct Depth {
...
@@ -76,6 +76,7 @@ public struct Depth {
- Parameter preset: DepthPreset.
- Parameter preset: DepthPreset.
*/
*/
public
init
(
preset
:
DepthPreset
)
{
public
init
(
preset
:
DepthPreset
)
{
self
.
init
()
self
.
preset
=
preset
self
.
preset
=
preset
}
}
...
...
Sources/iOS/ErrorTextField.swift
View file @
9a90a7d5
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
import
UIKit
import
UIKit
public
class
ErrorTextField
:
TextField
{
public
class
ErrorTextField
:
TextField
{
/// Controls the visibility of detailLabel
/// Controls the visibility of detailLabel
@IBInspectable
public
var
revealError
:
Bool
=
false
{
@IBInspectable
public
var
revealError
:
Bool
=
false
{
didSet
{
didSet
{
...
...
Sources/iOS/Grid.swift
View file @
9a90a7d5
...
@@ -150,7 +150,7 @@ public class Grid {
...
@@ -150,7 +150,7 @@ public class Grid {
}
}
/// Insets value for grid.
/// Insets value for grid.
public
var
contentInset
:
Inset
=
EdgeInsetsPresetToValue
(
preset
:
.
none
)
{
public
var
contentInset
:
EdgeInsets
=
EdgeInsetsPresetToValue
(
preset
:
.
none
)
{
didSet
{
didSet
{
reload
()
reload
()
}
}
...
...
Sources/iOS/Icon.swift
View file @
9a90a7d5
...
@@ -32,26 +32,29 @@ import UIKit
...
@@ -32,26 +32,29 @@ import UIKit
public
struct
Icon
{
public
struct
Icon
{
/// An internal reference to the icons bundle.
/// An internal reference to the icons bundle.
private
static
var
internalBundle
:
NS
Bundle
?
private
static
var
internalBundle
:
Bundle
?
/**
/**
A public reference to the icons bundle, that aims to detect
A public reference to the icons bundle, that aims to detect
the correct bundle to use.
the correct bundle to use.
*/
*/
public
static
var
bundle
:
NS
Bundle
{
public
static
var
bundle
:
Bundle
{
if
nil
==
Icon
.
internalBundle
{
if
nil
==
Icon
.
internalBundle
{
Icon
.
internalBundle
=
NSBundle
(
forClass
:
View
.
self
)
Icon
.
internalBundle
=
Bundle
(
for
:
View
.
self
)
let
b
:
NSBundle
?
=
NSBundle
(
URL
:
Icon
.
internalBundle
!.
resourceURL
!.
URLByAppendingPathComponent
(
"io.cosmicmind.material.icons.bundle"
))
let
url
=
Icon
.
internalBundle
!.
resourceURL
!
if
let
v
:
NSBundle
=
b
{
do
{
let
b
=
Bundle
(
url
:
try
url
.
appendingPathComponent
(
"io.cosmicmind.material.icons.bundle"
))
if
let
v
=
b
{
Icon
.
internalBundle
=
v
Icon
.
internalBundle
=
v
}
}
}
catch
{}
}
}
return
Icon
.
internalBundle
!
return
Icon
.
internalBundle
!
}
}
/// Get the icon by the file name.
/// Get the icon by the file name.
public
static
func
icon
(
name
:
String
)
->
UIImage
?
{
public
static
func
icon
(
_
name
:
String
)
->
UIImage
?
{
return
UIImage
(
named
:
name
,
in
Bundle
:
bundle
,
compatibleWithTraitCollection
:
nil
)?
.
imageWithRenderingMode
(
.
A
lwaysTemplate
)
return
UIImage
(
named
:
name
,
in
:
bundle
,
compatibleWith
:
nil
)?
.
withRenderingMode
(
.
a
lwaysTemplate
)
}
}
/// Google icons.
/// Google icons.
...
...
Sources/iOS/Layer.swift
View file @
9a90a7d5
...
@@ -286,52 +286,43 @@ public class Layer: CAShapeLayer {
...
@@ -286,52 +286,43 @@ public class Layer: CAShapeLayer {
}
}
/**
/**
A method that accepts CAAnimation objects and executes.
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
- Parameter animation: A CAAnimation instance.
*/
*/
public
func
animate
(
animation
:
CAAnimation
)
{
public
func
animate
(
animation
:
CAAnimation
)
{
animation
.
delegate
=
self
animation
.
delegate
=
self
if
let
a
:
CABasicAnimation
=
animation
as?
CABasicAnimation
{
if
let
a
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
nil
==
presentation
()
?
self
:
presentation
()
!
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
a
.
fromValue
=
(
nil
==
presentation
()
?
self
:
presentation
()
!
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
}
}
if
let
a
:
CAPropertyAnimation
=
animation
as?
CAPropertyAnimation
{
if
let
a
=
animation
as?
CAPropertyAnimation
{
add
(
a
,
forKey
:
a
.
keyPath
!
)
add
(
a
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
:
CAAnimationGroup
=
animation
as?
CAAnimationGroup
{
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
add
(
a
,
forKey
:
nil
)
add
(
a
,
forKey
:
nil
)
}
else
if
let
a
:
CATransition
=
animation
as?
CATransition
{
}
else
if
let
a
=
animation
as?
CATransition
{
add
(
a
,
forKey
:
kCATransition
)
add
(
a
,
forKey
:
kCATransition
)
}
}
}
}
/**
/**
A delegation method that is executed when the
layer start
s
A delegation method that is executed when the
backing layer stop
s
running an animation.
running an animation.
- Parameter animation: The currently running CAAnimation instance.
- Parameter animation: The CAAnimation instance that stopped running.
*/
public
override
func
animationDidStart
(
_
animation
:
CAAnimation
)
{
(
delegate
as?
AnimationDelegate
)?
.
materialAnimationDidStart
?(
animation
:
animation
)
}
/**
A delegation method that is executed when the layer stops
running an animation.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
because it was completed or interrupted. True if completed, false
if interrupted.
if interrupted.
*/
*/
public
override
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
public
override
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
:
CAPropertyAnimation
=
animation
as?
CAPropertyAnimation
{
if
let
a
=
animation
as?
CAPropertyAnimation
{
if
let
b
:
CABasicAnimation
=
a
as?
CABasicAnimation
{
if
let
b
=
a
as?
CABasicAnimation
{
if
let
v
:
AnyObject
=
b
.
toValue
{
if
let
v
=
b
.
toValue
{
if
let
k
:
String
=
b
.
keyPath
{
if
let
k
=
b
.
keyPath
{
setValue
(
v
,
forKeyPath
:
k
)
setValue
(
v
,
forKeyPath
:
k
)
removeAnimation
(
forKey
:
k
)
removeAnimation
(
forKey
:
k
)
}
}
}
}
}
}
(
delegate
as?
AnimationDelegate
)?
.
materialAnimationDidStop
?(
animation
:
animation
,
finished
:
flag
)
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
}
else
if
let
a
:
CAAnimationGroup
=
animation
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
animationDidStop
(
x
,
finished
:
true
)
}
}
...
@@ -340,7 +331,7 @@ public class Layer: CAShapeLayer {
...
@@ -340,7 +331,7 @@ public class Layer: CAShapeLayer {
/// Prepares the visualLayer property.
/// Prepares the visualLayer property.
public
func
prepareVisualLayer
()
{
public
func
prepareVisualLayer
()
{
visualLayer
=
CAShapeLayer
(
Z
visualLayer
=
CAShapeLayer
(
)
visualLayer
.
zPosition
=
0
visualLayer
.
zPosition
=
0
visualLayer
.
masksToBounds
=
true
visualLayer
.
masksToBounds
=
true
addSublayer
(
visualLayer
)
addSublayer
(
visualLayer
)
...
...
Sources/iOS/Material+String.swift
View file @
9a90a7d5
/*
/
//
*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
//
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
//
* All rights reserved.
*
//
*
* Redistribution and use in source and binary forms, with or without
//
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
//
* modification, are permitted provided that the following conditions are met:
*
//
*
* * Redistributions of source code must retain the above copyright notice, this
//
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
//
* list of conditions and the following disclaimer.
*
//
*
* * Redistributions in binary form must reproduce the above copyright notice,
//
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
//
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
//
* and/or other materials provided with the distribution.
*
//
*
* * Neither the name of CosmicMind nor the names of its
//
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
//
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
//
* this software without specific prior written permission.
*
//
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
//
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
//
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
//
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
//
* 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
//
* 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.
//
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
*/
//
import
UIKit
//
import UIKit
//
public
extension
String
{
//
public extension String {
/**
//
/**
:name: lines
//
:name: lines
*/
//
*/
public
var
lines
:
Array
<
String
>
{
//
public var lines: Array<String> {
return
componentsSeparatedByCharactersInSet
(
NSCharacterSet
.
newlineCharacterSet
())
//
return componentsSeparatedByCharactersInSet(NSCharacterSet.newlineCharacterSet())
}
//
}
//
/**
//
/**
:name: firstLine
//
:name: firstLine
*/
//
*/
public
var
firstLine
:
String
?
{
//
public var firstLine: String? {
return
lines
.
first
?
.
trim
()
//
return lines.first?.trim()
}
//
}
//
/**
//
/**
:name: lastLine
//
:name: lastLine
*/
//
*/
public
var
lastLine
:
String
?
{
//
public var lastLine: String? {
return
lines
.
last
?
.
trim
()
//
return lines.last?.trim()
}
//
}
//
/**
//
/**
:name: replaceNewLineCharater
//
:name: replaceNewLineCharater
*/
//
*/
public
func
replaceNewLineCharater
(
replace
:
String
=
" "
)
->
String
{
//
public func replaceNewLineCharater(replace: String = " ") -> String {
return
componentsSeparatedByCharactersInSet
(
NSCharacterSet
.
whitespaceAndNewlineCharacterSet
())
.
joinWithSeparator
(
replace
)
.
trim
()
//
return componentsSeparatedByCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).joinWithSeparator(replace).trim()
}
//
}
//
/**
//
/**
:name: replacePunctuationCharacters
//
:name: replacePunctuationCharacters
*/
//
*/
public
func
replacePunctuationCharacters
(
replace
:
String
=
""
)
->
String
{
//
public func replacePunctuationCharacters(replace: String = "") -> String {
return
componentsSeparatedByCharactersInSet
(
NSCharacterSet
.
punctuationCharacterSet
())
.
joinWithSeparator
(
replace
)
.
trim
()
//
return componentsSeparatedByCharactersInSet(NSCharacterSet.punctuationCharacterSet()).joinWithSeparator(replace).trim()
}
//
}
//
/**
//
/**
:name: trim
//
:name: trim
*/
//
*/
public
func
trim
()
->
String
{
//
public func trim() -> String {
return
stringByTrimmingCharactersInSet
(
NSCharacterSet
.
whitespaceAndNewlineCharacterSet
())
//
return stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
}
//
}
}
//
}
Sources/iOS/Material+UIFont.swift
View file @
9a90a7d5
...
@@ -35,8 +35,8 @@ public extension UIFont {
...
@@ -35,8 +35,8 @@ public extension UIFont {
:name: stringSize
:name: stringSize
*/
*/
public
func
stringSize
(
string
:
String
,
constrainedToWidth
width
:
Double
)
->
CGSize
{
public
func
stringSize
(
string
:
String
,
constrainedToWidth
width
:
Double
)
->
CGSize
{
return
string
.
boundingRect
WithSize
(
CGSize
(
width
:
width
,
height
:
DBL_MAX
),
return
string
.
boundingRect
(
with
:
CGSize
(
width
:
width
,
height
:
DBL_MAX
),
options
:
NSStringDrawingOptions
.
U
sesLineFragmentOrigin
,
options
:
NSStringDrawingOptions
.
u
sesLineFragmentOrigin
,
attributes
:
[
NSFontAttributeName
:
self
],
attributes
:
[
NSFontAttributeName
:
self
],
context
:
nil
)
.
size
context
:
nil
)
.
size
}
}
...
...
Sources/iOS/Material+UIImage+Blank.swift
deleted
100644 → 0
View file @
e15b9fff
/*
* 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
public
extension
UIImage
{
/**
Creates an clear image.
- Returns: A UIImage that is clear.
*/
public
class
func
clearImage
()
->
UIImage
{
UIGraphicsBeginImageContextWithOptions
(
CGSizeMake
(
36
,
36
),
false
,
0
)
let
image
:
UIImage
=
UIGraphicsGetImageFromCurrentImageContext
()
UIGraphicsEndImageContext
()
return
image
}
}
Sources/iOS/Material+UIImage+Color.swift
deleted
100644 → 0
View file @
e15b9fff
/*
* 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
public
extension
UIImage
{
/**
Creates an Image that is a color.
- Parameter color: The UIColor to create the image from.
- Parameter size: The size of the image to create.
- Returns: A UIImage that is the color passed in.
*/
public
class
func
imageWithColor
(
color
:
UIColor
,
size
:
CGSize
)
->
UIImage
{
let
rect
=
CGRectMake
(
0
,
0
,
size
.
width
,
size
.
height
)
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
0
)
color
.
setFill
()
UIRectFill
(
rect
)
let
image
:
UIImage
=
UIGraphicsGetImageFromCurrentImageContext
()
UIGraphicsEndImageContext
()
return
image
}
}
Sources/iOS/Material+UIImage+Crop.swift
deleted
100644 → 0
View file @
e15b9fff
/*
* 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
public
extension
UIImage
{
/**
:name: crop
*/
public
func
crop
(
toWidth
tw
:
CGFloat
,
toHeight
th
:
CGFloat
)
->
UIImage
?
{
let
g
:
UIImage
?
let
b
:
Bool
=
width
>
height
let
s
:
CGFloat
=
b
?
th
/
height
:
tw
/
width
let
t
:
CGSize
=
CGSizeMake
(
tw
,
th
)
let
w
=
width
*
s
let
h
=
height
*
s
UIGraphicsBeginImageContext
(
t
)
drawInRect
(
b
?
CGRectMake
(
-
1
*
(
w
-
t
.
width
)
/
2
,
0
,
w
,
h
)
:
CGRectMake
(
0
,
-
1
*
(
h
-
t
.
height
)
/
2
,
w
,
h
),
blendMode
:
.
Normal
,
alpha
:
1
)
g
=
UIGraphicsGetImageFromCurrentImageContext
()
UIGraphicsEndImageContext
()
return
g
!
}
}
\ No newline at end of file
Sources/iOS/Material+UIImage+FilterBlur.swift
View file @
9a90a7d5
/*
/
//
*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
//
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
//
* All rights reserved.
*
//
*
* Redistribution and use in source and binary forms, with or without
//
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
//
* modification, are permitted provided that the following conditions are met:
*
//
*
* * Redistributions of source code must retain the above copyright notice, this
//
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
//
* list of conditions and the following disclaimer.
*
//
*
* * Redistributions in binary form must reproduce the above copyright notice,
//
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
//
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
//
* and/or other materials provided with the distribution.
*
//
*
* * Neither the name of CosmicMind nor the names of its
//
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
//
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
//
* this software without specific prior written permission.
*
//
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
//
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
//
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
//
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
//
* 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
//
* 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.
//
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
*/
//
import
UIKit
//
import UIKit
import
Accelerate
//
import Accelerate
//
/// Creates an effect buffer for images that are already effected.
///
//
Creates an effect buffer for images that are already effected.
private
func
createEffectBuffer
(
context
:
CGContext
)
->
vImage_Buffer
{
//
private func createEffectBuffer(context: CGContext) -> vImage_Buffer {
let
data
=
CGBitmapContextGetData
(
context
)
//
let data = CGBitmapContextGetData(context)
let
width
=
vImagePixelCount
(
CGBitmapContextGetWidth
(
context
))
//
let width = vImagePixelCount(CGBitmapContextGetWidth(context))
let
height
=
vImagePixelCount
(
CGBitmapContextGetHeight
(
context
))
//
let height = vImagePixelCount(CGBitmapContextGetHeight(context))
let
rowBytes
=
CGBitmapContextGetBytesPerRow
(
context
)
//
let rowBytes = CGBitmapContextGetBytesPerRow(context)
return
vImage_Buffer
(
data
:
data
,
height
:
height
,
width
:
width
,
rowBytes
:
rowBytes
)
//
return vImage_Buffer(data: data, height: height, width: width, rowBytes: rowBytes)
}
//
}
//
public
extension
UIImage
{
//
public extension UIImage {
/**
//
/**
Applies a blur effect to a UIImage.
//
Applies a blur effect to a UIImage.
- Parameter blurRadius: The radius of the blur effect.
//
- Parameter blurRadius: The radius of the blur effect.
- Parameter tintColor: The color used for the blur effect (optional).
//
- Parameter tintColor: The color used for the blur effect (optional).
- Parameter saturationDeltaFactor: The delta factor for the saturation of the blur effect.
//
- Parameter saturationDeltaFactor: The delta factor for the saturation of the blur effect.
- Returns: a UIImage.
//
- Returns: a UIImage.
*/
//
*/
func
filterBlur
(
blurRadius
:
CGFloat
=
0
,
tintColor
:
UIColor
?
=
nil
,
saturationDeltaFactor
:
CGFloat
=
0
)
->
UIImage
?
{
//
func filterBlur(blurRadius: CGFloat = 0, tintColor: UIColor? = nil, saturationDeltaFactor: CGFloat = 0) -> UIImage? {
var
effectImage
:
UIImage
=
self
//
var effectImage: UIImage = self
//
let
screenScale
:
CGFloat
=
Device
.
scale
//
let screenScale: CGFloat = Device.scale
let
imageRect
:
CGRect
=
CGRect
(
origin
:
CGPoint
.
zero
,
size
:
size
)
//
let imageRect: CGRect = CGRect(origin: CGPoint.zero, size: size)
let
hasBlur
:
Bool
=
blurRadius
>
CGFloat
(
FLT_EPSILON
)
//
let hasBlur: Bool = blurRadius > CGFloat(FLT_EPSILON)
let
hasSaturationChange
:
Bool
=
fabs
(
saturationDeltaFactor
-
1.0
)
>
CGFloat
(
FLT_EPSILON
)
//
let hasSaturationChange: Bool = fabs(saturationDeltaFactor - 1.0) > CGFloat(FLT_EPSILON)
//
if
hasBlur
||
hasSaturationChange
{
//
if hasBlur || hasSaturationChange {
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
screenScale
)
//
UIGraphicsBeginImageContextWithOptions(size, false, screenScale)
let
effectInContext
:
CGContext
=
UIGraphicsGetCurrentContext
()
!
//
let effectInContext: CGContext = UIGraphicsGetCurrentContext()!
CGContextScaleCTM
(
effectInContext
,
1.0
,
-
1.0
)
//
CGContextScaleCTM(effectInContext, 1.0, -1.0)
CGContextTranslateCTM
(
effectInContext
,
0
,
-
size
.
height
)
//
CGContextTranslateCTM(effectInContext, 0, -size.height)
CGContextDrawImage
(
effectInContext
,
imageRect
,
self
.
cgImage
)
//
CGContextDrawImage(effectInContext, imageRect, self.cgImage)
var
effectInBuffer
:
vImage_Buffer
=
createEffectBuffer
(
effectInContext
)
//
var effectInBuffer: vImage_Buffer = createEffectBuffer(effectInContext)
//
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
screenScale
)
//
UIGraphicsBeginImageContextWithOptions(size, false, screenScale)
let
effectOutContext
:
CGContext
=
UIGraphicsGetCurrentContext
()
!
//
let effectOutContext: CGContext = UIGraphicsGetCurrentContext()!
var
effectOutBuffer
:
vImage_Buffer
=
createEffectBuffer
(
effectOutContext
)
//
var effectOutBuffer: vImage_Buffer = createEffectBuffer(effectOutContext)
//
if
hasBlur
{
//
if hasBlur {
let
inputRadius
:
CGFloat
=
blurRadius
*
screenScale
//
let inputRadius: CGFloat = blurRadius * screenScale
var
radius
:
UInt32
=
UInt32
(
floor
(
inputRadius
*
3.0
*
CGFloat
(
sqrt
(
2
*
M_PI
))
/
4
+
0.5
))
//
var radius: UInt32 = UInt32(floor(inputRadius * 3.0 * CGFloat(sqrt(2 * M_PI)) / 4 + 0.5))
if
1
!=
radius
%
2
{
//
if 1 != radius % 2 {
radius
+=
1
// force radius to be odd so that the three box-blur methodology works.
//
radius += 1 // force radius to be odd so that the three box-blur methodology works.
}
//
}
//
let
imageEdgeExtendFlags
:
UInt32
=
vImage_Flags
(
kvImageEdgeExtend
)
//
let imageEdgeExtendFlags: UInt32 = vImage_Flags(kvImageEdgeExtend)
//
vImageBoxConvolve_ARGB8888
(
&
effectInBuffer
,
&
effectOutBuffer
,
nil
,
0
,
0
,
radius
,
radius
,
nil
,
imageEdgeExtendFlags
)
//
vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, nil, 0, 0, radius, radius, nil, imageEdgeExtendFlags)
vImageBoxConvolve_ARGB8888
(
&
effectOutBuffer
,
&
effectInBuffer
,
nil
,
0
,
0
,
radius
,
radius
,
nil
,
imageEdgeExtendFlags
)
//
vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, nil, 0, 0, radius, radius, nil, imageEdgeExtendFlags)
vImageBoxConvolve_ARGB8888
(
&
effectInBuffer
,
&
effectOutBuffer
,
nil
,
0
,
0
,
radius
,
radius
,
nil
,
imageEdgeExtendFlags
)
//
vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, nil, 0, 0, radius, radius, nil, imageEdgeExtendFlags)
}
//
}
//
var
effectImageBuffersAreSwapped
:
Bool
=
false
//
var effectImageBuffersAreSwapped: Bool = false
//
if
hasSaturationChange
{
//
if hasSaturationChange {
let
s
:
CGFloat
=
saturationDeltaFactor
//
let s: CGFloat = saturationDeltaFactor
let
floatingPointSaturationMatrix
:
Array
<
CGFloat
>
=
[
//
let floatingPointSaturationMatrix: Array<CGFloat> = [
0.0722
+
0.9278
*
s
,
0.0722
-
0.0722
*
s
,
0.0722
-
0.0722
*
s
,
0
,
//
0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0,
0.7152
-
0.7152
*
s
,
0.7152
+
0.2848
*
s
,
0.7152
-
0.7152
*
s
,
0
,
//
0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0,
0.2126
-
0.2126
*
s
,
0.2126
-
0.2126
*
s
,
0.2126
+
0.7873
*
s
,
0
,
//
0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0,
0
,
0
,
0
,
1
//
0, 0, 0, 1
]
//
]
//
let
divisor
:
CGFloat
=
256
//
let divisor: CGFloat = 256
let
matrixSize
:
Int
=
floatingPointSaturationMatrix
.
count
//
let matrixSize: Int = floatingPointSaturationMatrix.count
var
saturationMatrix
:
Array
<
Int16
>
=
Array
<
Int16
>
(
count
:
matrixSize
,
repeatedValue
:
0
)
//
var saturationMatrix: Array<Int16> = Array<Int16>(count: matrixSize, repeatedValue: 0)
//
for
i
:
Int
in
0
..<
matrixSize
{
//
for i: Int in 0 ..< matrixSize {
saturationMatrix
[
i
]
=
Int16
(
round
(
floatingPointSaturationMatrix
[
i
]
*
divisor
))
//
saturationMatrix[i] = Int16(round(floatingPointSaturationMatrix[i] * divisor))
}
//
}
//
if
hasBlur
{
//
if hasBlur {
vImageMatrixMultiply_ARGB8888
(
&
effectOutBuffer
,
&
effectInBuffer
,
saturationMatrix
,
Int32
(
divisor
),
nil
,
nil
,
vImage_Flags
(
kvImageNoFlags
))
//
vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, Int32(divisor), nil, nil, vImage_Flags(kvImageNoFlags))
effectImageBuffersAreSwapped
=
true
//
effectImageBuffersAreSwapped = true
}
else
{
//
} else {
vImageMatrixMultiply_ARGB8888
(
&
effectInBuffer
,
&
effectOutBuffer
,
saturationMatrix
,
Int32
(
divisor
),
nil
,
nil
,
vImage_Flags
(
kvImageNoFlags
))
//
vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, Int32(divisor), nil, nil, vImage_Flags(kvImageNoFlags))
}
//
}
}
//
}
//
if
!
effectImageBuffersAreSwapped
{
//
if !effectImageBuffersAreSwapped {
effectImage
=
UIGraphicsGetImageFromCurrentImageContext
()
//
effectImage = UIGraphicsGetImageFromCurrentImageContext()
}
//
}
//
UIGraphicsEndImageContext
()
//
UIGraphicsEndImageContext()
//
if
effectImageBuffersAreSwapped
{
//
if effectImageBuffersAreSwapped {
effectImage
=
UIGraphicsGetImageFromCurrentImageContext
()
//
effectImage = UIGraphicsGetImageFromCurrentImageContext()
}
//
}
//
UIGraphicsEndImageContext
()
//
UIGraphicsEndImageContext()
}
//
}
//
// Set up output context.
//
// Set up output context.
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
screenScale
)
//
UIGraphicsBeginImageContextWithOptions(size, false, screenScale)
let
outputContext
:
CGContext
=
UIGraphicsGetCurrentContext
()
!
//
let outputContext: CGContext = UIGraphicsGetCurrentContext()!
CGContextScaleCTM
(
outputContext
,
1.0
,
-
1.0
)
//
CGContextScaleCTM(outputContext, 1.0, -1.0)
CGContextTranslateCTM
(
outputContext
,
0
,
-
size
.
height
)
//
CGContextTranslateCTM(outputContext, 0, -size.height)
//
// Draw base image.
//
// Draw base image.
CGContextDrawImage
(
outputContext
,
imageRect
,
self
.
cgImage
)
//
CGContextDrawImage(outputContext, imageRect, self.cgImage)
//
// Draw effect image.
//
// Draw effect image.
if
hasBlur
{
//
if hasBlur {
CGContextSaveGState
(
outputContext
)
//
CGContextSaveGState(outputContext)
CGContextDrawImage
(
outputContext
,
imageRect
,
effectImage
.
cgImage
)
//
CGContextDrawImage(outputContext, imageRect, effectImage.cgImage)
CGContextRestoreGState
(
outputContext
)
//
CGContextRestoreGState(outputContext)
}
//
}
//
// Add in color tint.
//
// Add in color tint.
if
let
v
:
UIColor
=
tintColor
{
//
if let v: UIColor = tintColor {
CGContextSaveGState
(
outputContext
)
//
CGContextSaveGState(outputContext)
CGContextSetFillColorWithColor
(
outputContext
,
v
.
cgColor
)
//
CGContextSetFillColorWithColor(outputContext, v.cgColor)
CGContextFillRect
(
outputContext
,
imageRect
)
//
CGContextFillRect(outputContext, imageRect)
CGContextRestoreGState
(
outputContext
)
//
CGContextRestoreGState(outputContext)
}
//
}
//
// Output image is ready.
//
// Output image is ready.
let
outputImage
:
UIImage
=
UIGraphicsGetImageFromCurrentImageContext
()
//
let outputImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext
()
//
UIGraphicsEndImageContext()
//
return
outputImage
//
return outputImage
}
//
}
}
//
}
Sources/iOS/Material+UIImage+Network.swift
deleted
100644 → 0
View file @
e15b9fff
/*
* 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
public
extension
UIImage
{
/**
Asynchronously load images with a completion block.
- Parameter URL: A URL destination to fetch the image from.
- Parameter completion: A completion block that is executed once the image
has been retrieved.
*/
public
class
func
contentsOfURL
(
URL
:
NSURL
,
completion
:
((
image
:
UIImage
?,
error
:
NSError
?)
->
Void
))
{
NSURLSession
.
sharedSession
()
.
dataTaskWithRequest
(
NSURLRequest
(
URL
:
URL
))
{
(
data
:
NSData
?,
response
:
NSURLResponse
?,
error
:
NSError
?)
in
dispatch_async
(
dispatch_get_main_queue
())
{
if
let
v
:
NSError
=
error
{
completion
(
image
:
nil
,
error
:
v
)
}
else
if
let
v
:
NSData
=
data
{
completion
(
image
:
UIImage
(
data
:
v
),
error
:
nil
)
}
}
}
.
resume
()
}
}
Sources/iOS/Material+UIImage+Resize.swift
View file @
9a90a7d5
...
@@ -45,9 +45,9 @@ public extension UIImage {
...
@@ -45,9 +45,9 @@ public extension UIImage {
}
}
let
g
:
UIImage
?
let
g
:
UIImage
?
let
t
:
CGRect
=
CGRectMake
(
0
,
0
,
w
??
tw
,
h
??
th
)
let
t
:
CGRect
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
w
??
tw
,
height
:
h
??
th
)
UIGraphicsBeginImageContextWithOptions
(
t
.
size
,
false
,
Device
.
scale
)
UIGraphicsBeginImageContextWithOptions
(
t
.
size
,
false
,
Device
.
scale
)
draw
InRect
(
t
,
blendMode
:
.
N
ormal
,
alpha
:
1
)
draw
(
in
:
t
,
blendMode
:
.
n
ormal
,
alpha
:
1
)
g
=
UIGraphicsGetImageFromCurrentImageContext
()
g
=
UIGraphicsGetImageFromCurrentImageContext
()
UIGraphicsEndImageContext
()
UIGraphicsEndImageContext
()
...
...
Sources/iOS/Material+UIImage+Size.swift
deleted
100644 → 0
View file @
e15b9fff
/*
* 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
public
extension
UIImage
{
/**
:name: width
*/
public
var
width
:
CGFloat
{
return
size
.
width
}
/**
:name: height
*/
public
var
height
:
CGFloat
{
return
size
.
height
}
}
\ No newline at end of file
Sources/iOS/Material+UIImage.swift
View file @
9a90a7d5
...
@@ -30,7 +30,151 @@
...
@@ -30,7 +30,151 @@
import
UIKit
import
UIKit
public
enum
ImageFormatType
{
public
enum
ImageFormat
{
case
PNG
case
png
case
JPEG
case
jpeg
}
public
extension
UIImage
{
/**
:name: width
*/
public
var
width
:
CGFloat
{
return
size
.
width
}
/**
:name: height
*/
public
var
height
:
CGFloat
{
return
size
.
height
}
/**
:name: internalResize
*/
private
func
internalResize
(
toWidth
tw
:
CGFloat
=
0
,
toHeight
th
:
CGFloat
=
0
)
->
UIImage
?
{
var
w
:
CGFloat
?
var
h
:
CGFloat
?
if
0
<
tw
{
h
=
height
*
tw
/
width
}
else
if
0
<
th
{
w
=
width
*
th
/
height
}
let
g
:
UIImage
?
let
t
:
CGRect
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
w
??
tw
,
height
:
h
??
th
)
UIGraphicsBeginImageContextWithOptions
(
t
.
size
,
false
,
Device
.
scale
)
draw
(
in
:
t
,
blendMode
:
.
normal
,
alpha
:
1
)
g
=
UIGraphicsGetImageFromCurrentImageContext
()
UIGraphicsEndImageContext
()
return
g
}
/**
:name: resize
*/
public
func
resize
(
toWidth
w
:
CGFloat
)
->
UIImage
?
{
return
internalResize
(
toWidth
:
w
)
}
/**
:name: resize
*/
public
func
resize
(
toHeight
h
:
CGFloat
)
->
UIImage
?
{
return
internalResize
(
toHeight
:
h
)
}
/**
Creates a new image with the passed in color.
- Parameter color: The UIColor to create the image from.
- Returns: A UIImage that is the color passed in.
*/
public
func
tintWithColor
(
color
:
UIColor
)
->
UIImage
?
{
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
Device
.
scale
)
guard
let
context
=
UIGraphicsGetCurrentContext
()
else
{
return
nil
}
context
.
scale
(
x
:
1.0
,
y
:
-
1.0
)
context
.
translate
(
x
:
0.0
,
y
:
-
size
.
height
)
context
.
setBlendMode
(
.
multiply
)
let
rect
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
size
.
width
,
height
:
size
.
height
)
context
.
clipToMask
(
rect
,
mask
:
cgImage
!
)
color
.
setFill
()
context
.
fill
(
rect
)
let
image
:
UIImage
=
UIGraphicsGetImageFromCurrentImageContext
()
!
UIGraphicsEndImageContext
()
return
image
}
/**
Creates an Image that is a color.
- Parameter color: The UIColor to create the image from.
- Parameter size: The size of the image to create.
- Returns: A UIImage that is the color passed in.
*/
public
class
func
imageWithColor
(
color
:
UIColor
,
size
:
CGSize
)
->
UIImage
?
{
let
rect
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
size
.
width
,
height
:
size
.
height
)
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
0
)
color
.
setFill
()
UIRectFill
(
rect
)
let
image
=
UIGraphicsGetImageFromCurrentImageContext
()
UIGraphicsEndImageContext
()
return
image
}
/**
:name: crop
*/
public
func
crop
(
toWidth
tw
:
CGFloat
,
toHeight
th
:
CGFloat
)
->
UIImage
?
{
let
g
:
UIImage
?
let
b
:
Bool
=
width
>
height
let
s
:
CGFloat
=
b
?
th
/
height
:
tw
/
width
let
t
:
CGSize
=
CGSize
(
width
:
tw
,
height
:
th
)
let
w
=
width
*
s
let
h
=
height
*
s
UIGraphicsBeginImageContext
(
t
)
draw
(
in
:
b
?
CGRect
(
x
:
-
1
*
(
w
-
t
.
width
)
/
2
,
y
:
0
,
width
:
w
,
height
:
h
)
:
CGRect
(
x
:
0
,
y
:
-
1
*
(
h
-
t
.
height
)
/
2
,
width
:
w
,
height
:
h
),
blendMode
:
.
normal
,
alpha
:
1
)
g
=
UIGraphicsGetImageFromCurrentImageContext
()
UIGraphicsEndImageContext
()
return
g
}
/**
Creates an clear image.
- Returns: A UIImage that is clear.
*/
public
class
func
clear
(
size
:
CGSize
=
CGSize
(
width
:
16
,
height
:
16
))
->
UIImage
?
{
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
0
)
let
image
=
UIGraphicsGetImageFromCurrentImageContext
()
UIGraphicsEndImageContext
()
return
image
}
/**
Asynchronously load images with a completion block.
- Parameter URL: A URL destination to fetch the image from.
- Parameter completion: A completion block that is executed once the image
has been retrieved.
*/
public
class
func
contentsOfURL
(
url
:
URL
,
completion
:
((
image
:
UIImage
?,
error
:
NSError
?)
->
Void
))
{
URLSession
.
shared
()
.
dataTask
(
with
:
URLRequest
(
url
:
url
))
{
(
data
:
Data
?,
response
:
URLResponse
?,
error
:
NSError
?)
in
DispatchQueue
.
main
.
async
{
if
let
v
=
error
{
completion
(
image
:
nil
,
error
:
v
)
}
else
if
let
v
=
data
{
completion
(
image
:
UIImage
(
data
:
v
),
error
:
nil
)
}
}
}
.
resume
()
}
}
}
Sources/iOS/Material.swift
View file @
9a90a7d5
...
@@ -43,7 +43,7 @@ public class Material {
...
@@ -43,7 +43,7 @@ public class Material {
}
}
/// A property that sets the cornerRadius of the backing layer.
/// A property that sets the cornerRadius of the backing layer.
public
var
cornerRadiusPreset
:
CornerRadiusPreset
{
public
var
cornerRadiusPreset
:
CornerRadiusPreset
=
.
none
{
didSet
{
didSet
{
guard
let
v
=
view
else
{
guard
let
v
=
view
else
{
return
return
...
@@ -56,7 +56,7 @@ public class Material {
...
@@ -56,7 +56,7 @@ public class Material {
}
}
/// A preset property to set the borderWidth.
/// A preset property to set the borderWidth.
public
var
borderWidthPreset
:
BorderWidthPreset
{
public
var
borderWidthPreset
:
BorderWidthPreset
=
.
none
{
didSet
{
didSet
{
guard
let
v
=
view
else
{
guard
let
v
=
view
else
{
return
return
...
@@ -79,7 +79,7 @@ public class Material {
...
@@ -79,7 +79,7 @@ public class Material {
}
}
/// Grid reference.
/// Grid reference.
public
var
depth
:
Depth
{
public
var
depth
:
Depth
=
Depth
.
zero
{
didSet
{
didSet
{
guard
let
v
=
view
else
{
guard
let
v
=
view
else
{
return
return
...
@@ -98,7 +98,7 @@ private var MaterialKey: UInt8 = 0
...
@@ -98,7 +98,7 @@ private var MaterialKey: UInt8 = 0
/// Grid extension for UIView.
/// Grid extension for UIView.
public
extension
UIView
{
public
extension
UIView
{
/// Material Reference.
/// Material Reference.
private
var
material
:
Material
{
internal
var
material
:
Material
{
get
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialKey
)
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialKey
)
{
return
Material
(
view
:
self
)
return
Material
(
view
:
self
)
...
...
Sources/iOS/MaterialCollectionReusableView.swift
View file @
9a90a7d5
...
@@ -264,8 +264,6 @@ public class MaterialCollectionReusableView: UICollectionReusableView {
...
@@ -264,8 +264,6 @@ public class MaterialCollectionReusableView: UICollectionReusableView {
- Parameter aDecoder: A NSCoder instance.
- Parameter aDecoder: A NSCoder instance.
*/
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
depthPreset
=
.
none
cornerRadiusPreset
=
.
none
contentsGravityPreset
=
.
ResizeAspectFill
contentsGravityPreset
=
.
ResizeAspectFill
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
prepareView
()
prepareView
()
...
@@ -278,8 +276,6 @@ public class MaterialCollectionReusableView: UICollectionReusableView {
...
@@ -278,8 +276,6 @@ public class MaterialCollectionReusableView: UICollectionReusableView {
- Parameter frame: A CGRect instance.
- Parameter frame: A CGRect instance.
*/
*/
public
override
init
(
frame
:
CGRect
)
{
public
override
init
(
frame
:
CGRect
)
{
depthPreset
=
.
none
cornerRadiusPreset
=
.
none
contentsGravityPreset
=
.
ResizeAspectFill
contentsGravityPreset
=
.
ResizeAspectFill
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
prepareView
()
prepareView
()
...
...
Sources/iOS/MaterialCollectionViewCell.swift
View file @
9a90a7d5
...
@@ -264,7 +264,6 @@ public class MaterialCollectionViewCell: UICollectionViewCell {
...
@@ -264,7 +264,6 @@ public class MaterialCollectionViewCell: UICollectionViewCell {
- Parameter aDecoder: A NSCoder instance.
- Parameter aDecoder: A NSCoder instance.
*/
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
cornerRadiusPreset
=
.
none
shape
=
.
none
shape
=
.
none
contentsGravityPreset
=
.
ResizeAspectFill
contentsGravityPreset
=
.
ResizeAspectFill
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
...
@@ -278,7 +277,6 @@ public class MaterialCollectionViewCell: UICollectionViewCell {
...
@@ -278,7 +277,6 @@ public class MaterialCollectionViewCell: UICollectionViewCell {
- Parameter frame: A CGRect instance.
- Parameter frame: A CGRect instance.
*/
*/
public
override
init
(
frame
:
CGRect
)
{
public
override
init
(
frame
:
CGRect
)
{
cornerRadiusPreset
=
.
none
shape
=
.
none
shape
=
.
none
contentsGravityPreset
=
.
ResizeAspectFill
contentsGravityPreset
=
.
ResizeAspectFill
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
...
...
Sources/iOS/MaterialCollectionViewLayout.swift
View file @
9a90a7d5
...
@@ -77,53 +77,53 @@ public class MaterialCollectionViewLayout: UICollectionViewLayout {
...
@@ -77,53 +77,53 @@ public class MaterialCollectionViewLayout: UICollectionViewLayout {
public
func
indexPathsOfItemsInRect
(
rect
:
CGRect
)
->
Array
<
NSIndexPath
>
{
public
func
indexPathsOfItemsInRect
(
rect
:
CGRect
)
->
Array
<
NSIndexPath
>
{
var
paths
:
Array
<
NSIndexPath
>
=
Array
<
NSIndexPath
>
()
var
paths
:
Array
<
NSIndexPath
>
=
Array
<
NSIndexPath
>
()
for
(
attribute
,
indexPath
)
in
layoutItems
{
for
(
attribute
,
indexPath
)
in
layoutItems
{
if
CGRectIntersectsRect
(
rect
,
attribute
.
frame
)
{
if
rect
.
intersects
(
attribute
.
frame
)
{
paths
.
append
(
indexPath
)
paths
.
append
(
indexPath
)
}
}
}
}
return
paths
return
paths
}
}
public
override
func
layoutAttributesForItem
AtIndexPath
(
indexPath
:
NS
IndexPath
)
->
UICollectionViewLayoutAttributes
?
{
public
override
func
layoutAttributesForItem
(
at
indexPath
:
IndexPath
)
->
UICollectionViewLayoutAttributes
?
{
let
attributes
:
UICollectionViewLayoutAttributes
=
UICollectionViewLayoutAttributes
(
forCellWithIndexPa
th
:
indexPath
)
let
attributes
=
UICollectionViewLayoutAttributes
(
forCellWi
th
:
indexPath
)
let
item
:
MaterialDataSourceItem
=
dataSourceItems
!
[
indexPath
.
item
]
let
item
:
MaterialDataSourceItem
=
dataSourceItems
!
[
indexPath
.
item
!
]
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
attributes
.
frame
=
CGRectMake
(
offset
.
x
,
offset
.
y
,
itemSize
.
width
-
contentInset
.
left
-
contentInset
.
right
,
itemSize
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
attributes
.
frame
=
CGRect
(
x
:
offset
.
x
,
y
:
offset
.
y
,
width
:
itemSize
.
width
-
contentInset
.
left
-
contentInset
.
right
,
height
:
itemSize
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
}
else
if
.
V
ertical
==
scrollDirection
{
}
else
if
.
v
ertical
==
scrollDirection
{
attributes
.
frame
=
CGRectMake
(
contentInset
.
left
,
offset
.
y
,
collectionView
!.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
,
nil
==
item
.
height
?
collectionView
!.
bounds
.
height
:
item
.
height
!
)
attributes
.
frame
=
CGRect
(
x
:
contentInset
.
left
,
y
:
offset
.
y
,
width
:
collectionView
!.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
,
height
:
item
.
height
??
collectionView
!.
bounds
.
height
)
}
else
{
}
else
{
attributes
.
frame
=
CGRectMake
(
offset
.
x
,
contentInset
.
top
,
nil
==
item
.
width
?
collectionView
!.
bounds
.
width
:
item
.
width
!
,
collectionView
!.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
attributes
.
frame
=
CGRect
(
x
:
offset
.
x
,
y
:
contentInset
.
top
,
width
:
item
.
width
??
collectionView
!.
bounds
.
width
,
height
:
collectionView
!.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
}
}
return
attributes
return
attributes
}
}
public
override
func
layoutAttributesForElements
InRect
(
rect
:
CGRect
)
->
[
UICollectionViewLayoutAttributes
]?
{
public
override
func
layoutAttributesForElements
(
in
rect
:
CGRect
)
->
[
UICollectionViewLayoutAttributes
]?
{
var
layoutAttributes
:
Array
<
UICollectionViewLayoutAttributes
>
=
Array
<
UICollectionViewLayoutAttributes
>
()
var
layoutAttributes
:
Array
<
UICollectionViewLayoutAttributes
>
=
Array
<
UICollectionViewLayoutAttributes
>
()
for
(
attribute
,
_
)
in
layoutItems
{
for
(
attribute
,
_
)
in
layoutItems
{
if
CGRectIntersectsRect
(
rect
,
attribute
.
frame
)
{
if
rect
.
intersects
(
attribute
.
frame
)
{
layoutAttributes
.
append
(
attribute
)
layoutAttributes
.
append
(
attribute
)
}
}
}
}
return
layoutAttributes
return
layoutAttributes
}
}
public
override
func
shouldInvalidateLayout
ForBoundsChange
(
newBounds
:
CGRect
)
->
Bool
{
public
override
func
shouldInvalidateLayout
(
forBoundsChange
newBounds
:
CGRect
)
->
Bool
{
return
.
V
ertical
==
scrollDirection
?
newBounds
.
width
!=
collectionView
!.
bounds
.
width
:
newBounds
.
height
!=
collectionView
!.
bounds
.
height
return
.
v
ertical
==
scrollDirection
?
newBounds
.
width
!=
collectionView
!.
bounds
.
width
:
newBounds
.
height
!=
collectionView
!.
bounds
.
height
}
}
public
override
func
collectionViewContentSize
()
->
CGSize
{
public
override
func
collectionViewContentSize
()
->
CGSize
{
return
contentSize
return
contentSize
}
}
public
override
func
prepare
Layout
()
{
public
override
func
prepare
()
{
if
let
dataSource
:
MaterialCollectionViewDataSource
=
collectionView
?
.
dataSource
as?
MaterialCollectionViewDataSource
{
if
let
dataSource
:
MaterialCollectionViewDataSource
=
collectionView
?
.
dataSource
as?
MaterialCollectionViewDataSource
{
prepareLayoutForItems
(
dataSource
.
items
())
prepareLayoutForItems
(
dataSource
Items
:
dataSource
.
items
())
}
}
}
}
public
override
func
targetContentOffset
ForProposedContentOffset
(
proposedContentOffset
:
CGPoint
)
->
CGPoint
{
public
override
func
targetContentOffset
(
forProposedContentOffset
proposedContentOffset
:
CGPoint
)
->
CGPoint
{
return
proposedContentOffset
return
proposedContentOffset
}
}
...
@@ -134,12 +134,10 @@ public class MaterialCollectionViewLayout: UICollectionViewLayout {
...
@@ -134,12 +134,10 @@ public class MaterialCollectionViewLayout: UICollectionViewLayout {
offset
.
x
=
contentInset
.
left
offset
.
x
=
contentInset
.
left
offset
.
y
=
contentInset
.
top
offset
.
y
=
contentInset
.
top
var
indexPath
:
NSIndexPath
?
for
i
in
0
..<
dataSourceItems
.
count
{
for
i
in
0
..<
dataSourceItems
.
count
{
let
item
:
MaterialDataSourceItem
=
dataSourceItems
[
i
]
let
item
:
MaterialDataSourceItem
=
dataSourceItems
[
i
]
indexPath
=
NSIndexPath
(
forItem
:
i
,
inS
ection
:
0
)
let
indexPath
=
IndexPath
(
item
:
i
,
s
ection
:
0
)
layoutItems
.
append
((
layoutAttributesForItem
AtIndexPath
(
indexPath
!
)
!
,
indexPath
!
))
layoutItems
.
append
((
layoutAttributesForItem
(
at
:
indexPath
)
!
,
indexPath
))
offset
.
x
+=
interimSpace
offset
.
x
+=
interimSpace
offset
.
x
+=
nil
==
item
.
width
?
itemSize
.
width
:
item
.
width
!
offset
.
x
+=
nil
==
item
.
width
?
itemSize
.
width
:
item
.
width
!
...
@@ -152,11 +150,11 @@ public class MaterialCollectionViewLayout: UICollectionViewLayout {
...
@@ -152,11 +150,11 @@ public class MaterialCollectionViewLayout: UICollectionViewLayout {
offset
.
y
+=
contentInset
.
bottom
-
interimSpace
offset
.
y
+=
contentInset
.
bottom
-
interimSpace
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
contentSize
=
CGSizeMake
(
offset
.
x
,
offset
.
y
)
contentSize
=
CGSize
(
width
:
offset
.
x
,
height
:
offset
.
y
)
}
else
if
.
V
ertical
==
scrollDirection
{
}
else
if
.
v
ertical
==
scrollDirection
{
contentSize
=
CGSizeMake
(
collectionView
!.
bounds
.
width
,
offset
.
y
)
contentSize
=
CGSize
(
width
:
collectionView
!.
bounds
.
width
,
height
:
offset
.
y
)
}
else
{
}
else
{
contentSize
=
CGSizeMake
(
offset
.
x
,
collectionView
!.
bounds
.
height
)
contentSize
=
CGSize
(
width
:
offset
.
x
,
height
:
collectionView
!.
bounds
.
height
)
}
}
}
}
}
}
Sources/iOS/MaterialLabel.swift
View file @
9a90a7d5
...
@@ -87,7 +87,7 @@ public class MaterialLabel : UILabel {
...
@@ -87,7 +87,7 @@ public class MaterialLabel : UILabel {
*/
*/
@IBInspectable
public
var
wrapped
:
Bool
{
@IBInspectable
public
var
wrapped
:
Bool
{
didSet
{
didSet
{
textLayer
.
w
rapped
=
wrapped
textLayer
.
isW
rapped
=
wrapped
}
}
}
}
...
@@ -148,6 +148,6 @@ public class MaterialLabel : UILabel {
...
@@ -148,6 +148,6 @@ public class MaterialLabel : UILabel {
*/
*/
public
func
prepareView
()
{
public
func
prepareView
()
{
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
textAlignment
=
.
L
eft
textAlignment
=
.
l
eft
}
}
}
}
Sources/iOS/MaterialTableViewCell.swift
View file @
9a90a7d5
...
@@ -240,12 +240,12 @@ public class MaterialTableViewCell: UITableViewCell {
...
@@ -240,12 +240,12 @@ public class MaterialTableViewCell: UITableViewCell {
/// Sets the shadow path.
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
shadowPathAutoSizeEnabled
{
if
.
none
==
depth
{
if
.
none
==
depth
Preset
{
shadowPath
=
nil
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
}
else
{
animate
(
Animation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
animate
(
animation
:
Animation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
}
}
}
}
}
}
...
...
Sources/iOS/MaterialTextLayer.swift
View file @
9a90a7d5
...
@@ -37,7 +37,7 @@ public class MaterialTextLayer : CATextLayer {
...
@@ -37,7 +37,7 @@ public class MaterialTextLayer : CATextLayer {
public
var
fontType
:
UIFont
?
{
public
var
fontType
:
UIFont
?
{
didSet
{
didSet
{
if
let
v
:
UIFont
=
fontType
{
if
let
v
:
UIFont
=
fontType
{
super
.
font
=
CGFont
CreateWithFontName
(
v
.
fontName
as
CFStringRef
)
!
super
.
font
=
CGFont
(
v
.
fontName
as
CFString
)
!
pointSize
=
v
.
pointSize
pointSize
=
v
.
pointSize
}
}
}
}
...
@@ -73,18 +73,18 @@ public class MaterialTextLayer : CATextLayer {
...
@@ -73,18 +73,18 @@ public class MaterialTextLayer : CATextLayer {
/**
/**
:name: textAlignment
:name: textAlignment
*/
*/
public
var
textAlignment
:
NSTextAlignment
=
.
L
eft
{
public
var
textAlignment
:
NSTextAlignment
=
.
l
eft
{
didSet
{
didSet
{
switch
textAlignment
{
switch
textAlignment
{
case
.
L
eft
:
case
.
l
eft
:
alignmentMode
=
kCAAlignmentLeft
alignmentMode
=
kCAAlignmentLeft
case
.
C
enter
:
case
.
c
enter
:
alignmentMode
=
kCAAlignmentCenter
alignmentMode
=
kCAAlignmentCenter
case
.
R
ight
:
case
.
r
ight
:
alignmentMode
=
kCAAlignmentRight
alignmentMode
=
kCAAlignmentRight
case
.
J
ustified
:
case
.
j
ustified
:
alignmentMode
=
kCAAlignmentJustified
alignmentMode
=
kCAAlignmentJustified
case
.
N
atural
:
case
.
n
atural
:
alignmentMode
=
kCAAlignmentNatural
alignmentMode
=
kCAAlignmentNatural
}
}
}
}
...
@@ -93,20 +93,20 @@ public class MaterialTextLayer : CATextLayer {
...
@@ -93,20 +93,20 @@ public class MaterialTextLayer : CATextLayer {
/**
/**
:name: lineBreakMode
:name: lineBreakMode
*/
*/
public
var
lineBreakMode
:
NSLineBreakMode
=
.
B
yWordWrapping
{
public
var
lineBreakMode
:
NSLineBreakMode
=
.
b
yWordWrapping
{
didSet
{
didSet
{
switch
lineBreakMode
{
switch
lineBreakMode
{
case
.
B
yWordWrapping
:
// Wrap at word boundaries, default
case
.
b
yWordWrapping
:
// Wrap at word boundaries, default
truncationMode
=
kCATruncationNone
truncationMode
=
kCATruncationNone
case
.
B
yCharWrapping
:
// Wrap at character boundaries
case
.
b
yCharWrapping
:
// Wrap at character boundaries
truncationMode
=
kCATruncationNone
truncationMode
=
kCATruncationNone
case
.
B
yClipping
:
// Simply clip
case
.
b
yClipping
:
// Simply clip
truncationMode
=
kCATruncationNone
truncationMode
=
kCATruncationNone
case
.
B
yTruncatingHead
:
// Truncate at head of line: "...wxyz"
case
.
b
yTruncatingHead
:
// Truncate at head of line: "...wxyz"
truncationMode
=
kCATruncationStart
truncationMode
=
kCATruncationStart
case
.
B
yTruncatingTail
:
// Truncate at tail of line: "abcd..."
case
.
b
yTruncatingTail
:
// Truncate at tail of line: "abcd..."
truncationMode
=
kCATruncationEnd
truncationMode
=
kCATruncationEnd
case
.
B
yTruncatingMiddle
:
// Truncate middle of line: "ab...yz"
case
.
b
yTruncatingMiddle
:
// Truncate middle of line: "ab...yz"
truncationMode
=
kCATruncationMiddle
truncationMode
=
kCATruncationMiddle
}
}
}
}
...
@@ -196,9 +196,9 @@ public class MaterialTextLayer : CATextLayer {
...
@@ -196,9 +196,9 @@ public class MaterialTextLayer : CATextLayer {
:name: stringSize
:name: stringSize
*/
*/
public
func
stringSize
(
constrainedToWidth
width
:
Double
)
->
CGSize
{
public
func
stringSize
(
constrainedToWidth
width
:
Double
)
->
CGSize
{
if
let
v
:
UIFont
=
fontType
{
if
let
v
=
fontType
{
if
0
<
text
?
.
utf16
.
count
{
if
0
<
text
?
.
utf16
.
count
{
return
v
.
stringSize
(
text
!
,
constrainedToWidth
:
width
)
return
v
.
stringSize
(
string
:
text
!
,
constrainedToWidth
:
width
)
}
}
}
}
return
CGSize
.
zero
return
CGSize
.
zero
...
@@ -209,9 +209,9 @@ public class MaterialTextLayer : CATextLayer {
...
@@ -209,9 +209,9 @@ public class MaterialTextLayer : CATextLayer {
*/
*/
internal
func
prepareLayer
()
{
internal
func
prepareLayer
()
{
textColor
=
Color
.
black
textColor
=
Color
.
black
textAlignment
=
.
L
eft
textAlignment
=
.
l
eft
w
rapped
=
true
isW
rapped
=
true
contentsScale
=
Device
.
scale
contentsScale
=
Device
.
scale
lineBreakMode
=
.
B
yWordWrapping
lineBreakMode
=
.
b
yWordWrapping
}
}
}
}
Sources/iOS/MenuController.swift
View file @
9a90a7d5
...
@@ -42,7 +42,7 @@ public extension UIViewController {
...
@@ -42,7 +42,7 @@ public extension UIViewController {
if
viewController
is
MenuController
{
if
viewController
is
MenuController
{
return
viewController
as?
MenuController
return
viewController
as?
MenuController
}
}
viewController
=
viewController
?
.
parent
ViewController
viewController
=
viewController
?
.
parent
}
}
return
nil
return
nil
}
}
...
@@ -62,7 +62,7 @@ public class MenuController : RootController {
...
@@ -62,7 +62,7 @@ public class MenuController : RootController {
if
true
==
isUserInteractionEnabled
{
if
true
==
isUserInteractionEnabled
{
isUserInteractionEnabled
=
false
isUserInteractionEnabled
=
false
rootViewController
.
view
.
alpha
=
0.5
rootViewController
.
view
.
alpha
=
0.5
menuView
.
open
(
completion
)
menuView
.
open
(
completion
:
completion
)
}
}
}
}
...
@@ -74,7 +74,7 @@ public class MenuController : RootController {
...
@@ -74,7 +74,7 @@ public class MenuController : RootController {
public
func
closeMenu
(
completion
:
(()
->
Void
)?
=
nil
)
{
public
func
closeMenu
(
completion
:
(()
->
Void
)?
=
nil
)
{
if
false
==
isUserInteractionEnabled
{
if
false
==
isUserInteractionEnabled
{
rootViewController
.
view
.
alpha
=
1
rootViewController
.
view
.
alpha
=
1
menuView
.
close
({
[
weak
self
]
in
menuView
.
close
(
completion
:
{
[
weak
self
]
in
self
?
.
isUserInteractionEnabled
=
true
self
?
.
isUserInteractionEnabled
=
true
completion
?()
completion
?()
})
})
...
...
Sources/iOS/MenuView.swift
View file @
9a90a7d5
...
@@ -33,6 +33,7 @@ import UIKit
...
@@ -33,6 +33,7 @@ import UIKit
@objc(MenuViewDelegate)
@objc(MenuViewDelegate)
public
protocol
MenuViewDelegate
:
MaterialDelegate
{
public
protocol
MenuViewDelegate
:
MaterialDelegate
{
/// Gets called when the user taps outside menu buttons.
/// Gets called when the user taps outside menu buttons.
@objc
optional
func
menuViewDidTapOutside
(
menuView
:
MenuView
)
optional
func
menuViewDidTapOutside
(
menuView
:
MenuView
)
}
}
...
@@ -89,26 +90,26 @@ public class MenuView : PulseView {
...
@@ -89,26 +90,26 @@ public class MenuView : PulseView {
}
}
}
}
public
override
func
hitTest
(
point
:
CGPoint
,
withEvent
event
:
UIEvent
?)
->
UIView
?
{
public
override
func
hitTest
(
_
point
:
CGPoint
,
with
event
:
UIEvent
?)
->
UIView
?
{
/**
/**
Since the subviews will be outside the bounds of this view,
Since the subviews will be outside the bounds of this view,
we need to look at the subviews to see if we have a hit.
we need to look at the subviews to see if we have a hit.
*/
*/
guard
!
h
idden
else
{
guard
!
isH
idden
else
{
return
nil
return
nil
}
}
for
v
in
subviews
{
for
v
in
subviews
{
let
p
:
CGPoint
=
v
.
convertPoint
(
point
,
fromView
:
self
)
let
p
=
v
.
convert
(
point
,
from
:
self
)
if
CGRectContainsPoint
(
v
.
bounds
,
p
)
{
if
v
.
bounds
.
contains
(
p
)
{
return
v
.
hitTest
(
p
,
with
Event
:
event
)
return
v
.
hitTest
(
p
,
with
:
event
)
}
}
}
}
if
menu
.
o
pened
{
if
menu
.
isO
pened
{
(
delegate
as?
MenuViewDelegate
)?
.
menuViewDidTapOutside
?(
self
)
(
delegate
as?
MenuViewDelegate
)?
.
menuViewDidTapOutside
?(
menuView
:
self
)
}
}
return
super
.
hitTest
(
point
,
with
Event
:
event
)
return
super
.
hitTest
(
point
,
with
:
event
)
}
}
}
}
Sources/iOS/NavigationBar.swift
View file @
9a90a7d5
...
@@ -69,7 +69,7 @@ public class NavigationBar : UINavigationBar {
...
@@ -69,7 +69,7 @@ public class NavigationBar : UINavigationBar {
}
}
/// A wrapper around grid.contentInset.
/// A wrapper around grid.contentInset.
@IBInspectable
public
var
contentInset
:
Insets
=
EdgeInsets
.
zero
{
@IBInspectable
public
var
contentInset
:
Edge
Insets
=
EdgeInsets
.
zero
{
didSet
{
didSet
{
layoutSubviews
()
layoutSubviews
()
}
}
...
@@ -205,25 +205,25 @@ public class NavigationBar : UINavigationBar {
...
@@ -205,25 +205,25 @@ public class NavigationBar : UINavigationBar {
}
}
}
}
public
override
func
sizeThatFits
(
size
:
CGSize
)
->
CGSize
{
public
override
func
sizeThatFits
(
_
size
:
CGSize
)
->
CGSize
{
return
intrinsicContentSize
()
return
intrinsicContentSize
()
}
}
public
override
func
layoutSubviews
()
{
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
if
let
v
:
UINavigationItem
=
topItem
{
if
let
v
=
topItem
{
layoutNavigationItem
(
v
)
layoutNavigationItem
(
item
:
v
)
}
}
if
let
v
:
UINavigationItem
=
backItem
{
if
let
v
=
backItem
{
layoutNavigationItem
(
v
)
layoutNavigationItem
(
item
:
v
)
}
}
}
}
public
override
func
push
NavigationItem
(
item
:
UINavigationItem
,
animated
:
Bool
)
{
public
override
func
push
Item
(
_
item
:
UINavigationItem
,
animated
:
Bool
)
{
super
.
push
Navigation
Item
(
item
,
animated
:
animated
)
super
.
pushItem
(
item
,
animated
:
animated
)
layoutNavigationItem
(
item
)
layoutNavigationItem
(
item
:
item
)
}
}
/**
/**
...
@@ -232,10 +232,11 @@ public class NavigationBar : UINavigationBar {
...
@@ -232,10 +232,11 @@ public class NavigationBar : UINavigationBar {
*/
*/
internal
func
layoutNavigationItem
(
item
:
UINavigationItem
)
{
internal
func
layoutNavigationItem
(
item
:
UINavigationItem
)
{
if
willRenderView
{
if
willRenderView
{
prepareItem
(
item
)
prepareItem
(
item
:
item
)
let
titleView
=
prepareTitleView
(
item
:
item
)
let
contentView
=
prepareContentView
(
item
:
item
)
if
let
titleView
:
UIView
=
prepareTitleView
(
item
)
{
if
let
contentView
:
UIView
=
prepareContentView
(
item
)
{
if
let
g
:
Int
=
Int
(
width
/
gridFactor
)
{
if
let
g
:
Int
=
Int
(
width
/
gridFactor
)
{
let
columns
:
Int
=
g
+
1
let
columns
:
Int
=
g
+
1
...
@@ -325,8 +326,6 @@ public class NavigationBar : UINavigationBar {
...
@@ -325,8 +326,6 @@ public class NavigationBar : UINavigationBar {
}
}
}
}
}
}
}
}
/**
/**
Prepares the view instance when intialized. When subclassing,
Prepares the view instance when intialized. When subclassing,
...
@@ -336,16 +335,16 @@ public class NavigationBar : UINavigationBar {
...
@@ -336,16 +335,16 @@ public class NavigationBar : UINavigationBar {
when subclassing.
when subclassing.
*/
*/
public
func
prepareView
()
{
public
func
prepareView
()
{
barStyle
=
.
B
lack
barStyle
=
.
b
lack
t
ranslucent
=
false
isT
ranslucent
=
false
depth
=
.
depth1
depth
Preset
=
.
depth1
interimSpacePreset
=
.
interimSpace1
interimSpacePreset
=
.
interimSpace1
contentEdgeInsetsPreset
=
.
S
quare1
contentEdgeInsetsPreset
=
.
s
quare1
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
backButtonImage
=
Icon
.
cm
.
arrowBack
backButtonImage
=
Icon
.
cm
.
arrowBack
let
image
:
UIImage
?
=
UIImage
.
imageWithColor
(
Color
.
clear
,
size
:
CGSizeMake
(
1
,
1
))
let
image
:
UIImage
?
=
UIImage
.
imageWithColor
(
color
:
Color
.
clear
,
size
:
CGSize
(
width
:
1
,
height
:
1
))
shadowImage
=
image
shadowImage
=
image
setBackgroundImage
(
image
,
for
BarMetrics
:
.
D
efault
)
setBackgroundImage
(
image
,
for
:
.
d
efault
)
backgroundColor
=
Color
.
white
backgroundColor
=
Color
.
white
}
}
...
@@ -379,7 +378,7 @@ public class NavigationBar : UINavigationBar {
...
@@ -379,7 +378,7 @@ public class NavigationBar : UINavigationBar {
if
nil
==
item
.
contentView
{
if
nil
==
item
.
contentView
{
item
.
contentView
=
UIView
(
frame
:
CGRect
.
zero
)
item
.
contentView
=
UIView
(
frame
:
CGRect
.
zero
)
}
}
item
.
contentView
!.
grid
.
axis
.
direction
=
.
V
ertical
item
.
contentView
!.
grid
.
axis
.
direction
=
.
v
ertical
return
item
.
contentView
!
return
item
.
contentView
!
}
}
}
}
Sources/iOS/NavigationController.swift
View file @
9a90a7d5
...
@@ -45,7 +45,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -45,7 +45,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
*/
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
NS
Bundle
?)
{
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
}
}
...
@@ -58,15 +58,15 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -58,15 +58,15 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
setViewControllers
([
rootViewController
],
animated
:
false
)
setViewControllers
([
rootViewController
],
animated
:
false
)
}
}
public
override
func
viewWillAppear
(
animated
:
Bool
)
{
public
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
super
.
viewWillAppear
(
animated
)
if
let
v
:
UIGestureRecognizer
=
interactivePopGestureRecognizer
{
if
let
v
:
UIGestureRecognizer
=
interactivePopGestureRecognizer
{
if
let
x
:
NavigationDrawerController
=
navigationDrawerController
{
if
let
x
:
NavigationDrawerController
=
navigationDrawerController
{
if
let
l
:
UIPanGestureRecognizer
=
x
.
leftPanGesture
{
if
let
l
:
UIPanGestureRecognizer
=
x
.
leftPanGesture
{
l
.
require
GestureRecognizerToFail
(
v
)
l
.
require
(
toFail
:
v
)
}
}
if
let
r
:
UIPanGestureRecognizer
=
x
.
rightPanGesture
{
if
let
r
:
UIPanGestureRecognizer
=
x
.
rightPanGesture
{
r
.
require
GestureRecognizerToFail
(
v
)
r
.
require
(
toFail
:
v
)
}
}
}
}
}
}
...
@@ -77,12 +77,12 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -77,12 +77,12 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
prepareView
()
prepareView
()
}
}
public
override
func
viewDidAppear
(
animated
:
Bool
)
{
public
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
super
.
viewDidAppear
(
animated
)
super
.
viewDidAppear
(
animated
)
// Load the initial topItem.
// Load the initial topItem.
if
let
v
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
if
let
v
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
if
let
item
:
UINavigationItem
=
v
.
topItem
{
if
let
item
:
UINavigationItem
=
v
.
topItem
{
v
.
layoutNavigationItem
(
item
)
v
.
layoutNavigationItem
(
item
:
item
)
}
}
}
}
}
}
...
@@ -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
,
shouldReceiveTouch
touch
:
UITouch
)
->
Bool
{
public
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
return
interactivePopGestureRecognizer
==
gestureRecognizer
&&
nil
!=
navigationBar
.
backItem
return
interactivePopGestureRecognizer
==
gestureRecognizer
&&
nil
!=
navigationBar
.
backItem
}
}
...
@@ -110,9 +110,8 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -110,9 +110,8 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
if
let
v
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
if
let
v
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
let
backButton
:
IconButton
=
IconButton
()
let
backButton
:
IconButton
=
IconButton
()
backButton
.
pulseColor
=
Color
.
white
backButton
.
pulseColor
=
Color
.
white
backButton
.
setImage
(
v
.
backButtonImage
,
forState
:
.
Normal
)
backButton
.
setImage
(
v
.
backButtonImage
,
for
:
.
highlighted
)
backButton
.
setImage
(
v
.
backButtonImage
,
forState
:
.
Highlighted
)
backButton
.
addTarget
(
self
,
action
:
#selector(
handleBackButton
)
,
for
:
.
touchUpInside
)
backButton
.
addTarget
(
self
,
action
:
#selector(
handleBackButton
)
,
forControlEvents
:
.
TouchUpInside
)
if
var
c
:
Array
<
UIControl
>
=
item
.
leftControls
{
if
var
c
:
Array
<
UIControl
>
=
item
.
leftControls
{
c
.
append
(
backButton
)
c
.
append
(
backButton
)
...
@@ -122,14 +121,14 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -122,14 +121,14 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
}
}
item
.
backButton
=
backButton
item
.
backButton
=
backButton
v
.
layoutNavigationItem
(
item
)
v
.
layoutNavigationItem
(
item
:
item
)
}
}
return
true
return
true
}
}
/// Handler for the back button.
/// Handler for the back button.
internal
func
handleBackButton
()
{
internal
func
handleBackButton
()
{
popViewController
Animated
(
true
)
popViewController
(
animated
:
true
)
}
}
/**
/**
...
@@ -145,7 +144,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -145,7 +144,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
// This ensures the panning gesture is available when going back between views.
// This ensures the panning gesture is available when going back between views.
if
let
v
:
UIGestureRecognizer
=
interactivePopGestureRecognizer
{
if
let
v
:
UIGestureRecognizer
=
interactivePopGestureRecognizer
{
v
.
e
nabled
=
true
v
.
isE
nabled
=
true
v
.
delegate
=
self
v
.
delegate
=
self
}
}
}
}
...
...
Sources/iOS/NavigationDrawerController.swift
View file @
9a90a7d5
...
@@ -31,9 +31,9 @@
...
@@ -31,9 +31,9 @@
import
UIKit
import
UIKit
@objc
@objc
public
enum
NavigationDrawerPosition
:
NSInteger
{
public
enum
NavigationDrawerPosition
:
NSInteger
{
case
L
eft
case
l
eft
case
R
ight
case
r
ight
}
}
public
extension
UIViewController
{
public
extension
UIViewController
{
...
@@ -60,60 +60,69 @@ public protocol NavigationDrawerControllerDelegate {
...
@@ -60,60 +60,69 @@ public protocol NavigationDrawerControllerDelegate {
An optional delegation method that is fired before the
An optional delegation method that is fired before the
NavigationDrawerController opens.
NavigationDrawerController opens.
*/
*/
@objc
optional
func
navigationDrawerWillOpen
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
NavigationDrawerPosition
)
optional
func
navigationDrawerWillOpen
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
NavigationDrawerPosition
)
/**
/**
An optional delegation method that is fired after the
An optional delegation method that is fired after the
NavigationDrawerController opened.
NavigationDrawerController opened.
*/
*/
@objc
optional
func
navigationDrawerDidOpen
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
NavigationDrawerPosition
)
optional
func
navigationDrawerDidOpen
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
NavigationDrawerPosition
)
/**
/**
An optional delegation method that is fired before the
An optional delegation method that is fired before the
NavigationDrawerController closes.
NavigationDrawerController closes.
*/
*/
@objc
optional
func
navigationDrawerWillClose
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
NavigationDrawerPosition
)
optional
func
navigationDrawerWillClose
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
NavigationDrawerPosition
)
/**
/**
An optional delegation method that is fired after the
An optional delegation method that is fired after the
NavigationDrawerController closed.
NavigationDrawerController closed.
*/
*/
@objc
optional
func
navigationDrawerDidClose
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
NavigationDrawerPosition
)
optional
func
navigationDrawerDidClose
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
NavigationDrawerPosition
)
/**
/**
An optional delegation method that is fired when the
An optional delegation method that is fired when the
NavigationDrawerController pan gesture begins.
NavigationDrawerController pan gesture begins.
*/
*/
@objc
optional
func
navigationDrawerPanDidBegin
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
NavigationDrawerPosition
)
optional
func
navigationDrawerPanDidBegin
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
NavigationDrawerPosition
)
/**
/**
An optional delegation method that is fired when the
An optional delegation method that is fired when the
NavigationDrawerController pan gesture changes position.
NavigationDrawerController pan gesture changes position.
*/
*/
@objc
optional
func
navigationDrawerPanDidChange
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
NavigationDrawerPosition
)
optional
func
navigationDrawerPanDidChange
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
NavigationDrawerPosition
)
/**
/**
An optional delegation method that is fired when the
An optional delegation method that is fired when the
NavigationDrawerController pan gesture ends.
NavigationDrawerController pan gesture ends.
*/
*/
@objc
optional
func
navigationDrawerPanDidEnd
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
NavigationDrawerPosition
)
optional
func
navigationDrawerPanDidEnd
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
NavigationDrawerPosition
)
/**
/**
An optional delegation method that is fired when the
An optional delegation method that is fired when the
NavigationDrawerController tap gesture executes.
NavigationDrawerController tap gesture executes.
*/
*/
@objc
optional
func
navigationDrawerDidTap
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
NavigationDrawerPosition
)
optional
func
navigationDrawerDidTap
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
NavigationDrawerPosition
)
/**
/**
An optional delegation method that is fired when the
An optional delegation method that is fired when the
status bar is about to change display, hidden or not.
status bar is about to change display, hidden or not.
*/
*/
@objc
optional
func
navigationDrawerStatusBarHiddenState
(
navigationDrawerController
:
NavigationDrawerController
,
hidden
:
Bool
)
optional
func
navigationDrawerStatusBarHiddenState
(
navigationDrawerController
:
NavigationDrawerController
,
hidden
:
Bool
)
}
}
@IBDesignable
@IBDesignable
@objc(NavigationDrawerController)
@objc(NavigationDrawerController)
public
class
NavigationDrawerController
:
RootController
,
UIGestureRecognizerDelegate
{
public
class
NavigationDrawerController
:
RootController
,
UIGestureRecognizerDelegate
{
/**
/**
A CGFloat property that is used internally to track
A CGFloat property that is used internally to track
the original (x) position of the container view when panning.
the original (x) position of the container view when panning.
...
@@ -275,7 +284,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -275,7 +284,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
A DepthPreset property that is used to set the depth of the
A DepthPreset property that is used to set the depth of the
leftView when opened.
leftView when opened.
*/
*/
public
var
d
epthPreset
=
.
depth1
public
var
depthPreset
:
D
epthPreset
=
.
depth1
/**
/**
A View property that is used to hide and reveal the
A View property that is used to hide and reveal the
...
@@ -358,7 +367,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -358,7 +367,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
*/
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
NS
Bundle
?)
{
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
}
}
...
@@ -404,7 +413,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -404,7 +413,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
if
let
vc
:
UIViewController
=
leftViewController
{
if
let
vc
:
UIViewController
=
leftViewController
{
vc
.
view
.
frame
.
size
.
width
=
v
.
width
vc
.
view
.
frame
.
size
.
width
=
v
.
width
vc
.
view
.
frame
.
size
.
height
=
v
.
height
vc
.
view
.
frame
.
size
.
height
=
v
.
height
vc
.
view
.
center
=
CGPointMake
(
v
.
width
/
2
,
v
.
height
/
2
)
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
width
/
2
,
y
:
v
.
height
/
2
)
}
}
}
}
...
@@ -415,13 +424,13 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -415,13 +424,13 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
if
let
vc
:
UIViewController
=
rightViewController
{
if
let
vc
:
UIViewController
=
rightViewController
{
vc
.
view
.
frame
.
size
.
width
=
v
.
width
vc
.
view
.
frame
.
size
.
width
=
v
.
width
vc
.
view
.
frame
.
size
.
height
=
v
.
height
vc
.
view
.
frame
.
size
.
height
=
v
.
height
vc
.
view
.
center
=
CGPointMake
(
v
.
width
/
2
,
v
.
height
/
2
)
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
width
/
2
,
y
:
v
.
height
/
2
)
}
}
}
}
}
}
public
override
func
viewWillTransitionToSize
(
size
:
CGSize
,
withTransitionCoordinator
coordinator
:
UIViewControllerTransitionCoordinator
)
{
public
override
func
viewWillTransition
(
to
size
:
CGSize
,
with
coordinator
:
UIViewControllerTransitionCoordinator
)
{
super
.
viewWillTransitionToSize
(
size
,
withTransitionCoordinator
:
coordinator
)
super
.
viewWillTransition
(
to
:
size
,
with
:
coordinator
)
// Ensures the view is hidden.
// Ensures the view is hidden.
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
v
.
position
.
x
=
size
.
width
+
(
openedRightView
?
-
v
.
width
:
v
.
width
)
/
2
v
.
position
.
x
=
size
.
width
+
(
openedRightView
?
-
v
.
width
:
v
.
width
)
/
2
...
@@ -452,46 +461,46 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -452,46 +461,46 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
v
.
shadowPathAutoSizeEnabled
=
false
v
.
shadowPathAutoSizeEnabled
=
false
if
hide
{
if
hide
{
UIView
.
animate
WithDuration
(
duration
,
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
bounds
.
size
.
width
=
width
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
-
width
/
2
v
.
position
.
x
=
-
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
s
.
rootViewController
.
view
.
alpha
=
1
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
shadowPathAutoSizeEnabled
=
true
v
.
shadowPathAutoSizeEnabled
=
true
s
.
layoutSubviews
()
s
.
layoutSubviews
()
s
.
hideView
(
v
)
s
.
hideView
(
container
:
v
)
}
}
}
}
}
else
{
}
else
{
UIView
.
animate
WithDuration
(
duration
,
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
bounds
.
size
.
width
=
width
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
width
/
2
v
.
position
.
x
=
width
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
s
.
rootViewController
.
view
.
alpha
=
0.5
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
shadowPathAutoSizeEnabled
=
true
v
.
shadowPathAutoSizeEnabled
=
true
s
.
layoutSubviews
()
s
.
layoutSubviews
()
s
.
showView
(
v
)
s
.
showView
(
container
:
v
)
}
}
}
}
}
}
}
else
{
}
else
{
v
.
bounds
.
size
.
width
=
width
v
.
bounds
.
size
.
width
=
width
if
hide
{
if
hide
{
hideView
(
v
)
hideView
(
container
:
v
)
v
.
position
.
x
=
-
v
.
width
/
2
v
.
position
.
x
=
-
v
.
width
/
2
rootViewController
.
view
.
alpha
=
1
rootViewController
.
view
.
alpha
=
1
}
else
{
}
else
{
v
.
shadowPathAutoSizeEnabled
=
false
v
.
shadowPathAutoSizeEnabled
=
false
showView
(
v
)
showView
(
container
:
v
)
v
.
position
.
x
=
width
/
2
v
.
position
.
x
=
width
/
2
rootViewController
.
view
.
alpha
=
0.5
rootViewController
.
view
.
alpha
=
0.5
v
.
shadowPathAutoSizeEnabled
=
true
v
.
shadowPathAutoSizeEnabled
=
true
...
@@ -526,46 +535,46 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -526,46 +535,46 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
v
.
shadowPathAutoSizeEnabled
=
false
v
.
shadowPathAutoSizeEnabled
=
false
if
hide
{
if
hide
{
UIView
.
animate
WithDuration
(
duration
,
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
bounds
.
size
.
width
=
width
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
s
.
view
.
bounds
.
width
+
width
/
2
v
.
position
.
x
=
s
.
view
.
bounds
.
width
+
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
s
.
rootViewController
.
view
.
alpha
=
1
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
shadowPathAutoSizeEnabled
=
true
v
.
shadowPathAutoSizeEnabled
=
true
s
.
layoutSubviews
()
s
.
layoutSubviews
()
s
.
hideView
(
v
)
s
.
hideView
(
container
:
v
)
}
}
}
}
}
else
{
}
else
{
UIView
.
animate
WithDuration
(
duration
,
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
bounds
.
size
.
width
=
width
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
s
.
view
.
bounds
.
width
-
width
/
2
v
.
position
.
x
=
s
.
view
.
bounds
.
width
-
width
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
s
.
rootViewController
.
view
.
alpha
=
0.5
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
shadowPathAutoSizeEnabled
=
true
v
.
shadowPathAutoSizeEnabled
=
true
s
.
layoutSubviews
()
s
.
layoutSubviews
()
s
.
showView
(
v
)
s
.
showView
(
container
:
v
)
}
}
}
}
}
}
}
else
{
}
else
{
v
.
bounds
.
size
.
width
=
width
v
.
bounds
.
size
.
width
=
width
if
hide
{
if
hide
{
hideView
(
v
)
hideView
(
container
:
v
)
v
.
position
.
x
=
view
.
bounds
.
width
+
v
.
width
/
2
v
.
position
.
x
=
view
.
bounds
.
width
+
v
.
width
/
2
rootViewController
.
view
.
alpha
=
1
rootViewController
.
view
.
alpha
=
1
}
else
{
}
else
{
v
.
shadowPathAutoSizeEnabled
=
false
v
.
shadowPathAutoSizeEnabled
=
false
showView
(
v
)
showView
(
container
:
v
)
v
.
position
.
x
=
view
.
bounds
.
width
-
width
/
2
v
.
position
.
x
=
view
.
bounds
.
width
-
width
/
2
rootViewController
.
view
.
alpha
=
0.5
rootViewController
.
view
.
alpha
=
0.5
v
.
shadowPathAutoSizeEnabled
=
true
v
.
shadowPathAutoSizeEnabled
=
true
...
@@ -583,7 +592,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -583,7 +592,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
leftView. Defaults to 0.
leftView. Defaults to 0.
*/
*/
public
func
toggleLeftView
(
velocity
:
CGFloat
=
0
)
{
public
func
toggleLeftView
(
velocity
:
CGFloat
=
0
)
{
openedLeftView
?
closeLeftView
(
velocity
)
:
openLeftView
(
velocity
)
openedLeftView
?
closeLeftView
(
velocity
:
velocity
)
:
openLeftView
(
velocity
:
velocity
)
}
}
/**
/**
...
@@ -594,7 +603,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -594,7 +603,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
leftView. Defaults to 0.
leftView. Defaults to 0.
*/
*/
public
func
toggleRightView
(
velocity
:
CGFloat
=
0
)
{
public
func
toggleRightView
(
velocity
:
CGFloat
=
0
)
{
openedRightView
?
closeRightView
(
velocity
)
:
openRightView
(
velocity
)
openedRightView
?
closeRightView
(
velocity
:
velocity
)
:
openRightView
(
velocity
:
velocity
)
}
}
/**
/**
...
@@ -607,16 +616,16 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -607,16 +616,16 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
if
enabledLeftView
{
if
enabledLeftView
{
if
let
v
:
View
=
leftView
{
if
let
v
:
View
=
leftView
{
hideStatusBar
()
hideStatusBar
()
showView
(
v
)
showView
(
container
:
v
)
isUserInteractionEnabled
=
false
isUserInteractionEnabled
=
false
delegate
?
.
navigationDrawerWillOpen
?(
self
,
position
:
.
L
eft
)
delegate
?
.
navigationDrawerWillOpen
?(
navigationDrawerController
:
self
,
position
:
.
l
eft
)
UIView
.
animate
WithDuration
(
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
animations
:
{
v
.
position
.
x
=
v
.
width
/
2
v
.
position
.
x
=
v
.
width
/
2
self
.
rootViewController
.
view
.
alpha
=
0.5
self
.
rootViewController
.
view
.
alpha
=
0.5
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
s
.
delegate
?
.
navigationDrawerDidOpen
?(
s
,
position
:
.
L
eft
)
s
.
delegate
?
.
navigationDrawerDidOpen
?(
navigationDrawerController
:
s
,
position
:
.
l
eft
)
}
}
}
}
}
}
...
@@ -633,18 +642,18 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -633,18 +642,18 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
if
enabledRightView
{
if
enabledRightView
{
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
hideStatusBar
()
hideStatusBar
()
showView
(
v
)
showView
(
container
:
v
)
isUserInteractionEnabled
=
false
isUserInteractionEnabled
=
false
delegate
?
.
navigationDrawerWillOpen
?(
self
,
position
:
.
R
ight
)
delegate
?
.
navigationDrawerWillOpen
?(
navigationDrawerController
:
self
,
position
:
.
r
ight
)
UIView
.
animate
WithDuration
(
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
position
.
x
=
s
.
view
.
bounds
.
width
-
v
.
width
/
2
v
.
position
.
x
=
s
.
view
.
bounds
.
width
-
v
.
width
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
s
.
rootViewController
.
view
.
alpha
=
0.5
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
s
.
delegate
?
.
navigationDrawerDidOpen
?(
s
,
position
:
.
R
ight
)
s
.
delegate
?
.
navigationDrawerDidOpen
?(
navigationDrawerController
:
s
,
position
:
.
r
ight
)
}
}
}
}
}
}
...
@@ -661,18 +670,18 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -661,18 +670,18 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
if
enabledLeftView
{
if
enabledLeftView
{
if
let
v
:
View
=
leftView
{
if
let
v
:
View
=
leftView
{
isUserInteractionEnabled
=
true
isUserInteractionEnabled
=
true
delegate
?
.
navigationDrawerWillClose
?(
self
,
position
:
.
L
eft
)
delegate
?
.
navigationDrawerWillClose
?(
navigationDrawerController
:
self
,
position
:
.
l
eft
)
UIView
.
animate
WithDuration
(
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
position
.
x
=
-
v
.
width
/
2
v
.
position
.
x
=
-
v
.
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
s
.
rootViewController
.
view
.
alpha
=
1
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
s
.
hideView
(
v
)
s
.
hideView
(
container
:
v
)
s
.
toggleStatusBar
()
s
.
toggleStatusBar
()
s
.
delegate
?
.
navigationDrawerDidClose
?(
s
,
position
:
.
L
eft
)
s
.
delegate
?
.
navigationDrawerDidClose
?(
navigationDrawerController
:
s
,
position
:
.
l
eft
)
}
}
}
}
}
}
...
@@ -689,18 +698,18 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -689,18 +698,18 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
if
enabledRightView
{
if
enabledRightView
{
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
isUserInteractionEnabled
=
true
isUserInteractionEnabled
=
true
delegate
?
.
navigationDrawerWillClose
?(
self
,
position
:
.
R
ight
)
delegate
?
.
navigationDrawerWillClose
?(
navigationDrawerController
:
self
,
position
:
.
r
ight
)
UIView
.
animate
WithDuration
(
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
v
.
position
.
x
=
s
.
view
.
bounds
.
width
+
v
.
width
/
2
v
.
position
.
x
=
s
.
view
.
bounds
.
width
+
v
.
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
s
.
rootViewController
.
view
.
alpha
=
1
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
s
.
hideView
(
v
)
s
.
hideView
(
container
:
v
)
s
.
toggleStatusBar
()
s
.
toggleStatusBar
()
s
.
delegate
?
.
navigationDrawerDidClose
?(
s
,
position
:
.
R
ight
)
s
.
delegate
?
.
navigationDrawerDidClose
?(
navigationDrawerController
:
s
,
position
:
.
r
ight
)
}
}
}
}
}
}
...
@@ -713,11 +722,11 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -713,11 +722,11 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter touch: The UITouch event.
- Parameter touch: The UITouch event.
- Returns: A Boolean of whether to continue the gesture or not.
- Returns: A Boolean of whether to continue the gesture or not.
*/
*/
public
func
gestureRecognizer
(
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceiveTouch
touch
:
UITouch
)
->
Bool
{
public
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
if
!
openedRightView
&&
gestureRecognizer
==
leftPanGesture
&&
(
openedLeftView
||
isPointContainedWithinLeftThreshold
(
touch
.
locationInView
(
view
)))
{
if
!
openedRightView
&&
gestureRecognizer
==
leftPanGesture
&&
(
openedLeftView
||
isPointContainedWithinLeftThreshold
(
point
:
touch
.
location
(
in
:
view
)))
{
return
true
return
true
}
}
if
!
openedLeftView
&&
gestureRecognizer
==
rightPanGesture
&&
(
openedRightView
||
isPointContainedWithinRighThreshold
(
touch
.
locationInView
(
view
)))
{
if
!
openedLeftView
&&
gestureRecognizer
==
rightPanGesture
&&
(
openedRightView
||
isPointContainedWithinRighThreshold
(
point
:
touch
.
location
(
in
:
view
)))
{
return
true
return
true
}
}
if
openedLeftView
&&
gestureRecognizer
==
leftTapGesture
{
if
openedLeftView
&&
gestureRecognizer
==
leftTapGesture
{
...
@@ -735,20 +744,21 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -735,20 +744,21 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter recognizer: A UIPanGestureRecognizer that is
- Parameter recognizer: A UIPanGestureRecognizer that is
passed to the handler when recognized.
passed to the handler when recognized.
*/
*/
@objc
internal
func
handleLeftViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
internal
func
handleLeftViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
if
enabledLeftView
&&
(
openedLeftView
||
!
openedRightView
&&
isPointContainedWithinLeftThreshold
(
recognizer
.
locationInView
(
view
)))
{
if
enabledLeftView
&&
(
openedLeftView
||
!
openedRightView
&&
isPointContainedWithinLeftThreshold
(
point
:
recognizer
.
location
(
in
:
view
)))
{
if
let
v
:
View
=
leftView
{
if
let
v
:
View
=
leftView
{
let
point
:
CGPoint
=
recognizer
.
location
InView
(
view
)
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
view
)
// Animate the panel.
// Animate the panel.
switch
recognizer
.
state
{
switch
recognizer
.
state
{
case
.
B
egan
:
case
.
b
egan
:
originalX
=
v
.
position
.
x
originalX
=
v
.
position
.
x
showView
(
v
)
showView
(
container
:
v
)
delegate
?
.
navigationDrawerPanDidBegin
?(
self
,
point
:
point
,
position
:
.
L
eft
)
delegate
?
.
navigationDrawerPanDidBegin
?(
navigationDrawerController
:
self
,
point
:
point
,
position
:
.
l
eft
)
case
.
C
hanged
:
case
.
c
hanged
:
let
w
:
CGFloat
=
v
.
width
let
w
:
CGFloat
=
v
.
width
let
translationX
:
CGFloat
=
recognizer
.
translation
InView
(
v
)
.
x
let
translationX
:
CGFloat
=
recognizer
.
translation
(
in
:
v
)
.
x
v
.
position
.
x
=
originalX
+
translationX
>
(
w
/
2
)
?
(
w
/
2
)
:
originalX
+
translationX
v
.
position
.
x
=
originalX
+
translationX
>
(
w
/
2
)
?
(
w
/
2
)
:
originalX
+
translationX
...
@@ -759,19 +769,19 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -759,19 +769,19 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
hideStatusBar
()
hideStatusBar
()
}
}
delegate
?
.
navigationDrawerPanDidChange
?(
self
,
point
:
point
,
position
:
.
L
eft
)
delegate
?
.
navigationDrawerPanDidChange
?(
navigationDrawerController
:
self
,
point
:
point
,
position
:
.
l
eft
)
case
.
Ended
,
.
Cancelled
,
.
F
ailed
:
case
.
ended
,
.
cancelled
,
.
f
ailed
:
let
p
:
CGPoint
=
recognizer
.
velocity
InView
(
recognizer
.
view
)
let
p
:
CGPoint
=
recognizer
.
velocity
(
in
:
recognizer
.
view
)
let
x
:
CGFloat
=
p
.
x
>=
1000
||
p
.
x
<=
-
1000
?
p
.
x
:
0
let
x
:
CGFloat
=
p
.
x
>=
1000
||
p
.
x
<=
-
1000
?
p
.
x
:
0
delegate
?
.
navigationDrawerPanDidEnd
?(
self
,
point
:
point
,
position
:
.
L
eft
)
delegate
?
.
navigationDrawerPanDidEnd
?(
navigationDrawerController
:
self
,
point
:
point
,
position
:
.
l
eft
)
if
v
.
x
<=
-
leftViewWidth
+
leftViewThreshold
||
x
<
-
1000
{
if
v
.
x
<=
-
leftViewWidth
+
leftViewThreshold
||
x
<
-
1000
{
closeLeftView
(
x
)
closeLeftView
(
velocity
:
x
)
}
else
{
}
else
{
openLeftView
(
x
)
openLeftView
(
velocity
:
x
)
}
}
case
.
P
ossible
:
break
case
.
p
ossible
:
break
}
}
}
}
}
}
...
@@ -783,20 +793,21 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -783,20 +793,21 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter recognizer: A UIPanGestureRecognizer that is
- Parameter recognizer: A UIPanGestureRecognizer that is
passed to the handler when recognized.
passed to the handler when recognized.
*/
*/
@objc
internal
func
handleRightViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
internal
func
handleRightViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
if
enabledRightView
&&
(
openedRightView
||
!
openedLeftView
&&
isPointContainedWithinRighThreshold
(
recognizer
.
locationInView
(
view
)))
{
if
enabledRightView
&&
(
openedRightView
||
!
openedLeftView
&&
isPointContainedWithinRighThreshold
(
point
:
recognizer
.
location
(
in
:
view
)))
{
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
let
point
:
CGPoint
=
recognizer
.
location
InView
(
view
)
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
view
)
// Animate the panel.
// Animate the panel.
switch
recognizer
.
state
{
switch
recognizer
.
state
{
case
.
B
egan
:
case
.
b
egan
:
originalX
=
v
.
position
.
x
originalX
=
v
.
position
.
x
showView
(
v
)
showView
(
container
:
v
)
delegate
?
.
navigationDrawerPanDidBegin
?(
self
,
point
:
point
,
position
:
.
R
ight
)
delegate
?
.
navigationDrawerPanDidBegin
?(
navigationDrawerController
:
self
,
point
:
point
,
position
:
.
r
ight
)
case
.
C
hanged
:
case
.
c
hanged
:
let
w
:
CGFloat
=
v
.
width
let
w
:
CGFloat
=
v
.
width
let
translationX
:
CGFloat
=
recognizer
.
translation
InView
(
v
)
.
x
let
translationX
:
CGFloat
=
recognizer
.
translation
(
in
:
v
)
.
x
v
.
position
.
x
=
originalX
+
translationX
<
view
.
bounds
.
width
-
(
w
/
2
)
?
view
.
bounds
.
width
-
(
w
/
2
)
:
originalX
+
translationX
v
.
position
.
x
=
originalX
+
translationX
<
view
.
bounds
.
width
-
(
w
/
2
)
?
view
.
bounds
.
width
-
(
w
/
2
)
:
originalX
+
translationX
...
@@ -807,19 +818,19 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -807,19 +818,19 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
hideStatusBar
()
hideStatusBar
()
}
}
delegate
?
.
navigationDrawerPanDidChange
?(
self
,
point
:
point
,
position
:
.
R
ight
)
delegate
?
.
navigationDrawerPanDidChange
?(
navigationDrawerController
:
self
,
point
:
point
,
position
:
.
r
ight
)
case
.
Ended
,
.
Cancelled
,
.
F
ailed
:
case
.
ended
,
.
cancelled
,
.
f
ailed
:
let
p
:
CGPoint
=
recognizer
.
velocity
InView
(
recognizer
.
view
)
let
p
:
CGPoint
=
recognizer
.
velocity
(
in
:
recognizer
.
view
)
let
x
:
CGFloat
=
p
.
x
>=
1000
||
p
.
x
<=
-
1000
?
p
.
x
:
0
let
x
:
CGFloat
=
p
.
x
>=
1000
||
p
.
x
<=
-
1000
?
p
.
x
:
0
delegate
?
.
navigationDrawerPanDidEnd
?(
self
,
point
:
point
,
position
:
.
R
ight
)
delegate
?
.
navigationDrawerPanDidEnd
?(
navigationDrawerController
:
self
,
point
:
point
,
position
:
.
r
ight
)
if
v
.
x
>=
rightViewThreshold
||
x
>
1000
{
if
v
.
x
>=
rightViewThreshold
||
x
>
1000
{
closeRightView
(
x
)
closeRightView
(
velocity
:
x
)
}
else
{
}
else
{
openRightView
(
x
)
openRightView
(
velocity
:
x
)
}
}
case
.
P
ossible
:
break
case
.
p
ossible
:
break
}
}
}
}
}
}
...
@@ -831,11 +842,12 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -831,11 +842,12 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter recognizer: A UITapGestureRecognizer that is
- Parameter recognizer: A UITapGestureRecognizer that is
passed to the handler when recognized.
passed to the handler when recognized.
*/
*/
@objc
internal
func
handleLeftViewTapGesture
(
recognizer
:
UITapGestureRecognizer
)
{
internal
func
handleLeftViewTapGesture
(
recognizer
:
UITapGestureRecognizer
)
{
if
openedLeftView
{
if
openedLeftView
{
if
let
v
:
View
=
leftView
{
if
let
v
:
View
=
leftView
{
delegate
?
.
navigationDrawerDidTap
?(
self
,
point
:
recognizer
.
locationInView
(
view
),
position
:
.
L
eft
)
delegate
?
.
navigationDrawerDidTap
?(
navigationDrawerController
:
self
,
point
:
recognizer
.
location
(
in
:
view
),
position
:
.
l
eft
)
if
enabledLeftView
&&
openedLeftView
&&
!
isPointContainedWithinView
(
v
,
point
:
recognizer
.
locationInView
(
v
))
{
if
enabledLeftView
&&
openedLeftView
&&
!
isPointContainedWithinView
(
container
:
v
,
point
:
recognizer
.
location
(
in
:
v
))
{
closeLeftView
()
closeLeftView
()
}
}
}
}
...
@@ -848,11 +860,12 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -848,11 +860,12 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter recognizer: A UITapGestureRecognizer that is
- Parameter recognizer: A UITapGestureRecognizer that is
passed to the handler when recognized.
passed to the handler when recognized.
*/
*/
@objc
internal
func
handleRightViewTapGesture
(
recognizer
:
UITapGestureRecognizer
)
{
internal
func
handleRightViewTapGesture
(
recognizer
:
UITapGestureRecognizer
)
{
if
openedRightView
{
if
openedRightView
{
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
delegate
?
.
navigationDrawerDidTap
?(
self
,
point
:
recognizer
.
locationInView
(
view
),
position
:
.
R
ight
)
delegate
?
.
navigationDrawerDidTap
?(
navigationDrawerController
:
self
,
point
:
recognizer
.
location
(
in
:
view
),
position
:
.
r
ight
)
if
enabledRightView
&&
openedRightView
&&
!
isPointContainedWithinView
(
v
,
point
:
recognizer
.
locationInView
(
v
))
{
if
enabledRightView
&&
openedRightView
&&
!
isPointContainedWithinView
(
container
:
v
,
point
:
recognizer
.
location
(
in
:
v
))
{
closeRightView
()
closeRightView
()
}
}
}
}
...
@@ -862,21 +875,21 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -862,21 +875,21 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
/// Prepares the contentViewController.
/// Prepares the contentViewController.
private
func
prepareContentViewController
()
{
private
func
prepareContentViewController
()
{
contentViewController
.
view
.
backgroundColor
=
Color
.
black
contentViewController
.
view
.
backgroundColor
=
Color
.
black
prepareViewControllerWithinContainer
(
contentViewController
,
container
:
view
)
prepareViewControllerWithinContainer
(
viewController
:
contentViewController
,
container
:
view
)
view
.
sendSubview
ToBack
(
contentViewController
.
view
)
view
.
sendSubview
(
toBack
:
contentViewController
.
view
)
}
}
/// A method that prepares the leftViewController.
/// A method that prepares the leftViewController.
private
func
prepareLeftViewController
()
{
private
func
prepareLeftViewController
()
{
if
let
v
:
View
=
leftView
{
if
let
v
:
View
=
leftView
{
prepareViewControllerWithinContainer
(
leftViewController
,
container
:
v
)
prepareViewControllerWithinContainer
(
viewController
:
leftViewController
,
container
:
v
)
}
}
}
}
/// A method that prepares the rightViewController.
/// A method that prepares the rightViewController.
private
func
prepareRightViewController
()
{
private
func
prepareRightViewController
()
{
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
prepareViewControllerWithinContainer
(
rightViewController
,
container
:
v
)
prepareViewControllerWithinContainer
(
viewController
:
rightViewController
,
container
:
v
)
}
}
}
}
...
@@ -890,7 +903,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -890,7 +903,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
leftViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
leftViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
leftView
=
View
()
leftView
=
View
()
leftView
!.
frame
=
CGRectMake
(
0
,
0
,
leftViewWidth
,
view
.
frame
.
height
)
leftView
!.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
leftViewWidth
,
height
:
view
.
frame
.
height
)
leftView
!.
backgroundColor
=
Color
.
clear
leftView
!.
backgroundColor
=
Color
.
clear
view
.
addSubview
(
leftView
!
)
view
.
addSubview
(
leftView
!
)
...
@@ -910,7 +923,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -910,7 +923,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
rightViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
rightViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
rightView
=
View
()
rightView
=
View
()
rightView
!.
frame
=
CGRectMake
(
0
,
0
,
rightViewWidth
,
view
.
frame
.
height
)
rightView
!.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
rightViewWidth
,
height
:
view
.
frame
.
height
)
rightView
!.
backgroundColor
=
Color
.
clear
rightView
!.
backgroundColor
=
Color
.
clear
view
.
addSubview
(
rightView
!
)
view
.
addSubview
(
rightView
!
)
...
@@ -923,7 +936,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -923,7 +936,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
/// Prepare the left pan gesture.
/// Prepare the left pan gesture.
private
func
prepareLeftPanGesture
()
{
private
func
prepareLeftPanGesture
()
{
if
nil
==
leftPanGesture
{
if
nil
==
leftPanGesture
{
leftPanGesture
=
UIPanGestureRecognizer
(
target
:
self
,
action
:
#selector(
handleLeftViewPanGesture(
_
:)
)
)
leftPanGesture
=
UIPanGestureRecognizer
(
target
:
self
,
action
:
#selector(
handleLeftViewPanGesture(
recognizer
:)
)
)
leftPanGesture
!.
delegate
=
self
leftPanGesture
!.
delegate
=
self
view
.
addGestureRecognizer
(
leftPanGesture
!
)
view
.
addGestureRecognizer
(
leftPanGesture
!
)
}
}
...
@@ -932,7 +945,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -932,7 +945,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
/// Prepare the left tap gesture.
/// Prepare the left tap gesture.
private
func
prepareLeftTapGesture
()
{
private
func
prepareLeftTapGesture
()
{
if
nil
==
leftTapGesture
{
if
nil
==
leftTapGesture
{
leftTapGesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
handleLeftViewTapGesture(
_
:)
)
)
leftTapGesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
handleLeftViewTapGesture(
recognizer
:)
)
)
leftTapGesture
!.
delegate
=
self
leftTapGesture
!.
delegate
=
self
leftTapGesture
!.
cancelsTouchesInView
=
false
leftTapGesture
!.
cancelsTouchesInView
=
false
view
.
addGestureRecognizer
(
leftTapGesture
!
)
view
.
addGestureRecognizer
(
leftTapGesture
!
)
...
@@ -942,7 +955,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -942,7 +955,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
/// Prepares the right pan gesture.
/// Prepares the right pan gesture.
private
func
prepareRightPanGesture
()
{
private
func
prepareRightPanGesture
()
{
if
nil
==
rightPanGesture
{
if
nil
==
rightPanGesture
{
rightPanGesture
=
UIPanGestureRecognizer
(
target
:
self
,
action
:
#selector(
handleRightViewPanGesture(
_
:)
)
)
rightPanGesture
=
UIPanGestureRecognizer
(
target
:
self
,
action
:
#selector(
handleRightViewPanGesture(
recognizer
:)
)
)
rightPanGesture
!.
delegate
=
self
rightPanGesture
!.
delegate
=
self
view
.
addGestureRecognizer
(
rightPanGesture
!
)
view
.
addGestureRecognizer
(
rightPanGesture
!
)
}
}
...
@@ -951,7 +964,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -951,7 +964,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
/// Prepares the right tap gesture.
/// Prepares the right tap gesture.
private
func
prepareRightTapGesture
()
{
private
func
prepareRightTapGesture
()
{
if
nil
==
rightTapGesture
{
if
nil
==
rightTapGesture
{
rightTapGesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
handleRightViewTapGesture(
_
:)
)
)
rightTapGesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
handleRightViewTapGesture(
recognizer
:)
)
)
rightTapGesture
!.
delegate
=
self
rightTapGesture
!.
delegate
=
self
rightTapGesture
!.
cancelsTouchesInView
=
false
rightTapGesture
!.
cancelsTouchesInView
=
false
view
.
addGestureRecognizer
(
rightTapGesture
!
)
view
.
addGestureRecognizer
(
rightTapGesture
!
)
...
@@ -1007,14 +1020,14 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -1007,14 +1020,14 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
private
func
showStatusBar
()
{
private
func
showStatusBar
()
{
if
isStatusBarHidden
{
if
isStatusBarHidden
{
isStatusBarHidden
=
false
isStatusBarHidden
=
false
dispatch_async
(
dispatch_get_main_queue
(),
{
[
weak
self
]
in
DispatchQueue
.
main
.
async
{
[
weak
self
]
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
if
let
v
:
UIWindow
=
UIApplication
.
sharedApplication
()
.
keyWindow
{
if
let
v
=
UIApplication
.
shared
()
.
keyWindow
{
v
.
windowLevel
=
UIWindowLevelNormal
v
.
windowLevel
=
UIWindowLevelNormal
s
.
delegate
?
.
navigationDrawerStatusBarHiddenState
?(
s
,
hidden
:
false
)
s
.
delegate
?
.
navigationDrawerStatusBarHiddenState
?(
navigationDrawerController
:
s
,
hidden
:
false
)
}
}
}
}
}
})
}
}
}
}
...
@@ -1023,14 +1036,14 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -1023,14 +1036,14 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
if
enableHideStatusBar
{
if
enableHideStatusBar
{
if
!
isStatusBarHidden
{
if
!
isStatusBarHidden
{
isStatusBarHidden
=
true
isStatusBarHidden
=
true
dispatch_async
(
dispatch_get_main_queue
(),
{
[
weak
self
]
in
DispatchQueue
.
main
.
async
{
[
weak
self
]
in
if
let
s
:
NavigationDrawerController
=
self
{
if
let
s
=
self
{
if
let
v
:
UIWindow
=
UIApplication
.
sharedApplication
()
.
keyWindow
{
if
let
v
=
UIApplication
.
shared
()
.
keyWindow
{
v
.
windowLevel
=
UIWindowLevelStatusBar
+
1
v
.
windowLevel
=
UIWindowLevelStatusBar
+
1
s
.
delegate
?
.
navigationDrawerStatusBarHiddenState
?(
s
,
hidden
:
true
)
s
.
delegate
?
.
navigationDrawerStatusBarHiddenState
?(
navigationDrawerController
:
s
,
hidden
:
true
)
}
}
}
}
}
})
}
}
}
}
}
}
...
@@ -1081,7 +1094,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -1081,7 +1094,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
otherwise.
otherwise.
*/
*/
private
func
isPointContainedWithinView
(
container
:
UIView
,
point
:
CGPoint
)
->
Bool
{
private
func
isPointContainedWithinView
(
container
:
UIView
,
point
:
CGPoint
)
->
Bool
{
return
CGRectContainsPoint
(
container
.
bounds
,
point
)
return
container
.
bounds
.
contains
(
point
)
}
}
/**
/**
...
@@ -1089,7 +1102,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -1089,7 +1102,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter container: A container view.
- Parameter container: A container view.
*/
*/
private
func
showView
(
container
:
View
)
{
private
func
showView
(
container
:
View
)
{
container
.
depth
=
depth
container
.
depth
Preset
=
depthPreset
container
.
isHidden
=
false
container
.
isHidden
=
false
}
}
...
@@ -1098,7 +1111,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
...
@@ -1098,7 +1111,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter container: A container view.
- Parameter container: A container view.
*/
*/
private
func
hideView
(
container
:
View
)
{
private
func
hideView
(
container
:
View
)
{
container
.
depth
=
.
none
container
.
depth
Preset
=
.
none
container
.
isHidden
=
true
container
.
isHidden
=
true
}
}
}
}
Sources/iOS/NavigationItem.swift
View file @
9a90a7d5
...
@@ -67,15 +67,15 @@ public class MaterialAssociatedObjectNavigationItem {
...
@@ -67,15 +67,15 @@ public class MaterialAssociatedObjectNavigationItem {
/// Prepares the titleLabel.
/// Prepares the titleLabel.
private
func
prepareTitleLabel
()
{
private
func
prepareTitleLabel
()
{
titleLabel
=
UILabel
()
titleLabel
=
UILabel
()
titleLabel
.
font
=
RobotoFont
.
mediumWithSize
(
17
)
titleLabel
.
font
=
RobotoFont
.
mediumWithSize
(
size
:
17
)
titleLabel
.
textAlignment
=
.
C
enter
titleLabel
.
textAlignment
=
.
c
enter
}
}
/// Prepares the detailLabel.
/// Prepares the detailLabel.
private
func
prepareDetailLabel
()
{
private
func
prepareDetailLabel
()
{
detailLabel
=
UILabel
()
detailLabel
=
UILabel
()
detailLabel
.
font
=
RobotoFont
.
regularWithSize
(
12
)
detailLabel
.
font
=
RobotoFont
.
regularWithSize
(
size
:
12
)
detailLabel
.
textAlignment
=
.
C
enter
detailLabel
.
textAlignment
=
.
c
enter
}
}
}
}
...
@@ -83,12 +83,12 @@ public extension UINavigationItem {
...
@@ -83,12 +83,12 @@ public extension UINavigationItem {
/// NavigationItem reference.
/// NavigationItem reference.
public
internal(set)
var
item
:
MaterialAssociatedObjectNavigationItem
{
public
internal(set)
var
item
:
MaterialAssociatedObjectNavigationItem
{
get
{
get
{
return
AssociatedObject
(
self
,
key
:
&
MaterialAssociatedObjectNavigationItemKey
)
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialAssociatedObjectNavigationItemKey
)
{
return
MaterialAssociatedObjectNavigationItem
()
return
MaterialAssociatedObjectNavigationItem
()
}
}
}
}
set
(
value
)
{
set
(
value
)
{
AssociateObject
(
self
,
key
:
&
MaterialAssociatedObjectNavigationItemKey
,
value
:
value
)
AssociateObject
(
base
:
self
,
key
:
&
MaterialAssociatedObjectNavigationItemKey
,
value
:
value
)
}
}
}
}
...
...
Sources/iOS/RootController.swift
View file @
9a90a7d5
...
@@ -114,21 +114,21 @@ public class RootController : UIViewController {
...
@@ -114,21 +114,21 @@ public class RootController : UIViewController {
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
)
{
public
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
transitionFromViewController
(
rootViewController
,
transition
(
from
:
rootViewController
,
toViewController
:
toViewController
,
to
:
toViewController
,
duration
:
duration
,
duration
:
duration
,
options
:
options
,
options
:
options
,
animations
:
animations
,
animations
:
animations
,
completion
:
{
[
weak
self
]
(
result
:
Bool
)
in
completion
:
{
[
weak
self
]
(
result
:
Bool
)
in
if
let
s
:
RootController
=
self
{
if
let
s
:
RootController
=
self
{
toViewController
.
didMove
ToParentViewController
(
s
)
toViewController
.
didMove
(
toParentViewController
:
s
)
s
.
rootViewController
.
removeFromParentViewController
()
s
.
rootViewController
.
removeFromParentViewController
()
s
.
rootViewController
=
toViewController
s
.
rootViewController
=
toViewController
s
.
rootViewController
.
view
.
clipsToBounds
=
true
s
.
rootViewController
.
view
.
clipsToBounds
=
true
s
.
rootViewController
.
view
.
autoresizingMask
=
[
.
FlexibleWidth
,
.
F
lexibleHeight
]
s
.
rootViewController
.
view
.
autoresizingMask
=
[
.
flexibleWidth
,
.
f
lexibleHeight
]
s
.
rootViewController
.
view
.
contentScaleFactor
=
Device
.
scale
s
.
rootViewController
.
view
.
contentScaleFactor
=
Device
.
scale
completion
?(
result
)
completion
?(
result
)
}
}
...
@@ -157,7 +157,7 @@ public class RootController : UIViewController {
...
@@ -157,7 +157,7 @@ public class RootController : UIViewController {
/// A method that prepares the rootViewController.
/// A method that prepares the rootViewController.
internal
func
prepareRootViewController
()
{
internal
func
prepareRootViewController
()
{
prepareViewControllerWithinContainer
(
rootViewController
,
container
:
view
)
prepareViewControllerWithinContainer
(
viewController
:
rootViewController
,
container
:
view
)
}
}
/**
/**
...
@@ -172,9 +172,9 @@ public class RootController : UIViewController {
...
@@ -172,9 +172,9 @@ public class RootController : UIViewController {
if
let
v
:
UIViewController
=
viewController
{
if
let
v
:
UIViewController
=
viewController
{
addChildViewController
(
v
)
addChildViewController
(
v
)
container
.
addSubview
(
v
.
view
)
container
.
addSubview
(
v
.
view
)
v
.
didMove
ToParentViewController
(
self
)
v
.
didMove
(
toParentViewController
:
self
)
v
.
view
.
clipsToBounds
=
true
v
.
view
.
clipsToBounds
=
true
v
.
view
.
autoresizingMask
=
[
.
FlexibleWidth
,
.
F
lexibleHeight
]
v
.
view
.
autoresizingMask
=
[
.
flexibleWidth
,
.
f
lexibleHeight
]
v
.
view
.
contentScaleFactor
=
Device
.
scale
v
.
view
.
contentScaleFactor
=
Device
.
scale
}
}
}
}
...
...
Sources/iOS/SearchBar.swift
View file @
9a90a7d5
...
@@ -40,9 +40,9 @@ public class SearchBar : BarView {
...
@@ -40,9 +40,9 @@ public class SearchBar : BarView {
/// Handle the clearButton manually.
/// Handle the clearButton manually.
@IBInspectable
public
var
clearButtonAutoHandleEnabled
:
Bool
=
true
{
@IBInspectable
public
var
clearButtonAutoHandleEnabled
:
Bool
=
true
{
didSet
{
didSet
{
clearButton
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
ControlEvents
:
.
T
ouchUpInside
)
clearButton
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
:
.
t
ouchUpInside
)
if
clearButtonAutoHandleEnabled
{
if
clearButtonAutoHandleEnabled
{
clearButton
.
addTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
ControlEvents
:
.
T
ouchUpInside
)
clearButton
.
addTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
:
.
t
ouchUpInside
)
}
}
}
}
}
}
...
@@ -71,7 +71,7 @@ public class SearchBar : BarView {
...
@@ -71,7 +71,7 @@ public class SearchBar : BarView {
@IBInspectable
public
var
placeholder
:
String
?
{
@IBInspectable
public
var
placeholder
:
String
?
{
didSet
{
didSet
{
if
let
v
:
String
=
placeholder
{
if
let
v
:
String
=
placeholder
{
textField
.
attributedPlaceholder
=
NS
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
textField
.
attributedPlaceholder
=
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
}
}
}
}
}
}
...
@@ -80,7 +80,7 @@ public class SearchBar : BarView {
...
@@ -80,7 +80,7 @@ public class SearchBar : BarView {
@IBInspectable
public
var
placeholderColor
:
UIColor
=
Color
.
darkText
.
others
{
@IBInspectable
public
var
placeholderColor
:
UIColor
=
Color
.
darkText
.
others
{
didSet
{
didSet
{
if
let
v
:
String
=
placeholder
{
if
let
v
:
String
=
placeholder
{
textField
.
attributedPlaceholder
=
NS
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
textField
.
attributedPlaceholder
=
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
}
}
}
}
}
}
...
@@ -136,7 +136,7 @@ public class SearchBar : BarView {
...
@@ -136,7 +136,7 @@ public class SearchBar : BarView {
/// Layout the clearButton.
/// Layout the clearButton.
public
func
layoutClearButton
()
{
public
func
layoutClearButton
()
{
let
h
:
CGFloat
=
textField
.
frame
.
height
let
h
:
CGFloat
=
textField
.
frame
.
height
clearButton
.
frame
=
CGRectMake
(
textField
.
frame
.
width
-
h
,
0
,
h
,
h
)
clearButton
.
frame
=
CGRect
(
x
:
textField
.
frame
.
width
-
h
,
y
:
0
,
width
:
h
,
height
:
h
)
}
}
/// Clears the textField text.
/// Clears the textField text.
...
@@ -148,9 +148,9 @@ public class SearchBar : BarView {
...
@@ -148,9 +148,9 @@ public class SearchBar : BarView {
private
func
prepareTextField
()
{
private
func
prepareTextField
()
{
textField
=
UITextField
()
textField
=
UITextField
()
textField
.
contentScaleFactor
=
Device
.
scale
textField
.
contentScaleFactor
=
Device
.
scale
textField
.
font
=
RobotoFont
.
regularWithSize
(
17
)
textField
.
font
=
RobotoFont
.
regularWithSize
(
size
:
17
)
textField
.
backgroundColor
=
Color
.
clear
textField
.
backgroundColor
=
Color
.
clear
textField
.
clearButtonMode
=
.
W
hileEditing
textField
.
clearButtonMode
=
.
w
hileEditing
tintColor
=
placeholderColor
tintColor
=
placeholderColor
textColor
=
Color
.
darkText
.
primary
textColor
=
Color
.
darkText
.
primary
placeholder
=
"Search"
placeholder
=
"Search"
...
@@ -163,11 +163,10 @@ public class SearchBar : BarView {
...
@@ -163,11 +163,10 @@ public class SearchBar : BarView {
clearButton
=
IconButton
()
clearButton
=
IconButton
()
clearButton
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
clearButton
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
clearButton
.
tintColor
=
placeholderColor
clearButton
.
tintColor
=
placeholderColor
clearButton
.
setImage
(
image
,
forState
:
.
Normal
)
clearButton
.
setImage
(
image
,
for
:
.
highlighted
)
clearButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
clearButtonAutoHandleEnabled
=
true
clearButtonAutoHandleEnabled
=
true
textField
.
clearButtonMode
=
.
N
ever
textField
.
clearButtonMode
=
.
n
ever
textField
.
rightViewMode
=
.
W
hileEditing
textField
.
rightViewMode
=
.
w
hileEditing
textField
.
rightView
=
clearButton
textField
.
rightView
=
clearButton
}
}
}
}
Sources/iOS/SearchBarController.swift
View file @
9a90a7d5
...
@@ -42,7 +42,7 @@ public extension UIViewController {
...
@@ -42,7 +42,7 @@ public extension UIViewController {
if
viewController
is
SearchBarController
{
if
viewController
is
SearchBarController
{
return
viewController
as?
SearchBarController
return
viewController
as?
SearchBarController
}
}
viewController
=
viewController
?
.
parent
ViewController
viewController
=
viewController
?
.
parent
}
}
return
nil
return
nil
}
}
...
...
Sources/iOS/StatusBarController.swift
View file @
9a90a7d5
...
@@ -42,7 +42,7 @@ public extension UIViewController {
...
@@ -42,7 +42,7 @@ public extension UIViewController {
if
viewController
is
StatusBarController
{
if
viewController
is
StatusBarController
{
return
viewController
as?
StatusBarController
return
viewController
as?
StatusBarController
}
}
viewController
=
viewController
?
.
parent
ViewController
viewController
=
viewController
?
.
parent
}
}
return
nil
return
nil
}
}
...
@@ -80,7 +80,7 @@ public class StatusBarController : RootController {
...
@@ -80,7 +80,7 @@ public class StatusBarController : RootController {
private
func
prepareStatusBarView
()
{
private
func
prepareStatusBarView
()
{
statusBarView
=
View
()
statusBarView
=
View
()
statusBarView
.
zPosition
=
3000
statusBarView
.
zPosition
=
3000
statusBarView
.
backgroundColor
=
Color
.
black
.
colorW
ithAlphaComponent
(
0.12
)
statusBarView
.
backgroundColor
=
Color
.
black
.
w
ithAlphaComponent
(
0.12
)
view
.
layout
(
statusBarView
)
.
top
(
0
)
.
horizontally
()
.
height
(
20
)
view
.
layout
(
statusBarView
)
.
top
(
0
)
.
horizontally
()
.
height
(
20
)
}
}
}
}
Sources/iOS/TabBar.swift
View file @
9a90a7d5
...
@@ -31,8 +31,8 @@
...
@@ -31,8 +31,8 @@
import
UIKit
import
UIKit
public
enum
TabBarLineAlignment
{
public
enum
TabBarLineAlignment
{
case
T
op
case
t
op
case
B
ottom
case
b
ottom
}
}
public
class
TabBar
:
View
{
public
class
TabBar
:
View
{
...
@@ -40,7 +40,7 @@ public class TabBar : View {
...
@@ -40,7 +40,7 @@ public class TabBar : View {
public
private(set)
var
line
:
UIView
!
public
private(set)
var
line
:
UIView
!
/// A value for the line alignment.
/// A value for the line alignment.
public
var
lineAlignment
:
TabBarLineAlignment
=
.
B
ottom
{
public
var
lineAlignment
:
TabBarLineAlignment
=
.
b
ottom
{
didSet
{
didSet
{
layoutSubviews
()
layoutSubviews
()
}
}
...
@@ -79,20 +79,21 @@ public class TabBar : View {
...
@@ -79,20 +79,21 @@ public class TabBar : View {
b
.
grid
.
columns
=
columns
b
.
grid
.
columns
=
columns
b
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
b
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
b
.
layer
.
cornerRadius
=
0
b
.
layer
.
cornerRadius
=
0
b
.
removeTarget
(
self
,
action
:
#selector(
handleButton(_:)
)
,
forControlEvents
:
.
T
ouchUpInside
)
b
.
removeTarget
(
self
,
action
:
#selector(
handleButton(button:)
)
,
for
:
.
t
ouchUpInside
)
b
.
addTarget
(
self
,
action
:
#selector(
handleButton(
_:)
)
,
forControlEvents
:
.
T
ouchUpInside
)
b
.
addTarget
(
self
,
action
:
#selector(
handleButton(
button:)
)
,
for
:
.
t
ouchUpInside
)
}
}
grid
.
views
=
v
as
[
UIView
]
grid
.
views
=
v
as
[
UIView
]
line
.
frame
=
CGRectMake
(
0
,
.
Bottom
==
lineAlignment
?
height
-
3
:
0
,
v
.
first
!.
frame
.
width
,
3
)
line
.
frame
=
CGRect
(
x
:
0
,
y
:
.
bottom
==
lineAlignment
?
height
-
3
:
0
,
width
:
v
.
first
!.
frame
.
width
,
height
:
3
)
}
}
}
}
}
}
}
}
/// Handles the button touch event.
/// Handles the button touch event.
@objc
internal
func
handleButton
(
button
:
UIButton
)
{
internal
func
handleButton
(
button
:
UIButton
)
{
UIView
.
animate
WithDuration
(
0.25
,
animations
:
{
[
weak
self
]
in
UIView
.
animate
(
withDuration
:
0.25
,
animations
:
{
[
weak
self
]
in
if
let
s
:
TabBar
=
self
{
if
let
s
=
self
{
s
.
line
.
frame
.
origin
.
x
=
button
.
frame
.
origin
.
x
s
.
line
.
frame
.
origin
.
x
=
button
.
frame
.
origin
.
x
s
.
line
.
frame
.
size
.
width
=
button
.
frame
.
size
.
width
s
.
line
.
frame
.
size
.
width
=
button
.
frame
.
size
.
width
}
}
...
@@ -108,7 +109,7 @@ public class TabBar : View {
...
@@ -108,7 +109,7 @@ public class TabBar : View {
*/
*/
public
override
func
prepareView
()
{
public
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
autoresizingMask
=
.
F
lexibleWidth
autoresizingMask
=
.
f
lexibleWidth
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
prepareBottomLayer
()
prepareBottomLayer
()
}
}
...
...
Sources/iOS/Text.swift
View file @
9a90a7d5
...
@@ -44,6 +44,7 @@ public protocol TextDelegate {
...
@@ -44,6 +44,7 @@ public protocol TextDelegate {
- Parameter range: The range of characters that are being
- Parameter range: The range of characters that are being
edited.
edited.
*/
*/
@objc
optional
func
textWillProcessEdit
(
text
:
Text
,
textStorage
:
TextStorage
,
string
:
String
,
range
:
NSRange
)
optional
func
textWillProcessEdit
(
text
:
Text
,
textStorage
:
TextStorage
,
string
:
String
,
range
:
NSRange
)
/**
/**
...
@@ -60,7 +61,8 @@ public protocol TextDelegate {
...
@@ -60,7 +61,8 @@ public protocol TextDelegate {
- Parameter stop: Halts a service which is either
- Parameter stop: Halts a service which is either
publishing or resolving.
publishing or resolving.
*/
*/
optional
func
textDidProcessEdit
(
text
:
Text
,
textStorage
:
TextStorage
,
string
:
String
,
result
:
NSTextCheckingResult
?,
flags
:
NSMatchingFlags
,
stop
:
UnsafeMutablePointer
<
ObjCBool
>
)
@objc
optional
func
textDidProcessEdit
(
text
:
Text
,
textStorage
:
TextStorage
,
string
:
String
,
result
:
TextCheckingResult
?,
flags
:
RegularExpression
.
MatchingFlags
,
stop
:
UnsafeMutablePointer
<
ObjCBool
>
)
}
}
@objc(Text)
@objc(Text)
...
@@ -111,19 +113,19 @@ public class Text : NSObject {
...
@@ -111,19 +113,19 @@ public class Text : NSObject {
/// Prepares the TextStorage regular expression for matching.
/// Prepares the TextStorage regular expression for matching.
private
func
prepareTextStorageExpression
()
{
private
func
prepareTextStorageExpression
()
{
textStorage
.
expression
=
try
?
NS
RegularExpression
(
pattern
:
pattern
,
options
:
[])
textStorage
.
expression
=
try
?
RegularExpression
(
pattern
:
pattern
,
options
:
[])
}
}
/// Prepares the pre and post processing callbacks.
/// Prepares the pre and post processing callbacks.
private
func
prepareTextStorageProcessingCallbacks
()
{
private
func
prepareTextStorageProcessingCallbacks
()
{
textStorage
.
textWillProcessEdit
=
{
[
weak
self
]
(
textStorage
:
TextStorage
,
string
:
String
,
range
:
NSRange
)
->
Void
in
textStorage
.
textWillProcessEdit
=
{
[
weak
self
]
(
textStorage
:
TextStorage
,
string
:
String
,
range
:
NSRange
)
->
Void
in
if
let
s
:
Text
=
self
{
if
let
s
:
Text
=
self
{
s
.
delegate
?
.
textWillProcessEdit
?(
s
,
textStorage
:
textStorage
,
string
:
string
,
range
:
range
)
s
.
delegate
?
.
textWillProcessEdit
?(
text
:
s
,
textStorage
:
textStorage
,
string
:
string
,
range
:
range
)
}
}
}
}
textStorage
.
textDidProcessEdit
=
{
[
weak
self
]
(
textStorage
:
TextStorage
,
result
:
NSTextCheckingResult
?,
flags
:
NS
MatchingFlags
,
stop
:
UnsafeMutablePointer
<
ObjCBool
>
)
->
Void
in
textStorage
.
textDidProcessEdit
=
{
[
weak
self
]
(
textStorage
:
TextStorage
,
result
:
TextCheckingResult
?,
flags
:
RegularExpression
.
MatchingFlags
,
stop
:
UnsafeMutablePointer
<
ObjCBool
>
)
->
Void
in
if
let
s
:
Text
=
self
{
if
let
s
:
Text
=
self
{
s
.
delegate
?
.
textDidProcessEdit
?(
s
,
textStorage
:
textStorage
,
string
:
textStorage
.
string
,
result
:
result
,
flags
:
flags
,
stop
:
stop
)
s
.
delegate
?
.
textDidProcessEdit
?(
text
:
s
,
textStorage
:
textStorage
,
string
:
textStorage
.
string
,
result
:
result
,
flags
:
flags
,
stop
:
stop
)
}
}
}
}
}
}
...
...
Sources/iOS/TextField.swift
View file @
9a90a7d5
...
@@ -30,10 +30,10 @@
...
@@ -30,10 +30,10 @@
import
UIKit
import
UIKit
public
protocol
TextFieldDelegate
:
UITextFieldDelegate
{}
public
protocol
TextFieldDelegate
:
UITextFieldDelegate
{}
@IBDesignable
@IBDesignable
public
class
TextField
:
UITextField
{
public
class
TextField
:
UITextField
{
/// A Boolean that indicates if the TextField is in an animating state.
/// A Boolean that indicates if the TextField is in an animating state.
public
private(set)
var
animating
:
Bool
=
false
public
private(set)
var
animating
:
Bool
=
false
...
@@ -96,7 +96,7 @@ public class TextField : UITextField {
...
@@ -96,7 +96,7 @@ public class TextField : UITextField {
/// Sets the divider.
/// Sets the divider.
@IBInspectable
public
var
dividerColor
:
UIColor
=
Color
.
darkText
.
dividers
{
@IBInspectable
public
var
dividerColor
:
UIColor
=
Color
.
darkText
.
dividers
{
didSet
{
didSet
{
if
!
e
diting
{
if
!
isE
diting
{
divider
.
backgroundColor
=
dividerColor
.
cgColor
divider
.
backgroundColor
=
dividerColor
.
cgColor
}
}
}
}
...
@@ -106,7 +106,7 @@ public class TextField : UITextField {
...
@@ -106,7 +106,7 @@ public class TextField : UITextField {
@IBInspectable
public
var
dividerActiveColor
:
UIColor
?
{
@IBInspectable
public
var
dividerActiveColor
:
UIColor
?
{
didSet
{
didSet
{
if
let
v
:
UIColor
=
dividerActiveColor
{
if
let
v
:
UIColor
=
dividerActiveColor
{
if
e
diting
{
if
isE
diting
{
divider
.
backgroundColor
=
v
.
cgColor
divider
.
backgroundColor
=
v
.
cgColor
}
}
}
}
...
@@ -137,7 +137,7 @@ public class TextField : UITextField {
...
@@ -137,7 +137,7 @@ public class TextField : UITextField {
set
(
value
)
{
set
(
value
)
{
placeholderLabel
.
text
=
value
placeholderLabel
.
text
=
value
if
let
v
:
String
=
value
{
if
let
v
:
String
=
value
{
placeholderLabel
.
attributedText
=
NS
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
placeholderLabel
.
attributedText
=
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
}
}
}
}
}
}
...
@@ -148,9 +148,9 @@ public class TextField : UITextField {
...
@@ -148,9 +148,9 @@ public class TextField : UITextField {
/// Placeholder textColor.
/// Placeholder textColor.
@IBInspectable
public
var
placeholderColor
:
UIColor
=
Color
.
darkText
.
others
{
@IBInspectable
public
var
placeholderColor
:
UIColor
=
Color
.
darkText
.
others
{
didSet
{
didSet
{
if
!
e
diting
{
if
!
isE
diting
{
if
let
v
:
String
=
placeholder
{
if
let
v
:
String
=
placeholder
{
placeholderLabel
.
attributedText
=
NS
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
placeholderLabel
.
attributedText
=
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
}
}
}
}
}
}
...
@@ -159,9 +159,9 @@ public class TextField : UITextField {
...
@@ -159,9 +159,9 @@ public class TextField : UITextField {
/// Placeholder active textColor.
/// Placeholder active textColor.
@IBInspectable
public
var
placeholderActiveColor
:
UIColor
=
Color
.
blue
.
base
{
@IBInspectable
public
var
placeholderActiveColor
:
UIColor
=
Color
.
blue
.
base
{
didSet
{
didSet
{
if
e
diting
{
if
isE
diting
{
if
let
v
:
String
=
placeholder
{
if
let
v
:
String
=
placeholder
{
placeholderLabel
.
attributedText
=
NS
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderActiveColor
])
placeholderLabel
.
attributedText
=
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderActiveColor
])
}
}
}
}
tintColor
=
placeholderActiveColor
tintColor
=
placeholderActiveColor
...
@@ -183,7 +183,7 @@ public class TextField : UITextField {
...
@@ -183,7 +183,7 @@ public class TextField : UITextField {
set
(
value
)
{
set
(
value
)
{
detailLabel
.
text
=
value
detailLabel
.
text
=
value
if
let
v
:
String
=
value
{
if
let
v
:
String
=
value
{
detailLabel
.
attributedText
=
NS
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
detailColor
])
detailLabel
.
attributedText
=
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
detailColor
])
}
}
layoutDetailLabel
()
layoutDetailLabel
()
}
}
...
@@ -193,7 +193,7 @@ public class TextField : UITextField {
...
@@ -193,7 +193,7 @@ public class TextField : UITextField {
@IBInspectable
public
var
detailColor
:
UIColor
=
Color
.
darkText
.
others
{
@IBInspectable
public
var
detailColor
:
UIColor
=
Color
.
darkText
.
others
{
didSet
{
didSet
{
if
let
v
:
String
=
detailLabel
.
text
{
if
let
v
:
String
=
detailLabel
.
text
{
detailLabel
.
attributedText
=
NS
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
detailColor
])
detailLabel
.
attributedText
=
AttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
detailColor
])
}
}
}
}
}
}
...
@@ -228,17 +228,16 @@ public class TextField : UITextField {
...
@@ -228,17 +228,16 @@ public class TextField : UITextField {
let
image
:
UIImage
?
=
Icon
.
cm
.
clear
let
image
:
UIImage
?
=
Icon
.
cm
.
clear
clearIconButton
=
IconButton
(
frame
:
CGRect
.
zero
)
clearIconButton
=
IconButton
(
frame
:
CGRect
.
zero
)
clearIconButton
!.
contentEdgeInsets
=
UIEdgeInsets
.
zero
clearIconButton
!.
contentEdgeInsets
=
UIEdgeInsets
.
zero
clearIconButton
!.
pulseAnimation
=
.
C
enter
clearIconButton
!.
pulseAnimation
=
.
c
enter
clearIconButton
!.
tintColor
=
placeholderColor
clearIconButton
!.
tintColor
=
placeholderColor
clearIconButton
!.
setImage
(
image
,
forState
:
.
Normal
)
clearIconButton
!.
setImage
(
image
,
for
:
.
highlighted
)
clearIconButton
!.
setImage
(
image
,
forState
:
.
Highlighted
)
clearButtonMode
=
.
never
clearButtonMode
=
.
Never
rightViewMode
=
.
whileEditing
rightViewMode
=
.
WhileEditing
rightView
=
clearIconButton
rightView
=
clearIconButton
clearIconButtonAutoHandle
=
clearIconButtonAutoHandle
?
true
:
false
clearIconButtonAutoHandle
=
clearIconButtonAutoHandle
?
true
:
false
}
}
}
else
{
}
else
{
clearIconButton
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearIconButton
)
,
for
ControlEvents
:
.
T
ouchUpInside
)
clearIconButton
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearIconButton
)
,
for
:
.
t
ouchUpInside
)
clearIconButton
=
nil
clearIconButton
=
nil
}
}
}
}
...
@@ -247,9 +246,9 @@ public class TextField : UITextField {
...
@@ -247,9 +246,9 @@ public class TextField : UITextField {
/// Enables the automatic handling of the clearIconButton.
/// Enables the automatic handling of the clearIconButton.
@IBInspectable
public
var
clearIconButtonAutoHandle
:
Bool
=
true
{
@IBInspectable
public
var
clearIconButtonAutoHandle
:
Bool
=
true
{
didSet
{
didSet
{
clearIconButton
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearIconButton
)
,
for
ControlEvents
:
.
T
ouchUpInside
)
clearIconButton
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearIconButton
)
,
for
:
.
t
ouchUpInside
)
if
clearIconButtonAutoHandle
{
if
clearIconButtonAutoHandle
{
clearIconButton
?
.
addTarget
(
self
,
action
:
#selector(
handleClearIconButton
)
,
for
ControlEvents
:
.
T
ouchUpInside
)
clearIconButton
?
.
addTarget
(
self
,
action
:
#selector(
handleClearIconButton
)
,
for
:
.
t
ouchUpInside
)
}
}
}
}
}
}
...
@@ -265,19 +264,18 @@ public class TextField : UITextField {
...
@@ -265,19 +264,18 @@ public class TextField : UITextField {
let
image
:
UIImage
?
=
Icon
.
visibility
let
image
:
UIImage
?
=
Icon
.
visibility
visibilityIconButton
=
IconButton
(
frame
:
CGRect
.
zero
)
visibilityIconButton
=
IconButton
(
frame
:
CGRect
.
zero
)
visibilityIconButton
!.
contentEdgeInsets
=
UIEdgeInsets
.
zero
visibilityIconButton
!.
contentEdgeInsets
=
UIEdgeInsets
.
zero
visibilityIconButton
!.
pulseAnimation
=
.
C
enter
visibilityIconButton
!.
pulseAnimation
=
.
c
enter
visibilityIconButton
!.
tintColor
=
placeholderColor
visibilityIconButton
!.
tintColor
=
placeholderColor
visibilityIconButton
!.
setImage
(
image
,
forState
:
.
Normal
)
visibilityIconButton
!.
setImage
(
image
,
for
:
.
highlighted
)
visibilityIconButton
!.
setImage
(
image
,
forState
:
.
Highlighted
)
visibilityIconButton
!.
tintColor
=
placeholderColor
.
withAlphaComponent
(
isSecureTextEntry
?
0.38
:
0.54
)
visibilityIconButton
!.
tintColor
=
placeholderColor
.
colorWithAlphaComponent
(
secureTextEntry
?
0.38
:
0.54
)
isSecureTextEntry
=
true
secureTextEntry
=
true
clearButtonMode
=
.
never
clearButtonMode
=
.
Never
rightViewMode
=
.
whileEditing
rightViewMode
=
.
WhileEditing
rightView
=
visibilityIconButton
rightView
=
visibilityIconButton
visibilityIconButtonAutoHandle
=
visibilityIconButtonAutoHandle
?
true
:
false
visibilityIconButtonAutoHandle
=
visibilityIconButtonAutoHandle
?
true
:
false
}
}
}
else
{
}
else
{
visibilityIconButton
?
.
removeTarget
(
self
,
action
:
#selector(
handleVisibilityIconButton
)
,
for
ControlEvents
:
.
T
ouchUpInside
)
visibilityIconButton
?
.
removeTarget
(
self
,
action
:
#selector(
handleVisibilityIconButton
)
,
for
:
.
t
ouchUpInside
)
visibilityIconButton
=
nil
visibilityIconButton
=
nil
}
}
}
}
...
@@ -286,9 +284,9 @@ public class TextField : UITextField {
...
@@ -286,9 +284,9 @@ public class TextField : UITextField {
/// Enables the automatic handling of the visibilityIconButton.
/// Enables the automatic handling of the visibilityIconButton.
@IBInspectable
public
var
visibilityIconButtonAutoHandle
:
Bool
=
true
{
@IBInspectable
public
var
visibilityIconButtonAutoHandle
:
Bool
=
true
{
didSet
{
didSet
{
visibilityIconButton
?
.
removeTarget
(
self
,
action
:
#selector(
handleVisibilityIconButton
)
,
for
ControlEvents
:
.
T
ouchUpInside
)
visibilityIconButton
?
.
removeTarget
(
self
,
action
:
#selector(
handleVisibilityIconButton
)
,
for
:
.
t
ouchUpInside
)
if
visibilityIconButtonAutoHandle
{
if
visibilityIconButtonAutoHandle
{
visibilityIconButton
?
.
addTarget
(
self
,
action
:
#selector(
handleVisibilityIconButton
)
,
for
ControlEvents
:
.
T
ouchUpInside
)
visibilityIconButton
?
.
addTarget
(
self
,
action
:
#selector(
handleVisibilityIconButton
)
,
for
:
.
t
ouchUpInside
)
}
}
}
}
}
}
...
@@ -329,8 +327,8 @@ public class TextField : UITextField {
...
@@ -329,8 +327,8 @@ public class TextField : UITextField {
layoutToSize
()
layoutToSize
()
}
}
public
override
func
layoutSublayers
OfLayer
(
layer
:
CALayer
)
{
public
override
func
layoutSublayers
(
of
layer
:
CALayer
)
{
super
.
layoutSublayers
OfLayer
(
layer
)
super
.
layoutSublayers
(
of
:
layer
)
if
self
.
layer
==
layer
{
if
self
.
layer
==
layer
{
layoutDivider
()
layoutDivider
()
}
}
...
@@ -338,7 +336,7 @@ public class TextField : UITextField {
...
@@ -338,7 +336,7 @@ public class TextField : UITextField {
/// Default size when using AutoLayout.
/// Default size when using AutoLayout.
public
override
func
intrinsicContentSize
()
->
CGSize
{
public
override
func
intrinsicContentSize
()
->
CGSize
{
return
CGSizeMake
(
width
,
32
)
return
CGSize
(
width
:
width
,
height
:
32
)
}
}
/// Handles the text editing did begin state.
/// Handles the text editing did begin state.
...
@@ -363,12 +361,12 @@ public class TextField : UITextField {
...
@@ -363,12 +361,12 @@ public class TextField : UITextField {
/// Handles the visibilityIconButton TouchUpInside event.
/// Handles the visibilityIconButton TouchUpInside event.
public
func
handleVisibilityIconButton
()
{
public
func
handleVisibilityIconButton
()
{
secureTextEntry
=
!
s
ecureTextEntry
isSecureTextEntry
=
!
isS
ecureTextEntry
if
!
s
ecureTextEntry
{
if
!
isS
ecureTextEntry
{
super
.
font
=
nil
super
.
font
=
nil
font
=
placeholderLabel
.
font
font
=
placeholderLabel
.
font
}
}
visibilityIconButton
?
.
tintColor
=
visibilityIconButton
?
.
tintColor
.
colorWithAlphaComponent
(
s
ecureTextEntry
?
0.38
:
0.54
)
visibilityIconButton
?
.
tintColor
=
visibilityIconButton
?
.
tintColor
.
withAlphaComponent
(
isS
ecureTextEntry
?
0.38
:
0.54
)
}
}
/**
/**
...
@@ -380,11 +378,11 @@ public class TextField : UITextField {
...
@@ -380,11 +378,11 @@ public class TextField : UITextField {
*/
*/
public
func
prepareView
()
{
public
func
prepareView
()
{
super
.
placeholder
=
nil
super
.
placeholder
=
nil
mask
sToBounds
=
false
clip
sToBounds
=
false
borderStyle
=
.
none
borderStyle
=
.
none
backgroundColor
=
nil
backgroundColor
=
nil
textColor
=
Color
.
darkText
.
primary
textColor
=
Color
.
darkText
.
primary
font
=
RobotoFont
.
regularWithSize
(
16
)
font
=
RobotoFont
.
regularWithSize
(
size
:
16
)
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
prepareDivider
()
prepareDivider
()
preparePlaceholderLabel
()
preparePlaceholderLabel
()
...
@@ -405,20 +403,20 @@ public class TextField : UITextField {
...
@@ -405,20 +403,20 @@ public class TextField : UITextField {
/// Layout the divider.
/// Layout the divider.
public
func
layoutDivider
()
{
public
func
layoutDivider
()
{
divider
.
frame
=
CGRectMake
(
0
,
height
,
width
,
e
diting
?
dividerActiveHeight
:
dividerHeight
)
divider
.
frame
=
CGRect
(
x
:
0
,
y
:
height
,
width
:
width
,
height
:
isE
diting
?
dividerActiveHeight
:
dividerHeight
)
}
}
/// Layout the placeholderLabel.
/// Layout the placeholderLabel.
public
func
layoutPlaceholderLabel
()
{
public
func
layoutPlaceholderLabel
()
{
if
!
e
diting
&&
true
==
text
?
.
isEmpty
{
if
!
isE
diting
&&
true
==
text
?
.
isEmpty
{
placeholderLabel
.
frame
=
bounds
placeholderLabel
.
frame
=
bounds
}
else
if
CGAffineTransformIsIdentity
(
placeholderLabel
.
transform
)
{
}
else
if
placeholderLabel
.
transform
.
isIdentity
{
placeholderLabel
.
frame
=
bounds
placeholderLabel
.
frame
=
bounds
placeholderLabel
.
transform
=
CGAffineTransform
MakeScale
(
0.75
,
0.75
)
placeholderLabel
.
transform
=
CGAffineTransform
(
scaleX
:
0.75
,
y
:
0.75
)
switch
textAlignment
{
switch
textAlignment
{
case
.
Left
,
.
N
atural
:
case
.
left
,
.
n
atural
:
placeholderLabel
.
frame
.
origin
.
x
=
0
placeholderLabel
.
frame
.
origin
.
x
=
0
case
.
R
ight
:
case
.
r
ight
:
placeholderLabel
.
frame
.
origin
.
x
=
width
-
placeholderLabel
.
frame
.
width
placeholderLabel
.
frame
.
origin
.
x
=
width
-
placeholderLabel
.
frame
.
width
default
:
break
default
:
break
}
}
...
@@ -426,11 +424,11 @@ public class TextField : UITextField {
...
@@ -426,11 +424,11 @@ public class TextField : UITextField {
placeholderLabel
.
textColor
=
placeholderColor
placeholderLabel
.
textColor
=
placeholderColor
}
else
{
}
else
{
switch
textAlignment
{
switch
textAlignment
{
case
.
Left
,
.
N
atural
:
case
.
left
,
.
n
atural
:
placeholderLabel
.
frame
.
origin
.
x
=
0
placeholderLabel
.
frame
.
origin
.
x
=
0
case
.
R
ight
:
case
.
r
ight
:
placeholderLabel
.
frame
.
origin
.
x
=
width
-
placeholderLabel
.
frame
.
width
placeholderLabel
.
frame
.
origin
.
x
=
width
-
placeholderLabel
.
frame
.
width
case
.
C
enter
:
case
.
c
enter
:
placeholderLabel
.
center
.
x
=
width
/
2
placeholderLabel
.
center
.
x
=
width
/
2
default
:
break
default
:
break
}
}
...
@@ -440,24 +438,24 @@ public class TextField : UITextField {
...
@@ -440,24 +438,24 @@ public class TextField : UITextField {
/// Layout the detailLabel.
/// Layout the detailLabel.
public
func
layoutDetailLabel
()
{
public
func
layoutDetailLabel
()
{
let
h
:
CGFloat
=
nil
==
detail
?
12
:
detailLabel
.
font
.
stringSize
(
detail
!
,
constrainedToWidth
:
Double
(
width
))
.
height
let
h
:
CGFloat
=
nil
==
detail
?
12
:
detailLabel
.
font
.
stringSize
(
string
:
detail
!
,
constrainedToWidth
:
Double
(
width
))
.
height
detailLabel
.
frame
=
CGRectMake
(
0
,
divider
.
frame
.
origin
.
y
+
detailVerticalOffset
,
width
,
h
)
detailLabel
.
frame
=
CGRect
(
x
:
0
,
y
:
divider
.
frame
.
origin
.
y
+
detailVerticalOffset
,
width
:
width
,
height
:
h
)
}
}
/// Layout the clearIconButton.
/// Layout the clearIconButton.
public
func
layoutClearIconButton
()
{
public
func
layoutClearIconButton
()
{
if
let
v
:
IconButton
=
clearIconButton
{
if
let
v
=
clearIconButton
{
if
0
<
width
&&
0
<
height
{
if
0
<
width
&&
0
<
height
{
v
.
frame
=
CGRectMake
(
width
-
height
,
0
,
height
,
height
)
v
.
frame
=
CGRect
(
x
:
width
-
height
,
y
:
0
,
width
:
height
,
height
:
height
)
}
}
}
}
}
}
/// Layout the visibilityIconButton.
/// Layout the visibilityIconButton.
public
func
layoutVisibilityIconButton
()
{
public
func
layoutVisibilityIconButton
()
{
if
let
v
:
IconButton
=
visibilityIconButton
{
if
let
v
=
visibilityIconButton
{
if
0
<
width
&&
0
<
height
{
if
0
<
width
&&
0
<
height
{
v
.
frame
=
CGRectMake
(
width
-
height
,
0
,
height
,
height
)
v
.
frame
=
CGRect
(
x
:
width
-
height
,
y
:
0
,
width
:
height
,
height
:
height
)
}
}
}
}
}
}
...
@@ -476,44 +474,44 @@ public class TextField : UITextField {
...
@@ -476,44 +474,44 @@ public class TextField : UITextField {
/// The animation for the placeholder when editing begins.
/// The animation for the placeholder when editing begins.
public
func
placeholderEditingDidBeginAnimation
()
{
public
func
placeholderEditingDidBeginAnimation
()
{
if
CGAffineTransformIsIdentity
(
placeholderLabel
.
transform
)
{
if
placeholderLabel
.
transform
.
isIdentity
{
animating
=
true
animating
=
true
UIView
.
animate
WithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
if
let
v
:
TextField
=
self
{
if
let
s
=
self
{
v
.
placeholderLabel
.
transform
=
CGAffineTransformMakeScale
(
0.75
,
0.75
)
s
.
placeholderLabel
.
transform
=
CGAffineTransform
(
scaleX
:
0.75
,
y
:
0.75
)
switch
v
.
textAlignment
{
switch
s
.
textAlignment
{
case
.
Left
,
.
N
atural
:
case
.
left
,
.
n
atural
:
v
.
placeholderLabel
.
frame
.
origin
.
x
=
0
s
.
placeholderLabel
.
frame
.
origin
.
x
=
0
case
.
R
ight
:
case
.
r
ight
:
v
.
placeholderLabel
.
frame
.
origin
.
x
=
v
.
width
-
v
.
placeholderLabel
.
frame
.
width
s
.
placeholderLabel
.
frame
.
origin
.
x
=
s
.
width
-
s
.
placeholderLabel
.
frame
.
width
default
:
break
default
:
break
}
}
v
.
placeholderLabel
.
frame
.
origin
.
y
=
-
v
.
placeholderLabel
.
frame
.
size
.
height
+
v
.
placeholderVerticalOffset
s
.
placeholderLabel
.
frame
.
origin
.
y
=
-
s
.
placeholderLabel
.
frame
.
size
.
height
+
s
.
placeholderVerticalOffset
v
.
placeholderLabel
.
textColor
=
v
.
placeholderActiveColor
s
.
placeholderLabel
.
textColor
=
s
.
placeholderActiveColor
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
self
?
.
animating
=
false
self
?
.
animating
=
false
}
}
}
else
if
e
diting
{
}
else
if
isE
diting
{
placeholderLabel
.
textColor
=
placeholderActiveColor
placeholderLabel
.
textColor
=
placeholderActiveColor
}
}
}
}
/// The animation for the placeholder when editing ends.
/// The animation for the placeholder when editing ends.
public
func
placeholderEditingDidEndAnimation
()
{
public
func
placeholderEditingDidEndAnimation
()
{
if
!
CGAffineTransformIsIdentity
(
placeholderLabel
.
transform
)
&&
true
==
text
?
.
isEmpty
{
if
!
placeholderLabel
.
transform
.
isIdentity
&&
true
==
text
?
.
isEmpty
{
animating
=
true
animating
=
true
UIView
.
animate
WithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
if
let
v
:
TextField
=
self
{
if
let
s
=
self
{
v
.
placeholderLabel
.
transform
=
CGAffineTransformI
dentity
s
.
placeholderLabel
.
transform
=
CGAffineTransform
.
i
dentity
v
.
placeholderLabel
.
frame
.
origin
.
x
=
0
s
.
placeholderLabel
.
frame
.
origin
.
x
=
0
v
.
placeholderLabel
.
frame
.
origin
.
y
=
0
s
.
placeholderLabel
.
frame
.
origin
.
y
=
0
v
.
placeholderLabel
.
textColor
=
v
.
placeholderColor
s
.
placeholderLabel
.
textColor
=
s
.
placeholderColor
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
self
?
.
animating
=
false
self
?
.
animating
=
false
}
}
}
else
if
!
e
diting
{
}
else
if
!
isE
diting
{
placeholderLabel
.
textColor
=
placeholderColor
placeholderLabel
.
textColor
=
placeholderColor
}
}
}
}
...
@@ -532,19 +530,19 @@ public class TextField : UITextField {
...
@@ -532,19 +530,19 @@ public class TextField : UITextField {
/// Prepares the detailLabel.
/// Prepares the detailLabel.
private
func
prepareDetailLabel
()
{
private
func
prepareDetailLabel
()
{
detailLabel
.
font
=
RobotoFont
.
regularWithSize
(
12
)
detailLabel
.
font
=
RobotoFont
.
regularWithSize
(
size
:
12
)
detailColor
=
Color
.
darkText
.
others
detailColor
=
Color
.
darkText
.
others
addSubview
(
detailLabel
)
addSubview
(
detailLabel
)
}
}
/// Prepares the target handlers.
/// Prepares the target handlers.
private
func
prepareTargetHandlers
()
{
private
func
prepareTargetHandlers
()
{
addTarget
(
self
,
action
:
#selector(
handleEditingDidBegin
)
,
for
ControlEvents
:
.
E
ditingDidBegin
)
addTarget
(
self
,
action
:
#selector(
handleEditingDidBegin
)
,
for
:
.
e
ditingDidBegin
)
addTarget
(
self
,
action
:
#selector(
handleEditingDidEnd
)
,
for
ControlEvents
:
.
E
ditingDidEnd
)
addTarget
(
self
,
action
:
#selector(
handleEditingDidEnd
)
,
for
:
.
e
ditingDidEnd
)
}
}
/// Prepares the textAlignment.
/// Prepares the textAlignment.
private
func
prepareTextAlignment
()
{
private
func
prepareTextAlignment
()
{
textAlignment
=
.
RightToLeft
==
UIApplication
.
sharedApplication
()
.
userInterfaceLayoutDirection
?
.
Right
:
.
L
eft
textAlignment
=
.
rightToLeft
==
UIApplication
.
shared
()
.
userInterfaceLayoutDirection
?
.
right
:
.
l
eft
}
}
}
}
Sources/iOS/TextStorage.swift
View file @
9a90a7d5
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
import
UIKit
import
UIKit
internal
typealias
TextWillProcessEdit
=
(
TextStorage
,
String
,
NSRange
)
->
Void
internal
typealias
TextWillProcessEdit
=
(
TextStorage
,
String
,
NSRange
)
->
Void
internal
typealias
TextDidProcessEdit
=
(
TextStorage
,
NSTextCheckingResult
?,
NS
MatchingFlags
,
UnsafeMutablePointer
<
ObjCBool
>
)
->
Void
internal
typealias
TextDidProcessEdit
=
(
TextStorage
,
TextCheckingResult
?,
RegularExpression
.
MatchingFlags
,
UnsafeMutablePointer
<
ObjCBool
>
)
->
Void
public
class
TextStorage
:
NSTextStorage
{
public
class
TextStorage
:
NSTextStorage
{
/// A callback that is executed when a process edit will happen.
/// A callback that is executed when a process edit will happen.
...
@@ -44,7 +44,7 @@ public class TextStorage: NSTextStorage {
...
@@ -44,7 +44,7 @@ public class TextStorage: NSTextStorage {
public
lazy
var
store
:
NSMutableAttributedString
=
NSMutableAttributedString
()
public
lazy
var
store
:
NSMutableAttributedString
=
NSMutableAttributedString
()
/// The regular expression to match text fragments against.
/// The regular expression to match text fragments against.
public
var
expression
:
NS
RegularExpression
?
public
var
expression
:
RegularExpression
?
/// Initializer.
/// Initializer.
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
...
@@ -63,11 +63,11 @@ public class TextStorage: NSTextStorage {
...
@@ -63,11 +63,11 @@ public class TextStorage: NSTextStorage {
/// Processes the text when editing.
/// Processes the text when editing.
public
override
func
processEditing
()
{
public
override
func
processEditing
()
{
let
range
:
NSRange
=
(
string
as
NSString
)
.
paragraphRange
ForRange
(
editedRange
)
let
range
:
NSRange
=
(
string
as
NSString
)
.
paragraphRange
(
for
:
editedRange
)
textWillProcessEdit
?(
self
,
string
,
range
)
textWillProcessEdit
?(
self
,
string
,
range
)
expression
!.
enumerateMatches
InString
(
string
,
options
:
[],
range
:
range
)
{
(
result
:
NSTextCheckingResult
?,
flags
:
NS
MatchingFlags
,
stop
:
UnsafeMutablePointer
<
ObjCBool
>
)
->
Void
in
expression
!.
enumerateMatches
(
in
:
string
,
options
:
[],
range
:
range
)
{
(
result
:
TextCheckingResult
?,
flags
:
RegularExpression
.
MatchingFlags
,
stop
:
UnsafeMutablePointer
<
ObjCBool
>
)
->
Void
in
self
.
textDidProcessEdit
?(
self
,
result
,
flags
,
stop
)
self
.
textDidProcessEdit
?(
self
,
result
,
flags
,
stop
)
}
}
super
.
processEditing
()
super
.
processEditing
()
...
@@ -85,8 +85,8 @@ public class TextStorage: NSTextStorage {
...
@@ -85,8 +85,8 @@ public class TextStorage: NSTextStorage {
If you don't need this value, pass NULL.
If you don't need this value, pass NULL.
- Returns: The attributes for the character at index.
- Returns: The attributes for the character at index.
*/
*/
public
override
func
attributes
AtIndex
(
location
:
Int
,
effectiveRange
range
:
NSRangePointer
)
->
[
String
:
AnyObject
]
{
public
override
func
attributes
(
at
location
:
Int
,
effectiveRange
range
:
NSRangePointer
?
)
->
[
String
:
AnyObject
]
{
return
store
.
attributes
AtIndex
(
location
,
effectiveRange
:
range
)
return
store
.
attributes
(
at
:
location
,
effectiveRange
:
range
)
}
}
/**
/**
...
@@ -95,9 +95,9 @@ public class TextStorage: NSTextStorage {
...
@@ -95,9 +95,9 @@ public class TextStorage: NSTextStorage {
- Parameter str: The string value that the characters
- Parameter str: The string value that the characters
will be replaced with.
will be replaced with.
*/
*/
public
override
func
replaceCharacters
InRange
(
range
:
NSRange
,
withString
str
:
String
)
{
public
override
func
replaceCharacters
(
in
range
:
NSRange
,
with
str
:
String
)
{
store
.
replaceCharacters
InRange
(
range
,
withString
:
str
)
store
.
replaceCharacters
(
in
:
range
,
with
:
str
)
edited
(
NSTextStorageEditActions
.
E
ditedCharacters
,
range
:
range
,
changeInLength
:
str
.
utf16
.
count
-
range
.
length
)
edited
(
NSTextStorageEditActions
.
e
ditedCharacters
,
range
:
range
,
changeInLength
:
str
.
utf16
.
count
-
range
.
length
)
}
}
/**
/**
...
@@ -106,8 +106,8 @@ public class TextStorage: NSTextStorage {
...
@@ -106,8 +106,8 @@ public class TextStorage: NSTextStorage {
- Parameter range: A range of characters that will have their
- Parameter range: A range of characters that will have their
attributes updated.
attributes updated.
*/
*/
public
override
func
setAttributes
(
attrs
:
[
String
:
AnyObject
]?,
range
:
NSRange
)
{
public
override
func
setAttributes
(
_
attrs
:
[
String
:
AnyObject
]?,
range
:
NSRange
)
{
store
.
setAttributes
(
attrs
,
range
:
range
)
store
.
setAttributes
(
attrs
,
range
:
range
)
edited
(
NSTextStorageEditActions
.
E
ditedAttributes
,
range
:
range
,
changeInLength
:
0
)
edited
(
NSTextStorageEditActions
.
e
ditedAttributes
,
range
:
range
,
changeInLength
:
0
)
}
}
}
}
Sources/iOS/TextView.swift
View file @
9a90a7d5
...
@@ -134,7 +134,7 @@ public class TextView: UITextView {
...
@@ -134,7 +134,7 @@ public class TextView: UITextView {
}
}
/// An override to the attributedText property.
/// An override to the attributedText property.
public
override
var
attributedText
:
NS
AttributedString
!
{
public
override
var
attributedText
:
AttributedString
!
{
didSet
{
didSet
{
handleTextViewTextDidChange
()
handleTextViewTextDidChange
()
}
}
...
@@ -151,7 +151,7 @@ public class TextView: UITextView {
...
@@ -151,7 +151,7 @@ public class TextView: UITextView {
}
}
/// Text container UIEdgeInset property.
/// Text container UIEdgeInset property.
public
override
var
textContainerInset
:
Insets
{
public
override
var
textContainerInset
:
Edge
Insets
{
didSet
{
didSet
{
reloadView
()
reloadView
()
}
}
...
@@ -244,12 +244,12 @@ public class TextView: UITextView {
...
@@ -244,12 +244,12 @@ public class TextView: UITextView {
/// Sets the shadow path.
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
shadowPathAutoSizeEnabled
{
if
.
none
==
depth
{
if
.
none
==
depth
Preset
{
shadowPath
=
nil
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
}
else
{
animate
(
Animation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
animate
(
animation
:
Animation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
}
}
}
}
}
}
...
@@ -265,7 +265,7 @@ public class TextView: UITextView {
...
@@ -265,7 +265,7 @@ public class TextView: UITextView {
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
textContainerInset
=
EdgeInsets
.
zero
textContainerInset
=
EdgeInsets
.
zero
backgroundColor
=
Color
.
white
backgroundColor
=
Color
.
white
mask
sToBounds
=
false
clip
sToBounds
=
false
removeNotificationHandlers
()
removeNotificationHandlers
()
prepareNotificationHandlers
()
prepareNotificationHandlers
()
reloadView
()
reloadView
()
...
@@ -305,9 +305,9 @@ public class TextView: UITextView {
...
@@ -305,9 +305,9 @@ public class TextView: UITextView {
v
.
text
=
s
v
.
text
=
s
}
}
let
h
:
CGFloat
=
ceil
(
v
.
font
.
lineHeight
)
let
h
:
CGFloat
=
ceil
(
v
.
font
.
lineHeight
)
v
.
frame
=
CGRectMake
(
0
,
-
h
,
bounds
.
width
,
h
)
v
.
frame
=
CGRect
(
x
:
0
,
y
:
-
h
,
width
:
bounds
.
width
,
height
:
h
)
v
.
isHidden
=
false
v
.
isHidden
=
false
UIView
.
animate
WithDuration
(
0.25
,
animations
:
{
[
weak
self
]
in
UIView
.
animate
(
withDuration
:
0.25
,
animations
:
{
[
weak
self
]
in
if
let
s
:
TextView
=
self
{
if
let
s
:
TextView
=
self
{
v
.
alpha
=
1
v
.
alpha
=
1
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
-
s
.
titleLabelAnimationDistance
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
-
s
.
titleLabelAnimationDistance
...
@@ -321,7 +321,7 @@ public class TextView: UITextView {
...
@@ -321,7 +321,7 @@ public class TextView: UITextView {
private
func
hideTitleLabel
()
{
private
func
hideTitleLabel
()
{
if
let
v
:
UILabel
=
titleLabel
{
if
let
v
:
UILabel
=
titleLabel
{
if
!
v
.
isHidden
{
if
!
v
.
isHidden
{
UIView
.
animate
WithDuration
(
0.25
,
animations
:
{
UIView
.
animate
(
withDuration
:
0.25
,
animations
:
{
v
.
alpha
=
0
v
.
alpha
=
0
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
})
{
_
in
})
{
_
in
...
@@ -333,15 +333,17 @@ public class TextView: UITextView {
...
@@ -333,15 +333,17 @@ public class TextView: UITextView {
/// Prepares the Notification handlers.
/// Prepares the Notification handlers.
private
func
prepareNotificationHandlers
()
{
private
func
prepareNotificationHandlers
()
{
NSNotificationCenter
.
defaultCenter
()
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidBegin
)
,
name
:
UITextViewTextDidBeginEditingNotification
,
object
:
nil
)
let
defaultCenter
=
NotificationCenter
.
default
()
NSNotificationCenter
.
defaultCenter
()
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidChange
)
,
name
:
UITextViewTextDidChangeNotification
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidBegin
)
,
name
:
NSNotification
.
Name
.
UITextViewTextDidBeginEditing
,
object
:
self
)
NSNotificationCenter
.
defaultCenter
()
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidEnd
)
,
name
:
UITextViewTextDidEndEditingNotification
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidChange
)
,
name
:
NSNotification
.
Name
.
UITextViewTextDidChange
,
object
:
self
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidEnd
)
,
name
:
NSNotification
.
Name
.
UITextViewTextDidEndEditing
,
object
:
self
)
}
}
/// Removes the Notification handlers.
/// Removes the Notification handlers.
private
func
removeNotificationHandlers
()
{
private
func
removeNotificationHandlers
()
{
NSNotificationCenter
.
defaultCenter
()
.
removeObserver
(
self
,
name
:
UITextViewTextDidBeginEditingNotification
,
object
:
nil
)
let
defaultCenter
=
NotificationCenter
.
default
()
NSNotificationCenter
.
defaultCenter
()
.
removeObserver
(
self
,
name
:
UITextViewTextDidChangeNotification
,
object
:
nil
)
defaultCenter
.
removeObserver
(
self
,
name
:
NSNotification
.
Name
.
UITextViewTextDidBeginEditing
,
object
:
self
)
NSNotificationCenter
.
defaultCenter
()
.
removeObserver
(
self
,
name
:
UITextViewTextDidEndEditingNotification
,
object
:
nil
)
defaultCenter
.
removeObserver
(
self
,
name
:
NSNotification
.
Name
.
UITextViewTextDidChange
,
object
:
self
)
defaultCenter
.
removeObserver
(
self
,
name
:
NSNotification
.
Name
.
UITextViewTextDidEndEditing
,
object
:
self
)
}
}
}
}
Sources/iOS/Toolbar.swift
View file @
9a90a7d5
...
@@ -144,15 +144,15 @@ public class Toolbar : BarView {
...
@@ -144,15 +144,15 @@ public class Toolbar : BarView {
private
func
prepareTitleLabel
()
{
private
func
prepareTitleLabel
()
{
titleLabel
=
UILabel
()
titleLabel
=
UILabel
()
titleLabel
.
contentScaleFactor
=
Device
.
scale
titleLabel
.
contentScaleFactor
=
Device
.
scale
titleLabel
.
font
=
RobotoFont
.
mediumWithSize
(
17
)
titleLabel
.
font
=
RobotoFont
.
mediumWithSize
(
size
:
17
)
titleLabel
.
textAlignment
=
.
L
eft
titleLabel
.
textAlignment
=
.
l
eft
}
}
/// Prepares the detailLabel.
/// Prepares the detailLabel.
private
func
prepareDetailLabel
()
{
private
func
prepareDetailLabel
()
{
detailLabel
=
UILabel
()
detailLabel
=
UILabel
()
detailLabel
.
contentScaleFactor
=
Device
.
scale
detailLabel
.
contentScaleFactor
=
Device
.
scale
detailLabel
.
font
=
RobotoFont
.
regularWithSize
(
12
)
detailLabel
.
font
=
RobotoFont
.
regularWithSize
(
size
:
12
)
detailLabel
.
textAlignment
=
.
L
eft
detailLabel
.
textAlignment
=
.
l
eft
}
}
}
}
Sources/iOS/ToolbarController.swift
View file @
9a90a7d5
...
@@ -42,7 +42,7 @@ public extension UIViewController {
...
@@ -42,7 +42,7 @@ public extension UIViewController {
if
viewController
is
ToolbarController
{
if
viewController
is
ToolbarController
{
return
viewController
as?
ToolbarController
return
viewController
as?
ToolbarController
}
}
viewController
=
viewController
?
.
parent
ViewController
viewController
=
viewController
?
.
parent
}
}
return
nil
return
nil
}
}
...
@@ -51,15 +51,19 @@ public extension UIViewController {
...
@@ -51,15 +51,19 @@ public extension UIViewController {
@objc(ToolbarControllerDelegate)
@objc(ToolbarControllerDelegate)
public
protocol
ToolbarControllerDelegate
:
MaterialDelegate
{
public
protocol
ToolbarControllerDelegate
:
MaterialDelegate
{
/// Delegation method that executes when the floatingViewController will open.
/// Delegation method that executes when the floatingViewController will open.
@objc
optional
func
toolbarControllerWillOpenFloatingViewController
(
toolbarController
:
ToolbarController
)
optional
func
toolbarControllerWillOpenFloatingViewController
(
toolbarController
:
ToolbarController
)
/// Delegation method that executes when the floatingViewController will close.
/// Delegation method that executes when the floatingViewController will close.
@objc
optional
func
toolbarControllerWillCloseFloatingViewController
(
toolbarController
:
ToolbarController
)
optional
func
toolbarControllerWillCloseFloatingViewController
(
toolbarController
:
ToolbarController
)
/// Delegation method that executes when the floatingViewController did open.
/// Delegation method that executes when the floatingViewController did open.
@objc
optional
func
toolbarControllerDidOpenFloatingViewController
(
toolbarController
:
ToolbarController
)
optional
func
toolbarControllerDidOpenFloatingViewController
(
toolbarController
:
ToolbarController
)
/// Delegation method that executes when the floatingViewController did close.
/// Delegation method that executes when the floatingViewController did close.
@objc
optional
func
toolbarControllerDidCloseFloatingViewController
(
toolbarController
:
ToolbarController
)
optional
func
toolbarControllerDidCloseFloatingViewController
(
toolbarController
:
ToolbarController
)
}
}
...
@@ -83,26 +87,26 @@ public class ToolbarController : RootController {
...
@@ -83,26 +87,26 @@ public class ToolbarController : RootController {
if
let
v
:
UIViewController
=
internalFloatingViewController
{
if
let
v
:
UIViewController
=
internalFloatingViewController
{
v
.
view
.
layer
.
rasterizationScale
=
Device
.
scale
v
.
view
.
layer
.
rasterizationScale
=
Device
.
scale
v
.
view
.
layer
.
shouldRasterize
=
true
v
.
view
.
layer
.
shouldRasterize
=
true
delegate
?
.
toolbarControllerWillCloseFloatingViewController
?(
self
)
delegate
?
.
toolbarControllerWillCloseFloatingViewController
?(
toolbarController
:
self
)
internalFloatingViewController
=
nil
internalFloatingViewController
=
nil
UIView
.
animate
WithDuration
(
0.5
,
UIView
.
animate
(
withDuration
:
0.5
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
ToolbarController
=
self
{
if
let
s
=
self
{
v
.
view
.
center
.
y
=
2
*
s
.
view
.
bounds
.
height
v
.
view
.
center
.
y
=
2
*
s
.
view
.
bounds
.
height
s
.
toolbar
.
alpha
=
1
s
.
toolbar
.
alpha
=
1
s
.
rootViewController
.
view
.
alpha
=
1
s
.
rootViewController
.
view
.
alpha
=
1
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
ToolbarController
=
self
{
if
let
s
=
self
{
v
.
willMove
ToParentViewController
(
nil
)
v
.
willMove
(
toParentViewController
:
nil
)
v
.
view
.
removeFromSuperview
()
v
.
view
.
removeFromSuperview
()
v
.
removeFromParentViewController
()
v
.
removeFromParentViewController
()
v
.
view
.
layer
.
shouldRasterize
=
false
v
.
view
.
layer
.
shouldRasterize
=
false
s
.
isUserInteractionEnabled
=
true
s
.
isUserInteractionEnabled
=
true
s
.
toolbar
.
isUserInteractionEnabled
=
true
s
.
toolbar
.
isUserInteractionEnabled
=
true
dispatch_async
(
dispatch_get_main_queue
())
{
[
weak
self
]
in
DispatchQueue
.
main
.
async
{
[
weak
self
]
in
if
let
s
:
ToolbarController
=
self
{
if
let
s
=
self
{
s
.
delegate
?
.
toolbarControllerDidCloseFloatingViewController
?(
s
)
s
.
delegate
?
.
toolbarControllerDidCloseFloatingViewController
?(
toolbarController
:
s
)
}
}
}
}
}
}
...
@@ -117,7 +121,7 @@ public class ToolbarController : RootController {
...
@@ -117,7 +121,7 @@ public class ToolbarController : RootController {
v
.
view
.
isHidden
=
true
v
.
view
.
isHidden
=
true
view
.
insertSubview
(
v
.
view
,
aboveSubview
:
toolbar
)
view
.
insertSubview
(
v
.
view
,
aboveSubview
:
toolbar
)
v
.
view
.
layer
.
zPosition
=
1500
v
.
view
.
layer
.
zPosition
=
1500
v
.
didMove
ToParentViewController
(
self
)
v
.
didMove
(
toParentViewController
:
self
)
// Animate the noteButton out and the noteViewController! in.
// Animate the noteButton out and the noteViewController! in.
v
.
view
.
isHidden
=
false
v
.
view
.
isHidden
=
false
...
@@ -128,21 +132,21 @@ public class ToolbarController : RootController {
...
@@ -128,21 +132,21 @@ public class ToolbarController : RootController {
internalFloatingViewController
=
v
internalFloatingViewController
=
v
isUserInteractionEnabled
=
false
isUserInteractionEnabled
=
false
toolbar
.
isUserInteractionEnabled
=
false
toolbar
.
isUserInteractionEnabled
=
false
delegate
?
.
toolbarControllerWillOpenFloatingViewController
?(
self
)
delegate
?
.
toolbarControllerWillOpenFloatingViewController
?(
toolbarController
:
self
)
UIView
.
animate
WithDuration
(
0.5
,
UIView
.
animate
(
withDuration
:
0.5
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
ToolbarController
=
self
{
if
let
s
=
self
{
v
.
view
.
center
.
y
=
s
.
view
.
bounds
.
height
/
2
v
.
view
.
center
.
y
=
s
.
view
.
bounds
.
height
/
2
s
.
toolbar
.
alpha
=
0.5
s
.
toolbar
.
alpha
=
0.5
s
.
rootViewController
.
view
.
alpha
=
0.5
s
.
rootViewController
.
view
.
alpha
=
0.5
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
ToolbarController
=
self
{
if
let
s
=
self
{
v
.
view
.
layer
.
shouldRasterize
=
false
v
.
view
.
layer
.
shouldRasterize
=
false
s
.
view
.
layer
.
shouldRasterize
=
false
s
.
view
.
layer
.
shouldRasterize
=
false
dispatch_async
(
dispatch_get_main_queue
())
{
[
weak
self
]
in
DispatchQueue
.
main
.
async
{
[
weak
self
]
in
if
let
s
:
ToolbarController
=
self
{
if
let
s
=
self
{
s
.
delegate
?
.
toolbarControllerDidOpenFloatingViewController
?(
s
)
s
.
delegate
?
.
toolbarControllerDidOpenFloatingViewController
?(
toolbarController
:
s
)
}
}
}
}
}
}
...
...
Sources/iOS/View.swift
View file @
9a90a7d5
...
@@ -186,20 +186,6 @@ public class View: UIView {
...
@@ -186,20 +186,6 @@ public class View: UIView {
}
}
}
}
/// A property that accesses the layer.cornerRadius.
@IBInspectable
public
var
cornerRadius
:
CGFloat
{
get
{
return
layer
.
cornerRadius
}
set
(
value
)
{
layer
.
cornerRadius
=
value
layoutShadowPath
()
if
.
circle
==
shape
{
shape
=
.
none
}
}
}
/**
/**
A property that manages the overall shape for the object. If either the
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
width or height property is set, the other will be automatically adjusted
...
...
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