Skip to content

Commit

Permalink
Release v3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
luannguyenkhoa-agilityio committed Sep 24, 2018
1 parent 45a18e0 commit 5ff9384
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 74 deletions.
6 changes: 5 additions & 1 deletion Example/LNSideMenu.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0910;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
Expand Down Expand Up @@ -401,12 +401,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -454,12 +456,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,7 +40,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -70,7 +69,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Example/LNSideMenu/NextViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NextViewController: UIViewController {
super.viewDidLoad()

// Do any additional setup after loading the view.
sideMenuManager?.instance()?.menu?.disabled = true
// sideMenuManager?.instance()?.menu?.disabled = false
}

override func viewWillAppear(_ animated: Bool) {
Expand Down
6 changes: 5 additions & 1 deletion Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LNSideMenu.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'LNSideMenu'
s.version = '3.3'
s.version = '3.4'
s.summary = 'A side menu control for iOS in Swift with custom layer and scrolling effect. Right and Left sides. iOS 8+.'

# This description is used to generate tags and improve search results.
Expand Down
2 changes: 1 addition & 1 deletion LNSideMenu/Classes/LNCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ObjectiveC
internal let screenHeight = UIScreen.main.bounds.height
internal let screenWidth = UIScreen.main.bounds.width
internal var kNavBarHeight: CGFloat {
return UIApplication.shared.statusBarFrame.height + ([.landscapeRight, .landscapeLeft].contains(UIApplication.shared.statusBarOrientation) ? 32 : 44)
return UIApplication.shared.statusBarFrame.size.height + ([.landscapeRight, .landscapeLeft].contains(UIApplication.shared.statusBarOrientation) ? 32 : 44)
}
internal let kDistanceItemToRight: CGFloat = 18

Expand Down
18 changes: 9 additions & 9 deletions LNSideMenu/Classes/LNPanelViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public final class LNPanelViewController: UIViewController {
fileprivate var didInit = false
weak var delegate: LNSMDelegate?
var position: Position = .left
var isNavigationBarChanged = false {
var isTranslucent = false {
didSet {
updateFrame()
}
}
// MARK: Colors
open var menuBgColor = LNColor.bgView.color
open var itemBgColor = LNColor.bgItem.color
open var highlightColor = LNColor.highlight.color
open var titleColor = LNColor.title.color
public var menuBgColor = LNColor.bgView.color
public var itemBgColor = LNColor.bgItem.color
public var highlightColor = LNColor.highlight.color
public var titleColor = LNColor.title.color

lazy var sideMenuView: LNSideMenuView = LNSideMenuView()

Expand All @@ -35,14 +35,14 @@ public final class LNPanelViewController: UIViewController {
self.sideMenuView.indexOfDefaultCellHighlight = highlightCellAtIndex
}

override open func viewDidLoad() {
override public func viewDidLoad() {
super.viewDidLoad()

self.view.backgroundColor = .clear
self.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
}

open override func viewWillAppear(_ animated: Bool) {
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if !didInit {
didInit = true
Expand All @@ -69,7 +69,7 @@ public final class LNPanelViewController: UIViewController {

internal func setViewFrame() -> Bool {
// Set frame for view
let distance: CGFloat = isNavigationBarChanged ? 0 : 64
let distance: CGFloat = isTranslucent ? 0 : 44 + UIApplication.shared.statusBarFrame.size.height
if view.y != distance {
view.y = distance
view.height = screenHeight - view.y
Expand All @@ -81,7 +81,7 @@ public final class LNPanelViewController: UIViewController {
internal func updateFrame() {
// Just refresh side menu iff the view frame has already changed
if setViewFrame() {
sideMenuView.refreshMenuWithFrame(view.frame, isChanged: isNavigationBarChanged)
sideMenuView.refreshMenuWithFrame(view.frame, translucent: isTranslucent)
}
}

Expand Down
67 changes: 34 additions & 33 deletions LNSideMenu/Classes/LNSideMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class LNSideMenu: NSObject {
If the content view's navigation bar is hidden or translucent, you should assign a `true` value to this property.
Otherwise, `false` value is that to moving down the default menu under navigation bar.
*/
open var isNavbarHiddenOrTransparent = false {
public var isNavbarHiddenOrTransparent = false {
didSet {
// Refresh side menu whenever this property is set a new value
refreshSideMenu()
Expand All @@ -46,39 +46,35 @@ public final class LNSideMenu: NSObject {
This property won't work for the default menu.
Check ``isNavbarHiddenOrTransparent`` out if you're planning to use the default menu.
*/
open var underNavigationBar: Bool = false

open weak var delegate: LNSideMenuDelegate?
open var allowLeftSwipe = true
open var allowRightSwipe = true
open var allowPanGesture = true
open var animationDuration = 0.5
open var hideWhenDidSelectOnCell = true
open var items = [String]()
public var underNavigationBar: Bool = false

public weak var delegate: LNSideMenuDelegate?
public var allowLeftSwipe = true
public var allowRightSwipe = true
public var allowPanGesture = true
public var animationDuration = 0.5
public var hideWhenDidSelectOnCell = true
public var items = [String]()
// uidynamic behavior, set false to disable it
open var enableDynamic: Bool = false {
public var enableDynamic: Bool = false {
didSet {
cacheEnableDynamic = enableDynamic
}
}

open var tapOutsideToDismiss = true
open var disabled: Bool = false {
didSet {
print("Reset Flag")
}
}
open var enableAnimation: Bool = true
open var customMenu: UIViewController?
open var isCustomMenu: Bool {
public var tapOutsideToDismiss = true
public var disabled: Bool = false
public var enableAnimation: Bool = true
public var customMenu: UIViewController?
public var isCustomMenu: Bool {
return customMenu != nil
}

// MARK: Private properties
fileprivate(set) open var isMenuOpen: Bool = false
fileprivate(set) open var position: Position = .left
fileprivate(set) public var isMenuOpen: Bool = false
fileprivate(set) public var position: Position = .left
fileprivate let sideMenuContainerView = UIView()
fileprivate(set) open var menuViewController: LNPanelViewController?
fileprivate(set) public var menuViewController: LNPanelViewController?
fileprivate var sourceView: UIView!
fileprivate var needUpdateAppearance = false
fileprivate var panGesture: UIPanGestureRecognizer?
Expand Down Expand Up @@ -256,7 +252,8 @@ public final class LNSideMenu: NSObject {
gesture.setTranslation(.zero, in: sourceView)

default:
if gesture.velocity(in: gesture.view).x == 0 {
let velX = gesture.velocity(in: gesture.view).x
if velX == 0 {
if (position == .left && sideMenuContainerView.x == -menuWidth)
|| (position == .right && sideMenuContainerView.x == menuWidth) {
return
Expand Down Expand Up @@ -429,13 +426,18 @@ public final class LNSideMenu: NSObject {
if !show {
centerx = position == .left ? -sourceView.width/2 : sourceView.width + sourceView.width/2
}
isMenuOpen = show
show ? delegate?.sideMenuWillOpen?() : delegate?.sideMenuWillClose?()
let stateChanged = show != isMenuOpen
if stateChanged {
show ? delegate?.sideMenuWillOpen?() : delegate?.sideMenuWillClose?()
isMenuOpen = show
}
UIView.animate(withDuration: animationDuration, animations: {
self.sideMenuContainerView.center.x = centerx
}) { _ in
self.animationCompleted = true
show ? self.delegate?.sideMenuDidOpen?() : self.delegate?.sideMenuDidClose?()
if stateChanged {
show ? self.delegate?.sideMenuDidOpen?() : self.delegate?.sideMenuDidClose?()
}
}
// Starting show/hide blur view animation
animateBlurview(isShow: show)
Expand All @@ -449,21 +451,21 @@ public final class LNSideMenu: NSObject {
}
}

open func toggleMenu(completion: Completion? = nil) {
public func toggleMenu(completion: Completion? = nil) {
// Revert boucingEnabled default value, because it might be changed by gesture handlers
cacheEnableDynamic = isMenuOpen ? false : enableDynamic
toggleMenu(!isMenuOpen, completion: completion)
if !isMenuOpen { updateSideMenuApperanceIfNeeded() }
}

open func hideSideMenu(_ completion: Completion? = nil) {
public func hideSideMenu(_ completion: Completion? = nil) {
// disable dynamic animator when hiding sidemenu
cacheEnableDynamic = false
// Just only hide sidemenu if it was really shown
if isMenuOpen { toggleMenu(false, completion: completion) }
}

open func showSideMenu(completion: Completion? = nil) {
public func showSideMenu(completion: Completion? = nil) {
// Revert boucingEnabled default value, because it might be changed by gesture handlers
cacheEnableDynamic = enableDynamic
// Just only show sidemenu if it was really hidden
Expand All @@ -472,7 +474,7 @@ public final class LNSideMenu: NSObject {

// MARK: Frame and refresh content

open func refreshMenu(_ items: [String]) {
public func refreshMenu(_ items: [String]) {
// Refresh side menu with a new list items
self.items = items
if !isCustomMenu {
Expand Down Expand Up @@ -503,7 +505,7 @@ public final class LNSideMenu: NSObject {
updateFrame()
// Handle navigation bar translucent if needed
if !isCustomMenu {
menuViewController?.isNavigationBarChanged = isNavbarHiddenOrTransparent
menuViewController?.isTranslucent = isNavbarHiddenOrTransparent
}
}

Expand Down Expand Up @@ -563,7 +565,6 @@ extension LNSideMenu: UIDynamicAnimatorDelegate {
extension LNSideMenu: UIGestureRecognizerDelegate {

public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
print("completed: \(animationCompleted)")
// Disable gesture if dynamic animator has not ended animation yet
if !dynamicAnimatorEnded {
return false
Expand Down
Loading

0 comments on commit 5ff9384

Please sign in to comment.