Commit e855d42c by Olzhas Aldabergenov

login vip_gamer fixed. Settings password fixed

parent bb24a1a8
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
3E2C3E9B1EFCB17E00E553CD /* Validator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E2C3E9A1EFCB17E00E553CD /* Validator.swift */; }; 3E2C3E9B1EFCB17E00E553CD /* Validator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E2C3E9A1EFCB17E00E553CD /* Validator.swift */; };
3E2E1E821F84DB0100DC0FE5 /* LKSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E2E1E811F84DB0100DC0FE5 /* LKSettingsViewController.swift */; }; 3E2E1E821F84DB0100DC0FE5 /* LKSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E2E1E811F84DB0100DC0FE5 /* LKSettingsViewController.swift */; };
3E323D501FBEF916009C3DA8 /* FeedFeedbackCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E323D4F1FBEF916009C3DA8 /* FeedFeedbackCell.swift */; }; 3E323D501FBEF916009C3DA8 /* FeedFeedbackCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E323D4F1FBEF916009C3DA8 /* FeedFeedbackCell.swift */; };
3E3BCC9C1FCEB692008613E2 /* Facade+NewLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E3BCC9B1FCEB692008613E2 /* Facade+NewLogin.swift */; };
3E5CC7A51FA83F7400B55DF0 /* BotManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E5CC7A41FA83F7400B55DF0 /* BotManager.swift */; }; 3E5CC7A51FA83F7400B55DF0 /* BotManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E5CC7A41FA83F7400B55DF0 /* BotManager.swift */; };
3E5CC7AE1FA84F9F00B55DF0 /* DateUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E5CC7AD1FA84F9F00B55DF0 /* DateUtil.swift */; }; 3E5CC7AE1FA84F9F00B55DF0 /* DateUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E5CC7AD1FA84F9F00B55DF0 /* DateUtil.swift */; };
3E6969B31FA2097200032D95 /* ServiceDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6969B21FA2097200032D95 /* ServiceDetailsViewController.swift */; }; 3E6969B31FA2097200032D95 /* ServiceDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6969B21FA2097200032D95 /* ServiceDetailsViewController.swift */; };
...@@ -644,6 +645,7 @@ ...@@ -644,6 +645,7 @@
3E2C3E9A1EFCB17E00E553CD /* Validator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Validator.swift; sourceTree = "<group>"; }; 3E2C3E9A1EFCB17E00E553CD /* Validator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Validator.swift; sourceTree = "<group>"; };
3E2E1E811F84DB0100DC0FE5 /* LKSettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LKSettingsViewController.swift; sourceTree = "<group>"; }; 3E2E1E811F84DB0100DC0FE5 /* LKSettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LKSettingsViewController.swift; sourceTree = "<group>"; };
3E323D4F1FBEF916009C3DA8 /* FeedFeedbackCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedFeedbackCell.swift; sourceTree = "<group>"; }; 3E323D4F1FBEF916009C3DA8 /* FeedFeedbackCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedFeedbackCell.swift; sourceTree = "<group>"; };
3E3BCC9B1FCEB692008613E2 /* Facade+NewLogin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Facade+NewLogin.swift"; sourceTree = "<group>"; };
3E5CC7A41FA83F7400B55DF0 /* BotManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BotManager.swift; sourceTree = "<group>"; }; 3E5CC7A41FA83F7400B55DF0 /* BotManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BotManager.swift; sourceTree = "<group>"; };
3E5CC7AD1FA84F9F00B55DF0 /* DateUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateUtil.swift; sourceTree = "<group>"; }; 3E5CC7AD1FA84F9F00B55DF0 /* DateUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateUtil.swift; sourceTree = "<group>"; };
3E6969B21FA2097200032D95 /* ServiceDetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceDetailsViewController.swift; sourceTree = "<group>"; }; 3E6969B21FA2097200032D95 /* ServiceDetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceDetailsViewController.swift; sourceTree = "<group>"; };
...@@ -1115,6 +1117,7 @@ ...@@ -1115,6 +1117,7 @@
988728DE1DDCD9E900CEEBAA /* Facade+Siebel.swift */, 988728DE1DDCD9E900CEEBAA /* Facade+Siebel.swift */,
3EB108501F15E321000EAE88 /* Facade+Bot.swift */, 3EB108501F15E321000EAE88 /* Facade+Bot.swift */,
3EAFC4831F6F804D00BB07AD /* Facade+Knowedge.swift */, 3EAFC4831F6F804D00BB07AD /* Facade+Knowedge.swift */,
3E3BCC9B1FCEB692008613E2 /* Facade+NewLogin.swift */,
); );
path = Facade; path = Facade;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2920,6 +2923,7 @@ ...@@ -2920,6 +2923,7 @@
B212590DBF21D2F2C3CDF95C /* SwiftyJSON.swift in Sources */, B212590DBF21D2F2C3CDF95C /* SwiftyJSON.swift in Sources */,
986917581DE3816200FC712D /* FullDamageModalTableCell.swift in Sources */, 986917581DE3816200FC712D /* FullDamageModalTableCell.swift in Sources */,
98A335611CFB172F00F1A76C /* GetProvidersRequest.swift in Sources */, 98A335611CFB172F00F1A76C /* GetProvidersRequest.swift in Sources */,
3E3BCC9C1FCEB692008613E2 /* Facade+NewLogin.swift in Sources */,
983343FD1C71C6440008D9CA /* BlankDetailViewController.swift in Sources */, 983343FD1C71C6440008D9CA /* BlankDetailViewController.swift in Sources */,
98E3F8701CFA21B700112FB7 /* Download.swift in Sources */, 98E3F8701CFA21B700112FB7 /* Download.swift in Sources */,
987457B61CFDFA1100BB32C6 /* OffersSelectListViewController.swift in Sources */, 987457B61CFDFA1100BB32C6 /* OffersSelectListViewController.swift in Sources */,
......
...@@ -58,11 +58,11 @@ ...@@ -58,11 +58,11 @@
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
filePath = "kt/ViewControllers/Cabinet/Login/LoginViewController.swift" filePath = "kt/ViewControllers/Cabinet/Login/LoginViewController.swift"
timestampString = "532607789.350001" timestampString = "533643136.585398"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "596" startingLineNumber = "605"
endingLineNumber = "596" endingLineNumber = "605"
landmarkName = "applicationWillResignActive()" landmarkName = "applicationWillResignActive()"
landmarkType = "7"> landmarkType = "7">
</BreakpointContent> </BreakpointContent>
...@@ -74,11 +74,11 @@ ...@@ -74,11 +74,11 @@
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
filePath = "kt/ViewControllers/Cabinet/Login/LoginViewController.swift" filePath = "kt/ViewControllers/Cabinet/Login/LoginViewController.swift"
timestampString = "532607789.350001" timestampString = "533643136.585398"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "596" startingLineNumber = "605"
endingLineNumber = "596" endingLineNumber = "605"
landmarkName = "applicationWillResignActive()" landmarkName = "applicationWillResignActive()"
landmarkType = "7"> landmarkType = "7">
</BreakpointContent> </BreakpointContent>
...@@ -90,11 +90,11 @@ ...@@ -90,11 +90,11 @@
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
filePath = "kt/ViewControllers/Cabinet/Login/LoginViewController.swift" filePath = "kt/ViewControllers/Cabinet/Login/LoginViewController.swift"
timestampString = "532607789.350001" timestampString = "533643136.585398"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "566" startingLineNumber = "575"
endingLineNumber = "566" endingLineNumber = "575"
landmarkName = "showHelpAlert()" landmarkName = "showHelpAlert()"
landmarkType = "7"> landmarkType = "7">
</BreakpointContent> </BreakpointContent>
...@@ -106,11 +106,11 @@ ...@@ -106,11 +106,11 @@
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
filePath = "kt/ViewControllers/Cabinet/Login/LoginViewController.swift" filePath = "kt/ViewControllers/Cabinet/Login/LoginViewController.swift"
timestampString = "532607789.350001" timestampString = "533643136.585398"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "571" startingLineNumber = "580"
endingLineNumber = "571" endingLineNumber = "580"
landmarkName = "showHelpAlert()" landmarkName = "showHelpAlert()"
landmarkType = "7"> landmarkType = "7">
</BreakpointContent> </BreakpointContent>
...@@ -179,5 +179,197 @@ ...@@ -179,5 +179,197 @@
landmarkType = "7"> landmarkType = "7">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+Login.swift"
timestampString = "533638224.276248"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "74"
endingLineNumber = "74"
landmarkName = "connection(connection:didReceiveData:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+NewLogin.swift"
timestampString = "533717289.948236"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "142"
endingLineNumber = "142"
landmarkName = "connection(connection:didReceiveData:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+NewLogin.swift"
timestampString = "533711902.853936"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "40"
endingLineNumber = "40"
landmarkName = "connection(connection:didReceiveResponse:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+NewLogin.swift"
timestampString = "533713289.888934"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "60"
endingLineNumber = "60"
landmarkName = "connection(connection:didReceiveResponse:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+NewLogin.swift"
timestampString = "533714725.253721"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "66"
endingLineNumber = "66"
landmarkName = "connection(connection:didReceiveResponse:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+NewLogin.swift"
timestampString = "533717289.948236"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "111"
endingLineNumber = "111"
landmarkName = "connection(connection:didReceiveData:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+NewLogin.swift"
timestampString = "533717289.948236"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "171"
endingLineNumber = "171"
landmarkName = "connection(connection:didReceiveData:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+NewLogin.swift"
timestampString = "533717289.948236"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "73"
endingLineNumber = "73"
landmarkName = "connection(connection:didReceiveData:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+NewLogin.swift"
timestampString = "533718542.915068"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "159"
endingLineNumber = "159"
landmarkName = "connection(connection:didReceiveData:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Facade/Facade+NewLogin.swift"
timestampString = "533723569.307867"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "222"
endingLineNumber = "222"
landmarkName = "loginIdPort(login:password:loginType:onSuccess:onError:onFinish:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/ViewControllers/Cabinet/Login/LoginViewController.swift"
timestampString = "533723657.954344"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "329"
endingLineNumber = "329"
landmarkName = "loginRequest(withTrimFirstSymbol:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "kt/Utils/StringUtil.swift"
timestampString = "533724097.514757"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "24"
endingLineNumber = "24"
landmarkName = "containsLetters(checkString:)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints> </Breakpoints>
</Bucket> </Bucket>
...@@ -29,6 +29,7 @@ extension Facade { ...@@ -29,6 +29,7 @@ extension Facade {
case .Failure(let error): case .Failure(let error):
Router.globalLog.error(error.debugDescription) Router.globalLog.error(error.debugDescription)
onError?(error) onError?(error)
break
case .Success(let json): case .Success(let json):
Router.globalLog.debug(resp.response!) Router.globalLog.debug(resp.response!)
Router.globalLog.debug(json) Router.globalLog.debug(json)
...@@ -36,6 +37,7 @@ extension Facade { ...@@ -36,6 +37,7 @@ extension Facade {
Facade.accountId = json["account_id"] as? Int Facade.accountId = json["account_id"] as? Int
Facade.guid = "\(Facade.serverId!)-\(Facade.accountId!)" Facade.guid = "\(Facade.serverId!)-\(Facade.accountId!)"
onSuccess?() onSuccess?()
break
} }
} }
} }
......
...@@ -13,348 +13,348 @@ let FacadeUserNeedAuthError = NSError(domain: "telecom.kz", code: -1000, userInf ...@@ -13,348 +13,348 @@ let FacadeUserNeedAuthError = NSError(domain: "telecom.kz", code: -1000, userInf
let TokenExpiredNotification = "TokentExpired" let TokenExpiredNotification = "TokentExpired"
class CustomConnectionDelegate: NSObject, NSURLConnectionDataDelegate { class CustomConnectionDelegate: NSObject, NSURLConnectionDataDelegate {
var onFinish: (() -> Void)! var onFinish: (() -> Void)!
var onError: ((NSError) -> Void)! var onError: ((NSError) -> Void)!
var onSuccess: (() -> Void)! var onSuccess: (() -> Void)!
static var randomToken: String = "" static var randomToken: String = ""
var login: String = "" var login: String = ""
var password: String = "" var password: String = ""
var loginType: Facade.LoginType! var loginType: Facade.LoginType!
static var counter = 0 static var counter = 0
override init() {
} override init() {
func connection(connection: NSURLConnection, didFailWithError error: NSError) { }
// let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
// NSLocalizedDescriptionKey: §"login.error.incorrect_login_or_password",
// ])
Router.globalLog.error(error.debugDescription) func connection(connection: NSURLConnection, didFailWithError error: NSError) {
self.onError(error) // let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
} // NSLocalizedDescriptionKey: §"login.error.incorrect_login_or_password",
// ])
func connection(connection: NSURLConnection, didReceiveResponse response: NSURLResponse) {
print(response) Router.globalLog.error(error.debugDescription)
Router.globalLog.debug(response) self.onError(error)
guard CustomConnectionDelegate.counter == 1 else { return }
self.onFinish()
if let responseUrl = response.URL where responseUrl.host == "www.google.kz" {
let params = [
Facade.LoginParamsKeys.ThirdStepClientId: CustomConnectionDelegate.randomToken
]
let r = request(.POST, Facade.LoginUrls.ThirdStep, parameters: params, encoding: .JSON)
let customDel = CustomConnectionDelegate()
customDel.onError = onError
customDel.onFinish = onFinish
customDel.onSuccess = onSuccess
customDel.login = login
customDel.password = password
customDel.loginType = loginType
CustomConnectionDelegate.counter += 1
let con = NSURLConnection(request: r.request!, delegate: customDel)
con!.start()
} else {
let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
NSLocalizedDescriptionKey: §"login.error.incorrect_login_or_password",
])
self.onError(error)
} }
}
func connection(connection: NSURLConnection, didReceiveResponse response: NSURLResponse) {
func connection(connection: NSURLConnection, didReceiveData data: NSData) { print(response)
switch CustomConnectionDelegate.counter { Router.globalLog.debug(response)
case 0: guard CustomConnectionDelegate.counter == 1 else { return }
onFinish() self.onFinish()
if let responseUrl = response.URL where responseUrl.host == "www.google.kz" {
let url = NSURL(string: Facade.LoginUrls.SecondStep)! let params = [
var mutableRequest = NSMutableURLRequest(URL: url) Facade.LoginParamsKeys.ThirdStepClientId: CustomConnectionDelegate.randomToken
mutableRequest.HTTPMethod = Method.GET.rawValue ]
let r = request(.POST, Facade.LoginUrls.ThirdStep, parameters: params, encoding: .JSON)
var params = Facade.LoginParams.SecondStep let customDel = CustomConnectionDelegate()
params[Facade.LoginParamsKeys.ClientIdKey] = CustomConnectionDelegate.randomToken customDel.onError = onError
customDel.onFinish = onFinish
mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: params).0 customDel.onSuccess = onSuccess
customDel.login = login
var userParams = Facade.LoginParams.SecondStepBody customDel.password = password
userParams[Facade.LoginParamsKeys.BodyAuthType] = loginType.rawValue customDel.loginType = loginType
userParams[Facade.LoginParamsKeys.BodyUsername] = login CustomConnectionDelegate.counter += 1
userParams[Facade.LoginParamsKeys.BodyPassword] = password let con = NSURLConnection(request: r.request!, delegate: customDel)
con!.start()
mutableRequest.HTTPMethod = Method.POST.rawValue
mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: userParams).0
let r = request(mutableRequest)
let customDel = CustomConnectionDelegate()
customDel.onError = onError
customDel.onFinish = onFinish
customDel.onSuccess = onSuccess
customDel.login = login
customDel.password = password
customDel.loginType = loginType
CustomConnectionDelegate.counter += 1
let con = NSURLConnection(request: r.request!, delegate: customDel)
con!.start()
break
case 2:
self.onFinish()
let json = JSON(data: data)
if let errorCode = json["error_code"].int {
// Success login
if errorCode == 0 {
// let access_token = json["access_token"] as! String
// let client_id = randomToken
Facade.expiresIn = json["expires_in"].doubleValue
Facade.accessToken = json["access_token"].stringValue
Facade.clientId = CustomConnectionDelegate.randomToken
// Facade.clientId = json["client_id"] as? String
// self.notificationCenter.postNotificationName(FacadeLoginSuccess, object: self)
UserManager.sharedInstance().login = self.login
UserManager.sharedInstance().password = self.password
self.onSuccess()
} else { } else {
let error = NSError(domain: "kz.telecom", code: 0, userInfo: [ let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
NSLocalizedDescriptionKey: json["error"].stringValue, NSLocalizedDescriptionKey: §"login.error.incorrect_login_or_password",
]) ])
self.onError(error) self.onError(error)
// self.notificationCenter.postNotificationName(FacadeLoginError, object: self, userInfo: [ }
// FacadeNotificationErrorKey: error, }
// ])
func connection(connection: NSURLConnection, didReceiveData data: NSData) {
switch CustomConnectionDelegate.counter {
case 0:
onFinish()
let url = NSURL(string: Facade.LoginUrls.SecondStep)!
var mutableRequest = NSMutableURLRequest(URL: url)
mutableRequest.HTTPMethod = Method.GET.rawValue
var params = Facade.LoginParams.SecondStep
params[Facade.LoginParamsKeys.ClientIdKey] = CustomConnectionDelegate.randomToken
mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: params).0
var userParams = Facade.LoginParams.SecondStepBody
userParams[Facade.LoginParamsKeys.BodyAuthType] = loginType.rawValue
userParams[Facade.LoginParamsKeys.BodyUsername] = login
userParams[Facade.LoginParamsKeys.BodyPassword] = password
mutableRequest.HTTPMethod = Method.POST.rawValue
mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: userParams).0
let r = request(mutableRequest)
let customDel = CustomConnectionDelegate()
customDel.onError = onError
customDel.onFinish = onFinish
customDel.onSuccess = onSuccess
customDel.login = login
customDel.password = password
customDel.loginType = loginType
CustomConnectionDelegate.counter += 1
let con = NSURLConnection(request: r.request!, delegate: customDel)
con!.start()
break
case 2:
self.onFinish()
let json = JSON(data: data)
if let errorCode = json["error_code"].int {
// Success login
if errorCode == 0 {
// let access_token = json["access_token"] as! String
// let client_id = randomToken
Facade.expiresIn = json["expires_in"].doubleValue
Facade.accessToken = json["access_token"].stringValue
Facade.clientId = CustomConnectionDelegate.randomToken
// Facade.clientId = json["client_id"] as? String
// self.notificationCenter.postNotificationName(FacadeLoginSuccess, object: self)
UserManager.sharedInstance().login = self.login
UserManager.sharedInstance().password = self.password
self.onSuccess()
} else {
let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
NSLocalizedDescriptionKey: json["error"].stringValue,
])
self.onError(error)
// self.notificationCenter.postNotificationName(FacadeLoginError, object: self, userInfo: [
// FacadeNotificationErrorKey: error,
// ])
}
break
}
// Error login or password
// CustomConnectionDelegate.counter += 1
break
default:
break
} }
break
}
// Error login or password
// CustomConnectionDelegate.counter += 1
break
default:
break
} }
} func connection(connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: NSURLProtectionSpace) -> Bool {
return protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust
func connection(connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: NSURLProtectionSpace) -> Bool { }
return protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust
} func connection(connection: NSURLConnection, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge) {
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
func connection(connection: NSURLConnection, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge) { // if challenge.protectionSpace.host.containsString("cabinet.idport.kz") {
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { challenge.sender?.useCredential(NSURLCredential(forTrust: challenge.protectionSpace.serverTrust!), forAuthenticationChallenge: challenge)
// if challenge.protectionSpace.host.containsString("cabinet.idport.kz") {
challenge.sender?.useCredential(NSURLCredential(forTrust: challenge.protectionSpace.serverTrust!), forAuthenticationChallenge: challenge) challenge.sender?.continueWithoutCredentialForAuthenticationChallenge(challenge)
// }
challenge.sender?.continueWithoutCredentialForAuthenticationChallenge(challenge) }
// }
} }
}
} }
extension Facade { extension Facade {
var UserNeedAuthNotification: NSNotification { var UserNeedAuthNotification: NSNotification {
return NSNotification(name: FacadeUserNeedAuth, object: self, return NSNotification(name: FacadeUserNeedAuth, object: self,
userInfo: [FacadeNotificationErrorKey: FacadeUserNeedAuthError]) userInfo: [FacadeNotificationErrorKey: FacadeUserNeedAuthError])
} }
// randomToken // randomToken
// loginType.rawValue // loginType.rawValue
// login // login
// password // password
static var phoneNumber: String? = nil static var phoneNumber: String? = nil
static var accessToken: String? = nil static var accessToken: String? = nil
static var clientId: String? = nil static var clientId: String? = nil
static var expiresIn: NSTimeInterval? = nil { static var expiresIn: NSTimeInterval? = nil {
didSet { didSet {
guard let expiresIn = expiresIn else { guard let expiresIn = expiresIn else {
return return
} }
let seconds = Double(NSDate(timeIntervalSince1970: expiresIn).secondsFrom(NSDate())) let seconds = Double(NSDate(timeIntervalSince1970: expiresIn).secondsFrom(NSDate()))
let delay = seconds * Double(NSEC_PER_SEC) let delay = seconds * Double(NSEC_PER_SEC)
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue(), {() in dispatch_after(time, dispatch_get_main_queue(), {() in
if self.expiresIn != nil { if self.expiresIn != nil {
NSNotificationCenter.defaultCenter().postNotificationName(TokenExpiredNotification, object: nil) NSNotificationCenter.defaultCenter().postNotificationName(TokenExpiredNotification, object: nil)
}
})
} }
})
} }
}
struct LoginUrls {
static let FirstStep = "https://cabinet.idport.kz:8443/IdPort/oauth/"
static let SecondStep = "https://cabinet.idport.kz:8443/IdPort/oauth/process.cfm"
static let ThirdStep = "https://telecom.kz/api/account/get_token.json"
}
struct LoginParams {
// Apend IN_CLIENT_ID before sending
static let FirstStep: [String: AnyObject] = [
"IN_SYSTEM_PROVIDER_CODE": "KAZNET",
"IN_URL_REDIRECT": "https://www.google.kz",
"IN_URL_TOKEN": "http://telecom.kz/auth20/save_access_token",
]
// Apend IN_CLIENT_ID before sending struct LoginUrls {
static let SecondStep: [String: AnyObject] = [ static let FirstStep = "https://cabinet.idport.kz:8443/IdPort/oauth/"
"IN_SYSTEM_PROVIDER_CODE": "KAZNET", static let SecondStep = "https://cabinet.idport.kz:8443/IdPort/oauth/process.cfm"
"IN_URL_REDIRECT": "https://www.google.kz", static let ThirdStep = "https://telecom.kz/api/account/get_token.json"
"IN_URL_TOKEN": "http://telecom.kz/auth20/save_access_token",
"isProvider": 0,
]
static let SecondStepBody: [String: AnyObject] = [
"sSubmit": "ВХОД В КАБИНЕТ",
]
}
struct LoginParamsKeys {
static let ClientIdKey = "IN_CLIENT_ID"
static let BodyAuthType = "AuthType"
static let BodyUsername = "j_username"
static let BodyPassword = "j_password"
static let ThirdStepClientId = "client_id"
}
enum LoginType: Int {
case Login = 1
case PhoneNumber = 2
}
func login(login: String, password: String, loginType: LoginType, onSuccess: () -> Void, onError: (error: NSError) -> Void, onFinish: () -> Void) {
CustomConnectionDelegate.counter = 0
let cookiesStorage = NSHTTPCookieStorage.sharedHTTPCookieStorage()
if let cookies = cookiesStorage.cookies where cookies.count != 0 {
for cookie in cookies {
if cookie.domain.rangeOfString("cabinet.idport.kz") != nil {
cookiesStorage.deleteCookie(cookie)
}
}
} }
let uuid = NSUUID().UUIDString
let randomToken = uuid.stringByReplacingOccurrencesOfString("-", withString: "")
var params = LoginParams.FirstStep
params[LoginParamsKeys.ClientIdKey] = randomToken
// First Step: Simple .GET struct LoginParams {
let r = request(.GET, LoginUrls.FirstStep, parameters: params, encoding: .URL) // Apend IN_CLIENT_ID before sending
let customDel = CustomConnectionDelegate() static let FirstStep: [String: AnyObject] = [
customDel.onError = onError "IN_SYSTEM_PROVIDER_CODE": "KAZNET",
customDel.onFinish = onFinish "IN_URL_REDIRECT": "https://www.google.kz",
CustomConnectionDelegate.randomToken = randomToken "IN_URL_TOKEN": "http://telecom.kz/auth20/save_access_token",
customDel.onSuccess = onSuccess ]
customDel.login = login
customDel.password = password // Apend IN_CLIENT_ID before sending
customDel.loginType = loginType static let SecondStep: [String: AnyObject] = [
"IN_SYSTEM_PROVIDER_CODE": "KAZNET",
"IN_URL_REDIRECT": "https://www.google.kz",
"IN_URL_TOKEN": "http://telecom.kz/auth20/save_access_token",
"isProvider": 0,
]
static let SecondStepBody: [String: AnyObject] = [
"sSubmit": "ВХОД В КАБИНЕТ",
]
}
let con = NSURLConnection(request: r.request!, delegate: customDel) struct LoginParamsKeys {
con!.start() static let ClientIdKey = "IN_CLIENT_ID"
static let BodyAuthType = "AuthType"
static let BodyUsername = "j_username"
static let BodyPassword = "j_password"
static let ThirdStepClientId = "client_id"
}
Router.globalLog.debug("loginRequestStarted") enum LoginType: Int {
case Login = 1
case PhoneNumber = 2
}
// print(r.cURLRepresentation()) func login(login: String, password: String, loginType: LoginType, onSuccess: () -> Void, onError: (error: NSError) -> Void, onFinish: () -> Void) {
// r.responseData { (resp) in CustomConnectionDelegate.counter = 0
// onFinish() let cookiesStorage = NSHTTPCookieStorage.sharedHTTPCookieStorage()
// switch resp.result {
// // Error on sending data if let cookies = cookiesStorage.cookies where cookies.count != 0 {
// case .Failure(let error): for cookie in cookies {
// onError(error: error) if cookie.domain.rangeOfString("cabinet.idport.kz") != nil {
// // self.notificationCenter.postNotificationName(FacadeLoginError, object: self, userInfo: [ cookiesStorage.deleteCookie(cookie)
// // FacadeNotificationErrorKey: error }
// // ]) }
// break }
// // Second Step: OAuth on iDPort let uuid = NSUUID().UUIDString
// case .Success: let randomToken = uuid.stringByReplacingOccurrencesOfString("-", withString: "")
// let url = NSURL(string: LoginUrls.SecondStep)! var params = LoginParams.FirstStep
// var mutableRequest = NSMutableURLRequest(URL: url) params[LoginParamsKeys.ClientIdKey] = randomToken
// mutableRequest.HTTPMethod = Method.GET.rawValue
// // First Step: Simple .GET
// var params = LoginParams.SecondStep let r = request(.GET, LoginUrls.FirstStep, parameters: params, encoding: .URL)
// params[LoginParamsKeys.ClientIdKey] = randomToken let customDel = CustomConnectionDelegate()
// customDel.onError = onError
// mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: params).0 customDel.onFinish = onFinish
// CustomConnectionDelegate.randomToken = randomToken
// var userParams = LoginParams.SecondStepBody customDel.onSuccess = onSuccess
// userParams[LoginParamsKeys.BodyAuthType] = loginType.rawValue customDel.login = login
// userParams[LoginParamsKeys.BodyUsername] = login customDel.password = password
// userParams[LoginParamsKeys.BodyPassword] = password customDel.loginType = loginType
//
// mutableRequest.HTTPMethod = Method.POST.rawValue let con = NSURLConnection(request: r.request!, delegate: customDel)
// mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: userParams).0 con!.start()
//
// let r = request(mutableRequest) Router.globalLog.debug("loginRequestStarted")
// // print(r.cURLRepresentation())
// r.responseData(completionHandler: { (resp) in // print(r.cURLRepresentation())
// onFinish() // r.responseData { (resp) in
// switch resp.result { // onFinish()
// // Error in sending on Second Step // switch resp.result {
// case .Failure(let error): // // Error on sending data
// // self.notificationCenter.postNotificationName(FacadeLoginError, object: self, // case .Failure(let error):
// // userInfo: [ // onError(error: error)
// // FacadeNotificationErrorKey: error // // self.notificationCenter.postNotificationName(FacadeLoginError, object: self, userInfo: [
// // ] // // FacadeNotificationErrorKey: error
// // ) // // ])
// onError(error: error) // break
// break // // Second Step: OAuth on iDPort
// case .Success: // case .Success:
// // If Second Step success // let url = NSURL(string: LoginUrls.SecondStep)!
// if let responseUrl = resp.response?.URL where responseUrl.host == "www.google.kz" { // var mutableRequest = NSMutableURLRequest(URL: url)
// let params = [ // mutableRequest.HTTPMethod = Method.GET.rawValue
// LoginParamsKeys.ThirdStepClientId: randomToken //
// ] // var params = LoginParams.SecondStep
// let r = request(.POST, LoginUrls.ThirdStep, parameters: params, encoding: .JSON) // params[LoginParamsKeys.ClientIdKey] = randomToken
// // print(r.cURLRepresentation()) //
// r.responseJSON(completionHandler: { (resp) in // mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: params).0
// onFinish() //
// switch resp.result { // var userParams = LoginParams.SecondStepBody
// case .Failure(let error): // userParams[LoginParamsKeys.BodyAuthType] = loginType.rawValue
// // self.notificationCenter.postNotificationName(FacadeLoginError, object: self, // userParams[LoginParamsKeys.BodyUsername] = login
// // userInfo: [ // userParams[LoginParamsKeys.BodyPassword] = password
// // FacadeNotificationErrorKey: error //
// // ] // mutableRequest.HTTPMethod = Method.POST.rawValue
// // ) // mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: userParams).0
// onError(error: error) //
// break // let r = request(mutableRequest)
// case .Success(let json): // // print(r.cURLRepresentation())
// if let errorCode = json["error_code"] as? Int { // r.responseData(completionHandler: { (resp) in
// // Success login // onFinish()
// if errorCode == 0 { // switch resp.result {
// // let access_token = json["access_token"] as! String // // Error in sending on Second Step
// // let client_id = randomToken // case .Failure(let error):
// Facade.expiresIn = json["expires_in"] as! Double // // self.notificationCenter.postNotificationName(FacadeLoginError, object: self,
// Facade.accessToken = json["access_token"] as? String // // userInfo: [
// Facade.clientId = randomToken // // FacadeNotificationErrorKey: error
// // Facade.clientId = json["client_id"] as? String // // ]
// // self.notificationCenter.postNotificationName(FacadeLoginSuccess, object: self) // // )
// UserManager.sharedInstance().login = login // onError(error: error)
// UserManager.sharedInstance().password = password // break
// onSuccess() // case .Success:
// } else { // // If Second Step success
// let error = NSError(domain: "kz.telecom", code: 0, userInfo: [ // if let responseUrl = resp.response?.URL where responseUrl.host == "www.google.kz" {
// NSLocalizedDescriptionKey: json["error"] as! String, // let params = [
// ]) // LoginParamsKeys.ThirdStepClientId: randomToken
// onError(error: error) // ]
// // self.notificationCenter.postNotificationName(FacadeLoginError, object: self, userInfo: [ // let r = request(.POST, LoginUrls.ThirdStep, parameters: params, encoding: .JSON)
// // FacadeNotificationErrorKey: error, // // print(r.cURLRepresentation())
// // ]) // r.responseJSON(completionHandler: { (resp) in
// } // onFinish()
// break // switch resp.result {
// } // case .Failure(let error):
// } // // self.notificationCenter.postNotificationName(FacadeLoginError, object: self,
// // Error login or password // // userInfo: [
// }) // // FacadeNotificationErrorKey: error
// } else { // // ]
// let error = NSError(domain: "kz.telecom", code: 0, userInfo: [ // // )
// NSLocalizedDescriptionKey: §"login.error.incorrect_login_or_password", // onError(error: error)
// ]) // break
// onError(error: error) // case .Success(let json):
// // self.notificationCenter.postNotificationName(FacadeLoginError, object: self, userInfo: [ // if let errorCode = json["error_code"] as? Int {
// // FacadeNotificationErrorKey: error, // // Success login
// // ]) // if errorCode == 0 {
// } // // let access_token = json["access_token"] as! String
// } // // let client_id = randomToken
// }) // Facade.expiresIn = json["expires_in"] as! Double
// } // Facade.accessToken = json["access_token"] as? String
// } // Facade.clientId = randomToken
} // // Facade.clientId = json["client_id"] as? String
// // self.notificationCenter.postNotificationName(FacadeLoginSuccess, object: self)
// UserManager.sharedInstance().login = login
// UserManager.sharedInstance().password = password
// onSuccess()
// } else {
// let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
// NSLocalizedDescriptionKey: json["error"] as! String,
// ])
// onError(error: error)
// // self.notificationCenter.postNotificationName(FacadeLoginError, object: self, userInfo: [
// // FacadeNotificationErrorKey: error,
// // ])
// }
// break
// }
// }
// // Error login or password
// })
// } else {
// let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
// NSLocalizedDescriptionKey: §"login.error.incorrect_login_or_password",
// ])
// onError(error: error)
// // self.notificationCenter.postNotificationName(FacadeLoginError, object: self, userInfo: [
// // FacadeNotificationErrorKey: error,
// // ])
// }
// }
// })
// }
// }
}
} }
//
// Facade+NewLogin.swift
// kt
//
// Created by neox on 29.11.17.
// Copyright © 2017 SimpleCode. All rights reserved.
//
import Foundation
import XCGLogger
class LoginConnectionDelegate: NSObject, NSURLConnectionDataDelegate {
var onFinish: (() -> Void)!
var onError: ((NSError) -> Void)!
var onSuccess: (() -> Void)!
static var randomToken: String = ""
var login: String = ""
var password: String = ""
var loginType: Facade.LoginType!
static var counter = 0
override init() {
}
func connection(connection: NSURLConnection, didFailWithError error: NSError) {
// let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
// NSLocalizedDescriptionKey: §"login.error.incorrect_login_or_password",
// ])
Router.globalLog.error(error.debugDescription)
self.onError(error)
}
func connection(connection: NSURLConnection, didReceiveResponse response: NSURLResponse) {
//print(response)
print("-=-=-=-=-=-=-")
Router.globalLog.debug(response)
print("-=-=-=-=-=-=-")
guard LoginConnectionDelegate.counter == 1 else { return }
self.onFinish()
if let responseUrl = response.URL where responseUrl.host == "www.google.kz" {
let params = [
Facade.LoginParamsKeys.ThirdStepClientId: LoginConnectionDelegate.randomToken
]
let r = request(.POST, Facade.LoginUrls.ThirdStep, parameters: params, encoding: .JSON)
let customDel = LoginConnectionDelegate()
customDel.onError = onError
customDel.onFinish = onFinish
customDel.onSuccess = onSuccess
customDel.login = login
customDel.password = password
customDel.loginType = loginType
LoginConnectionDelegate.counter += 1
print(r.cURLRepresentation())
let con = NSURLConnection(request: r.request!, delegate: customDel)
con!.start()
} else {
let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
NSLocalizedDescriptionKey: §"login.error.incorrect_login_or_password",
])
self.onError(error)
}
}
func connection(connection: NSURLConnection, didReceiveData data: NSData) {
print(String(data: data, encoding: NSUTF8StringEncoding))
switch LoginConnectionDelegate.counter {
case 0:
onFinish()
let url = NSURL(string: Facade.LoginUrls.SecondStep)!
var mutableRequest = NSMutableURLRequest(URL: url)
mutableRequest.HTTPMethod = Method.GET.rawValue
var params = Facade.LoginParams.SecondStep
params[Facade.LoginParamsKeys.ClientIdKey] = LoginConnectionDelegate.randomToken
mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: params).0
var userParams = Facade.LoginParams.SecondStepBody
userParams[Facade.LoginParamsKeys.BodyAuthType] = loginType.rawValue
userParams[Facade.LoginParamsKeys.BodyUsername] = login
userParams[Facade.LoginParamsKeys.BodyPassword] = password
userParams[Facade.LoginParamsKeys.ClientIdKey] = LoginConnectionDelegate.randomToken
print(userParams)
mutableRequest.HTTPMethod = Method.POST.rawValue
mutableRequest = ParameterEncoding.URL.encode(mutableRequest, parameters: userParams).0
let r = request(mutableRequest)
let customDel = LoginConnectionDelegate()
customDel.onError = onError
customDel.onFinish = onFinish
customDel.onSuccess = onSuccess
customDel.login = login
customDel.password = password
customDel.loginType = loginType
LoginConnectionDelegate.counter += 1
print(r.cURLRepresentation())
let con = NSURLConnection(request: r.request!, delegate: customDel)
con!.start()
break
// case 1:
// self.onFinish()
// let params = [
// Facade.LoginParamsKeys.ThirdStepClientId: LoginConnectionDelegate.randomToken,
//
// Facade.LoginParamsKeys.ClientIdKey: LoginConnectionDelegate.randomToken
//
// ]
// print(params)
// let r = request(.POST, Facade.LoginUrls.ThirdStep, parameters: params, encoding: .JSON)
// let customDel = LoginConnectionDelegate()
// customDel.onError = onError
// customDel.onFinish = onFinish
// customDel.onSuccess = onSuccess
// customDel.login = login
// customDel.password = password
// customDel.loginType = loginType
// LoginConnectionDelegate.counter += 1
// let con = NSURLConnection(request: r.request!, delegate: customDel)
// con!.start()
//
// break
case 2:
self.onFinish()
let json = JSON(data: data)
print (json)
if let errorCode = json["error_code"].int {
// Success login
if errorCode == 0 {
// let access_token = json["access_token"] as! String
// let client_id = randomToken
Facade.expiresIn = json["expires_in"].doubleValue
Facade.accessToken = json["access_token"].stringValue
Facade.clientId = LoginConnectionDelegate.randomToken
// Facade.clientId = json["client_id"] as? String
// self.notificationCenter.postNotificationName(FacadeLoginSuccess, object: self)
UserManager.sharedInstance().login = self.login
UserManager.sharedInstance().password = self.password
self.onSuccess()
} else {
let error = NSError(domain: "kz.telecom", code: 0, userInfo: [
NSLocalizedDescriptionKey: json["error"].stringValue,
])
self.onError(error)
// self.notificationCenter.postNotificationName(FacadeLoginError, object: self, userInfo: [
// FacadeNotificationErrorKey: error,
// ])
}
}
// Error login or password
// CustomConnectionDelegate.counter += 1
break
default:
break
}
}
func connection(connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: NSURLProtectionSpace) -> Bool {
return protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust
}
func connection(connection: NSURLConnection, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge) {
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
// if challenge.protectionSpace.host.containsString("cabinet.idport.kz") {
challenge.sender?.useCredential(NSURLCredential(forTrust: challenge.protectionSpace.serverTrust!), forAuthenticationChallenge: challenge)
challenge.sender?.continueWithoutCredentialForAuthenticationChallenge(challenge)
// }
}
}
}
extension Facade {
func loginIdPort(login: String, password: String, loginType: LoginType, onSuccess: () -> Void, onError: (error: NSError) -> Void, onFinish: () -> Void) {
LoginConnectionDelegate.counter = 0
let cookiesStorage = NSHTTPCookieStorage.sharedHTTPCookieStorage()
if let cookies = cookiesStorage.cookies where cookies.count != 0 {
for cookie in cookies {
if cookie.domain.rangeOfString("cabinet.idport.kz") != nil {
cookiesStorage.deleteCookie(cookie)
}
}
}
let uuid = NSUUID().UUIDString
let randomToken = uuid.stringByReplacingOccurrencesOfString("-", withString: "")
var params = LoginParams.FirstStep
params[LoginParamsKeys.ClientIdKey] = randomToken
// First Step: Simple .GET
let r = request(.GET, LoginUrls.FirstStep, parameters: params, encoding: .URL)
let customDel = LoginConnectionDelegate()
customDel.onError = onError
customDel.onFinish = onFinish
LoginConnectionDelegate.randomToken = randomToken
customDel.onSuccess = onSuccess
customDel.login = login
customDel.password = password
customDel.loginType = loginType
print(r.cURLRepresentation())
let con = NSURLConnection(request: r.request!, delegate: customDel)
con!.start()
Router.globalLog.debug("loginRequestStarted")
}
}
...@@ -1033,11 +1033,6 @@ ...@@ -1033,11 +1033,6 @@
<action selector="testLogin_touchUpInside:" destination="faD-wp-261" eventType="touchUpInside" id="fni-lg-ksD"/> <action selector="testLogin_touchUpInside:" destination="faD-wp-261" eventType="touchUpInside" id="fni-lg-ksD"/>
</connections> </connections>
</button> </button>
<label opaque="NO" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="left" text="Версия 1.0, сборка 53" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hea-SM-eVd">
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CTQ-mM-kz7" customClass="HelpButton" customModule="telecom" customModuleProvider="target"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CTQ-mM-kz7" customClass="HelpButton" customModule="telecom" customModuleProvider="target">
<constraints> <constraints>
<constraint firstAttribute="height" constant="44" id="sJQ-dQ-tqd"/> <constraint firstAttribute="height" constant="44" id="sJQ-dQ-tqd"/>
...@@ -1077,7 +1072,6 @@ ...@@ -1077,7 +1072,6 @@
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
<constraint firstItem="mDW-lm-hs5" firstAttribute="top" secondItem="WFI-fo-Rky" secondAttribute="bottom" constant="60" id="1p7-ZJ-j63"/> <constraint firstItem="mDW-lm-hs5" firstAttribute="top" secondItem="WFI-fo-Rky" secondAttribute="bottom" constant="60" id="1p7-ZJ-j63"/>
<constraint firstItem="hea-SM-eVd" firstAttribute="trailing" secondItem="Nxe-gd-eO9" secondAttribute="trailingMargin" id="5Ii-kM-TKH"/>
<constraint firstItem="f5l-v6-3UO" firstAttribute="leading" secondItem="Nxe-gd-eO9" secondAttribute="leadingMargin" id="5Zi-Q9-20d"/> <constraint firstItem="f5l-v6-3UO" firstAttribute="leading" secondItem="Nxe-gd-eO9" secondAttribute="leadingMargin" id="5Zi-Q9-20d"/>
<constraint firstItem="f5l-v6-3UO" firstAttribute="top" secondItem="8Gg-7i-aK6" secondAttribute="bottom" constant="16" id="7Z1-42-GMu"/> <constraint firstItem="f5l-v6-3UO" firstAttribute="top" secondItem="8Gg-7i-aK6" secondAttribute="bottom" constant="16" id="7Z1-42-GMu"/>
<constraint firstItem="CTQ-mM-kz7" firstAttribute="centerX" secondItem="Nxe-gd-eO9" secondAttribute="centerX" id="8fE-qw-5P3"/> <constraint firstItem="CTQ-mM-kz7" firstAttribute="centerX" secondItem="Nxe-gd-eO9" secondAttribute="centerX" id="8fE-qw-5P3"/>
...@@ -1087,12 +1081,10 @@ ...@@ -1087,12 +1081,10 @@
<constraint firstItem="mDW-lm-hs5" firstAttribute="centerX" secondItem="Nxe-gd-eO9" secondAttribute="centerX" id="IbB-gt-eEd"/> <constraint firstItem="mDW-lm-hs5" firstAttribute="centerX" secondItem="Nxe-gd-eO9" secondAttribute="centerX" id="IbB-gt-eEd"/>
<constraint firstItem="VHN-P8-7SV" firstAttribute="leading" secondItem="Nxe-gd-eO9" secondAttribute="leadingMargin" id="Muz-YL-qDb"/> <constraint firstItem="VHN-P8-7SV" firstAttribute="leading" secondItem="Nxe-gd-eO9" secondAttribute="leadingMargin" id="Muz-YL-qDb"/>
<constraint firstItem="8Gg-7i-aK6" firstAttribute="leading" secondItem="Nxe-gd-eO9" secondAttribute="leadingMargin" id="NhW-an-LLE"/> <constraint firstItem="8Gg-7i-aK6" firstAttribute="leading" secondItem="Nxe-gd-eO9" secondAttribute="leadingMargin" id="NhW-an-LLE"/>
<constraint firstItem="hea-SM-eVd" firstAttribute="top" secondItem="VHN-P8-7SV" secondAttribute="bottom" constant="23" id="OH2-RE-iwU"/>
<constraint firstAttribute="trailingMargin" secondItem="Cwt-LS-RsF" secondAttribute="trailing" constant="16" id="QZy-7h-Hhd"/> <constraint firstAttribute="trailingMargin" secondItem="Cwt-LS-RsF" secondAttribute="trailing" constant="16" id="QZy-7h-Hhd"/>
<constraint firstItem="Bfw-9Q-UWv" firstAttribute="top" secondItem="CTQ-mM-kz7" secondAttribute="bottom" id="TsW-qp-xV6"/> <constraint firstItem="Bfw-9Q-UWv" firstAttribute="top" secondItem="CTQ-mM-kz7" secondAttribute="bottom" id="TsW-qp-xV6"/>
<constraint firstItem="VHN-P8-7SV" firstAttribute="top" secondItem="3cO-TQ-vvg" secondAttribute="bottom" constant="16" id="UMs-f4-uP3"/> <constraint firstItem="VHN-P8-7SV" firstAttribute="top" secondItem="3cO-TQ-vvg" secondAttribute="bottom" constant="16" id="UMs-f4-uP3"/>
<constraint firstItem="VHN-P8-7SV" firstAttribute="trailing" secondItem="Nxe-gd-eO9" secondAttribute="trailingMargin" id="X7u-gg-4K9"/> <constraint firstItem="VHN-P8-7SV" firstAttribute="trailing" secondItem="Nxe-gd-eO9" secondAttribute="trailingMargin" id="X7u-gg-4K9"/>
<constraint firstItem="hea-SM-eVd" firstAttribute="leading" secondItem="Nxe-gd-eO9" secondAttribute="leadingMargin" id="Zry-au-sxB"/>
<constraint firstItem="8Gg-7i-aK6" firstAttribute="top" secondItem="mDW-lm-hs5" secondAttribute="bottom" constant="34" id="o3v-iQ-VXW"/> <constraint firstItem="8Gg-7i-aK6" firstAttribute="top" secondItem="mDW-lm-hs5" secondAttribute="bottom" constant="34" id="o3v-iQ-VXW"/>
<constraint firstItem="3cO-TQ-vvg" firstAttribute="top" secondItem="f5l-v6-3UO" secondAttribute="bottom" constant="39" id="wuW-cg-fmG"/> <constraint firstItem="3cO-TQ-vvg" firstAttribute="top" secondItem="f5l-v6-3UO" secondAttribute="bottom" constant="39" id="wuW-cg-fmG"/>
<constraint firstItem="3cO-TQ-vvg" firstAttribute="trailing" secondItem="Nxe-gd-eO9" secondAttribute="trailingMargin" id="xVx-Ew-dZe"/> <constraint firstItem="3cO-TQ-vvg" firstAttribute="trailing" secondItem="Nxe-gd-eO9" secondAttribute="trailingMargin" id="xVx-Ew-dZe"/>
...@@ -1430,15 +1422,19 @@ ...@@ -1430,15 +1422,19 @@
<frame key="frameInset" width="414" height="43"/> <frame key="frameInset" width="414" height="43"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="5" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qZu-i5-IkV"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qZu-i5-IkV">
<frame key="frameInset" minX="8" minY="11" width="361" height="22"/>
<fontDescription key="fontDescription" name="PTSans-Regular" family="PT Sans" pointSize="17"/> <fontDescription key="fontDescription" name="PTSans-Regular" family="PT Sans" pointSize="17"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
</subviews> </subviews>
<constraints>
<constraint firstItem="qZu-i5-IkV" firstAttribute="top" secondItem="zUj-fk-hK8" secondAttribute="top" constant="8" id="QVX-ls-2JC"/>
<constraint firstAttribute="bottom" secondItem="qZu-i5-IkV" secondAttribute="bottom" constant="8" id="cf0-pC-GC6"/>
</constraints>
</tableViewCellContentView> </tableViewCellContentView>
<constraints> <constraints>
<constraint firstItem="qZu-i5-IkV" firstAttribute="centerY" secondItem="SQN-x5-07i" secondAttribute="centerY" id="49g-mT-lnE"/>
<constraint firstAttribute="trailing" secondItem="qZu-i5-IkV" secondAttribute="trailing" constant="8" id="6iQ-xr-It7"/> <constraint firstAttribute="trailing" secondItem="qZu-i5-IkV" secondAttribute="trailing" constant="8" id="6iQ-xr-It7"/>
<constraint firstItem="qZu-i5-IkV" firstAttribute="leading" secondItem="SQN-x5-07i" secondAttribute="leading" constant="8" id="Isp-FJ-vrU"/> <constraint firstItem="qZu-i5-IkV" firstAttribute="leading" secondItem="SQN-x5-07i" secondAttribute="leading" constant="8" id="Isp-FJ-vrU"/>
</constraints> </constraints>
...@@ -1467,7 +1463,7 @@ ...@@ -1467,7 +1463,7 @@
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yrI-iU-iSw" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="yrI-iU-iSw" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="-5154" y="3167"/> <point key="canvasLocation" x="-5154.3999999999996" y="3166.866566716642"/>
</scene> </scene>
<!--Navigation Controller--> <!--Navigation Controller-->
<scene sceneID="7pQ-gJ-z0O"> <scene sceneID="7pQ-gJ-z0O">
...@@ -5416,10 +5412,10 @@ ...@@ -5416,10 +5412,10 @@
<viewControllerLayoutGuide type="bottom" id="4K9-5I-gyS"/> <viewControllerLayoutGuide type="bottom" id="4K9-5I-gyS"/>
</layoutGuides> </layoutGuides>
<view key="view" contentMode="scaleToFill" id="RGj-b4-vyk"> <view key="view" contentMode="scaleToFill" id="RGj-b4-vyk">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="1000"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" bounces="NO" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="ZzT-CM-q0s"> <tableView clipsSubviews="YES" contentMode="scaleToFill" bounces="NO" keyboardDismissMode="onDrag" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="ZzT-CM-q0s">
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/> <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
<prototypes> <prototypes>
...@@ -5572,14 +5568,15 @@ ...@@ -5572,14 +5568,15 @@
<outlet property="titleLabel" destination="625-d4-Prf" id="8N7-CH-C4j"/> <outlet property="titleLabel" destination="625-d4-Prf" id="8N7-CH-C4j"/>
</connections> </connections>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="buttonCell" rowHeight="90" id="vJX-hl-NQO" customClass="OnlinePaymentButtonCell" customModule="telecom" customModuleProvider="target"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="buttonCell" rowHeight="66" id="vJX-hl-NQO" customClass="OnlinePaymentButtonCell" customModule="telecom" customModuleProvider="target">
<rect key="frame" x="0.0" y="562" width="375" height="90"/> <rect key="frame" x="0.0" y="562" width="375" height="66"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vJX-hl-NQO" id="SRA-lI-sjQ"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="vJX-hl-NQO" id="SRA-lI-sjQ">
<frame key="frameInset" width="375" height="90"/> <frame key="frameInset" width="375" height="66"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="phS-30-t8f" customClass="UIButtonRoundedBlue" customModule="telecom" customModuleProvider="target"> <button opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="phS-30-t8f" customClass="UIButtonRoundedBlue" customModule="telecom" customModuleProvider="target">
<frame key="frameInset" minX="8" minY="8" width="359" height="48"/>
<color key="backgroundColor" red="0.095081739127635956" green="0.37402468919754028" blue="0.67706954479217529" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.095081739127635956" green="0.37402468919754028" blue="0.67706954479217529" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="48" id="XpL-Cv-Dhy"/> <constraint firstAttribute="height" constant="48" id="XpL-Cv-Dhy"/>
...@@ -5594,12 +5591,11 @@ ...@@ -5594,12 +5591,11 @@
</button> </button>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstAttribute="trailingMargin" secondItem="phS-30-t8f" secondAttribute="trailing" constant="12" id="4cC-CG-gEB"/> <constraint firstItem="phS-30-t8f" firstAttribute="top" secondItem="SRA-lI-sjQ" secondAttribute="top" constant="16" id="4NX-6b-gBm"/>
<constraint firstAttribute="bottomMargin" relation="greaterThanOrEqual" secondItem="phS-30-t8f" secondAttribute="bottom" constant="7" id="9Ue-3G-LfU"/> <constraint firstAttribute="trailing" secondItem="phS-30-t8f" secondAttribute="trailing" constant="16" id="X2i-D4-LRL"/>
<constraint firstAttribute="leadingMargin" secondItem="phS-30-t8f" secondAttribute="leading" constant="-11" id="BZd-kT-aZI"/> <constraint firstItem="phS-30-t8f" firstAttribute="leading" secondItem="SRA-lI-sjQ" secondAttribute="leading" constant="16" id="gW9-hs-gpG"/>
<constraint firstItem="phS-30-t8f" firstAttribute="leading" secondItem="SRA-lI-sjQ" secondAttribute="leadingMargin" constant="11" id="Lk1-Di-8od"/>
<constraint firstItem="phS-30-t8f" firstAttribute="top" secondItem="SRA-lI-sjQ" secondAttribute="topMargin" constant="7" id="N3a-x9-LqY"/>
<constraint firstItem="phS-30-t8f" firstAttribute="centerY" secondItem="SRA-lI-sjQ" secondAttribute="centerY" id="rFg-hG-0Nc"/> <constraint firstItem="phS-30-t8f" firstAttribute="centerY" secondItem="SRA-lI-sjQ" secondAttribute="centerY" id="rFg-hG-0Nc"/>
<constraint firstAttribute="bottom" secondItem="phS-30-t8f" secondAttribute="bottom" constant="16" id="x6o-V9-i7h"/>
</constraints> </constraints>
<variation key="default"> <variation key="default">
<mask key="constraints"> <mask key="constraints">
...@@ -5613,10 +5609,6 @@ ...@@ -5613,10 +5609,6 @@
</connections> </connections>
</tableViewCell> </tableViewCell>
</prototypes> </prototypes>
<connections>
<outlet property="dataSource" destination="Mk2-z4-0Kv" id="drz-CZ-XQf"/>
<outlet property="delegate" destination="Mk2-z4-0Kv" id="r5w-8H-HWM"/>
</connections>
</tableView> </tableView>
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
...@@ -5627,14 +5619,16 @@ ...@@ -5627,14 +5619,16 @@
<constraint firstAttribute="trailing" secondItem="ZzT-CM-q0s" secondAttribute="trailing" id="wkn-Jx-q23"/> <constraint firstAttribute="trailing" secondItem="ZzT-CM-q0s" secondAttribute="trailing" id="wkn-Jx-q23"/>
</constraints> </constraints>
</view> </view>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="375" height="1000"/>
<connections> <connections>
<outlet property="tableView" destination="ZzT-CM-q0s" id="48P-ma-GqU"/> <outlet property="tableView" destination="ZzT-CM-q0s" id="fXE-1T-Cv9"/>
<segue destination="6GO-eQ-XmS" kind="show" identifier="payment_form" id="koG-5n-Fpb"/> <segue destination="6GO-eQ-XmS" kind="show" identifier="payment_form" id="koG-5n-Fpb"/>
</connections> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="gCf-qO-oCs" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="gCf-qO-oCs" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="-4204" y="-6917"/> <point key="canvasLocation" x="-4204" y="-6917.5412293853078"/>
</scene> </scene>
<!--Online Payment Form View Controller--> <!--Online Payment Form View Controller-->
<scene sceneID="DVA-v8-mDv"> <scene sceneID="DVA-v8-mDv">
...@@ -5645,7 +5639,7 @@ ...@@ -5645,7 +5639,7 @@
<viewControllerLayoutGuide type="bottom" id="5FN-jo-Bxq"/> <viewControllerLayoutGuide type="bottom" id="5FN-jo-Bxq"/>
</layoutGuides> </layoutGuides>
<view key="view" contentMode="scaleToFill" id="9Vc-M5-sRP"> <view key="view" contentMode="scaleToFill" id="9Vc-M5-sRP">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="1000"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WFf-dl-BPt"> <webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WFf-dl-BPt">
...@@ -11195,10 +11189,10 @@ ...@@ -11195,10 +11189,10 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cDB-uH-L8k"> <view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cDB-uH-L8k">
<frame key="frameInset" minY="20" width="414" height="575"/> <frame key="frameInset" minY="20" width="374" height="575"/>
<subviews> <subviews>
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pmu-CW-ZEs"> <view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pmu-CW-ZEs">
<frame key="frameInset" width="414" height="575"/> <frame key="frameInset" width="374" height="575"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view> </view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="ecy-Wc-Hfz"> <tableView clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="ecy-Wc-Hfz">
...@@ -11337,6 +11331,7 @@ ...@@ -11337,6 +11331,7 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstItem="pmu-CW-ZEs" firstAttribute="top" secondItem="cDB-uH-L8k" secondAttribute="top" id="6op-Rr-vA9"/> <constraint firstItem="pmu-CW-ZEs" firstAttribute="top" secondItem="cDB-uH-L8k" secondAttribute="top" id="6op-Rr-vA9"/>
<constraint firstItem="pmu-CW-ZEs" firstAttribute="width" secondItem="cDB-uH-L8k" secondAttribute="width" id="ALv-K6-7rE"/>
<constraint firstAttribute="bottom" secondItem="ecy-Wc-Hfz" secondAttribute="bottom" id="Gyk-uS-0Sk"/> <constraint firstAttribute="bottom" secondItem="ecy-Wc-Hfz" secondAttribute="bottom" id="Gyk-uS-0Sk"/>
<constraint firstAttribute="trailing" secondItem="pmu-CW-ZEs" secondAttribute="trailing" id="Iv2-07-uZW"/> <constraint firstAttribute="trailing" secondItem="pmu-CW-ZEs" secondAttribute="trailing" id="Iv2-07-uZW"/>
<constraint firstItem="ecy-Wc-Hfz" firstAttribute="leading" secondItem="cDB-uH-L8k" secondAttribute="leading" id="Wg7-Jg-DoO"/> <constraint firstItem="ecy-Wc-Hfz" firstAttribute="leading" secondItem="cDB-uH-L8k" secondAttribute="leading" id="Wg7-Jg-DoO"/>
...@@ -11389,6 +11384,7 @@ ...@@ -11389,6 +11384,7 @@
<constraint firstItem="cDB-uH-L8k" firstAttribute="leading" secondItem="aNv-Xu-rfm" secondAttribute="leading" id="4ri-kd-Dba"/> <constraint firstItem="cDB-uH-L8k" firstAttribute="leading" secondItem="aNv-Xu-rfm" secondAttribute="leading" id="4ri-kd-Dba"/>
<constraint firstItem="ODV-xS-2kt" firstAttribute="top" secondItem="D1e-2d-VXz" secondAttribute="bottom" id="CBo-we-4WQ"/> <constraint firstItem="ODV-xS-2kt" firstAttribute="top" secondItem="D1e-2d-VXz" secondAttribute="bottom" id="CBo-we-4WQ"/>
<constraint firstItem="cDB-uH-L8k" firstAttribute="top" secondItem="DmU-m0-6bM" secondAttribute="bottom" id="Jdb-D0-mJJ"/> <constraint firstItem="cDB-uH-L8k" firstAttribute="top" secondItem="DmU-m0-6bM" secondAttribute="bottom" id="Jdb-D0-mJJ"/>
<constraint firstItem="cDB-uH-L8k" firstAttribute="width" secondItem="aNv-Xu-rfm" secondAttribute="width" id="Lu3-1T-2NO"/>
<constraint firstAttribute="trailing" secondItem="cDB-uH-L8k" secondAttribute="trailing" id="PUc-Ul-O5R"/> <constraint firstAttribute="trailing" secondItem="cDB-uH-L8k" secondAttribute="trailing" id="PUc-Ul-O5R"/>
<constraint firstItem="D1e-2d-VXz" firstAttribute="top" secondItem="cDB-uH-L8k" secondAttribute="bottom" id="tGv-Dv-Df9"/> <constraint firstItem="D1e-2d-VXz" firstAttribute="top" secondItem="cDB-uH-L8k" secondAttribute="bottom" id="tGv-Dv-Df9"/>
<constraint firstAttribute="trailing" secondItem="D1e-2d-VXz" secondAttribute="trailing" id="uE6-nH-q5e"/> <constraint firstAttribute="trailing" secondItem="D1e-2d-VXz" secondAttribute="trailing" id="uE6-nH-q5e"/>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>61</string> <string>65</string>
<key>Fabric</key> <key>Fabric</key>
<dict> <dict>
<key>APIKey</key> <key>APIKey</key>
......
...@@ -9,12 +9,24 @@ ...@@ -9,12 +9,24 @@
import Foundation import Foundation
func containsLetters(checkString: String) -> Bool { func containsLetters(checkString: String) -> Bool {
let characterSet:NSCharacterSet = NSCharacterSet(charactersInString: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ") // let characterSet:NSCharacterSet = NSCharacterSet(charactersInString: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ")
let nsStringed = NSString(string: checkString) // let nsStringed = NSString(string: checkString)
if (nsStringed.rangeOfCharacterFromSet(characterSet.invertedSet).location == NSNotFound){ // if (nsStringed.rangeOfCharacterFromSet(characterSet.invertedSet).location == NSNotFound){
return true // return true
} // }
return false // return false
let letters = NSCharacterSet.letterCharacterSet()
let range = checkString.rangeOfCharacterFromSet(letters)
// range will be nil if no letters is found
if range != nil {
return true
}
else {
return false
}
} }
func containsCharacter(checkString: String, containingCharacters: String) -> Bool { func containsCharacter(checkString: String, containingCharacters: String) -> Bool {
......
...@@ -483,7 +483,6 @@ class LKSettingsViewController: ViewControllerWithCustomTitle, UITableViewDelega ...@@ -483,7 +483,6 @@ class LKSettingsViewController: ViewControllerWithCustomTitle, UITableViewDelega
func changeAbonentSettings(){ func changeAbonentSettings(){
fillVarsFromFields() fillVarsFromFields()
PKNotification.loading(true)
let abSet = AbonentSettingsRequest(abonentSettings: self.abonentSettings!, let abSet = AbonentSettingsRequest(abonentSettings: self.abonentSettings!,
email: email, email: email,
...@@ -494,7 +493,16 @@ class LKSettingsViewController: ViewControllerWithCustomTitle, UITableViewDelega ...@@ -494,7 +493,16 @@ class LKSettingsViewController: ViewControllerWithCustomTitle, UITableViewDelega
mobilePhone: Int64(mobilePhone), mobilePhone: Int64(mobilePhone),
oldPassword: oldPassword, oldPassword: oldPassword,
newPassword: newPassword) newPassword: newPassword)
guard abSet.validateFields() else { AlertViewUtil.showAlert(abSet.validationMessage); return } print (abSet)
guard abSet.validateFields()
else {
AlertViewUtil.showAlert(abSet.validationMessage);
return
}
PKNotification.loading(true)
Facade.sharedInstance().setAbonentSettings(abSet.json, Facade.sharedInstance().setAbonentSettings(abSet.json,
onError: { (error) -> Void in onError: { (error) -> Void in
PKNotification.loading(false) PKNotification.loading(false)
...@@ -629,13 +637,18 @@ extension LKSettingsViewController { ...@@ -629,13 +637,18 @@ extension LKSettingsViewController {
} }
setDataInCell(cell, forRowAtIndexPath: indexPath) setDataInCell(cell, forRowAtIndexPath: indexPath)
if ( indexPath.row == 3 ) { // if ( indexPath.row == 3 && indexPath.section == 0 ) {
if let cell = cell as? SettingTextFieldTableViewCell { // if let cell = cell as? SettingTextFieldTableViewCell {
cell.getTextField().addTarget(self, action: #selector(textFieldDidChange(_:)), forControlEvents: UIControlEvents.EditingChanged) // cell.getTextField().addTarget(self, action: #selector(textFieldDidChange(_:)), forControlEvents: UIControlEvents.EditingChanged)
cell.getTextField().keyboardType = .NumberPad // //cell.getTextField().keyboardType = .NumberPad
} // }
//
} // }
// if ( indexPath.row == 5 ) {
// if let cell = cell as? SettingTextFieldTableViewCell {
// cell.getTextField().addTarget(self, action: #selector(passwordDidChange(_:)), forControlEvents: UIControlEvents.EditingChanged)
// }
// }
return cell return cell
} }
...@@ -652,9 +665,14 @@ extension LKSettingsViewController { ...@@ -652,9 +665,14 @@ extension LKSettingsViewController {
if !settingsArr.isEmpty { if !settingsArr.isEmpty {
cell.setTitle(field.text) cell.setTitle(field.text)
cell.setPlaceholder(field.placeholder) cell.setPlaceholder(field.placeholder)
if( indexPath.row == 3 ) { if ( indexPath.row == 3 ) {
print(field.text)
cell.setMyTextField(getFormattedPhone(settingsArr[indexPath.section][indexPath.row] as! String)) cell.setMyTextField(getFormattedPhone(settingsArr[indexPath.section][indexPath.row] as! String))
cell.getTextField().keyboardType = .NumberPad cell.getTextField().keyboardType = .NumberPad
//cell.getTextField().addTarget(self, action: #selector(textFieldDidChange(_:)), forControlEvents: UIControlEvents.ValueChanged)
//cell.getTextField().addTarget(self, action: #selector(textFieldDidChange(_:)), forControlEvents: UIControlEvents.EditingChanged)
} else { } else {
cell.setMyTextField(settingsArr[indexPath.section][indexPath.row] as! String) cell.setMyTextField(settingsArr[indexPath.section][indexPath.row] as! String)
} }
...@@ -710,9 +728,19 @@ extension LKSettingsViewController { ...@@ -710,9 +728,19 @@ extension LKSettingsViewController {
} }
func textFieldDidChange(textField: UITextField) { // func textFieldDidChange(textField: UITextField) {
let phone = textField.text! as String // //if ( textField.tag == 101 ) {
textField.text = getFormattedPhone(phone) // let phone = textField.text! as String
// print("phone: " + phone)
// textField.text = getFormattedPhone(phone)
// //}
//
// print("\(textField.tag): " + textField.text!)
// }
func passwordDidChange(textField: UITextField) {
let str = textField.text! as String
print(str)
} }
private func cellIdentifierForIndexPath(indexPath: NSIndexPath) -> String { private func cellIdentifierForIndexPath(indexPath: NSIndexPath) -> String {
...@@ -725,6 +753,16 @@ extension LKSettingsViewController { ...@@ -725,6 +753,16 @@ extension LKSettingsViewController {
return _textCellIdentifier return _textCellIdentifier
} }
} }
func setParam(fieldTitle: String, newText: UITextField) {
if ( fieldTitle == "settings.mobile_phone" ) {
newText.text = getFormattedPhone(newText.text!)
params[fieldTitle] = getPhoneDigits(newText.text!)
} else {
params[fieldTitle] = newText.text!
}
}
} }
extension LKSettingsViewController { extension LKSettingsViewController {
......
...@@ -37,7 +37,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -37,7 +37,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
} }
private func registerObservers() { private func registerObservers() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(LoginViewController.updateUserInfoSuccess(_:)), NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(LoginViewController.updateUserInfoSuccess(_:)),
name: Facade.AbonentInfoNotificationNames.Success, object: nil) name: Facade.AbonentInfoNotificationNames.Success, object: nil)
...@@ -91,9 +91,9 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -91,9 +91,9 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
let showPasswordGesture = UITapGestureRecognizer(target: self, action: #selector(LoginViewController.showPasswordEvent(_:))) let showPasswordGesture = UITapGestureRecognizer(target: self, action: #selector(LoginViewController.showPasswordEvent(_:)))
showPasswordIcon.userInteractionEnabled = true showPasswordIcon.userInteractionEnabled = true
showPasswordIcon.addGestureRecognizer(showPasswordGesture) showPasswordIcon.addGestureRecognizer(showPasswordGesture)
// NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(applicationWillResignActive), name: UIApplicationWillResignActiveNotification, object: nil)
// NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(applicationWillResignActive), name: UIApplicationWillResignActiveNotification, object: nil)
} }
func showPasswordEvent(tapGestureRecognizer: UITapGestureRecognizer) { func showPasswordEvent(tapGestureRecognizer: UITapGestureRecognizer) {
...@@ -109,23 +109,23 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -109,23 +109,23 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
} }
func keyboardWillShow(notification: NSNotification) { func keyboardWillShow(notification: NSNotification) {
// if (keyboardShowed) { // if (keyboardShowed) {
// return // return
// } // }
// if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() { // if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
// self.view.frame.origin.y -= (keyboardSize.height / 2) // self.view.frame.origin.y -= (keyboardSize.height / 2)
// } // }
// keyboardShowed = true // keyboardShowed = true
} }
func keyboardWillHide(notification: NSNotification) { func keyboardWillHide(notification: NSNotification) {
// if (!keyboardShowed) { // if (!keyboardShowed) {
// return // return
// } // }
// if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() { // if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
// self.view.frame.origin.y += (keyboardSize.height / 2) // self.view.frame.origin.y += (keyboardSize.height / 2)
// } // }
// keyboardShowed = false // keyboardShowed = false
} }
override func viewDidAppear(animated: Bool) { override func viewDidAppear(animated: Bool) {
...@@ -166,8 +166,8 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -166,8 +166,8 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
fillFieldsWithDefaultValues() fillFieldsWithDefaultValues()
self.loginTryCount = 0 self.loginTryCount = 0
_loginTextField.text = "7172682610" // ntcnjdsq 7278177224 _loginTextField.text = ""//"7172682610" // ntcnjdsq 7278177224
_passwordTextField.text = "NewPassword1" _passwordTextField.text = ""//"NewPassword1"
let loginFieldValue = _loginTextField.text let loginFieldValue = _loginTextField.text
if containsLetters(_loginTextField.text!) { if containsLetters(_loginTextField.text!) {
...@@ -206,7 +206,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -206,7 +206,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
PKNotification.loading(false) PKNotification.loading(false)
}) })
} }
func generateRecoverAlert(recoverType: String) { func generateRecoverAlert(recoverType: String) {
...@@ -260,7 +260,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -260,7 +260,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
textField.text = "+7 " textField.text = "+7 "
textField.keyboardType = UIKeyboardType.NumberPad textField.keyboardType = UIKeyboardType.NumberPad
} }
alertVC.addTextField(textField) alertVC.addTextField(textField)
alertVC.addButtonHandlers({ (button) -> Void in alertVC.addButtonHandlers({ (button) -> Void in
}, rightButtonHandler: { (button) -> Void in }, rightButtonHandler: { (button) -> Void in
...@@ -364,19 +364,27 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -364,19 +364,27 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
func processingLoggedInError(error : NSError) { func processingLoggedInError(error : NSError) {
dispatch_async(dispatch_get_main_queue()) { dispatch_async(dispatch_get_main_queue()) {
if self.loginTryCount < 2 { // if self.loginTryCount < 2 {
self.loginTryCount += 1 // self.loginTryCount += 1
self.loginRequest(true) // self.loginRequest(true)
} else { // } else {
self.loginTryCount = 0 self.loginTryCount = 0
self.processRequest(false) self.processRequest(false)
AlertViewUtil.showErrorAlert(error.localizedDescription, vc: self) AlertViewUtil.showErrorAlert(error.localizedDescription, vc: self)
} // }
} }
} }
func sendRequestLogin(userName : String, password : String, loginType : Int, onSuccess: () -> Void, onError: (NSError) -> Void) { func sendRequestLogin(userName : String, password : String, loginType : Int, onSuccess: () -> Void, onError: (NSError) -> Void) {
_facade.login(userName, password: password, loginType: Facade.LoginType(rawValue: loginType)!, onSuccess: { () -> Void in // _facade.login(userName, password: password, loginType: Facade.LoginType(rawValue: loginType)!, onSuccess: { () -> Void in
// onSuccess()
// }, onError: { (error) -> Void in
// onError(error)
//
// }, onFinish: {
// })
_facade.loginIdPort(userName, password: password, loginType: Facade.LoginType(rawValue: loginType)!, onSuccess: { () -> Void in
onSuccess() onSuccess()
}, onError: { (error) -> Void in }, onError: { (error) -> Void in
onError(error) onError(error)
...@@ -384,6 +392,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -384,6 +392,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
}, onFinish: { }, onFinish: {
}) })
} }
override func textFieldDidEndEditing(textField: UITextField) { override func textFieldDidEndEditing(textField: UITextField) {
...@@ -476,27 +485,27 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -476,27 +485,27 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
@IBAction func webView_touchUpInside(sender: UIButton) { @IBAction func webView_touchUpInside(sender: UIButton) {
} }
@IBAction func testLogin_touchUpInside(sender: UIButton) { // @IBAction func testLogin_touchUpInside(sender: UIButton) {
//
// 7278177224 // // 7278177224
//
_facade.login("7278177224", password: "Fvbh1988", loginType: Facade.LoginType.PhoneNumber, onSuccess: { () -> Void in // _facade.login("7278177224", password: "Fvbh1988", loginType: Facade.LoginType.PhoneNumber, onSuccess: { () -> Void in
if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone { // if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone {
self.performSegueWithIdentifier("loggedIn", sender: nil) // self.performSegueWithIdentifier("loggedIn", sender: nil)
} else if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad { // } else if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad {
AbonentInfoManager.sharedInstance.updateUserInfo() // AbonentInfoManager.sharedInstance.updateUserInfo()
self.dismissViewControllerAnimated(true, completion: nil) // self.dismissViewControllerAnimated(true, completion: nil)
} // }
self.processRequest(false) // self.processRequest(false)
}, onError: { (error) -> Void in // }, onError: { (error) -> Void in
dispatch_async(dispatch_get_main_queue()) { // dispatch_async(dispatch_get_main_queue()) {
self.processRequest(false) // self.processRequest(false)
AlertViewUtil.showErrorAlert(error.localizedDescription, vc: self) // AlertViewUtil.showErrorAlert(error.localizedDescription, vc: self)
} // }
}, onFinish: { // }, onFinish: {
// self.processRequest(false) // // self.processRequest(false)
}) // })
} // }
@IBAction func sendLogs_touchUpInside(sender: UIButton) { @IBAction func sendLogs_touchUpInside(sender: UIButton) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
...@@ -540,7 +549,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -540,7 +549,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
customAlertVC.addTextField(textField) customAlertVC.addTextField(textField)
} }
// KeyboardUtil.changeKeyboardType(UIKeyboardType.NumberPad, textField: alertVC.textFields[1]) // KeyboardUtil.changeKeyboardType(UIKeyboardType.NumberPad, textField: alertVC.textFields[1])
self.cityButton = UIButton(frame: CGRect(origin: CGPointZero, size: CGSize.zero)) self.cityButton = UIButton(frame: CGRect(origin: CGPointZero, size: CGSize.zero))
self.cityButton.setTitle(self.selectedRegion?.name ?? "", forState: .Normal) self.cityButton.setTitle(self.selectedRegion?.name ?? "", forState: .Normal)
...@@ -558,7 +567,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -558,7 +567,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
let guidField = alertVC.textFields[0].text let guidField = alertVC.textFields[0].text
let guid = self.selectedRegion?.guid_server_id! let guid = self.selectedRegion?.guid_server_id!
let data = "\(guid!)-\(guidField!)" let data = "\(guid!)-\(guidField!)"
if guidField == "" || self.selectedRegion == nil { if guidField == "" || self.selectedRegion == nil {
AlertViewUtil.showIncorrectAlert() AlertViewUtil.showIncorrectAlert()
} else { } else {
...@@ -595,5 +604,5 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning ...@@ -595,5 +604,5 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
dynamic private func applicationWillResignActive() { dynamic private func applicationWillResignActive() {
self.view.endEditing(true) self.view.endEditing(true)
} }
} }
...@@ -20,7 +20,7 @@ class MainKnowedgeViewController: UIViewController { ...@@ -20,7 +20,7 @@ class MainKnowedgeViewController: UIViewController {
self.tableview.estimatedRowHeight = 44.0; self.tableview.estimatedRowHeight = 44.0;
self.tableview.rowHeight = UITableViewAutomaticDimension; self.tableview.rowHeight = UITableViewAutomaticDimension;
self.tableview.separatorStyle = .None //self.tableview.separatorStyle = .None
Facade.sharedInstance().getCategories({ (knowedgeList: [KnowedgeModel]) in Facade.sharedInstance().getCategories({ (knowedgeList: [KnowedgeModel]) in
self.knowedgeList = knowedgeList self.knowedgeList = knowedgeList
...@@ -41,8 +41,10 @@ class MainKnowedgeViewController: UIViewController { ...@@ -41,8 +41,10 @@ class MainKnowedgeViewController: UIViewController {
cell.label.text = knowedgeList[indexPath.row].name cell.label.text = knowedgeList[indexPath.row].name
if knowedgeList[indexPath.row].type == "category" { if knowedgeList[indexPath.row].type == "category" {
cell.backgroundColor = UIColor(red: 236.0 / 255.0, green: 236.0 / 255.0, blue: 236.0 / 255.0, alpha: 1.0) cell.backgroundColor = UIColor(red: 236.0 / 255.0, green: 236.0 / 255.0, blue: 236.0 / 255.0, alpha: 1.0)
cell.accessoryType = UITableViewCellAccessoryType.None
} else { } else {
cell.backgroundColor = UIColor.whiteColor() cell.backgroundColor = UIColor.whiteColor()
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
} }
return cell return cell
} }
......
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
import Foundation import Foundation
import UIKit import UIKit
class OnlinePaymentViewController: KeyboardedViewController, UITableViewDataSource, UITableViewDelegate { class OnlinePaymentViewController: UIViewController, UITextViewDelegate, UITableViewDataSource, UITableViewDelegate {
private static let titleCellIdentifier = "titleCell" private static let titleCellIdentifier = "titleCell"
private static let fieldCellIdentifier = "fieldCell" private static let fieldCellIdentifier = "fieldCell"
...@@ -30,24 +29,83 @@ class OnlinePaymentViewController: KeyboardedViewController, UITableViewDataSour ...@@ -30,24 +29,83 @@ class OnlinePaymentViewController: KeyboardedViewController, UITableViewDataSour
[OnlinePaymentViewController.fieldCellIdentifier, "payment_summ"], [OnlinePaymentViewController.fieldCellIdentifier, "payment_summ"],
[OnlinePaymentViewController.buttonCellIdentifier, "go_payment"]] [OnlinePaymentViewController.buttonCellIdentifier, "go_payment"]]
var keyboardAtOrigin = true
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
localize() localize()
configureBlueNavbar() configureBlueNavbar()
tableView.delegate = self
tableView.dataSource = self
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(OnlinePaymentViewController.keyboardWillShow(_:)), name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(OnlinePaymentViewController.keyboardWillHide(_:)), name: UIKeyboardWillHideNotification, object: nil)
} }
private func registerForKeyboardAction() { var initialInset: UIEdgeInsets?
let notificationCenter = NSNotificationCenter.defaultCenter()
notificationCenter.addObserver(self, selector: #selector(OnlinePaymentViewController.keyboardDidShow(_:)), func keyboardWillShow(notification: NSNotification) {
name:UIKeyboardWillShowNotification, object: nil) if ((notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue()) != nil {
notificationCenter.addObserver(self, selector: #selector(OnlinePaymentViewController.keyboardWillBeHidden(_:)), //self.view.frame.origin.y -= keyboardSize.height
name: UIKeyboardWillHideNotification, object: nil) initialInset = tableView.contentInset
var userInfo = notification.userInfo!
var keyboardFrame:CGRect = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).CGRectValue()
keyboardFrame = self.view.convertRect(keyboardFrame, fromView: nil)
var contentInset:UIEdgeInsets = self.tableView.contentInset
contentInset.bottom = keyboardFrame.size.height + 30
self.tableView.contentInset = contentInset
//get indexpath
let indexpath = NSIndexPath(forRow: 1, inSection: 0)
self.tableView.scrollToRowAtIndexPath(indexpath, atScrollPosition: UITableViewScrollPosition.Top, animated: true)
}
}
func keyboardWillHide(notification: NSNotification) {
if ((notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue()) != nil {
let contentInset:UIEdgeInsets = UIEdgeInsetsZero
// self.tableView.contentInset = contentInset
self.tableView.contentInset = initialInset!
}
} }
// func keyboardWillShow(notification: NSNotification) {
// if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() where keyboardAtOrigin {
// self.view.frame.origin.y -= keyboardSize.height
// keyboardAtOrigin = false
// }
// }
//
// func keyboardWillHide(notification: NSNotification) {
// if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() where !keyboardAtOrigin {
// self.view.frame.origin.y += keyboardSize.height
// keyboardAtOrigin = true
// }
// }
func textFieldShouldReturn(textField: UITextField) -> Bool {
self.view.endEditing(true)
return false
}
// private func registerForKeyboardAction() {
// let notificationCenter = NSNotificationCenter.defaultCenter()
// notificationCenter.addObserver(self, selector: #selector(OnlinePaymentViewController.keyboardDidShow(_:)),
// name:UIKeyboardWillShowNotification, object: nil)
// notificationCenter.addObserver(self, selector: #selector(OnlinePaymentViewController.keyboardWillBeHidden(_:)),
// name: UIKeyboardWillHideNotification, object: nil)
// }
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
tableView.addGestureRecognizer(tapGestureRecognizer) //tableView.addGestureRecognizer(tapGestureRecognizer)
registerForKeyboardAction() //registerForKeyboardAction()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(OnlinePaymentViewController.requestAbonent), NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(OnlinePaymentViewController.requestAbonent),
name: AbonentInfoManager.NotificationNames.Update, object: AbonentInfoManager.sharedInstance) name: AbonentInfoManager.NotificationNames.Update, object: AbonentInfoManager.sharedInstance)
if AbonentInfoManager.sharedInstance.abonentInfo != nil { if AbonentInfoManager.sharedInstance.abonentInfo != nil {
...@@ -62,34 +120,45 @@ class OnlinePaymentViewController: KeyboardedViewController, UITableViewDataSour ...@@ -62,34 +120,45 @@ class OnlinePaymentViewController: KeyboardedViewController, UITableViewDataSour
tableView.reloadData() tableView.reloadData()
} }
// MARK: Keyboard action // // MARK: Keyboard action
func keyboardDidShow(notification: NSNotification) { // func keyboardDidShow(notification: NSNotification) {
let info = notification.userInfo! // let info = notification.userInfo!
var kbRect = info[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue // var kbRect = info[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue
kbRect = view.convertRect(kbRect, fromView: nil) // kbRect = view.convertRect(kbRect, fromView: nil)
//
let contentInsets = UIEdgeInsets(top: 0.0, left: 0.0, // let contentInsets = UIEdgeInsets(top: 0.0, left: 0.0,
bottom: kbRect.height, right: 0.0) // bottom: kbRect.height, right: 0.0)
tableView.contentInset = contentInsets // tableView.contentInset = contentInsets
tableView.scrollIndicatorInsets = contentInsets // tableView.scrollIndicatorInsets = contentInsets
let aRect = view.frame // let aRect = view.frame
if let textField = activeField where !CGRectContainsPoint(aRect, textField.frame.origin) { // if let textField = activeField where !CGRectContainsPoint(aRect, textField.frame.origin) {
tableView.scrollRectToVisible(textField.frame, animated: true) // tableView.scrollRectToVisible(textField.frame, animated: true)
} // }
tapGestureRecognizer.enabled = true // //tapGestureRecognizer.enabled = true
} // }
//
// func keyboardWillBeHidden(notification: NSNotification) {
// let contentInsets = UIEdgeInsetsZero
// tableView.contentInset = contentInsets
// tableView.scrollIndicatorInsets = contentInsets
// resizeScrollViewToFitSubviews()
// //tapGestureRecognizer.enabled = false
// }
func keyboardWillBeHidden(notification: NSNotification) { // func resizeScrollViewToFitSubviews() {
let contentInsets = UIEdgeInsetsZero // // OnlinePaymentViewController.textFields = [String: UITextField]()
tableView.contentInset = contentInsets // tableView.reloadData()
tableView.scrollIndicatorInsets = contentInsets // }
resizeScrollViewToFitSubviews()
tapGestureRecognizer.enabled = false
}
func resizeScrollViewToFitSubviews() { func textViewShouldBeginEditing(textView: UITextView) -> Bool {
// OnlinePaymentViewController.textFields = [String: UITextField]() var pointInTable:CGPoint = textView.superview!.convertPoint(textView.frame.origin, toView: tableView)
tableView.reloadData() var contentOffset:CGPoint = tableView.contentOffset
contentOffset.y = pointInTable.y
if let accessoryView = textView.inputAccessoryView {
contentOffset.y -= accessoryView.frame.size.height
}
tableView.contentOffset = contentOffset
return true
} }
private func configureTableView() { private func configureTableView() {
......
...@@ -340,6 +340,24 @@ extension ClaimListViewController { ...@@ -340,6 +340,24 @@ extension ClaimListViewController {
// UITableViewDataSource // UITableViewDataSource
extension ClaimListViewController { extension ClaimListViewController {
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
var numOfSections: Int = 1
if !claims.isEmpty {
tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine
numOfSections = 1
tableView.backgroundView = nil
}
else {
let noDataLabel: UILabel = UILabel(frame: CGRect(x: 0, y: 0, width: tableView.bounds.size.width, height: tableView.bounds.size.height))
noDataLabel.text = LS("no_data")
noDataLabel.textColor = UIColor.darkGrayColor()
noDataLabel.textAlignment = NSTextAlignment.Center
tableView.backgroundView = noDataLabel
tableView.separatorStyle = UITableViewCellSeparatorStyle.None
}
return numOfSections
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tabIndex == 0 ? cellsRepairBureauItem.count : cellsServiceStatementItem.count return tabIndex == 0 ? cellsRepairBureauItem.count : cellsServiceStatementItem.count
} }
......
...@@ -34,6 +34,9 @@ class UIListBoxViewController : UIViewController, UITableViewDelegate, UITableVi ...@@ -34,6 +34,9 @@ class UIListBoxViewController : UIViewController, UITableViewDelegate, UITableVi
super.viewWillAppear(animated) super.viewWillAppear(animated)
configureBlueNavbar() configureBlueNavbar()
addBackButtonForDefault(.whiteColor()) addBackButtonForDefault(.whiteColor())
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 44.0;
} }
override func viewDidLoad() { override func viewDidLoad() {
......
...@@ -11,16 +11,16 @@ import MapKit ...@@ -11,16 +11,16 @@ import MapKit
protocol WayProtocol { protocol WayProtocol {
func setWayToLocation(location : CLLocation) func setWayToLocation(location : CLLocation)
func getDirections(destination: CLLocationCoordinate2D) func getDirections(destination: CLLocationCoordinate2D)
} }
func _regionForCoordinate(coordinate: CLLocationCoordinate2D) -> MKCoordinateRegion { func _regionForCoordinate(coordinate: CLLocationCoordinate2D) -> MKCoordinateRegion {
return MKCoordinateRegion(center: coordinate, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)) return MKCoordinateRegion(center: coordinate, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
} }
func cityForCoordinate(coordinate: CLLocationCoordinate2D) -> MKCoordinateRegion { func cityForCoordinate(coordinate: CLLocationCoordinate2D) -> MKCoordinateRegion {
return MKCoordinateRegion(center: coordinate, span: MKCoordinateSpan(latitudeDelta: 0.4, longitudeDelta: 0.4)) return MKCoordinateRegion(center: coordinate, span: MKCoordinateSpan(latitudeDelta: 0.4, longitudeDelta: 0.4))
} }
extension UINavigationController { extension UINavigationController {
...@@ -35,39 +35,38 @@ extension UINavigationController { ...@@ -35,39 +35,38 @@ extension UINavigationController {
} }
class WiFiPointsViewController : ViewControllerWithMenu { class WiFiPointsViewController : ViewControllerWithMenu {
var locationManager = CLLocationManager() var locationManager = CLLocationManager()
@IBOutlet private weak var wifiMapView : MKMapView! @IBOutlet private weak var wifiMapView : MKMapView!
@IBOutlet private weak var standardButton: UIButton! @IBOutlet private weak var standardButton: UIButton!
@IBOutlet private weak var hybridButton: UIButton! @IBOutlet private weak var hybridButton: UIButton!
@IBOutlet private weak var satelliteButton: UIButton! @IBOutlet private weak var satelliteButton: UIButton!
var destination: MKMapItem? var destination: MKMapItem?
private let notificationCenter = NSNotificationCenter.defaultCenter() private let notificationCenter = NSNotificationCenter.defaultCenter()
private let facade = Facade.sharedInstance() private let facade = Facade.sharedInstance()
private var wifiPoints: [WiFi]? private var wifiPoints: [WiFi]?
private let annotationViewIdentifier = "wifiAnnotation" private let annotationViewIdentifier = "wifiAnnotation"
// MARK: View life cycle // MARK: View life cycle
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
locationManager.requestAlwaysAuthorization() locationManager.requestAlwaysAuthorization()
configureRightIndicator() configureRightIndicator()
self.navigationItem.title = LocalizedString("menu.wifi-points", description: "Точки Wi-Fi") self.navigationItem.title = LocalizedString("menu.wifi-points", description: "Точки Wi-Fi")
loadingIndicator!.startAnimating() loadingIndicator!.startAnimating()
//configureBlueNavbar() //configureBlueNavbar()
registerForWiFiPoints() registerForWiFiPoints()
facade.getWiFiPointsForCity(CitiesManager.sharedInstance().userCity()) facade.getWiFiPointsForCity(CitiesManager.sharedInstance().userCity())
wifiMapView.mapType = .Standard wifiMapView.mapType = .Standard
} }
override func configureBlueNavbar() { override func configureBlueNavbar() {
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarPosition: UIBarPosition.Any, barMetrics: UIBarMetrics.Default) self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarPosition: UIBarPosition.Any, barMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = UIImage() self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.barTintColor = Color.DashboardBlueColor //self.navigationController?.navigationBar.barTintColor = Color.DashboardBlueColor
self.navigationController?.navigationBar.barStyle = UIBarStyle.Black self.navigationController?.navigationBar.barStyle = UIBarStyle.Black
// self.navigationController?.navigationBar.tintColor = nil
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor() self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
navigationController?.navigationBar.setBottomBorderColor(UIColor.whiteColor(), height: 0) navigationController?.navigationBar.setBottomBorderColor(UIColor.whiteColor(), height: 0)
...@@ -76,206 +75,209 @@ class WiFiPointsViewController : ViewControllerWithMenu { ...@@ -76,206 +75,209 @@ class WiFiPointsViewController : ViewControllerWithMenu {
self.navigationController?.WhiteLabel() self.navigationController?.WhiteLabel()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
configureBlueNavbar()
}
// MARK: Notifications
private func registerForWiFiPoints() {
notificationCenter.addObserver(self, selector: #selector(WiFiPointsViewController.setWiFiPoints(_:)),
name: FacadeWiFiPointsSuccess, object: facade)
}
private func unregisterForWiFiPoints() {
notificationCenter.removeObserver(self, name: FacadeWiFiPointsSuccess, object: facade)
} }
override func viewWillAppear(animated: Bool) { // MARK: Facade observering
super.viewWillAppear(animated)
configureBlueNavbar()
}
// MARK: Notifications
private func registerForWiFiPoints() {
notificationCenter.addObserver(self, selector: #selector(WiFiPointsViewController.setWiFiPoints(_:)),
name: FacadeWiFiPointsSuccess, object: facade)
}
private func unregisterForWiFiPoints() {
notificationCenter.removeObserver(self, name: FacadeWiFiPointsSuccess, object: facade)
}
// MARK: Facade observering
func setWiFiPoints(notification: NSNotification) {
loadingIndicator!.stopAnimating()
showListButton()
unregisterForWiFiPoints() func setWiFiPoints(notification: NSNotification) {
let points = notification.userInfo!["points"] as! [WiFi] loadingIndicator!.stopAnimating()
showListButton()
unregisterForWiFiPoints()
let points = notification.userInfo!["points"] as! [WiFi]
wifiMapView.showAnnotations(points, animated: true)
wifiPoints = points
self.wifiMapView.addAnnotations(points)
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = kCLLocationAccuracyKilometer
locationManager.startUpdatingLocation()
var location = locationManager.location
var coordinate = location?.coordinate
if (coordinate != nil) {
wifiMapView.setCenterCoordinate(coordinate!, animated: true)
wifiMapView.region = MKCoordinateRegionMakeWithDistance(coordinate!, 1000, 1000)
}
}
wifiMapView.showAnnotations(points, animated: true) // MARK: - public actions
wifiPoints = points
self.wifiMapView.addAnnotations(points)
func setCoordinate(coordinate: CLLocationCoordinate2D) {
// TODO: ====
wifiMapView.region = _regionForCoordinate(coordinate)
}
// MARK: - Helper
func showListButton() {
let button = UIButton(frame: CGRect(x: -10, y: 0, width: 32, height: 32))
button.tintColor = UIColor.whiteColor()
button.setImage(UIImage(named: "map_address_icon_hidhlighted" ), forState: .Normal)
// FIXME: cahnge image color
button.setImage(UIImage(named: "map_address_icon"), forState: .Highlighted)
button.addTarget(self, action: #selector(WiFiPointsViewController.showWiFiList(_:)), forControlEvents: .TouchUpInside)
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: button)
}
func showWiFiList(sender: UIButton) {
let vc = storyboard!.instantiateViewControllerWithIdentifier("WiFiTableViewController") as! WiFiTableViewController
vc.wifiPoints = wifiPoints
vc.pvc = self
let nvc = UINavigationController(rootViewController: vc)
presentViewController(nvc, animated: true, completion: nil)
}
locationManager.desiredAccuracy = kCLLocationAccuracyBest // MARK: - Actions
locationManager.distanceFilter = kCLLocationAccuracyKilometer
locationManager.startUpdatingLocation()
var location = locationManager.location
var coordinate = location?.coordinate
if (coordinate != nil) { @IBAction func standardButton_TouchUpInside(sender: UIButton?) {
wifiMapView.setCenterCoordinate(coordinate!, animated: true) self.wifiMapView.mapType = .Standard
wifiMapView.region = MKCoordinateRegionMakeWithDistance(coordinate!, 1000, 1000) selectButton(standardButton)
} }
}
// MARK: - public actions
func setCoordinate(coordinate: CLLocationCoordinate2D) {
// TODO: ====
wifiMapView.region = _regionForCoordinate(coordinate)
}
// MARK: - Helper
func showListButton() {
let button = UIButton(frame: CGRect(x: -10, y: 0, width: 32, height: 32))
button.setImage(UIImage(named: "map_address_icon_highlighted"), forState: .Normal)
// FIXME: cahnge image color
button.setImage(UIImage(named: "map_address_icon"), forState: .Highlighted)
button.addTarget(self, action: #selector(WiFiPointsViewController.showWiFiList(_:)), forControlEvents: .TouchUpInside)
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: button)
}
func showWiFiList(sender: UIButton) {
let vc = storyboard!.instantiateViewControllerWithIdentifier("WiFiTableViewController") as! WiFiTableViewController
vc.wifiPoints = wifiPoints
vc.pvc = self
let nvc = UINavigationController(rootViewController: vc)
presentViewController(nvc, animated: true, completion: nil)
}
// MARK: - Actions
@IBAction func standardButton_TouchUpInside(sender: UIButton?) {
self.wifiMapView.mapType = .Standard
selectButton(standardButton)
}
@IBAction func hybridButton_TouchUpInside(sender: UIButton?) {
self.wifiMapView.mapType = .Hybrid
selectButton(hybridButton)
}
@IBAction func satelliteButton_TouchUpInside(sender: UIButton?) {
self.wifiMapView.mapType = .Satellite
selectButton(satelliteButton)
}
private func selectButton(button: UIButton) {
standardButton.selected = false
hybridButton.selected = false
satelliteButton.selected = false
button.selected = true @IBAction func hybridButton_TouchUpInside(sender: UIButton?) {
} self.wifiMapView.mapType = .Hybrid
selectButton(hybridButton)
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { }
if segue.identifier == "showInfo" {
let dvc = segue.destinationViewController as! MapPointInfoController @IBAction func satelliteButton_TouchUpInside(sender: UIButton?) {
dvc.mapViewController = self self.wifiMapView.mapType = .Satellite
dvc.point = sender as! MKAnnotation selectButton(satelliteButton)
}
private func selectButton(button: UIButton) {
standardButton.selected = false
hybridButton.selected = false
satelliteButton.selected = false
button.selected = true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showInfo" {
let dvc = segue.destinationViewController as! MapPointInfoController
dvc.mapViewController = self
dvc.point = sender as! MKAnnotation
}
} }
}
} }
// MARK: - MKMapViewDelegate // MARK: - MKMapViewDelegate
extension WiFiPointsViewController: MKMapViewDelegate { extension WiFiPointsViewController: MKMapViewDelegate {
func showRoute(response: MKDirectionsResponse) {
for route in response.routes { func showRoute(response: MKDirectionsResponse) {
wifiMapView.addOverlay(route.polyline, for route in response.routes {
level: MKOverlayLevel.AboveRoads)
wifiMapView.addOverlay(route.polyline,
for step in route.steps { level: MKOverlayLevel.AboveRoads)
print(step.instructions)
} for step in route.steps {
print(step.instructions)
}
}
let userLocation = wifiMapView.userLocation
let region = MKCoordinateRegionMakeWithDistance(
userLocation.location!.coordinate, 2000, 2000)
wifiMapView.setRegion(region, animated: true)
} }
let userLocation = wifiMapView.userLocation
let region = MKCoordinateRegionMakeWithDistance(
userLocation.location!.coordinate, 2000, 2000)
wifiMapView.setRegion(region, animated: true) func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
} if annotation.isKindOfClass(MKUserLocation) {
return nil
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { }
if annotation.isKindOfClass(MKUserLocation) { var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier(annotationViewIdentifier)
return nil if annotationView != nil {
} annotationView!.annotation = annotation
var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier(annotationViewIdentifier) } else {
if annotationView != nil { annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: annotationViewIdentifier)
annotationView!.annotation = annotation annotationView!.canShowCallout = true
} else {
annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: annotationViewIdentifier) let button = UIButton(type: .InfoLight) as UIButton
annotationView!.canShowCallout = true button.addTarget(nil, action: nil, forControlEvents: .TouchUpInside)
let button = UIButton(type: .InfoLight) as UIButton annotationView!.rightCalloutAccessoryView = button
button.addTarget(nil, action: nil, forControlEvents: .TouchUpInside) }
annotationView!.rightCalloutAccessoryView = button return annotationView
} }
return annotationView func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
} performSegueWithIdentifier("showInfo", sender: view.annotation)
func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
performSegueWithIdentifier("showInfo", sender: view.annotation)
}
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
if overlay is MKPolyline {
let pr = MKPolylineRenderer(overlay: overlay)
pr.strokeColor = Color.BlueColorForHighlighted
pr.fillColor = Color.BlueColorForHighlighted
pr.lineWidth = 3
return pr
} }
return MKPolylineRenderer(overlay: overlay) func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
}
if overlay is MKPolyline {
let pr = MKPolylineRenderer(overlay: overlay)
pr.strokeColor = Color.BlueColorForHighlighted
pr.fillColor = Color.BlueColorForHighlighted
pr.lineWidth = 3
return pr
}
return MKPolylineRenderer(overlay: overlay)
}
} }
extension WiFiPointsViewController: WayProtocol { extension WiFiPointsViewController: WayProtocol {
func setWayToLocation(location: CLLocation) { func setWayToLocation(location: CLLocation) {
}
func getDirections(location: CLLocationCoordinate2D){
// Coordinates for simplecode - latitude: 49.803455, longitude: 73.085145
let destlocation = CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude)
let mapManager = MapManager()
if let sourceLocation = LocationManager().location?.coordinate {
mapManager.directionsUsingGoogle(from: sourceLocation, to: destlocation) { (route, directionInformation, boundingRegion, error) -> () in
if let error = error { }
print(error)
} else { func getDirections(location: CLLocationCoordinate2D){
if let web = self.wifiMapView { // Coordinates for simplecode - latitude: 49.803455, longitude: 73.085145
dispatch_async(dispatch_get_main_queue()) { let destlocation = CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude)
web.removeOverlays(web.overlays) let mapManager = MapManager()
web.addOverlay(route!) if let sourceLocation = LocationManager().location?.coordinate {
web.setVisibleMapRect(boundingRegion!, animated: true) mapManager.directionsUsingGoogle(from: sourceLocation, to: destlocation) { (route, directionInformation, boundingRegion, error) -> () in
if let error = error {
print(error)
} else {
if let web = self.wifiMapView {
dispatch_async(dispatch_get_main_queue()) {
web.removeOverlays(web.overlays)
web.addOverlay(route!)
web.setVisibleMapRect(boundingRegion!, animated: true)
}
}
}
} }
} } else {
AlertViewUtil.showErrorAlert(LS("error"), message: LS("wifi_points.unavailable_current_location"))
} }
}
} else {
AlertViewUtil.showErrorAlert(LS("error"), message: LS("wifi_points.unavailable_current_location"))
} }
}
} }
extension WiFiPointsViewController { extension WiFiPointsViewController {
override var localizedId: String { override var localizedId: String {
return "wifi_points" return "wifi_points"
} }
} }
...@@ -10,40 +10,42 @@ import Foundation ...@@ -10,40 +10,42 @@ import Foundation
import UIKit import UIKit
class OnlinePaymentFieldCell : UITableViewCell { class OnlinePaymentFieldCell : UITableViewCell {
@IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var textField: UITextField! @IBOutlet weak var textField: UITextField!
var textValue = "" var textValue = ""
var vc: OnlinePaymentViewController! var vc: OnlinePaymentViewController!
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
textField.addTarget(self, action: #selector(OnlinePaymentFieldCell.textChanged(_:)), forControlEvents: UIControlEvents.EditingChanged)
textField.applyUITextFieldStyle() textField.addTarget(self, action: #selector(OnlinePaymentFieldCell.textChanged(_:)), forControlEvents: UIControlEvents.EditingChanged)
} textField.applyUITextFieldStyle()
func textChanged(textField: UITextField) {
vc.params[textValue] = textField.text
}
func fillCell(text: String, vc: OnlinePaymentViewController) {
textValue = text
self.vc = vc
textField.delegate = self.vc
let abonentInfo = AbonentInfoManager.sharedInstance.abonentInfo
switch text {
case "email":
titleLabel.text = LS("online_payment.email")
textField.placeholder = "Email"
textField.text = OnlinePaymentViewController.email != nil ? OnlinePaymentViewController.email! : abonentInfo != nil ? abonentInfo!.email : ""
break
case "payment_summ":
titleLabel.text = LS("online_payment.payment_sum")
textField.placeholder = ""
textField.text = OnlinePaymentViewController.summ != nil ? OnlinePaymentViewController.summ! : abonentInfo != nil ? "\(abonentInfo!.balance == nil ? 0 : lround(ceil(0 - (abonentInfo!.balance!))))" : ""
break
default: break
} }
vc.params[textValue] = textField.text
} func textChanged(textField: UITextField) {
vc.params[textValue] = textField.text
}
func fillCell(text: String, vc: OnlinePaymentViewController) {
textValue = text
self.vc = vc
textField.delegate = self.vc
let abonentInfo = AbonentInfoManager.sharedInstance.abonentInfo
switch text {
case "email":
titleLabel.text = LS("online_payment.email")
textField.placeholder = "Email"
textField.text = OnlinePaymentViewController.email != nil ? OnlinePaymentViewController.email! : abonentInfo != nil ? abonentInfo!.email : ""
break
case "payment_summ":
titleLabel.text = LS("online_payment.payment_sum")
textField.placeholder = ""
textField.text = OnlinePaymentViewController.summ != nil ? OnlinePaymentViewController.summ! : abonentInfo != nil ? "\(abonentInfo!.balance == nil ? 0 : lround(ceil(0 - (abonentInfo!.balance!))))" : ""
break
default: break
}
vc.params[textValue] = textField.text
}
} }
...@@ -88,7 +88,7 @@ class SettingTextFieldTableViewCell: UITableViewCell { ...@@ -88,7 +88,7 @@ class SettingTextFieldTableViewCell: UITableViewCell {
func textChanged(textField: UITextField){ func textChanged(textField: UITextField){
// delegate.onChangeText(textField.text!, cell: self) // delegate.onChangeText(textField.text!, cell: self)
if textField.text!.characters.count <= textField.maxLength { if textField.text!.characters.count <= textField.maxLength {
vc.params[fieldTitle] = getPhoneDigits(textField.text!) vc.setParam(fieldTitle, newText: textField)
self.vc.isChangedSettings() self.vc.isChangedSettings()
} }
......
...@@ -24,12 +24,19 @@ class FeedCollectionViewCell: UICollectionViewCell { ...@@ -24,12 +24,19 @@ class FeedCollectionViewCell: UICollectionViewCell {
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
let tap = UITapGestureRecognizer(target: self, action: #selector(FeedCollectionViewCell.tapFunction)) // let tap = UITapGestureRecognizer(target: self, action: #selector(FeedCollectionViewCell.tapFunction))
payButton.addGestureRecognizer(tap) // payButton.addGestureRecognizer(tap)
//
// let tap2 = UITapGestureRecognizer(target: self, action: #selector(FeedCollectionViewCell.tapFunction))
// image.userInteractionEnabled = true
// image.addGestureRecognizer(tap2)
} }
func tapFunction(sender:UITapGestureRecognizer) { func tapFunction(sender:UITapGestureRecognizer) {
openService()
}
func openService() {
let serviceItem = ServiceItem() let serviceItem = ServiceItem()
serviceItem.id = self.id serviceItem.id = self.id
serviceItem.type = "landing" serviceItem.type = "landing"
...@@ -38,13 +45,13 @@ class FeedCollectionViewCell: UICollectionViewCell { ...@@ -38,13 +45,13 @@ class FeedCollectionViewCell: UICollectionViewCell {
let storyboard = UIStoryboard(name: "Main", bundle: nil) let storyboard = UIStoryboard(name: "Main", bundle: nil)
////this is old version ////this is old version
// let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceItemScrollViewController") as! ServiceItemScrollViewController // let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceItemScrollViewController") as! ServiceItemScrollViewController
// destination.serviceItemForLoading = serviceItem // destination.serviceItemForLoading = serviceItem
// navController!.pushViewController(destination, animated: true) // navController!.pushViewController(destination, animated: true)
// let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceCalculatorViewController") as! ServiceCalculatorViewController // let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceCalculatorViewController") as! ServiceCalculatorViewController
// destination.serviceItem = serviceItem // destination.serviceItem = serviceItem
// navController!.pushViewController(destination, animated: true) // navController!.pushViewController(destination, animated: true)
let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceVIPTableViewController") as! ServiceVIPTableViewController let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceVIPTableViewController") as! ServiceVIPTableViewController
destination.serviceItem = serviceItem destination.serviceItem = serviceItem
......
...@@ -32,6 +32,11 @@ class FeedPackagesCell: UITableViewCell, UICollectionViewDataSource, UICollectio ...@@ -32,6 +32,11 @@ class FeedPackagesCell: UITableViewCell, UICollectionViewDataSource, UICollectio
} }
} }
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let cell = collectionView.cellForItemAtIndexPath(indexPath) as! FeedCollectionViewCell
cell.openService()
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return feed.count return feed.count
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment