Skip to content

Commit

Permalink
Merge branch 'release/v2.2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrojimenez committed Dec 2, 2016
2 parents e939721 + 72338a8 commit 681485b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
6 changes: 5 additions & 1 deletion App/Network/SwiftRequestVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ class SwiftRequestVC: UIViewController {
@IBAction func onButtonImageDownloadTap(_ sender: AnyObject) {
Request(
method: "GET",
baseUrl: "http://api-discover-mcd.s.gigigoapps.com/media/image/qLXSBtDE/100/185/90",
baseUrl: "http://api-discover-mcd.s.gigigoapps.com/media/image/qLXSBtDE/100/185/90?query1=1&query2=2",
endpoint: "",
urlParams: [
"query2": "2",
"query3": "3"
],
verbose: true
)
.fetch(completionHandler: processResponse)
Expand Down
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.3</string>
<string>2.2.5</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
8 changes: 4 additions & 4 deletions GiGLibrary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2379,11 +2379,11 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 2.2.3;
CURRENT_PROJECT_VERSION = 2.2.5;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.1;
DYLIB_CURRENT_VERSION = 2.2.3;
DYLIB_CURRENT_VERSION = 2.2.5;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/GIGLibraryFramework/Info.plist";
Expand All @@ -2407,10 +2407,10 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 2.2.3;
CURRENT_PROJECT_VERSION = 2.2.5;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.1;
DYLIB_CURRENT_VERSION = 2.2.3;
DYLIB_CURRENT_VERSION = 2.2.5;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/GIGLibraryFramework/Info.plist";
Expand Down
28 changes: 23 additions & 5 deletions Source/GIGUtils/String/StyledString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,16 @@ public extension NSAttributedString {

public convenience init?(fromHTML html: String) {

try? self.init(data: html.data(using: String.Encoding.utf8)!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
let htmlData: Data

if let data = html.data(using: String.Encoding.utf8) {
htmlData = data
} else {
htmlData = Data()
LogWarn("Could not convert to data from: " + html)
}

try? self.init(data: htmlData, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: String.Encoding.utf8.rawValue], documentAttributes: nil)
}

Expand Down Expand Up @@ -189,7 +198,7 @@ public struct StyledString {

// MARK: PRIVATE

func attributedStringFrom(styledStringFraction: StyledStringFraction, font:UIFont) -> NSAttributedString {
func attributedStringFrom(styledStringFraction: StyledStringFraction, font: UIFont) -> NSAttributedString {

let currentString = styledStringFraction.string
let currentStyle = styledStringFraction.styles
Expand All @@ -206,7 +215,7 @@ public struct StyledString {
string.addAttribute(key, value:value, range: NSMakeRange(0, string.length))

if (key == NSFontAttributeName) {
currentFont = style.value(forFont: currentFont) as! UIFont
currentFont = style.value(forFont: currentFont) as? UIFont ?? UIFont.systemFont(ofSize: 14)
}
return string
}
Expand Down Expand Up @@ -308,9 +317,18 @@ public enum Style {
case .backgroundColor(let color):
return color
case .size(let pointSize):
return UIFont(name: font.fontName, size: pointSize)!
if let font = UIFont(name: font.fontName, size: pointSize) {
return font
} else {
return UIFont.systemFont(ofSize: pointSize)
}
case .fontName(let fontName):
return UIFont(name: fontName, size: font.pointSize)!
if let font = UIFont(name: fontName, size: font.pointSize) {
return font
} else {
LogWarn("Could not find font with name: " + fontName)
return UIFont.systemFont(ofSize: font.pointSize)
}
case .font(let font):
return font
case .underline:
Expand Down
17 changes: 16 additions & 1 deletion Source/SwiftNetwork/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ open class Request: Selfie {
var url = URLComponents(string: self.baseURL)
url?.path = (url?.path)! + self.endpoint

url?.queryItems = self.urlParams?.map { key, value in
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 Expand Up @@ -151,3 +153,16 @@ open class Request: Selfie {
}

}


func concat(_ lhs: [URLQueryItem]?, _ rhs: [URLQueryItem]?) -> [URLQueryItem] {
guard let left = lhs else {
return rhs ?? []
}

guard let right = rhs else {
return left
}

return left + right
}

0 comments on commit 681485b

Please sign in to comment.