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