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
4e5e7bcc
Commit
4e5e7bcc
authored
Mar 27, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issues with Swift 3
parent
7cccc6ec
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
86 additions
and
125 deletions
+86
-125
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
+0
-6
Examples/Programmatic/App/App/AppSearchBarViewController.swift
+6
-8
Examples/Programmatic/App/App/ItemViewController.swift
+6
-0
Examples/Programmatic/App/App/RecipesViewController.swift
+3
-1
Material.xcodeproj/project.pbxproj
+0
-6
Sources/CardView.swift
+6
-2
Sources/ImageCardView.swift
+6
-2
Sources/Material+UIImage+Crop.swift
+5
-5
Sources/Material+UIImage+PhotoLibrary.swift
+0
-41
Sources/Material+UIImage+Resize.swift
+9
-6
Sources/MaterialButton.swift
+3
-6
Sources/MaterialCollectionViewCell.swift
+3
-6
Sources/MaterialLayout.swift
+4
-2
Sources/MaterialPulseAnimation.swift
+17
-14
Sources/MaterialPulseView.swift
+3
-6
Sources/MaterialTableViewCell.swift
+3
-6
Sources/SideNavigationController.swift
+12
-8
No files found.
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
View file @
4e5e7bcc
...
...
@@ -7,8 +7,6 @@
objects
=
{
/* Begin PBXBuildFile section */
96162C691CA7191800E3A235
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C681CA7191800E3A235
/* Material.framework */
;
};
96162C6A1CA7191800E3A235
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C681CA7191800E3A235
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
96162C6C1CA71C8700E3A235
/* VideoViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C6B1CA71C8700E3A235
/* VideoViewController.swift */
;
};
96162C6E1CA7274E00E3A235
/* PhotoViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C6D1CA7274E00E3A235
/* PhotoViewController.swift */
;
};
9663F9321C7A744600AF0965
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9311C7A744600AF0965
/* AppDelegate.swift */
;
};
...
...
@@ -30,7 +28,6 @@
dstPath
=
""
;
dstSubfolderSpec
=
10
;
files
=
(
96162C6A1CA7191800E3A235
/* Material.framework in Embed Frameworks */
,
);
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -38,7 +35,6 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
96162C681CA7191800E3A235
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
96162C6B1CA71C8700E3A235
/* VideoViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
VideoViewController.swift
;
sourceTree
=
"<group>"
;
};
96162C6D1CA7274E00E3A235
/* PhotoViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoViewController.swift
;
sourceTree
=
"<group>"
;
};
9663F92E1C7A744600AF0965
/* App.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
App.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
...
...
@@ -60,7 +56,6 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
96162C691CA7191800E3A235
/* Material.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -70,7 +65,6 @@
9663F9251C7A744500AF0965
=
{
isa
=
PBXGroup
;
children
=
(
96162C681CA7191800E3A235
/* Material.framework */
,
9663F9301C7A744600AF0965
/* App */
,
9663F92F1C7A744600AF0965
/* Products */
,
);
...
...
Examples/Programmatic/App/App/AppSearchBarViewController.swift
View file @
4e5e7bcc
...
...
@@ -43,12 +43,6 @@ class AppSearchBarController: SearchBarController {
prepareSearchBar
()
}
override
func
viewWillDisappear
(
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
searchBar
.
textField
.
resignFirstResponder
()
sideNavigationController
?
.
enabled
=
true
}
override
func
viewWillAppear
(
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
searchBar
.
statusBarStyle
=
.
Default
...
...
@@ -60,6 +54,12 @@ class AppSearchBarController: SearchBarController {
searchBar
.
textField
.
becomeFirstResponder
()
}
override
func
viewWillDisappear
(
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
searchBar
.
textField
.
resignFirstResponder
()
sideNavigationController
?
.
enabled
=
true
}
/// Toggle SideSearchViewController left UIViewController.
internal
func
handleBackButton
()
{
searchBar
.
textField
.
resignFirstResponder
()
...
...
@@ -108,8 +108,6 @@ class AppSearchBarController: SearchBarController {
searchBar
.
placeholderTextColor
=
MaterialColor
.
grey
.
darken4
searchBar
.
textField
.
font
=
RobotoFont
.
regular
searchBar
.
textField
.
delegate
=
self
searchBar
.
contentInset
.
left
=
8
searchBar
.
contentInset
.
right
=
8
searchBar
.
clearButton
=
clearButton
searchBar
.
leftControls
=
[
backButton
]
...
...
Examples/Programmatic/App/App/ItemViewController.swift
View file @
4e5e7bcc
...
...
@@ -73,6 +73,12 @@ class ItemViewController: UIViewController {
prepareImageCardView
()
}
override
func
viewWillAppear
(
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
// Stops the scrollView contentInsets from being automatically adjusted.
automaticallyAdjustsScrollViewInsets
=
false
}
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
scrollView
.
frame
=
view
.
bounds
...
...
Examples/Programmatic/App/App/RecipesViewController.swift
View file @
4e5e7bcc
...
...
@@ -63,6 +63,9 @@ class RecipesViewController: UIViewController {
override
func
viewWillAppear
(
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
// Stops the tableView contentInsets from being automatically adjusted.
automaticallyAdjustsScrollViewInsets
=
false
// Set the navigationBar style.
navigationController
?
.
navigationBar
.
statusBarStyle
=
.
LightContent
...
...
@@ -213,7 +216,6 @@ class RecipesViewController: UIViewController {
/// Prepares view.
private
func
prepareView
()
{
view
.
backgroundColor
=
MaterialColor
.
white
automaticallyAdjustsScrollViewInsets
=
false
}
/// Prepares the titleLabel.
...
...
Material.xcodeproj/project.pbxproj
View file @
4e5e7bcc
...
...
@@ -13,7 +13,6 @@
960B232E1C383EAA00E96216
/* Material+UIImage.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B23281C383EAA00E96216
/* Material+UIImage.swift */
;
};
960B232F1C383EAA00E96216
/* Material+UIImage+Crop.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B23291C383EAA00E96216
/* Material+UIImage+Crop.swift */
;
};
960B23301C383EAA00E96216
/* Material+UIImage+Network.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B232A1C383EAA00E96216
/* Material+UIImage+Network.swift */
;
};
960B23311C383EAA00E96216
/* Material+UIImage+PhotoLibrary.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B232B1C383EAA00E96216
/* Material+UIImage+PhotoLibrary.swift */
;
};
960B23321C383EAA00E96216
/* Material+UIImage+Resize.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B232C1C383EAA00E96216
/* Material+UIImage+Resize.swift */
;
};
960B23331C383EAA00E96216
/* Material+UIImage+Size.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B232D1C383EAA00E96216
/* Material+UIImage+Size.swift */
;
};
960B23461C38480E00E96216
/* Text.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B23431C38480E00E96216
/* Text.swift */
;
};
...
...
@@ -23,7 +22,6 @@
960B234A1C38490D00E96216
/* Material+UIImage.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B23281C383EAA00E96216
/* Material+UIImage.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
960B234B1C38490D00E96216
/* Material+UIImage+Crop.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B23291C383EAA00E96216
/* Material+UIImage+Crop.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
960B234C1C38490D00E96216
/* Material+UIImage+Network.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B232A1C383EAA00E96216
/* Material+UIImage+Network.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
960B234D1C38490D00E96216
/* Material+UIImage+PhotoLibrary.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B232B1C383EAA00E96216
/* Material+UIImage+PhotoLibrary.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
960B234E1C38490D00E96216
/* Material+UIImage+Resize.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B232C1C383EAA00E96216
/* Material+UIImage+Resize.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
960B234F1C38490D00E96216
/* Material+UIImage+Size.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B232D1C383EAA00E96216
/* Material+UIImage+Size.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
960B23501C38490D00E96216
/* Text.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
960B23431C38480E00E96216
/* Text.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
...
@@ -181,7 +179,6 @@
960B23281C383EAA00E96216
/* Material+UIImage.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage.swift"
;
sourceTree
=
"<group>"
;
};
960B23291C383EAA00E96216
/* Material+UIImage+Crop.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Crop.swift"
;
sourceTree
=
"<group>"
;
};
960B232A1C383EAA00E96216
/* Material+UIImage+Network.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Network.swift"
;
sourceTree
=
"<group>"
;
};
960B232B1C383EAA00E96216
/* Material+UIImage+PhotoLibrary.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+PhotoLibrary.swift"
;
sourceTree
=
"<group>"
;
};
960B232C1C383EAA00E96216
/* Material+UIImage+Resize.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Resize.swift"
;
sourceTree
=
"<group>"
;
};
960B232D1C383EAA00E96216
/* Material+UIImage+Size.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+Size.swift"
;
sourceTree
=
"<group>"
;
};
960B23431C38480E00E96216
/* Text.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Text.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -554,7 +551,6 @@
960B23281C383EAA00E96216
/* Material+UIImage.swift */
,
960B23291C383EAA00E96216
/* Material+UIImage+Crop.swift */
,
960B232A1C383EAA00E96216
/* Material+UIImage+Network.swift */
,
960B232B1C383EAA00E96216
/* Material+UIImage+PhotoLibrary.swift */
,
960B232C1C383EAA00E96216
/* Material+UIImage+Resize.swift */
,
960B232D1C383EAA00E96216
/* Material+UIImage+Size.swift */
,
96DBA7351C61198400844821
/* Material+UIImage+Color.swift */
,
...
...
@@ -657,7 +653,6 @@
960B234A1C38490D00E96216
/* Material+UIImage.swift in Headers */
,
960B234B1C38490D00E96216
/* Material+UIImage+Crop.swift in Headers */
,
960B234C1C38490D00E96216
/* Material+UIImage+Network.swift in Headers */
,
960B234D1C38490D00E96216
/* Material+UIImage+PhotoLibrary.swift in Headers */
,
960B234E1C38490D00E96216
/* Material+UIImage+Resize.swift in Headers */
,
960B234F1C38490D00E96216
/* Material+UIImage+Size.swift in Headers */
,
960B23501C38490D00E96216
/* Text.swift in Headers */
,
...
...
@@ -838,7 +833,6 @@
96D88C221C1328D800B91418
/* FabButton.swift in Sources */
,
96D88C3F1C1328D800B91418
/* RaisedButton.swift in Sources */
,
65FDC2EB1C66858A00103AC2
/* Menu.swift in Sources */
,
960B23311C383EAA00E96216
/* Material+UIImage+PhotoLibrary.swift in Sources */
,
960B23321C383EAA00E96216
/* Material+UIImage+Resize.swift in Sources */
,
96D88C3C1C1328D800B91418
/* MaterialTransitionAnimation.swift in Sources */
,
96D88C361C1328D800B91418
/* MaterialPulseView.swift in Sources */
,
...
...
Sources/CardView.swift
View file @
4e5e7bcc
...
...
@@ -322,7 +322,7 @@ public class CardView : MaterialPulseView {
d
[
k
]
=
b
if
0
==
i
++
{
if
0
==
i
{
h
+=
"-(left)-"
}
else
{
h
+=
"-(left_right)-"
...
...
@@ -332,6 +332,8 @@ public class CardView : MaterialPulseView {
addSubview
(
b
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
i
+=
1
}
addConstraints
(
MaterialLayout
.
constraint
(
h
,
options
:
[],
metrics
:
[
"left"
:
contentInset
.
left
+
leftButtonsInset
.
left
,
"left_right"
:
leftButtonsInset
.
left
+
leftButtonsInset
.
right
],
views
:
d
))
...
...
@@ -352,7 +354,7 @@ public class CardView : MaterialPulseView {
h
+=
"[
\(
k
)
]"
if
0
==
i
--
{
if
0
==
i
{
h
+=
"-(right)-"
}
else
{
h
+=
"-(right_left)-"
...
...
@@ -360,6 +362,8 @@ public class CardView : MaterialPulseView {
addSubview
(
b
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
i
-=
1
}
addConstraints
(
MaterialLayout
.
constraint
(
h
+
"|"
,
options
:
[],
metrics
:
[
"right"
:
contentInset
.
right
+
rightButtonsInset
.
right
,
"right_left"
:
rightButtonsInset
.
right
+
rightButtonsInset
.
left
],
views
:
d
))
...
...
Sources/ImageCardView.swift
View file @
4e5e7bcc
...
...
@@ -425,7 +425,7 @@ public class ImageCardView : MaterialPulseView {
d
[
k
]
=
b
if
0
==
i
++
{
if
0
==
i
{
h
+=
"-(left)-"
}
else
{
h
+=
"-(left_right)-"
...
...
@@ -435,6 +435,8 @@ public class ImageCardView : MaterialPulseView {
addSubview
(
b
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
contentInset
.
bottom
+
leftButtonsInset
.
bottom
)
i
+=
1
}
addConstraints
(
MaterialLayout
.
constraint
(
h
,
options
:
[],
metrics
:
[
"left"
:
contentInset
.
left
+
leftButtonsInset
.
left
,
"left_right"
:
leftButtonsInset
.
left
+
leftButtonsInset
.
right
],
views
:
d
))
...
...
@@ -455,7 +457,7 @@ public class ImageCardView : MaterialPulseView {
h
+=
"[
\(
k
)
]"
if
0
==
i
--
{
if
0
==
i
{
h
+=
"-(right)-"
}
else
{
h
+=
"-(right_left)-"
...
...
@@ -463,6 +465,8 @@ public class ImageCardView : MaterialPulseView {
addSubview
(
b
)
MaterialLayout
.
alignFromBottom
(
self
,
child
:
b
,
bottom
:
contentInset
.
bottom
+
rightButtonsInset
.
bottom
)
i
-=
1
}
addConstraints
(
MaterialLayout
.
constraint
(
h
+
"|"
,
options
:
[],
metrics
:
[
"right"
:
contentInset
.
right
+
rightButtonsInset
.
right
,
"right_left"
:
rightButtonsInset
.
right
+
rightButtonsInset
.
left
],
views
:
d
))
...
...
Sources/Material+UIImage+Crop.swift
View file @
4e5e7bcc
...
...
@@ -34,14 +34,14 @@ public extension UIImage {
/**
:name: crop
*/
public
func
crop
(
var
toWidth
w
:
CGFloat
,
var
toHeight
h
:
CGFloat
)
->
UIImage
?
{
public
func
crop
(
toWidth
tw
:
CGFloat
,
toHeight
t
h
:
CGFloat
)
->
UIImage
?
{
let
g
:
UIImage
?
let
b
:
Bool
=
width
>
height
let
s
:
CGFloat
=
b
?
h
/
height
:
w
/
width
let
t
:
CGSize
=
CGSizeMake
(
w
,
h
)
let
s
:
CGFloat
=
b
?
th
/
height
:
t
w
/
width
let
t
:
CGSize
=
CGSizeMake
(
tw
,
t
h
)
w
=
width
*
s
h
=
height
*
s
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
)
...
...
Sources/Material+UIImage+PhotoLibrary.swift
deleted
100644 → 0
View file @
7cccc6ec
/*
* 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 Material 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: writeToPhotoLibrary
*/
public
func
writeToPhotoLibrary
(
target
t
:
AnyObject
?
=
nil
)
{
UIImageWriteToSavedPhotosAlbum
(
self
,
t
,
"image:didFinishSavingWithError:contextInfo:"
,
nil
)
}
}
\ No newline at end of file
Sources/Material+UIImage+Resize.swift
View file @
4e5e7bcc
...
...
@@ -34,15 +34,18 @@ public extension UIImage {
/**
:name: internalResize
*/
private
func
internalResize
(
var
toWidth
w
:
CGFloat
=
0
,
var
toHeight
h
:
CGFloat
=
0
)
->
UIImage
?
{
if
0
<
w
{
h
=
height
*
w
/
width
}
else
if
0
<
h
{
w
=
width
*
h
/
height
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
=
CGRectMake
(
0
,
0
,
w
,
h
)
let
t
:
CGRect
=
CGRectMake
(
0
,
0
,
nil
==
w
?
tw
:
w
!
,
nil
==
h
?
th
:
h
!
)
UIGraphicsBeginImageContextWithOptions
(
t
.
size
,
false
,
MaterialDevice
.
scale
)
drawInRect
(
t
,
blendMode
:
.
Normal
,
alpha
:
1
)
g
=
UIGraphicsGetImageFromCurrentImageContext
()
...
...
Sources/MaterialButton.swift
View file @
4e5e7bcc
...
...
@@ -408,15 +408,12 @@ public class MaterialButton : UIButton {
- Parameter point: A Optional point to pulse from, otherwise pulses
from the center.
*/
public
func
pulse
(
var
point
:
CGPoint
?
=
nil
)
{
if
nil
==
point
{
point
=
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
}
public
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
let
p
:
CGPoint
=
nil
==
point
?
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
:
point
!
let
duration
:
NSTimeInterval
=
MaterialAnimation
.
pulseDuration
(
width
)
if
let
v
:
UIColor
=
pulseColor
{
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
p
oint
!
,
width
:
width
,
height
:
height
,
duration
:
duration
)
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
p
,
width
:
width
,
height
:
height
,
duration
:
duration
)
}
if
pulseScale
{
...
...
Sources/MaterialCollectionViewCell.swift
View file @
4e5e7bcc
...
...
@@ -513,15 +513,12 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
- Parameter point: A Optional point to pulse from, otherwise pulses
from the center.
*/
public
func
pulse
(
var
point
:
CGPoint
?
=
nil
)
{
if
nil
==
point
{
point
=
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
}
public
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
let
p
:
CGPoint
=
nil
==
point
?
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
:
point
!
let
duration
:
NSTimeInterval
=
MaterialAnimation
.
pulseDuration
(
width
)
if
let
v
:
UIColor
=
pulseColor
{
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
p
oint
!
,
width
:
width
,
height
:
height
,
duration
:
duration
)
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
p
,
width
:
width
,
height
:
height
,
duration
:
duration
)
}
if
pulseScale
{
...
...
Sources/MaterialLayout.swift
View file @
4e5e7bcc
...
...
@@ -66,7 +66,8 @@ public struct MaterialLayout {
var
i
:
Int
=
1
var
views
:
Dictionary
<
String
,
UIView
>
=
Dictionary
<
String
,
UIView
>
()
for
v
in
children
{
let
k
:
String
=
"view
\(
i
++
)
"
let
k
:
String
=
"view
\(
i
)
"
i
+=
1
views
[
k
]
=
v
format
+=
i
>
children
.
count
?
"[
\(
k
)
(==view1)]-(right)-|"
:
"[
\(
k
)
(==view1)]-(spacing)-"
}
...
...
@@ -83,7 +84,8 @@ public struct MaterialLayout {
var
i
:
Int
=
1
var
views
:
Dictionary
<
String
,
UIView
>
=
Dictionary
<
String
,
UIView
>
()
for
v
in
children
{
let
k
:
String
=
"view
\(
i
++
)
"
let
k
:
String
=
"view
\(
i
)
"
i
+=
1
views
[
k
]
=
v
format
+=
i
>
children
.
count
?
"[
\(
k
)
(==view1)]-(bottom)-|"
:
"[
\(
k
)
(==view1)]-(spacing)-"
}
...
...
Sources/MaterialPulseAnimation.swift
View file @
4e5e7bcc
...
...
@@ -42,7 +42,7 @@ internal extension MaterialAnimation {
- Parameter duration: Animation duration.
- Parameter pulseLayer: An Optional pulseLayer to use in the animation.
*/
internal
static
func
pulseAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
color
:
UIColor
,
point
:
CGPoint
,
width
:
CGFloat
,
height
:
CGFloat
,
duration
:
NSTimeInterval
,
var
pulseLayer
:
CAShapeLayer
?
=
nil
)
{
internal
static
func
pulseAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
color
:
UIColor
,
point
:
CGPoint
,
width
:
CGFloat
,
height
:
CGFloat
,
duration
:
NSTimeInterval
,
pulseLayer
:
CAShapeLayer
?
=
nil
)
{
let
r
:
CGFloat
=
(
width
<
height
?
height
:
width
)
/
2
let
f
:
CGFloat
=
3
...
...
@@ -50,37 +50,40 @@ internal extension MaterialAnimation {
let
d
:
CGFloat
=
2
*
f
var
b
:
Bool
=
false
var
pLayer
:
CAShapeLayer
?
if
nil
==
pulseLayer
{
p
ulse
Layer
=
CAShapeLayer
()
pLayer
=
CAShapeLayer
()
b
=
true
}
else
{
pLayer
=
pulseLayer
}
p
ulse
Layer
!.
hidden
=
true
p
ulse
Layer
!.
zPosition
=
1
p
ulse
Layer
!.
backgroundColor
=
color
.
CGColor
visualLayer
.
addSublayer
(
p
ulse
Layer
!
)
pLayer
!.
hidden
=
true
pLayer
!.
zPosition
=
1
pLayer
!.
backgroundColor
=
color
.
CGColor
visualLayer
.
addSublayer
(
pLayer
!
)
MaterialAnimation
.
animationDisabled
{
p
ulse
Layer
!.
bounds
=
CGRectMake
(
0
,
0
,
v
,
v
)
p
ulse
Layer
!.
position
=
point
p
ulse
Layer
!.
cornerRadius
=
r
/
d
p
ulse
Layer
!.
hidden
=
false
pLayer
!.
bounds
=
CGRectMake
(
0
,
0
,
v
,
v
)
pLayer
!.
position
=
point
pLayer
!.
cornerRadius
=
r
/
d
pLayer
!.
hidden
=
false
}
p
ulse
Layer
!.
addAnimation
(
MaterialAnimation
.
scale
((
b
?
3
:
1.7
)
*
d
,
duration
:
duration
),
forKey
:
nil
)
pLayer
!.
addAnimation
(
MaterialAnimation
.
scale
((
b
?
3
:
1.7
)
*
d
,
duration
:
duration
),
forKey
:
nil
)
if
b
{
MaterialAnimation
.
delay
(
duration
)
{
MaterialAnimation
.
animateWithDuration
(
duration
,
animations
:
{
p
ulse
Layer
?
.
hidden
=
true
pLayer
?
.
hidden
=
true
})
{
p
ulse
Layer
?
.
removeFromSuperlayer
()
pLayer
?
.
removeFromSuperlayer
()
}
}
}
else
{
MaterialAnimation
.
delay
(
duration
/
2
)
{
p
ulse
Layer
?
.
addAnimation
(
MaterialAnimation
.
scale
(
1.3
*
d
,
duration
:
duration
),
forKey
:
nil
)
pLayer
?
.
addAnimation
(
MaterialAnimation
.
scale
(
1.3
*
d
,
duration
:
duration
),
forKey
:
nil
)
}
}
}
...
...
Sources/MaterialPulseView.swift
View file @
4e5e7bcc
...
...
@@ -51,15 +51,12 @@ public class MaterialPulseView : MaterialView {
- Parameter point: A Optional point to pulse from, otherwise pulses
from the center.
*/
public
func
pulse
(
var
point
:
CGPoint
?
=
nil
)
{
if
nil
==
point
{
point
=
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
}
public
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
let
p
:
CGPoint
=
nil
==
point
?
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
:
point
!
let
duration
:
NSTimeInterval
=
MaterialAnimation
.
pulseDuration
(
width
)
if
let
v
:
UIColor
=
pulseColor
{
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
p
oint
!
,
width
:
width
,
height
:
height
,
duration
:
duration
)
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
p
,
width
:
width
,
height
:
height
,
duration
:
duration
)
}
if
pulseScale
{
...
...
Sources/MaterialTableViewCell.swift
View file @
4e5e7bcc
...
...
@@ -363,15 +363,12 @@ public class MaterialTableViewCell : UITableViewCell {
- Parameter point: A Optional point to pulse from, otherwise pulses
from the center.
*/
public
func
pulse
(
var
point
:
CGPoint
?
=
nil
)
{
if
nil
==
point
{
point
=
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
}
public
func
pulse
(
point
:
CGPoint
?
=
nil
)
{
let
p
:
CGPoint
=
nil
==
point
?
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
:
point
!
let
duration
:
NSTimeInterval
=
MaterialAnimation
.
pulseDuration
(
width
)
if
let
v
:
UIColor
=
pulseColor
{
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
p
oint
!
,
width
:
width
,
height
:
height
,
duration
:
duration
)
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
p
,
width
:
width
,
height
:
height
,
duration
:
duration
)
}
if
pulseScale
{
...
...
Sources/SideNavigationController.swift
View file @
4e5e7bcc
...
...
@@ -365,18 +365,20 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
- Parameter animated: A Boolean value that indicates to animate
the leftView width change.
*/
public
func
setLeftViewWidth
(
width
:
CGFloat
,
var
hidden
:
Bool
,
animated
:
Bool
,
duration
:
NSTimeInterval
=
0.5
)
{
public
func
setLeftViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
NSTimeInterval
=
0.5
)
{
if
let
v
:
MaterialView
=
leftView
{
leftViewWidth
=
width
var
hide
:
Bool
=
hidden
if
openedRightView
{
hid
den
=
true
hid
e
=
true
}
if
animated
{
v
.
shadowPathAutoSizeEnabled
=
false
if
hid
den
{
if
hid
e
{
UIView
.
animateWithDuration
(
duration
,
animations
:
{
[
unowned
self
]
in
v
.
bounds
.
size
.
width
=
width
...
...
@@ -401,7 +403,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
}
}
else
{
v
.
bounds
.
size
.
width
=
width
if
hid
den
{
if
hid
e
{
hideView
(
v
)
v
.
position
.
x
=
-
v
.
width
/
2
rootViewController
.
view
.
alpha
=
1
...
...
@@ -429,18 +431,20 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
- Parameter animated: A Boolean value that indicates to animate
the rightView width change.
*/
public
func
setRightViewWidth
(
width
:
CGFloat
,
var
hidden
:
Bool
,
animated
:
Bool
,
duration
:
NSTimeInterval
=
0.5
)
{
public
func
setRightViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
NSTimeInterval
=
0.5
)
{
if
let
v
:
MaterialView
=
rightView
{
rightViewWidth
=
width
var
hide
:
Bool
=
hidden
if
openedLeftView
{
hid
den
=
true
hid
e
=
true
}
if
animated
{
v
.
shadowPathAutoSizeEnabled
=
false
if
hid
den
{
if
hid
e
{
UIView
.
animateWithDuration
(
duration
,
animations
:
{
[
unowned
self
]
in
v
.
bounds
.
size
.
width
=
width
...
...
@@ -465,7 +469,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
}
}
else
{
v
.
bounds
.
size
.
width
=
width
if
hid
den
{
if
hid
e
{
hideView
(
v
)
v
.
position
.
x
=
view
.
bounds
.
width
+
v
.
width
/
2
rootViewController
.
view
.
alpha
=
1
...
...
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