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
44b579be
Commit
44b579be
authored
Oct 19, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating SideNavigationViewController API and animations
parent
654641a9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
61 deletions
+83
-61
Source/MaterialAnimation.swift
+0
-7
Source/MaterialButton.swift
+10
-10
Source/MaterialPulseCollectionViewCell.swift
+10
-10
Source/MaterialTextView.swift
+7
-7
Source/MaterialView.swift
+8
-8
Source/SearchBarView.swift
+12
-6
Source/SideNavigationViewController.swift
+36
-13
No files found.
Source/MaterialAnimation.swift
View file @
44b579be
...
...
@@ -20,14 +20,7 @@ import UIKit
@objc(MaterialAnimationDelegate)
public
protocol
MaterialAnimationDelegate
:
MaterialDelegate
{
/**
:name: materialAnimationDidStart
*/
optional
func
materialAnimationDidStart
(
animation
:
CAAnimation
)
/**
:name: materialAnimationDidStop
*/
optional
func
materialAnimationDidStop
(
animation
:
CAAnimation
,
finished
flag
:
Bool
)
}
...
...
Source/MaterialButton.swift
View file @
44b579be
...
...
@@ -106,10 +106,10 @@ public class MaterialButton : UIButton {
*/
public
var
x
:
CGFloat
{
get
{
return
frame
.
origin
.
x
return
layer
.
frame
.
origin
.
x
}
set
(
value
)
{
frame
.
origin
.
x
=
value
layer
.
frame
.
origin
.
x
=
value
}
}
...
...
@@ -118,10 +118,10 @@ public class MaterialButton : UIButton {
*/
public
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
return
layer
.
frame
.
origin
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
layer
.
frame
.
origin
.
y
=
value
}
}
...
...
@@ -130,12 +130,12 @@ public class MaterialButton : UIButton {
*/
public
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
return
layer
.
frame
.
size
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
layer
.
frame
.
size
.
width
=
value
if
.
None
!=
shape
{
frame
.
size
.
height
=
value
layer
.
frame
.
size
.
height
=
value
}
}
}
...
...
@@ -145,12 +145,12 @@ public class MaterialButton : UIButton {
*/
public
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
return
layer
.
frame
.
size
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
layer
.
frame
.
size
.
height
=
value
if
.
None
!=
shape
{
frame
.
size
.
width
=
value
layer
.
frame
.
size
.
width
=
value
}
}
}
...
...
Source/MaterialPulseCollectionViewCell.swift
View file @
44b579be
...
...
@@ -128,10 +128,10 @@ public class MaterialPulseCollectionViewCell : UICollectionViewCell {
*/
public
var
x
:
CGFloat
{
get
{
return
frame
.
origin
.
x
return
layer
.
frame
.
origin
.
x
}
set
(
value
)
{
frame
.
origin
.
x
=
value
layer
.
frame
.
origin
.
x
=
value
}
}
...
...
@@ -140,10 +140,10 @@ public class MaterialPulseCollectionViewCell : UICollectionViewCell {
*/
public
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
return
layer
.
frame
.
origin
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
layer
.
frame
.
origin
.
y
=
value
}
}
...
...
@@ -152,12 +152,12 @@ public class MaterialPulseCollectionViewCell : UICollectionViewCell {
*/
public
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
return
layer
.
frame
.
size
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
layer
.
frame
.
size
.
width
=
value
if
.
None
!=
shape
{
frame
.
size
.
height
=
value
layer
.
frame
.
size
.
height
=
value
}
}
}
...
...
@@ -167,12 +167,12 @@ public class MaterialPulseCollectionViewCell : UICollectionViewCell {
*/
public
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
return
layer
.
frame
.
size
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
layer
.
frame
.
size
.
height
=
value
if
.
None
!=
shape
{
frame
.
size
.
width
=
value
layer
.
frame
.
size
.
width
=
value
}
}
}
...
...
Source/MaterialTextView.swift
View file @
44b579be
...
...
@@ -27,7 +27,7 @@ public class MaterialTextView: UITextView {
internal
lazy
var
layoutConstraints
:
Array
<
NSLayoutConstraint
>
=
Array
<
NSLayoutConstraint
>
()
/**
:name: init
:name: init
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
...
...
@@ -35,7 +35,7 @@ public class MaterialTextView: UITextView {
}
/**
:name: init
:name: init
*/
public
override
init
(
frame
:
CGRect
,
textContainer
:
NSTextContainer
?)
{
super
.
init
(
frame
:
frame
,
textContainer
:
textContainer
)
...
...
@@ -50,7 +50,7 @@ public class MaterialTextView: UITextView {
}
/**
:name: placeholder
:name: placeholder
*/
public
var
placeholderLabel
:
UILabel
?
{
didSet
{
...
...
@@ -69,7 +69,7 @@ public class MaterialTextView: UITextView {
/**
:name: text
:name: text
*/
public
override
var
text
:
String
!
{
didSet
{
...
...
@@ -78,7 +78,7 @@ public class MaterialTextView: UITextView {
}
/**
:name: attributedText
:name: attributedText
*/
public
override
var
attributedText
:
NSAttributedString
!
{
didSet
{
...
...
@@ -87,7 +87,7 @@ public class MaterialTextView: UITextView {
}
/**
:name: textContainerInset
:name: textContainerInset
*/
public
override
var
textContainerInset
:
UIEdgeInsets
{
didSet
{
...
...
@@ -101,7 +101,7 @@ public class MaterialTextView: UITextView {
}
/**
:name: updateLabelConstraints
:name: updateLabelConstraints
*/
internal
func
updateLabelConstraints
()
{
if
let
p
=
placeholderLabel
{
...
...
Source/MaterialView.swift
View file @
44b579be
...
...
@@ -113,10 +113,10 @@ public class MaterialView : UIView {
*/
public
var
y
:
CGFloat
{
get
{
return
frame
.
origin
.
y
return
layer
.
frame
.
origin
.
y
}
set
(
value
)
{
frame
.
origin
.
y
=
value
layer
.
frame
.
origin
.
y
=
value
}
}
...
...
@@ -125,12 +125,12 @@ public class MaterialView : UIView {
*/
public
var
width
:
CGFloat
{
get
{
return
frame
.
size
.
width
return
layer
.
frame
.
size
.
width
}
set
(
value
)
{
frame
.
size
.
width
=
value
layer
.
frame
.
size
.
width
=
value
if
.
None
!=
shape
{
frame
.
size
.
height
=
value
layer
.
frame
.
size
.
height
=
value
}
}
}
...
...
@@ -140,12 +140,12 @@ public class MaterialView : UIView {
*/
public
var
height
:
CGFloat
{
get
{
return
frame
.
size
.
height
return
layer
.
frame
.
size
.
height
}
set
(
value
)
{
frame
.
size
.
height
=
value
layer
.
frame
.
size
.
height
=
value
if
.
None
!=
shape
{
frame
.
size
.
width
=
value
layer
.
frame
.
size
.
width
=
value
}
}
}
...
...
Source/SearchBarView.swift
View file @
44b579be
...
...
@@ -18,6 +18,13 @@
import
UIKit
@objc(SearchBarViewDelegate)
public
protocol
SearchBarViewDelegate
:
MaterialDelegate
{
optional
func
materialSearchBarDidBeginEditing
(
searchBarView
:
SearchBarView
)
optional
func
materialSearchBarDidEndEditing
(
searchBarView
:
SearchBarView
)
}
@objc(SearchBarView)
public
class
SearchBarView
:
MaterialView
,
UITextFieldDelegate
{
/**
:name: internalBackgroundColor
...
...
@@ -216,7 +223,7 @@ public class SearchBarView : MaterialView, UITextFieldDelegate {
views
[
"textField"
]
=
textField
addSubview
(
textField
)
print
(
contentInsetsRef
)
MaterialLayout
.
alignToParentHorizontallyWithInsets
(
self
,
child
:
textField
,
left
:
contentInsetsRef
.
left
+
textFieldInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
textFieldInsetsRef
.
right
)
// leftButtons
...
...
@@ -300,20 +307,19 @@ public class SearchBarView : MaterialView, UITextFieldDelegate {
internal
func
prepareTextField
()
{
textField
.
translatesAutoresizingMaskIntoConstraints
=
false
textField
.
delegate
=
self
textField
.
placeholder
=
"Search"
}
public
func
textField
ShouldBeginEditing
(
textField
:
UITextField
)
->
Bool
{
public
func
textField
DidBeginEditing
(
textField
:
UITextField
)
{
if
let
v
:
UIColor
=
editingBackgroundColor
{
internalBackgroundColor
=
backgroundColor
backgroundColor
=
v
}
return
true
(
delegate
as?
SearchBarViewDelegate
)?
.
materialSearchBarDidBeginEditing
?(
self
)
}
public
func
textField
ShouldEndEditing
(
textField
:
UITextField
)
->
Bool
{
public
func
textField
DidEndEditing
(
textField
:
UITextField
)
{
backgroundColor
=
internalBackgroundColor
internalBackgroundColor
=
nil
return
true
(
delegate
as?
SearchBarViewDelegate
)?
.
materialSearchBarDidEndEditing
?(
self
)
}
}
Source/SideNavigationViewController.swift
View file @
44b579be
...
...
@@ -138,16 +138,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/**
:name: leftViewControllerWidth
*/
public
var
leftViewControllerWidth
:
CGFloat
=
240
{
didSet
{
if
let
v
=
leftView
{
v
.
width
=
leftViewControllerWidth
MaterialAnimation
.
animationDisabled
({
v
.
position
=
CGPointMake
(
-
v
.
width
/
2
,
v
.
height
/
2
)
})
}
}
}
public
private(set)
var
leftViewControllerWidth
:
CGFloat
=
240
/**
:name: init
...
...
@@ -182,6 +173,33 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
super
.
viewDidLoad
()
edgesForExtendedLayout
=
.
None
}
public
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
layoutBackdropLayer
()
if
let
v
:
MaterialView
=
leftView
{
leftViewController
?
.
view
.
frame
=
v
.
bounds
}
}
/**
:name: setLeftViewControllerWidth
*/
public
func
setLeftViewControllerWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
CFTimeInterval
=
0.25
)
{
leftViewControllerWidth
=
width
MaterialAnimation
.
animationDisabled
({
self
.
leftView
!.
width
=
width
})
if
animated
{
leftView
!.
animation
(
MaterialAnimation
.
position
(
CGPointMake
((
hidden
?
-
width
:
width
)
/
2
,
leftView
!.
position
.
y
),
duration
:
duration
))
}
else
{
MaterialAnimation
.
animationDisabled
({
self
.
leftView
!.
position
.
x
=
(
hidden
?
-
width
:
width
)
/
2
})
}
}
/**
:name: toggleLeftViewContainer
...
...
@@ -397,23 +415,28 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
// :name: prepareBackdropLayer
//
private
func
prepareBackdropLayer
()
{
view
.
layer
.
addSublayer
(
backdropLayer
)
}
//
// :name: layoutBackdropLayer
//
private
func
layoutBackdropLayer
()
{
MaterialAnimation
.
animationDisabled
({
self
.
backdropLayer
.
frame
=
self
.
view
.
bounds
self
.
backdropLayer
.
zPosition
=
900
self
.
backdropLayer
.
hidden
=
true
})
view
.
layer
.
addSublayer
(
backdropLayer
)
}
//
// :name: prepareViewControllerWithinContainer
//
private
func
prepareViewControllerWithinContainer
(
controller
:
UIViewController
,
container
:
UIView
)
{
controller
.
view
.
translatesAutoresizingMaskIntoConstraints
=
false
controller
.
view
.
autoresizingMask
=
[
.
FlexibleWidth
,
.
FlexibleHeight
]
addChildViewController
(
controller
)
container
.
addSubview
(
controller
.
view
)
controller
.
didMoveToParentViewController
(
self
)
MaterialLayout
.
alignToParent
(
container
,
child
:
controller
.
view
)
}
//
...
...
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