From c6f1979be343f051765c4f981906f142c2005713 Mon Sep 17 00:00:00 2001 From: Ayush Awasthi Date: Tue, 8 Jan 2019 18:25:30 +0530 Subject: [PATCH 1/7] Google login added with validation utils --- KiwiPods.podspec | 6 +- KiwiPods.xcodeproj/project.pbxproj | 16 ++ KiwiPods/Social/Google/GoogleHandler.swift | 50 +++++++ KiwiPods/ValidationsUtils.swift | 166 +++++++++++++++++++++ Podfile | 2 +- 5 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 KiwiPods/Social/Google/GoogleHandler.swift create mode 100644 KiwiPods/ValidationsUtils.swift diff --git a/KiwiPods.podspec b/KiwiPods.podspec index ac0df1d..cf3286a 100644 --- a/KiwiPods.podspec +++ b/KiwiPods.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "KiwiPods" - s.version = "0.0.2" + s.version = "0.0.3" s.summary = "sdfgdgf" # This description is used to generate tags and improve search results. @@ -119,6 +119,10 @@ Pod::Spec.new do |s| twitter.source_files = "KiwiPods/Social/Twitter/**/*.{h,m,swift}" twitter.dependency 'TwitterKit' end + socialMedia.subspec 'Google' do |google| + google.source_files = "KiwiPods/Social/Google/**/*.{h,m,swift}" + google.dependency 'GoogleSignIn' + end end s.subspec 'ImagePicker' do |imagePicker| diff --git a/KiwiPods.xcodeproj/project.pbxproj b/KiwiPods.xcodeproj/project.pbxproj index 1b1d12e..59a9e6c 100644 --- a/KiwiPods.xcodeproj/project.pbxproj +++ b/KiwiPods.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 38F04F541C2C888359AB8568 /* Pods_KiwiPods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41185E9826A76800BF01C8A8 /* Pods_KiwiPods.framework */; }; + D66402A921E4D4C70024B3D3 /* ValidationsUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66402A821E4D4C70024B3D3 /* ValidationsUtils.swift */; }; + D66402AF21E4D4FF0024B3D3 /* GoogleHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66402AE21E4D4FF0024B3D3 /* GoogleHandler.swift */; }; D66ADF4121D50488004499F2 /* HashTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66ADF3E21D50488004499F2 /* HashTextView.swift */; }; D66ADF4221D50488004499F2 /* UILinkLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66ADF4021D50488004499F2 /* UILinkLabel.swift */; }; D66ADF4F21D504B0004499F2 /* ImagePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D66ADF4321D504AD004499F2 /* ImagePickerController.swift */; }; @@ -31,6 +33,8 @@ 41185E9826A76800BF01C8A8 /* Pods_KiwiPods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_KiwiPods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 807FADC5BC231460701B403A /* Pods-KiwiPods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-KiwiPods.release.xcconfig"; path = "Pods/Target Support Files/Pods-KiwiPods/Pods-KiwiPods.release.xcconfig"; sourceTree = ""; }; C57934D16A5207D271DDC35C /* Pods-KiwiPods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-KiwiPods.debug.xcconfig"; path = "Pods/Target Support Files/Pods-KiwiPods/Pods-KiwiPods.debug.xcconfig"; sourceTree = ""; }; + D66402A821E4D4C70024B3D3 /* ValidationsUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidationsUtils.swift; sourceTree = ""; }; + D66402AE21E4D4FF0024B3D3 /* GoogleHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GoogleHandler.swift; sourceTree = ""; }; D66ADF3E21D50488004499F2 /* HashTextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HashTextView.swift; sourceTree = ""; }; D66ADF4021D50488004499F2 /* UILinkLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UILinkLabel.swift; sourceTree = ""; }; D66ADF4321D504AD004499F2 /* ImagePickerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImagePickerController.swift; sourceTree = ""; }; @@ -73,6 +77,14 @@ name = Pods; sourceTree = ""; }; + D66402AD21E4D4FF0024B3D3 /* Google */ = { + isa = PBXGroup; + children = ( + D66402AE21E4D4FF0024B3D3 /* GoogleHandler.swift */, + ); + path = Google; + sourceTree = ""; + }; D66ADF3D21D50488004499F2 /* HashTextView */ = { isa = PBXGroup; children = ( @@ -110,6 +122,7 @@ D66ADF5D21D504D8004499F2 /* Social */ = { isa = PBXGroup; children = ( + D66402AD21E4D4FF0024B3D3 /* Google */, D66ADF5B21D504BA004499F2 /* Facebook */, D66ADF5C21D504C6004499F2 /* Twitter */, ); @@ -158,6 +171,7 @@ D66ADF3D21D50488004499F2 /* HashTextView */, D66ADF3F21D50488004499F2 /* UILinkLabel */, D6B031672189D2C9003431C6 /* Networking */, + D66402A821E4D4C70024B3D3 /* ValidationsUtils.swift */, D6B031602189D172003431C6 /* Info.plist */, ); path = KiwiPods; @@ -311,6 +325,8 @@ D66ADF5821D504B0004499F2 /* ImagePicker.swift in Sources */, D66ADF4F21D504B0004499F2 /* ImagePickerController.swift in Sources */, D66ADF5421D504B0004499F2 /* TwitterHelper.swift in Sources */, + D66402AF21E4D4FF0024B3D3 /* GoogleHandler.swift in Sources */, + D66402A921E4D4C70024B3D3 /* ValidationsUtils.swift in Sources */, D66ADF5521D504B0004499F2 /* ImagePickerCell.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/KiwiPods/Social/Google/GoogleHandler.swift b/KiwiPods/Social/Google/GoogleHandler.swift new file mode 100644 index 0000000..3a3ab18 --- /dev/null +++ b/KiwiPods/Social/Google/GoogleHandler.swift @@ -0,0 +1,50 @@ +// +// GoogleHandler.swift +// +// +// Created by KiwiTech on 07/01/19. +// Copyright © 2019 KiwiTech. All rights reserved. +// + +import UIKit +import GoogleSignIn +class GoogleHandler: NSObject { + static let `shared` = GoogleHandler() + override private init() { + super.init() + GIDSignIn.sharedInstance()?.delegate = self + } + fileprivate var loginCompletion: ((String?, Error?) -> Void)? + fileprivate var loginHandlerController: UIViewController? + func getUser(from controller: UIViewController, completion: @escaping (_ token: String?, _ error: Error?) -> Void) { + if let user = GIDSignIn.sharedInstance()?.currentUser { + loginCompletion = nil + completion(user.authentication.idToken, nil) + } else { + loginCompletion = completion + loginHandlerController = controller + GIDSignIn.sharedInstance()?.uiDelegate = self + GIDSignIn.sharedInstance()?.signIn() + } + } +} +extension GoogleHandler: GIDSignInDelegate { + func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { + guard error == nil else { + loginCompletion?(nil, error) + return + } + loginCompletion?(user.authentication.idToken, nil) + } +} +extension GoogleHandler: GIDSignInUIDelegate { + func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!) { + guard let controller = loginHandlerController else { + return + } + controller.present(viewController, animated: true, completion: nil) + } + func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!) { + viewController.dismiss(animated: true, completion: nil) + } +} diff --git a/KiwiPods/ValidationsUtils.swift b/KiwiPods/ValidationsUtils.swift new file mode 100644 index 0000000..eaea42d --- /dev/null +++ b/KiwiPods/ValidationsUtils.swift @@ -0,0 +1,166 @@ +// +// ValidationsUtils.swift +// Treble +// +// Created by kiwitech on 03/02/17. +// Copyright © 2016 KiwiTech. All rights reserved. +// + +import UIKit + +class ValidationsUtils: NSObject { + //----------------------------------------------- + // Mark Email validation + //----------------------------------------------- + class func validateEmail(emailID: String) -> Bool { + let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}" + // NSString *emailRegEx = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; + let emailTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", emailRegEx) + return emailTest.evaluate(with: + emailID) + } + //----------------------------------------------- + // Alpha - Numeric validation + //----------------------------------------------- + class func alphanumericValidation(validation: String) -> Bool { + let alphanumericRegEx = "^[a-zA-Z0-9]+$" + let alphanumericTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", alphanumericRegEx) + return alphanumericTest.evaluate(with: validation) + } + //----------------------------------------------- + // Mark number validation + //----------------------------------------------- + class func onlyNumberValidation(number: String) -> Bool { + let nameRegex: String = "^[0-9]+$" + let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) + return nameTest.evaluate(with: number) + } + //----------------------------------------------- + // Mark number validation + //----------------------------------------------- + class func onlyNumberValidationWithDash(number: String) -> Bool { + let nameRegex: String = "^[0-9 '-]+$" + let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) + return nameTest.evaluate(with: number) + } + //----------------------------------------------- + // Mark enter only alphabets + //----------------------------------------------- + class func onlyAlphabetsValidation(alphabet: String) -> Bool { + let nameRegex: String = "^[a-zA-Z '-]+$" + ///^[a-zA-Z ]*$/ + let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) + return nameTest.evaluate(with: alphabet) + // return true + } + class func onlyAlphabetsWithSpaceValidation(alphabet: String) -> Bool { + let nameRegex: String = "^[a-zA-Z ]+$" + let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) + return nameTest.evaluate(with: alphabet) + } + class func onlyAlphaNumericWithSpaceValidation(alphabet: String) -> Bool { + let nameRegex: String = "^[a-zA-Z0-9 ]+$" + let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) + return nameTest.evaluate(with: alphabet) + } + //----------------------------------------------- + // Mark mathch password + //----------------------------------------------- + class func confirmationPasswordValidation(password: String, confirmationPassword: String) -> Bool { + if password == confirmationPassword { + return true + } else { + return false + } + } + var tableSourceList: [[String]] = [[Int](0..<20).map({ "section 0, cell \($0)" })] + class func contentView(text: String) -> UIView { + let view = UIView(frame: CGRect(x: 0, y: 0, width: 375, height: 64)) + view.autoresizingMask = [.flexibleWidth, .flexibleHeight] + let label = UILabel(frame: view.bounds) + label.frame.origin.x = 10 + label.frame.origin.y = 10 + label.frame.size.width -= label.frame.origin.x + label.frame.size.height -= label.frame.origin.y + label.autoresizingMask = [.flexibleWidth, .flexibleHeight] + label.text = text + label.numberOfLines = 2 + label.textColor = UIColor.white + view.addSubview(label) + return view + } + class func isEmpty(text: String) -> Bool { + if text.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { + return true + } + return false + } + class func trimeedCount(text: String) -> Int { + + return text.trimmingCharacters(in: CharacterSet.whitespaces).count + } + class func isValidCountPassword(passwordString: String) -> Bool { + if passwordString.count >= 4 { + return true + } + return false + } + class func isValidPassword(passwordString: String) -> Bool { + if passwordString.count < 4 || passwordString.count > 24 { + return false + } + return true + } + class func isValidUsername(usernameString: String) -> Bool { + let stricterFilterString = "^([\\w&-]+)$" + let usernameTest = NSPredicate(format: "SELF MATCHES %@", stricterFilterString) + return usernameTest.evaluate(with: usernameString) + } + class func hasCharacterInString(string: String) -> Bool { + let stricterFilterString = ".*[a-zA-Z]+.*" + let stringTest = NSPredicate(format: "SELF MATCHES %@", stricterFilterString) + return stringTest.evaluate(with: string) + } + class func isValidCountCharacterLimit(textString: String) -> Bool { + if textString.count > 0 && textString.count <= 30 { + return true + } + return false + } + + class func isValidCountOfMobile(textString: String) -> Bool { + if textString.count != 10 { + return false + } + return true + } + class func isValidZipCode(textString: String) -> Bool { + if textString.count != 5 { + return false + } + return true + } + class func formatPhoneNumber(contactStr: String) -> String { + let range = contactStr.range(of: contactStr) + let strippedValue = contactStr.replacingOccurrences(of: "[^0-9]", with: "", options: .regularExpression, range: range) + var formattedString = "" + if strippedValue.count == 0 { + formattedString = "" + } else if strippedValue.count < 3 { + formattedString = strippedValue + } else if strippedValue.count == 3 { + formattedString = strippedValue + } else if strippedValue.count < 6 { + let startIndex = strippedValue.index(strippedValue.startIndex, offsetBy: 3) + formattedString = "(" + String(strippedValue[...startIndex]) + ") " + String(strippedValue[startIndex...]) + } else if strippedValue.count == 6 { + let startIndex = strippedValue.index(strippedValue.startIndex, offsetBy: 3) + formattedString = "(" + String(strippedValue[...startIndex]) + ") " + String(strippedValue[startIndex...]) + " - " + } else if strippedValue.count <= 10 { + //let startIndex = strippedValue.index(strippedValue.startIndex, offsetBy: 3) +// formattedString = "(" + String(strippedValue[...startIndex]) + ") " + strippedValue.substring(with: NSMakeRange(0, contactStr.count)) + " - " + String(strippedValue[startIndex...]) + } else if strippedValue.count >= 11 { + } + return formattedString + } + } diff --git a/Podfile b/Podfile index 0ed5ba3..36eec5c 100644 --- a/Podfile +++ b/Podfile @@ -10,6 +10,6 @@ target 'KiwiPods' do pod 'SDWebImage' pod 'TwitterKit' pod 'MBProgressHUD' - # Pods for KiwiPods + pod 'GoogleSignIn' end From e07353824f728c7781653dbdae255d78aa3de975 Mon Sep 17 00:00:00 2001 From: Ayush Awasthi Date: Tue, 8 Jan 2019 19:03:03 +0530 Subject: [PATCH 2/7] method and class exposed --- KiwiPods/Social/Google/GoogleHandler.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/KiwiPods/Social/Google/GoogleHandler.swift b/KiwiPods/Social/Google/GoogleHandler.swift index 3a3ab18..4d05279 100644 --- a/KiwiPods/Social/Google/GoogleHandler.swift +++ b/KiwiPods/Social/Google/GoogleHandler.swift @@ -8,15 +8,15 @@ import UIKit import GoogleSignIn -class GoogleHandler: NSObject { - static let `shared` = GoogleHandler() +open class GoogleHandler: NSObject { + static public let `shared` = GoogleHandler() override private init() { super.init() GIDSignIn.sharedInstance()?.delegate = self } fileprivate var loginCompletion: ((String?, Error?) -> Void)? fileprivate var loginHandlerController: UIViewController? - func getUser(from controller: UIViewController, completion: @escaping (_ token: String?, _ error: Error?) -> Void) { + public func getUser(from controller: UIViewController, completion: @escaping (_ token: String?, _ error: Error?) -> Void) { if let user = GIDSignIn.sharedInstance()?.currentUser { loginCompletion = nil completion(user.authentication.idToken, nil) From 6e87cab7fc069d75da5c66475be6d014185211e4 Mon Sep 17 00:00:00 2001 From: Ayush Awasthi Date: Tue, 8 Jan 2019 19:08:06 +0530 Subject: [PATCH 3/7] protocol methods made public --- KiwiPods/Social/Google/GoogleHandler.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/KiwiPods/Social/Google/GoogleHandler.swift b/KiwiPods/Social/Google/GoogleHandler.swift index 4d05279..0ba5426 100644 --- a/KiwiPods/Social/Google/GoogleHandler.swift +++ b/KiwiPods/Social/Google/GoogleHandler.swift @@ -29,7 +29,7 @@ open class GoogleHandler: NSObject { } } extension GoogleHandler: GIDSignInDelegate { - func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { + public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { guard error == nil else { loginCompletion?(nil, error) return @@ -38,13 +38,13 @@ extension GoogleHandler: GIDSignInDelegate { } } extension GoogleHandler: GIDSignInUIDelegate { - func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!) { + public func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!) { guard let controller = loginHandlerController else { return } controller.present(viewController, animated: true, completion: nil) } - func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!) { + public func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!) { viewController.dismiss(animated: true, completion: nil) } } From 58a464874d932aec38e99c418c19c0c70e71da77 Mon Sep 17 00:00:00 2001 From: Ayush Awasthi Date: Tue, 8 Jan 2019 19:17:02 +0530 Subject: [PATCH 4/7] framework added for pod if google pod used --- KiwiPods.podspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/KiwiPods.podspec b/KiwiPods.podspec index cf3286a..26765fc 100644 --- a/KiwiPods.podspec +++ b/KiwiPods.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "KiwiPods" - s.version = "0.0.3" + s.version = "0.0.2" s.summary = "sdfgdgf" # This description is used to generate tags and improve search results. @@ -122,6 +122,7 @@ Pod::Spec.new do |s| socialMedia.subspec 'Google' do |google| google.source_files = "KiwiPods/Social/Google/**/*.{h,m,swift}" google.dependency 'GoogleSignIn' + s.framework = 'GoogleSignIn' end end From 80e95c7b0b51258e7fff91cbee0f79bc25a8f9f4 Mon Sep 17 00:00:00 2001 From: Ayush Awasthi Date: Wed, 9 Jan 2019 13:36:58 +0530 Subject: [PATCH 5/7] class, methods and vars/lets made open/public --- KiwiPods/ValidationsUtils.swift | 53 +++++++++++---------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/KiwiPods/ValidationsUtils.swift b/KiwiPods/ValidationsUtils.swift index eaea42d..a0505de 100644 --- a/KiwiPods/ValidationsUtils.swift +++ b/KiwiPods/ValidationsUtils.swift @@ -8,11 +8,11 @@ import UIKit -class ValidationsUtils: NSObject { +open class ValidationsUtils: NSObject { //----------------------------------------------- // Mark Email validation //----------------------------------------------- - class func validateEmail(emailID: String) -> Bool { + class public func validateEmail(emailID: String) -> Bool { let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}" // NSString *emailRegEx = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; let emailTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", emailRegEx) @@ -22,7 +22,7 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Alpha - Numeric validation //----------------------------------------------- - class func alphanumericValidation(validation: String) -> Bool { + class public func alphanumericValidation(validation: String) -> Bool { let alphanumericRegEx = "^[a-zA-Z0-9]+$" let alphanumericTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", alphanumericRegEx) return alphanumericTest.evaluate(with: validation) @@ -30,7 +30,7 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Mark number validation //----------------------------------------------- - class func onlyNumberValidation(number: String) -> Bool { + class public func onlyNumberValidation(number: String) -> Bool { let nameRegex: String = "^[0-9]+$" let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: number) @@ -38,7 +38,7 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Mark number validation //----------------------------------------------- - class func onlyNumberValidationWithDash(number: String) -> Bool { + class public func onlyNumberValidationWithDash(number: String) -> Bool { let nameRegex: String = "^[0-9 '-]+$" let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: number) @@ -46,19 +46,19 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Mark enter only alphabets //----------------------------------------------- - class func onlyAlphabetsValidation(alphabet: String) -> Bool { + class public func onlyAlphabetsValidation(alphabet: String) -> Bool { let nameRegex: String = "^[a-zA-Z '-]+$" ///^[a-zA-Z ]*$/ let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: alphabet) // return true } - class func onlyAlphabetsWithSpaceValidation(alphabet: String) -> Bool { + class public func onlyAlphabetsWithSpaceValidation(alphabet: String) -> Bool { let nameRegex: String = "^[a-zA-Z ]+$" let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: alphabet) } - class func onlyAlphaNumericWithSpaceValidation(alphabet: String) -> Bool { + class public func onlyAlphaNumericWithSpaceValidation(alphabet: String) -> Bool { let nameRegex: String = "^[a-zA-Z0-9 ]+$" let nameTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", nameRegex) return nameTest.evaluate(with: alphabet) @@ -66,15 +66,15 @@ class ValidationsUtils: NSObject { //----------------------------------------------- // Mark mathch password //----------------------------------------------- - class func confirmationPasswordValidation(password: String, confirmationPassword: String) -> Bool { + class public func confirmationPasswordValidation(password: String, confirmationPassword: String) -> Bool { if password == confirmationPassword { return true } else { return false } } - var tableSourceList: [[String]] = [[Int](0..<20).map({ "section 0, cell \($0)" })] - class func contentView(text: String) -> UIView { + public var tableSourceList: [[String]] = [[Int](0..<20).map({ "section 0, cell \($0)" })] + class public func contentView(text: String) -> UIView { let view = UIView(frame: CGRect(x: 0, y: 0, width: 375, height: 64)) view.autoresizingMask = [.flexibleWidth, .flexibleHeight] let label = UILabel(frame: view.bounds) @@ -89,58 +89,41 @@ class ValidationsUtils: NSObject { view.addSubview(label) return view } - class func isEmpty(text: String) -> Bool { + class public func isEmpty(text: String) -> Bool { if text.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty { return true } return false } - class func trimeedCount(text: String) -> Int { + class public func trimeedCount(text: String) -> Int { return text.trimmingCharacters(in: CharacterSet.whitespaces).count } - class func isValidCountPassword(passwordString: String) -> Bool { + class public func isValidCountPassword(passwordString: String) -> Bool { if passwordString.count >= 4 { return true } return false } - class func isValidPassword(passwordString: String) -> Bool { - if passwordString.count < 4 || passwordString.count > 24 { - return false - } - return true - } - class func isValidUsername(usernameString: String) -> Bool { - let stricterFilterString = "^([\\w&-]+)$" - let usernameTest = NSPredicate(format: "SELF MATCHES %@", stricterFilterString) - return usernameTest.evaluate(with: usernameString) - } - class func hasCharacterInString(string: String) -> Bool { + class public func hasCharacterInString(string: String) -> Bool { let stricterFilterString = ".*[a-zA-Z]+.*" let stringTest = NSPredicate(format: "SELF MATCHES %@", stricterFilterString) return stringTest.evaluate(with: string) } - class func isValidCountCharacterLimit(textString: String) -> Bool { - if textString.count > 0 && textString.count <= 30 { - return true - } - return false - } - class func isValidCountOfMobile(textString: String) -> Bool { + class public func isValidCountOfMobile(textString: String) -> Bool { if textString.count != 10 { return false } return true } - class func isValidZipCode(textString: String) -> Bool { + class public func isValidZipCode(textString: String) -> Bool { if textString.count != 5 { return false } return true } - class func formatPhoneNumber(contactStr: String) -> String { + class public func formatPhoneNumber(contactStr: String) -> String { let range = contactStr.range(of: contactStr) let strippedValue = contactStr.replacingOccurrences(of: "[^0-9]", with: "", options: .regularExpression, range: range) var formattedString = "" From 3cd9e34cf0652d9409cd1d25702c2b6f92e6e8f7 Mon Sep 17 00:00:00 2001 From: Ayush Awasthi Date: Thu, 10 Jan 2019 16:36:22 +0530 Subject: [PATCH 6/7] network model updated --- KiwiPods/Networking/NetworkModel.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/KiwiPods/Networking/NetworkModel.swift b/KiwiPods/Networking/NetworkModel.swift index cf7a0da..46d2784 100644 --- a/KiwiPods/Networking/NetworkModel.swift +++ b/KiwiPods/Networking/NetworkModel.swift @@ -30,7 +30,7 @@ public enum RequestType: String { //using our own URLRequestConvertible so that networking library can be updated easily public protocol URLRequestConvertible { - func asURLRequest() -> URLRequest? + func asURLRequest() throws -> URLRequest } public protocol APIConfigurable: URLRequestConvertible { @@ -41,7 +41,7 @@ public protocol APIConfigurable: URLRequestConvertible { } public extension APIConfigurable { - public func asURLRequest() -> URLRequest? { + public func asURLRequest() throws -> URLRequest { var queryItems = "" if type == .GET, parameters.count > 0 { queryItems = parameters.reduce("?") { (value: String, arg1: (String, Any)) -> String in @@ -56,20 +56,18 @@ public extension APIConfigurable { if type != .GET { urlRequest.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: JSONSerialization.WritingOptions.prettyPrinted) } - urlRequest.cachePolicy = .reloadIgnoringCacheData return urlRequest } catch { - print(error.localizedDescription) - return nil + throw error } } } public protocol ParameterConvertible: Codable { - static func objectFrom(json: Any, decoder: JSONDecoder)throws -> ParameterConvertible? + static func objectFrom(json: Any, decoder: JSONDecoder)throws -> Self? func toParams()throws -> [String: Any]? } public extension ParameterConvertible { - static public func objectFrom(json: Any, decoder: JSONDecoder) throws -> ParameterConvertible? { + static public func objectFrom(json: Any, decoder: JSONDecoder = JSONDecoder()) throws -> Self? { do { let data = try JSONSerialization.data(withJSONObject: json, options: JSONSerialization.WritingOptions.prettyPrinted) let jsonModel = try decoder.decode(self, from: data) @@ -95,7 +93,7 @@ public enum Response where ResponseType: ParameterConvertible { public let error: Error? public let statusCode: Int? public let errorValue: [String: Any]? - public init(error: Error?, statusCode: Int?, errorValue: [String: Any]? = nil) { + public init(error: Error?, statusCode: Int? = nil, errorValue: [String: Any]? = nil) { self.error = error self.statusCode = statusCode self.errorValue = errorValue From 173eb78f4c5b0409e6e9a5e930d40fd4e52f7b6f Mon Sep 17 00:00:00 2001 From: Ayush Awasthi Date: Thu, 10 Jan 2019 17:41:32 +0530 Subject: [PATCH 7/7] Added workaround to fix google sign-in framework issue --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a153934..009bdef 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,13 @@ # KiwiPods To integrate Kiwipods in your app add `pod 'KiwiPods', :git => 'https://github.com/KiwiTechLLC/KiwiPods.git'` to your pod file. -KiwiPods are supported for `Swift 4.2` and `iOS 11.0 and above` +KiwiPods are supported for `Swift 4.2` and `iOS 11.0 and above` + + +In case `Social` depandency is needed, add following code in `podfile` : +``` +pre_install do |installer| + # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289 + Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} +end +```