Skip to content

Commit

Permalink
Merge branch 'release/v2.2.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrojimenez committed Feb 25, 2017
2 parents 681485b + 0e0239f commit 0e1583c
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 22 deletions.
2 changes: 1 addition & 1 deletion GIGLibraryFramework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.2.5</string>
<string>2.2.6</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
8 changes: 8 additions & 0 deletions Source/GIGUtils/Date/NSDate+GIGExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public extension Date {
return Date()
}

public func string(with format: String = DateISOFormat) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format
dateFormatter.amSymbol = ""
dateFormatter.pmSymbol = ""
return dateFormatter.string(from: self)
}


/**
Set the time to a NSDate
Expand Down
8 changes: 8 additions & 0 deletions Source/GIGUtils/SwiftJson/Json.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ open class JSON: Sequence, CustomStringConvertible {

return dic
}

open func toArray() -> [Any]? {
guard let array = self.json as? [Any] else {
return []
}

return array
}

// MARK - Sequence Methods

Expand Down
8 changes: 4 additions & 4 deletions Source/SwiftNetwork/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ open class Request: Selfie {
var url = URLComponents(string: self.baseURL)
url?.path = (url?.path)! + self.endpoint

let urlParams = self.urlParams?.map { key, value in
URLQueryItem(name: key, value: String(describing: value))
}

if let urlParams = self.urlParams?.map({ key, value in
URLQueryItem(name: key, value: String(describing: value))
}) {
url?.queryItems = concat(url?.queryItems, urlParams)
}

return url?.string ?? "NOT VALID URL"
}
Expand Down
6 changes: 5 additions & 1 deletion Source/UIComponents/SlideMenu/MenuSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ open class MenuSection {
open let icon: UIImage
open let storyboard: String
open let viewController: String?
open var modeButtonType: Bool?
open var completionButtonType: (() -> Void)?

lazy var sectionController: UIViewController = self.instantiateViewController()


public init(name: String, icon: UIImage, storyboard: String, viewController: String? = nil) {
public init(name: String, icon: UIImage, storyboard: String, viewController: String? = nil, modeButtonType: Bool? = nil, completionButtonType: (() -> Void)? = nil) {
self.name = name
self.icon = icon
self.storyboard = storyboard
self.viewController = viewController
self.modeButtonType = modeButtonType
self.completionButtonType = completionButtonType
}


Expand Down
26 changes: 16 additions & 10 deletions Source/UIComponents/SlideMenu/Private/MenuSectionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MenuSectionCell: UITableViewCell {
@IBOutlet weak fileprivate var imageMenuSection: UIImageView!
@IBOutlet weak fileprivate var labelMenuSection: UILabel!
@IBOutlet weak fileprivate var viewSelector: UIView!

override func awakeFromNib() {
self.viewSelector.backgroundColor = SlideMenuConfig.shared.sectionSelectorColor
Expand All @@ -23,21 +23,27 @@ class MenuSectionCell: UITableViewCell {
func bindMenuSection(_ menuSection: MenuSection) {
self.labelMenuSection.text = menuSection.name
self.imageMenuSection.image = menuSection.icon
self.viewSelector.alpha = 0

guard let modeButtonType = menuSection.modeButtonType else {
return
}

if modeButtonType {
self.viewSelector.backgroundColor = UIColor.clear
} else {
self.viewSelector.backgroundColor = SlideMenuConfig.shared.sectionSelectorColor
}
}


override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)

UIView.animate(withDuration: 0.4, animations: {
if selected {
self.viewSelector.alpha = 1
}
else {
self.viewSelector.alpha = 0
}
})
if selected {
self.viewSelector.alpha = 1
} else {
self.viewSelector.alpha = 0
}
}

}
15 changes: 13 additions & 2 deletions Source/UIComponents/SlideMenu/Private/SlideMenuTableVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class SlideMenuTableVC: UIViewController, UITableViewDataSource, UITableViewDele
// MARK - Public Methods

func selectSection(_ index: Int) {
self.indexToShow = index
guard self.tableView != nil else {
self.indexToShow = index
return
}

Expand Down Expand Up @@ -94,6 +94,17 @@ class SlideMenuTableVC: UIViewController, UITableViewDataSource, UITableViewDele
}

delegate.tableDidSelecteSection(menuSection, index: (indexPath as NSIndexPath).row)

guard let modeButtonType = menuSection.modeButtonType else {
self.indexToShow = indexPath.row
return
}

if modeButtonType {
guard let index = self.indexToShow else {
return
}
self.selectSection(index)
}
}

}
15 changes: 12 additions & 3 deletions Source/UIComponents/SlideMenu/Private/SlideMenuVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class SlideMenuVC: UIViewController, MenuTableDelegate, UIGestureRecognizerDeleg

if let index = self.sectionIndexToShow {
self.menuTableView?.selectSection(index)
self.sectionIndexToShow = nil
}
}

Expand Down Expand Up @@ -225,8 +224,18 @@ class SlideMenuVC: UIViewController, MenuTableDelegate, UIGestureRecognizerDeleg
// MARK: - MenuTableDelegate

func tableDidSelecteSection(_ menuSection: MenuSection, index: Int) {
self.setSection(menuSection.sectionController, index: index)
self.animate(closeMenu)

guard let _ = menuSection.modeButtonType else {
self.setSection(menuSection.sectionController, index: index)
self.animate(closeMenu)
return
}

guard let completion = menuSection.completionButtonType else {
LogWarn("completion Button Type nil!")
return
}
completion()
}


Expand Down
19 changes: 18 additions & 1 deletion Tests/GIGUtils/GIGParseJsonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ class GIGParseJsonTests: XCTestCase {
"bool": true,
"date": dateString,
"double": 22.1,
"dictionary": ["key":"value"]
"dictionary": ["key":"value"],
"arrayNumber": [1,2,3,4],
"arrayString": ["a","b","c","d","e"],
"arrayDic": [["key":1,"value":"a"],["key":2,"value":"a"]]
] as AnyObject)

XCTAssertTrue(json["string"]!.toString() == "Text")
Expand All @@ -63,6 +66,20 @@ class GIGParseJsonTests: XCTestCase {
let dic = json["dictionary"]!.toDictionary()
XCTAssertTrue (dic?.count > 0)
XCTAssertTrue(dic!["key"] as! String == "value")

let arrayNumber = json["arrayNumber"]!.toArray()
XCTAssertTrue (arrayNumber?.count == 4)

let arrayString = json["arrayString"]!.toArray()
XCTAssertTrue (arrayString?.count == 5)

let arrayDic = json["arrayDic"]!.toArray()
XCTAssertTrue (arrayDic?.count == 2)
for dic in arrayDic! {
let json = JSON(from: dic)
let dic = json.toDictionary()
XCTAssertTrue(dic!["value"] as! String == "a")
}
}

func test_incorrect_format_json() {
Expand Down

0 comments on commit 0e1583c

Please sign in to comment.