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
e77a0cf2
Commit
e77a0cf2
authored
Dec 19, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated memory management for Side Nav
parent
69f50f6f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
51 deletions
+56
-51
Examples/MaterialKit.xcworkspace/contents.xcworkspacedata
+7
-7
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController.xcodeproj/project.pbxproj
+6
-0
Sources/SideNavigationViewController.swift
+43
-44
No files found.
Examples/MaterialKit.xcworkspace/contents.xcworkspacedata
View file @
e77a0cf2
...
...
@@ -23,6 +23,13 @@
</Group>
<Group
location =
"container:"
name =
"TextField"
>
<FileRef
location =
"group:Programmatic/TextField/TextField.xcodeproj"
>
</FileRef>
</Group>
<Group
location =
"container:"
name =
"MaterialView"
>
<FileRef
location =
"group:Programmatic/MaterialView/MaterialView.xcodeproj"
>
...
...
@@ -77,13 +84,6 @@
location =
"group:Programmatic/SideNavigationViewController/SideNavigationViewController.xcodeproj"
>
</FileRef>
</Group>
<Group
location =
"container:"
name =
"TextField"
>
<FileRef
location =
"group:Programmatic/TextField/TextField.xcodeproj"
>
</FileRef>
</Group>
</Group>
<Group
location =
"container:"
...
...
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController.xcodeproj/project.pbxproj
View file @
e77a0cf2
...
...
@@ -7,6 +7,8 @@
objects
=
{
/* Begin PBXBuildFile section */
9637D2141C25F7FF00BCAF93
/* MaterialKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9637D2131C25F7FF00BCAF93
/* MaterialKit.framework */
;
};
9637D2151C25F7FF00BCAF93
/* MaterialKit.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9637D2131C25F7FF00BCAF93
/* MaterialKit.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
9642FA1B1C1B50E700022BC6
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9642FA1A1C1B50E700022BC6
/* AppDelegate.swift */
;
};
9642FA1D1C1B50E700022BC6
/* AMainViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9642FA1C1C1B50E700022BC6
/* AMainViewController.swift */
;
};
9642FA221C1B50E700022BC6
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9642FA211C1B50E700022BC6
/* Assets.xcassets */
;
};
...
...
@@ -22,6 +24,7 @@
dstPath
=
""
;
dstSubfolderSpec
=
10
;
files
=
(
9637D2151C25F7FF00BCAF93
/* MaterialKit.framework in Embed Frameworks */
,
);
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -29,6 +32,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
9637D2131C25F7FF00BCAF93
/* MaterialKit.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
MaterialKit.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-anypxbsecgdqqxevbavirvnffqxd/Build/Products/Debug-iphoneos/MaterialKit.framework"
;
sourceTree
=
"<absolute>"
;
};
9642FA171C1B50E700022BC6
/* SideNavigationViewController.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
SideNavigationViewController.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
9642FA1A1C1B50E700022BC6
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
9642FA1C1C1B50E700022BC6
/* AMainViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AMainViewController.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -44,6 +48,7 @@
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
9637D2141C25F7FF00BCAF93
/* MaterialKit.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -53,6 +58,7 @@
9642FA0E1C1B50E700022BC6
=
{
isa
=
PBXGroup
;
children
=
(
9637D2131C25F7FF00BCAF93
/* MaterialKit.framework */
,
9642FA191C1B50E700022BC6
/* SideNavigationViewController */
,
9642FA181C1B50E700022BC6
/* Products */
,
);
...
...
Sources/SideNavigationViewController.swift
View file @
e77a0cf2
...
...
@@ -241,12 +241,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
duration
:
duration
,
options
:
options
,
animations
:
animations
,
completion
:
{
(
result
:
Bool
)
in
self
.
mainViewController
.
removeFromParentViewController
()
toViewController
.
didMoveToParentViewController
(
self
)
self
.
mainViewController
=
toViewController
self
.
userInteractionEnabled
=
!
self
.
opened
completion
?(
result
)
completion
:
{
[
unowned
self
,
mainViewController
=
self
.
mainViewController
]
(
result
:
Bool
)
in
mainViewController
.
removeFromParentViewController
()
toViewController
.
didMoveToParentViewController
(
self
)
self
.
mainViewController
=
toViewController
self
.
userInteractionEnabled
=
!
self
.
opened
completion
?(
result
)
})
}
...
...
@@ -259,16 +259,16 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let
w
:
CGFloat
=
(
hidden
?
-
width
:
width
)
/
2
if
animated
{
MaterialAnimation
.
animateWithDuration
(
0.25
,
animations
:
{
s
elf
.
s
ideView
.
width
=
width
s
elf
.
s
ideView
.
position
.
x
=
w
})
{
MaterialAnimation
.
animateWithDuration
(
0.25
,
animations
:
{
[
unowned
sideView
=
self
.
sideView
]
in
sideView
.
width
=
width
sideView
.
position
.
x
=
w
})
{
[
unowned
self
]
in
self
.
userInteractionEnabled
=
false
}
}
else
{
MaterialAnimation
.
animationDisabled
{
s
elf
.
s
ideView
.
width
=
width
s
elf
.
s
ideView
.
position
.
x
=
w
MaterialAnimation
.
animationDisabled
{
[
unowned
sideView
=
self
.
sideView
]
in
sideView
.
width
=
width
sideView
.
position
.
x
=
w
}
}
}
...
...
@@ -290,18 +290,18 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
delegate
?
.
sideNavigationViewWillOpen
?(
self
)
MaterialAnimation
.
animateWithDuration
(
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
sideView
.
x
/
velocity
)))),
animations
:
{
s
elf
.
sideView
.
position
=
CGPointMake
(
self
.
sideView
.
width
/
2
,
self
.
sideView
.
height
/
2
)
})
{
animations
:
{
[
unowned
sideView
=
self
.
sideView
]
in
s
ideView
.
position
=
CGPointMake
(
sideView
.
width
/
2
,
sideView
.
height
/
2
)
})
{
[
unowned
self
,
weak
delegate
=
self
.
delegate
]
in
self
.
userInteractionEnabled
=
false
if
self
.
enableShadowDepth
{
MaterialAnimation
.
animationDisabled
{
s
elf
.
s
ideView
.
shadowDepth
=
self
.
shadowDepth
MaterialAnimation
.
animationDisabled
{
[
unowned
self
,
unowned
sideView
=
self
.
sideView
]
in
sideView
.
shadowDepth
=
self
.
shadowDepth
}
}
self
.
delegate
?
.
sideNavigationViewDidOpen
?(
self
)
delegate
?
.
sideNavigationViewDidOpen
?(
self
)
}
}
...
...
@@ -315,18 +315,18 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
delegate
?
.
sideNavigationViewWillClose
?(
self
)
MaterialAnimation
.
animateWithDuration
(
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
sideView
.
x
/
velocity
)))),
animations
:
{
s
elf
.
sideView
.
position
=
CGPointMake
(
-
self
.
sideView
.
width
/
2
,
self
.
sideView
.
height
/
2
)
})
{
animations
:
{
[
unowned
sideView
=
self
.
sideView
]
in
s
ideView
.
position
=
CGPointMake
(
-
sideView
.
width
/
2
,
sideView
.
height
/
2
)
})
{
[
unowned
self
,
weak
delegate
=
self
.
delegate
]
in
self
.
userInteractionEnabled
=
true
if
self
.
enableShadowDepth
{
MaterialAnimation
.
animationDisabled
{
s
elf
.
s
ideView
.
shadowDepth
=
.
None
MaterialAnimation
.
animationDisabled
{
[
unowned
sideView
=
self
.
sideView
]
in
sideView
.
shadowDepth
=
.
None
}
}
self
.
delegate
?
.
sideNavigationViewDidClose
?(
self
)
delegate
?
.
sideNavigationViewDidClose
?(
self
)
}
}
...
...
@@ -334,16 +334,15 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
:name: gestureRecognizer
*/
public
func
gestureRecognizer
(
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceiveTouch
touch
:
UITouch
)
->
Bool
{
if
!
enabled
{
return
false
}
if
gestureRecognizer
==
sidePanGesture
{
return
gesturePanSideViewController
(
gestureRecognizer
,
withTouchPoint
:
touch
.
locationInView
(
view
))
}
if
gestureRecognizer
==
sideTapGesture
&&
opened
{
let
point
:
CGPoint
=
touch
.
locationInView
(
view
)
delegate
?
.
sideNavigationViewDidTap
?(
self
,
point
:
point
)
return
!
isPointContainedWithinViewController
(
sideView
,
point
:
point
)
if
enabled
{
if
gestureRecognizer
==
sidePanGesture
{
return
gesturePanSideViewController
(
gestureRecognizer
,
withTouchPoint
:
touch
.
locationInView
(
view
))
}
if
gestureRecognizer
==
sideTapGesture
&&
opened
{
let
point
:
CGPoint
=
touch
.
locationInView
(
view
)
delegate
?
.
sideNavigationViewDidTap
?(
self
,
point
:
point
)
return
!
isPointContainedWithinViewController
(
sideView
,
point
:
point
)
}
}
return
false
}
...
...
@@ -380,9 +379,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
sideView
.
backgroundColor
=
MaterialColor
.
clear
view
.
addSubview
(
sideView
)
MaterialAnimation
.
animationDisabled
{
s
elf
.
s
ideView
.
position
.
x
=
-
self
.
sideViewControllerWidth
/
2
s
elf
.
s
ideView
.
zPosition
=
1000
MaterialAnimation
.
animationDisabled
{
[
unowned
self
,
unowned
sideView
=
self
.
sideView
]
in
sideView
.
position
.
x
=
-
self
.
sideViewControllerWidth
/
2
sideView
.
zPosition
=
1000
}
prepareSideViewController
()
...
...
@@ -399,8 +398,8 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
originalPosition
=
sideView
.
position
toggleStatusBar
(
true
)
if
enableShadowDepth
{
MaterialAnimation
.
animationDisabled
{
s
elf
.
s
ideView
.
shadowDepth
=
self
.
shadowDepth
MaterialAnimation
.
animationDisabled
{
[
unowned
self
,
sideView
=
self
.
sideView
]
in
sideView
.
shadowDepth
=
self
.
shadowDepth
}
}
delegate
?
.
sideNavigationViewPanDidBegin
?(
self
,
point
:
sideView
.
position
)
...
...
@@ -408,9 +407,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let
translation
:
CGPoint
=
recognizer
.
translationInView
(
sideView
)
let
w
:
CGFloat
=
sideView
.
width
MaterialAnimation
.
animationDisabled
{
s
elf
.
s
ideView
.
position
.
x
=
self
.
originalPosition
.
x
+
translation
.
x
>
(
w
/
2
)
?
(
w
/
2
)
:
self
.
originalPosition
.
x
+
translation
.
x
self
.
delegate
?
.
sideNavigationViewPanDidChange
?(
self
,
point
:
self
.
sideView
.
position
)
MaterialAnimation
.
animationDisabled
{
[
unowned
self
,
weak
delegate
=
self
.
delegate
,
unowned
sideView
=
self
.
sideView
]
in
sideView
.
position
.
x
=
self
.
originalPosition
.
x
+
translation
.
x
>
(
w
/
2
)
?
(
w
/
2
)
:
self
.
originalPosition
.
x
+
translation
.
x
delegate
?
.
sideNavigationViewPanDidChange
?(
self
,
point
:
sideView
.
position
)
}
case
.
Ended
,
.
Cancelled
,
.
Failed
:
let
point
:
CGPoint
=
recognizer
.
velocityInView
(
recognizer
.
view
)
...
...
@@ -519,7 +518,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
:name: layoutBackdropLayer
*/
private
func
layoutBackdropLayer
()
{
MaterialAnimation
.
animationDisabled
{
MaterialAnimation
.
animationDisabled
{
[
unowned
self
]
in
self
.
backdropLayer
.
frame
=
self
.
view
.
bounds
}
}
...
...
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