Commit e855d42c by Olzhas Aldabergenov

login vip_gamer fixed. Settings password fixed

parent bb24a1a8
......@@ -89,6 +89,7 @@
3E2C3E9B1EFCB17E00E553CD /* Validator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E2C3E9A1EFCB17E00E553CD /* Validator.swift */; };
3E2E1E821F84DB0100DC0FE5 /* LKSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E2E1E811F84DB0100DC0FE5 /* LKSettingsViewController.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 */; };
3E5CC7AE1FA84F9F00B55DF0 /* DateUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E5CC7AD1FA84F9F00B55DF0 /* DateUtil.swift */; };
3E6969B31FA2097200032D95 /* ServiceDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6969B21FA2097200032D95 /* ServiceDetailsViewController.swift */; };
......@@ -644,6 +645,7 @@
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>"; };
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>"; };
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>"; };
......@@ -1115,6 +1117,7 @@
988728DE1DDCD9E900CEEBAA /* Facade+Siebel.swift */,
3EB108501F15E321000EAE88 /* Facade+Bot.swift */,
3EAFC4831F6F804D00BB07AD /* Facade+Knowedge.swift */,
3E3BCC9B1FCEB692008613E2 /* Facade+NewLogin.swift */,
);
path = Facade;
sourceTree = "<group>";
......@@ -2920,6 +2923,7 @@
B212590DBF21D2F2C3CDF95C /* SwiftyJSON.swift in Sources */,
986917581DE3816200FC712D /* FullDamageModalTableCell.swift in Sources */,
98A335611CFB172F00F1A76C /* GetProvidersRequest.swift in Sources */,
3E3BCC9C1FCEB692008613E2 /* Facade+NewLogin.swift in Sources */,
983343FD1C71C6440008D9CA /* BlankDetailViewController.swift in Sources */,
98E3F8701CFA21B700112FB7 /* Download.swift in Sources */,
987457B61CFDFA1100BB32C6 /* OffersSelectListViewController.swift in Sources */,
......
......@@ -29,6 +29,7 @@ extension Facade {
case .Failure(let error):
Router.globalLog.error(error.debugDescription)
onError?(error)
break
case .Success(let json):
Router.globalLog.debug(resp.response!)
Router.globalLog.debug(json)
......@@ -36,6 +37,7 @@ extension Facade {
Facade.accountId = json["account_id"] as? Int
Facade.guid = "\(Facade.serverId!)-\(Facade.accountId!)"
onSuccess?()
break
}
}
}
......
//
// 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")
}
}
......@@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>61</string>
<string>65</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
......
......@@ -9,12 +9,24 @@
import Foundation
func containsLetters(checkString: String) -> Bool {
let characterSet:NSCharacterSet = NSCharacterSet(charactersInString: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ")
let nsStringed = NSString(string: checkString)
if (nsStringed.rangeOfCharacterFromSet(characterSet.invertedSet).location == NSNotFound){
return true
}
return false
// let characterSet:NSCharacterSet = NSCharacterSet(charactersInString: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ")
// let nsStringed = NSString(string: checkString)
// if (nsStringed.rangeOfCharacterFromSet(characterSet.invertedSet).location == NSNotFound){
// return true
// }
// 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 {
......
......@@ -483,7 +483,6 @@ class LKSettingsViewController: ViewControllerWithCustomTitle, UITableViewDelega
func changeAbonentSettings(){
fillVarsFromFields()
PKNotification.loading(true)
let abSet = AbonentSettingsRequest(abonentSettings: self.abonentSettings!,
email: email,
......@@ -494,7 +493,16 @@ class LKSettingsViewController: ViewControllerWithCustomTitle, UITableViewDelega
mobilePhone: Int64(mobilePhone),
oldPassword: oldPassword,
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,
onError: { (error) -> Void in
PKNotification.loading(false)
......@@ -629,13 +637,18 @@ extension LKSettingsViewController {
}
setDataInCell(cell, forRowAtIndexPath: indexPath)
if ( indexPath.row == 3 ) {
if let cell = cell as? SettingTextFieldTableViewCell {
cell.getTextField().addTarget(self, action: #selector(textFieldDidChange(_:)), forControlEvents: UIControlEvents.EditingChanged)
cell.getTextField().keyboardType = .NumberPad
}
}
// if ( indexPath.row == 3 && indexPath.section == 0 ) {
// if let cell = cell as? SettingTextFieldTableViewCell {
// cell.getTextField().addTarget(self, action: #selector(textFieldDidChange(_:)), forControlEvents: UIControlEvents.EditingChanged)
// //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
}
......@@ -652,9 +665,14 @@ extension LKSettingsViewController {
if !settingsArr.isEmpty {
cell.setTitle(field.text)
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.getTextField().keyboardType = .NumberPad
//cell.getTextField().addTarget(self, action: #selector(textFieldDidChange(_:)), forControlEvents: UIControlEvents.ValueChanged)
//cell.getTextField().addTarget(self, action: #selector(textFieldDidChange(_:)), forControlEvents: UIControlEvents.EditingChanged)
} else {
cell.setMyTextField(settingsArr[indexPath.section][indexPath.row] as! String)
}
......@@ -710,9 +728,19 @@ extension LKSettingsViewController {
}
func textFieldDidChange(textField: UITextField) {
let phone = textField.text! as String
textField.text = getFormattedPhone(phone)
// func textFieldDidChange(textField: UITextField) {
// //if ( textField.tag == 101 ) {
// 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 {
......@@ -725,6 +753,16 @@ extension LKSettingsViewController {
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 {
......
......@@ -37,7 +37,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
}
private func registerObservers() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(LoginViewController.updateUserInfoSuccess(_:)),
name: Facade.AbonentInfoNotificationNames.Success, object: nil)
......@@ -91,9 +91,9 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
let showPasswordGesture = UITapGestureRecognizer(target: self, action: #selector(LoginViewController.showPasswordEvent(_:)))
showPasswordIcon.userInteractionEnabled = true
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) {
......@@ -109,23 +109,23 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
}
func keyboardWillShow(notification: NSNotification) {
// if (keyboardShowed) {
// return
// }
// if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
// self.view.frame.origin.y -= (keyboardSize.height / 2)
// }
// keyboardShowed = true
// if (keyboardShowed) {
// return
// }
// if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
// self.view.frame.origin.y -= (keyboardSize.height / 2)
// }
// keyboardShowed = true
}
func keyboardWillHide(notification: NSNotification) {
// if (!keyboardShowed) {
// return
// }
// if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
// self.view.frame.origin.y += (keyboardSize.height / 2)
// }
// keyboardShowed = false
// if (!keyboardShowed) {
// return
// }
// if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
// self.view.frame.origin.y += (keyboardSize.height / 2)
// }
// keyboardShowed = false
}
override func viewDidAppear(animated: Bool) {
......@@ -166,8 +166,8 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
fillFieldsWithDefaultValues()
self.loginTryCount = 0
_loginTextField.text = "7172682610" // ntcnjdsq 7278177224
_passwordTextField.text = "NewPassword1"
_loginTextField.text = ""//"7172682610" // ntcnjdsq 7278177224
_passwordTextField.text = ""//"NewPassword1"
let loginFieldValue = _loginTextField.text
if containsLetters(_loginTextField.text!) {
......@@ -206,7 +206,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
PKNotification.loading(false)
})
}
func generateRecoverAlert(recoverType: String) {
......@@ -260,7 +260,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
textField.text = "+7 "
textField.keyboardType = UIKeyboardType.NumberPad
}
alertVC.addTextField(textField)
alertVC.addButtonHandlers({ (button) -> Void in
}, rightButtonHandler: { (button) -> Void in
......@@ -364,19 +364,27 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
func processingLoggedInError(error : NSError) {
dispatch_async(dispatch_get_main_queue()) {
if self.loginTryCount < 2 {
self.loginTryCount += 1
self.loginRequest(true)
} else {
// if self.loginTryCount < 2 {
// self.loginTryCount += 1
// self.loginRequest(true)
// } else {
self.loginTryCount = 0
self.processRequest(false)
AlertViewUtil.showErrorAlert(error.localizedDescription, vc: self)
}
// }
}
}
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()
}, onError: { (error) -> Void in
onError(error)
......@@ -384,6 +392,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
}, onFinish: {
})
}
override func textFieldDidEndEditing(textField: UITextField) {
......@@ -476,27 +485,27 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
@IBAction func webView_touchUpInside(sender: UIButton) {
}
@IBAction func testLogin_touchUpInside(sender: UIButton) {
// 7278177224
_facade.login("7278177224", password: "Fvbh1988", loginType: Facade.LoginType.PhoneNumber, onSuccess: { () -> Void in
if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone {
self.performSegueWithIdentifier("loggedIn", sender: nil)
} else if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad {
AbonentInfoManager.sharedInstance.updateUserInfo()
self.dismissViewControllerAnimated(true, completion: nil)
}
self.processRequest(false)
}, onError: { (error) -> Void in
dispatch_async(dispatch_get_main_queue()) {
self.processRequest(false)
AlertViewUtil.showErrorAlert(error.localizedDescription, vc: self)
}
}, onFinish: {
// self.processRequest(false)
})
}
// @IBAction func testLogin_touchUpInside(sender: UIButton) {
//
// // 7278177224
//
// _facade.login("7278177224", password: "Fvbh1988", loginType: Facade.LoginType.PhoneNumber, onSuccess: { () -> Void in
// if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone {
// self.performSegueWithIdentifier("loggedIn", sender: nil)
// } else if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad {
// AbonentInfoManager.sharedInstance.updateUserInfo()
// self.dismissViewControllerAnimated(true, completion: nil)
// }
// self.processRequest(false)
// }, onError: { (error) -> Void in
// dispatch_async(dispatch_get_main_queue()) {
// self.processRequest(false)
// AlertViewUtil.showErrorAlert(error.localizedDescription, vc: self)
// }
// }, onFinish: {
// // self.processRequest(false)
// })
// }
@IBAction func sendLogs_touchUpInside(sender: UIButton) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
......@@ -540,7 +549,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
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.setTitle(self.selectedRegion?.name ?? "", forState: .Normal)
......@@ -558,7 +567,7 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
let guidField = alertVC.textFields[0].text
let guid = self.selectedRegion?.guid_server_id!
let data = "\(guid!)-\(guidField!)"
if guidField == "" || self.selectedRegion == nil {
AlertViewUtil.showIncorrectAlert()
} else {
......@@ -595,5 +604,5 @@ class LoginViewController: ScrolledViewController, UIViewControllerTransitioning
dynamic private func applicationWillResignActive() {
self.view.endEditing(true)
}
}
......@@ -20,7 +20,7 @@ class MainKnowedgeViewController: UIViewController {
self.tableview.estimatedRowHeight = 44.0;
self.tableview.rowHeight = UITableViewAutomaticDimension;
self.tableview.separatorStyle = .None
//self.tableview.separatorStyle = .None
Facade.sharedInstance().getCategories({ (knowedgeList: [KnowedgeModel]) in
self.knowedgeList = knowedgeList
......@@ -41,8 +41,10 @@ class MainKnowedgeViewController: UIViewController {
cell.label.text = knowedgeList[indexPath.row].name
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.accessoryType = UITableViewCellAccessoryType.None
} else {
cell.backgroundColor = UIColor.whiteColor()
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
}
return cell
}
......
......@@ -9,8 +9,7 @@
import Foundation
import UIKit
class OnlinePaymentViewController: KeyboardedViewController, UITableViewDataSource, UITableViewDelegate {
class OnlinePaymentViewController: UIViewController, UITextViewDelegate, UITableViewDataSource, UITableViewDelegate {
private static let titleCellIdentifier = "titleCell"
private static let fieldCellIdentifier = "fieldCell"
......@@ -30,24 +29,83 @@ class OnlinePaymentViewController: KeyboardedViewController, UITableViewDataSour
[OnlinePaymentViewController.fieldCellIdentifier, "payment_summ"],
[OnlinePaymentViewController.buttonCellIdentifier, "go_payment"]]
var keyboardAtOrigin = true
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
localize()
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() {
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)
var initialInset: UIEdgeInsets?
func keyboardWillShow(notification: NSNotification) {
if ((notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue()) != nil {
//self.view.frame.origin.y -= keyboardSize.height
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() {
super.viewDidLoad()
tableView.addGestureRecognizer(tapGestureRecognizer)
registerForKeyboardAction()
//tableView.addGestureRecognizer(tapGestureRecognizer)
//registerForKeyboardAction()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(OnlinePaymentViewController.requestAbonent),
name: AbonentInfoManager.NotificationNames.Update, object: AbonentInfoManager.sharedInstance)
if AbonentInfoManager.sharedInstance.abonentInfo != nil {
......@@ -62,34 +120,45 @@ class OnlinePaymentViewController: KeyboardedViewController, UITableViewDataSour
tableView.reloadData()
}
// MARK: Keyboard action
func keyboardDidShow(notification: NSNotification) {
let info = notification.userInfo!
var kbRect = info[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue
kbRect = view.convertRect(kbRect, fromView: nil)
let contentInsets = UIEdgeInsets(top: 0.0, left: 0.0,
bottom: kbRect.height, right: 0.0)
tableView.contentInset = contentInsets
tableView.scrollIndicatorInsets = contentInsets
let aRect = view.frame
if let textField = activeField where !CGRectContainsPoint(aRect, textField.frame.origin) {
tableView.scrollRectToVisible(textField.frame, animated: true)
}
tapGestureRecognizer.enabled = true
}
// // MARK: Keyboard action
// func keyboardDidShow(notification: NSNotification) {
// let info = notification.userInfo!
// var kbRect = info[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue
// kbRect = view.convertRect(kbRect, fromView: nil)
//
// let contentInsets = UIEdgeInsets(top: 0.0, left: 0.0,
// bottom: kbRect.height, right: 0.0)
// tableView.contentInset = contentInsets
// tableView.scrollIndicatorInsets = contentInsets
// let aRect = view.frame
// if let textField = activeField where !CGRectContainsPoint(aRect, textField.frame.origin) {
// tableView.scrollRectToVisible(textField.frame, animated: 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) {
let contentInsets = UIEdgeInsetsZero
tableView.contentInset = contentInsets
tableView.scrollIndicatorInsets = contentInsets
resizeScrollViewToFitSubviews()
tapGestureRecognizer.enabled = false
}
// func resizeScrollViewToFitSubviews() {
// // OnlinePaymentViewController.textFields = [String: UITextField]()
// tableView.reloadData()
// }
func resizeScrollViewToFitSubviews() {
// OnlinePaymentViewController.textFields = [String: UITextField]()
tableView.reloadData()
func textViewShouldBeginEditing(textView: UITextView) -> Bool {
var pointInTable:CGPoint = textView.superview!.convertPoint(textView.frame.origin, toView: tableView)
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() {
......
......@@ -340,6 +340,24 @@ extension ClaimListViewController {
// UITableViewDataSource
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 {
return tabIndex == 0 ? cellsRepairBureauItem.count : cellsServiceStatementItem.count
}
......
......@@ -34,6 +34,9 @@ class UIListBoxViewController : UIViewController, UITableViewDelegate, UITableVi
super.viewWillAppear(animated)
configureBlueNavbar()
addBackButtonForDefault(.whiteColor())
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 44.0;
}
override func viewDidLoad() {
......
......@@ -10,40 +10,42 @@ import Foundation
import UIKit
class OnlinePaymentFieldCell : UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var textField: UITextField!
var textValue = ""
var vc: OnlinePaymentViewController!
override func awakeFromNib() {
super.awakeFromNib()
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
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var textField: UITextField!
var textValue = ""
var vc: OnlinePaymentViewController!
override func awakeFromNib() {
super.awakeFromNib()
textField.addTarget(self, action: #selector(OnlinePaymentFieldCell.textChanged(_:)), forControlEvents: UIControlEvents.EditingChanged)
textField.applyUITextFieldStyle()
}
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 {
func textChanged(textField: UITextField){
// delegate.onChangeText(textField.text!, cell: self)
if textField.text!.characters.count <= textField.maxLength {
vc.params[fieldTitle] = getPhoneDigits(textField.text!)
vc.setParam(fieldTitle, newText: textField)
self.vc.isChangedSettings()
}
......
......@@ -24,12 +24,19 @@ class FeedCollectionViewCell: UICollectionViewCell {
override func awakeFromNib() {
super.awakeFromNib()
let tap = UITapGestureRecognizer(target: self, action: #selector(FeedCollectionViewCell.tapFunction))
payButton.addGestureRecognizer(tap)
// let tap = UITapGestureRecognizer(target: self, action: #selector(FeedCollectionViewCell.tapFunction))
// payButton.addGestureRecognizer(tap)
//
// let tap2 = UITapGestureRecognizer(target: self, action: #selector(FeedCollectionViewCell.tapFunction))
// image.userInteractionEnabled = true
// image.addGestureRecognizer(tap2)
}
func tapFunction(sender:UITapGestureRecognizer) {
openService()
}
func openService() {
let serviceItem = ServiceItem()
serviceItem.id = self.id
serviceItem.type = "landing"
......@@ -38,13 +45,13 @@ class FeedCollectionViewCell: UICollectionViewCell {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
////this is old version
// let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceItemScrollViewController") as! ServiceItemScrollViewController
// destination.serviceItemForLoading = serviceItem
// navController!.pushViewController(destination, animated: true)
// let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceItemScrollViewController") as! ServiceItemScrollViewController
// destination.serviceItemForLoading = serviceItem
// navController!.pushViewController(destination, animated: true)
// let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceCalculatorViewController") as! ServiceCalculatorViewController
// destination.serviceItem = serviceItem
// navController!.pushViewController(destination, animated: true)
// let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceCalculatorViewController") as! ServiceCalculatorViewController
// destination.serviceItem = serviceItem
// navController!.pushViewController(destination, animated: true)
let destination = storyboard.instantiateViewControllerWithIdentifier("ServiceVIPTableViewController") as! ServiceVIPTableViewController
destination.serviceItem = serviceItem
......
......@@ -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 {
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