Skip to content

Commit

Permalink
Release 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
luannguyenkhoa-agilityio committed May 30, 2018
1 parent 83a5475 commit ae4de65
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Example/LNSideMenu/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
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.1'
s.version = '3.2'
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
4 changes: 3 additions & 1 deletion LNSideMenu/Classes/LNCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import ObjectiveC
// MARK: Global variables
internal let screenHeight = UIScreen.main.bounds.height
internal let screenWidth = UIScreen.main.bounds.width
internal let navigationBarHeight: CGFloat = 64
internal var kNavBarHeight: CGFloat {
return UIApplication.shared.statusBarFrame.height + ([.landscapeRight, .landscapeLeft].contains(UIApplication.shared.statusBarOrientation) ? 32 : 44)
}
internal let kDistanceItemToRight: CGFloat = 18

// MARK: Typealias
Expand Down
5 changes: 1 addition & 4 deletions LNSideMenu/Classes/LNSideMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ public final class LNSideMenu: NSObject {
fileprivate let kGravityDirection: CGFloat = 3.5
fileprivate let shortDuration: TimeInterval = 0.25
fileprivate let maxXPan: CGFloat = 30
fileprivate var kNavBarHeight: CGFloat {
return [.landscapeRight, .landscapeLeft].contains(UIApplication.shared.statusBarOrientation) ? 52 : 64
}


// MARK: Properties
// This property should be private for this release
fileprivate var menuWidth: CGFloat = UIScreen.main.bounds.width {
Expand Down
17 changes: 11 additions & 6 deletions LNSideMenu/Classes/LNSideMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ import QuartzCore
internal final class LNSideMenuView: UIView, UIScrollViewDelegate {

// MARK: Constants
fileprivate let isPlus = UIScreen.main.bounds.width == 736
fileprivate let kNumberDefaultItemHeight: CGFloat = 60
fileprivate let kNumberDefaultSpace: CGFloat = 30
fileprivate let kNumberDefaultDistance: CGFloat = 40
fileprivate var kNumberDefaultDistance: CGFloat {
return isPlus ? 40 : 30
}
fileprivate let kNumberDurationAnimation: TimeInterval = 0.25
fileprivate let kNumberDefaultItemsHoziConstant: Int = 2
fileprivate let kNumberAriProg: Int = 10
fileprivate var kNumberAriProg: Int {
return isPlus ? 10 : 8
}
fileprivate let kNumberVelocityConstant: CGFloat = 60

// MARK: Variables
Expand Down Expand Up @@ -120,8 +125,8 @@ internal final class LNSideMenuView: UIView, UIScrollViewDelegate {
// Re-draw shape in self
draw(self.frame)
// Update x position of scrollview
let distanceToTop = isChanged ? navigationBarHeight : kNumberDefaultSpace
self.menusScrollView.y = distanceToTop
let distanceToTop = isChanged ? kNavBarHeight : kNumberDefaultSpace
self.menusScrollView.y = self.menusScrollView.y - 30 + distanceToTop
}

func refresh() {
Expand Down Expand Up @@ -166,12 +171,13 @@ internal final class LNSideMenuView: UIView, UIScrollViewDelegate {
// The number of items on screen is always an odd, because it helps to calculate frames of items more easier and cooler
if totalCellOnScreen % 2 == 0 && totalCells > totalCellOnScreen {
totalCellOnScreen -= 1
frame.height -= kNumberDefaultItemHeight
}
// CurrentIndex is presented for index of item at center of screen
currentIndex = Int(totalCellOnScreen/2)
index = currentIndex
// Calculate frame of scrollview
frame.y = kNumberDefaultSpace
frame.y = kNumberDefaultSpace + (space - frame.height) / 2
frame.x = isRight ? kNumberDefaultDistance : 0
menusScrollView.frame = frame
}
Expand Down Expand Up @@ -209,7 +215,6 @@ internal final class LNSideMenuView: UIView, UIScrollViewDelegate {
let dest = abs(index-currentIndex)
let sum = (0..<dest).reduce(0, { $0 + $1*kNumberAriProg })
let originX = (right ? 1 : -1) * CGFloat(sum + kNumberDefaultItemsHoziConstant*dest)
print(dest, sum, originX)
let itemFrame = CGRect(x: originX, y: CGFloat(index*Int(kNumberDefaultItemHeight)), width: menusScrollView.width, height: kNumberDefaultItemHeight)

// Initial item by index
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sideMenuManager?.sideMenuController()?.sideMenu?.isNavbarHiddenOrTransparent = t
## Using your own menu

Initialize sidemenu as below in NavigationController subclass:
In order for customizing the menu size in width, we can use one of 3 types of size that consists of full, half and twothird.
In order for customizing the menu size in width, we can use one of 4 types of size that consists of full, half, twothird and custom(CGFloat).
```swift
func initialCustomMenu(pos position: Position) {
let menu = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "LeftMenuTableViewController") as! LeftMenuTableViewController
Expand Down

0 comments on commit ae4de65

Please sign in to comment.