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
05b19fa0
Unverified
Commit
05b19fa0
authored
Sep 09, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated NavigationDrawerController to be open rather than public
parent
d5605753
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
34 deletions
+47
-34
Sources/iOS/NavigationDrawerController.swift
+47
-34
No files found.
Sources/iOS/NavigationDrawerController.swift
View file @
05b19fa0
...
...
@@ -122,7 +122,7 @@ public protocol NavigationDrawerControllerDelegate {
@IBDesignable
@objc(NavigationDrawerController)
public
class
NavigationDrawerController
:
RootController
,
UIGestureRecognizerDelegate
{
open
class
NavigationDrawerController
:
RootController
,
UIGestureRecognizerDelegate
{
/**
A CGFloat property that is used internally to track
the original (x) position of the container view when panning.
...
...
@@ -185,13 +185,15 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
A CGFloat property that sets the animation duration of the
leftView when closing and opening. Defaults to 0.25.
*/
@IBInspectable
public
var
animationDuration
:
TimeInterval
=
0.25
@IBInspectable
open
var
animationDuration
:
TimeInterval
=
0.25
/**
A Boolean property that enables and disables the leftView from
opening and closing. Defaults to true.
*/
@IBInspectable
public
var
enabled
:
Bool
{
@IBInspectable
open
var
enabled
:
Bool
{
get
{
return
enabledLeftView
||
enabledRightView
}
...
...
@@ -209,7 +211,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
A Boolean property that enables and disables the leftView from
opening and closing. Defaults to true.
*/
@IBInspectable
public
var
enabledLeftView
:
Bool
=
false
{
@IBInspectable
open
var
enabledLeftView
=
false
{
didSet
{
enabledLeftPanGesture
=
enabledLeftView
enabledLeftTapGesture
=
enabledLeftView
...
...
@@ -217,7 +220,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
}
/// Enables the left pan gesture.
@IBInspectable
public
var
enabledLeftPanGesture
:
Bool
=
false
{
@IBInspectable
open
var
enabledLeftPanGesture
=
false
{
didSet
{
if
enabledLeftPanGesture
{
prepareLeftPanGesture
()
...
...
@@ -228,7 +232,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
}
/// Enables the left tap gesture.
@IBInspectable
public
var
enabledLeftTapGesture
:
Bool
=
false
{
@IBInspectable
open
var
enabledLeftTapGesture
=
false
{
didSet
{
if
enabledLeftTapGesture
{
prepareLeftTapGesture
()
...
...
@@ -242,7 +247,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
A Boolean property that enables and disables the rightView from
opening and closing. Defaults to true.
*/
@IBInspectable
public
var
enabledRightView
:
Bool
=
false
{
@IBInspectable
open
var
enabledRightView
=
false
{
didSet
{
enabledRightPanGesture
=
enabledRightView
enabledRightTapGesture
=
enabledRightView
...
...
@@ -250,7 +256,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
}
/// Enables the right pan gesture.
@IBInspectable
public
var
enabledRightPanGesture
:
Bool
=
false
{
@IBInspectable
open
var
enabledRightPanGesture
=
false
{
didSet
{
if
enabledRightPanGesture
{
prepareRightPanGesture
()
...
...
@@ -261,7 +268,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
}
/// Enables the right tap gesture.
@IBInspectable
public
var
enabledRightTapGesture
:
Bool
=
false
{
@IBInspectable
open
var
enabledRightTapGesture
=
false
{
didSet
{
if
enabledRightTapGesture
{
prepareRightTapGesture
()
...
...
@@ -275,38 +283,39 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
A Boolean property that triggers the status bar to be hidden
when the leftView is opened. Defaults to true.
*/
@IBInspectable
public
var
enableHideStatusBar
:
Bool
=
true
@IBInspectable
open
var
enableHideStatusBar
=
true
/// Sets the statusBar to hidden or not.
public
private(set)
var
isStatusBarHidden
:
Bool
=
false
open
private(set)
var
isStatusBarHidden
=
false
/**
A DepthPreset property that is used to set the depth of the
leftView when opened.
*/
public
var
depthPreset
:
DepthPreset
=
.
depth1
open
var
depthPreset
=
DepthPreset
.
depth1
/**
A View property that is used to hide and reveal the
leftViewController. It is very rare that this property will
need to be accessed externally.
*/
public
private(set)
var
leftView
:
View
?
open
private(set)
var
leftView
:
View
?
/**
A View property that is used to hide and reveal the
rightViewController. It is very rare that this property will
need to be accessed externally.
*/
public
private(set)
var
rightView
:
View
?
open
private(set)
var
rightView
:
View
?
/// Indicates whether the leftView or rightView is opened.
public
var
opened
:
Bool
{
open
var
opened
:
Bool
{
return
openedLeftView
||
openedRightView
}
/// indicates if the leftView is opened.
public
var
openedLeftView
:
Bool
{
open
var
openedLeftView
:
Bool
{
guard
nil
!=
leftView
else
{
return
false
}
...
...
@@ -314,7 +323,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
}
/// Indicates if the rightView is opened.
public
var
openedRightView
:
Bool
{
open
var
openedRightView
:
Bool
{
guard
nil
!=
rightView
else
{
return
false
}
...
...
@@ -328,31 +337,33 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
this, and to add a hidden transition viewController for complex
situations, the contentViewController was added.
*/
public
private(set)
lazy
var
contentViewController
:
UIViewController
=
UIViewController
()
open
private(set)
lazy
var
contentViewController
:
UIViewController
=
UIViewController
()
/**
A UIViewController property that references the
active left UIViewController.
*/
public
private(set)
var
leftViewController
:
UIViewController
?
open
private(set)
var
leftViewController
:
UIViewController
?
/**
A UIViewController property that references the
active right UIViewController.
*/
public
private(set)
var
rightViewController
:
UIViewController
?
open
private(set)
var
rightViewController
:
UIViewController
?
/**
A CGFloat property to access the width that the leftView
opens up to.
*/
@IBInspectable
public
private(set)
var
leftViewWidth
:
CGFloat
!
@IBInspectable
open
private(set)
var
leftViewWidth
:
CGFloat
!
/**
A CGFloat property to access the width that the rightView
opens up to.
*/
@IBInspectable
public
private(set)
var
rightViewWidth
:
CGFloat
!
@IBInspectable
open
private(set)
var
rightViewWidth
:
CGFloat
!
/**
An initializer that initializes the object with a NSCoder object.
...
...
@@ -360,6 +371,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
/**
...
...
@@ -369,6 +381,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
*/
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
prepareView
()
}
/**
...
...
@@ -391,7 +404,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
The super.prepareView method should always be called immediately
when subclassing.
*/
public
override
func
prepareView
()
{
open
override
func
prepareView
()
{
super
.
prepareView
()
prepareContentViewController
()
prepareLeftView
()
...
...
@@ -399,7 +412,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
}
/// Layout subviews.
public
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
if
opened
{
hideStatusBar
()
}
else
{
...
...
@@ -429,7 +442,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
}
}
public
override
func
viewWillTransition
(
to
size
:
CGSize
,
with
coordinator
:
UIViewControllerTransitionCoordinator
)
{
open
override
func
viewWillTransition
(
to
size
:
CGSize
,
with
coordinator
:
UIViewControllerTransitionCoordinator
)
{
super
.
viewWillTransition
(
to
:
size
,
with
:
coordinator
)
// Ensures the view is hidden.
if
let
v
:
View
=
rightView
{
...
...
@@ -447,7 +460,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
- Parameter animated: A Boolean value that indicates to animate
the leftView width change.
*/
public
func
setLeftViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
TimeInterval
=
0.5
)
{
open
func
setLeftViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
TimeInterval
=
0.5
)
{
if
let
v
:
View
=
leftView
{
leftViewWidth
=
width
...
...
@@ -521,7 +534,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
- Parameter animated: A Boolean value that indicates to animate
the rightView width change.
*/
public
func
setRightViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
TimeInterval
=
0.5
)
{
open
func
setRightViewWidth
(
width
:
CGFloat
,
hidden
:
Bool
,
animated
:
Bool
,
duration
:
TimeInterval
=
0.5
)
{
if
let
v
:
View
=
rightView
{
rightViewWidth
=
width
...
...
@@ -591,7 +604,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
velocity of the user interaction when animating the
leftView. Defaults to 0.
*/
public
func
toggleLeftView
(
velocity
:
CGFloat
=
0
)
{
open
func
toggleLeftView
(
velocity
:
CGFloat
=
0
)
{
openedLeftView
?
closeLeftView
(
velocity
:
velocity
)
:
openLeftView
(
velocity
:
velocity
)
}
...
...
@@ -602,7 +615,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
velocity of the user interaction when animating the
leftView. Defaults to 0.
*/
public
func
toggleRightView
(
velocity
:
CGFloat
=
0
)
{
open
func
toggleRightView
(
velocity
:
CGFloat
=
0
)
{
openedRightView
?
closeRightView
(
velocity
:
velocity
)
:
openRightView
(
velocity
:
velocity
)
}
...
...
@@ -612,7 +625,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
velocity of the user interaction when animating the
leftView. Defaults to 0.
*/
public
func
openLeftView
(
velocity
:
CGFloat
=
0
)
{
open
func
openLeftView
(
velocity
:
CGFloat
=
0
)
{
if
enabledLeftView
{
if
let
v
:
View
=
leftView
{
hideStatusBar
()
...
...
@@ -638,7 +651,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
velocity of the user interaction when animating the
leftView. Defaults to 0.
*/
public
func
openRightView
(
velocity
:
CGFloat
=
0
)
{
open
func
openRightView
(
velocity
:
CGFloat
=
0
)
{
if
enabledRightView
{
if
let
v
:
View
=
rightView
{
hideStatusBar
()
...
...
@@ -666,7 +679,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
velocity of the user interaction when animating the
leftView. Defaults to 0.
*/
public
func
closeLeftView
(
velocity
:
CGFloat
=
0
)
{
open
func
closeLeftView
(
velocity
:
CGFloat
=
0
)
{
if
enabledLeftView
{
if
let
v
:
View
=
leftView
{
isUserInteractionEnabled
=
true
...
...
@@ -694,7 +707,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
velocity of the user interaction when animating the
leftView. Defaults to 0.
*/
public
func
closeRightView
(
velocity
:
CGFloat
=
0
)
{
open
func
closeRightView
(
velocity
:
CGFloat
=
0
)
{
if
enabledRightView
{
if
let
v
:
View
=
rightView
{
isUserInteractionEnabled
=
true
...
...
@@ -722,7 +735,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
- Parameter touch: The UITouch event.
- Returns: A Boolean of whether to continue the gesture or not.
*/
public
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
open
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
if
!
openedRightView
&&
gestureRecognizer
==
leftPanGesture
&&
(
openedLeftView
||
isPointContainedWithinLeftThreshold
(
point
:
touch
.
location
(
in
:
view
)))
{
return
true
}
...
...
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