|
@ -28,7 +28,6 @@ class LoginViewController: UIViewController { |
|
|
|
|
|
|
|
|
@IBOutlet weak var userNameTextField: UITextField! |
|
|
@IBOutlet weak var userNameTextField: UITextField! |
|
|
@IBOutlet weak var passwordTextField: UITextField! |
|
|
@IBOutlet weak var passwordTextField: UITextField! |
|
|
var mQwertyTransKey: TransKey! |
|
|
|
|
|
|
|
|
|
|
|
// views |
|
|
// views |
|
|
@IBOutlet weak var backgroundTextfieldsView: UIView! |
|
|
@IBOutlet weak var backgroundTextfieldsView: UIView! |
|
@ -56,9 +55,6 @@ class LoginViewController: UIViewController { |
|
|
var presenter: LoginModuleInterface? |
|
|
var presenter: LoginModuleInterface? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var qwertyCipherString : String! |
|
|
|
|
|
var qwertyPlainData:[CChar] = [CChar](repeating: 0, count: 256) |
|
|
|
|
|
var secureKey : NSData! |
|
|
|
|
|
// MARK: VC's Life cycle |
|
|
// MARK: VC's Life cycle |
|
|
|
|
|
|
|
|
override func viewDidLoad() { |
|
|
override func viewDidLoad() { |
|
@ -68,7 +64,7 @@ class LoginViewController: UIViewController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func configureLanguage() { |
|
|
private func configureLanguage() { |
|
|
// Localize.setCurrentLanguage("th") |
|
|
|
|
|
|
|
|
Localize.setCurrentLanguage("th") |
|
|
self.headerTitle.text = StringConstants.headerTitle |
|
|
self.headerTitle.text = StringConstants.headerTitle |
|
|
self.subtitle.text = StringConstants.subHeaderTitle |
|
|
self.subtitle.text = StringConstants.subHeaderTitle |
|
|
self.userIdTitleLabel.text = StringConstants.userIdTitle |
|
|
self.userIdTitleLabel.text = StringConstants.userIdTitle |
|
@ -96,113 +92,86 @@ class LoginViewController: UIViewController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@IBAction func login(_ sender: UIButton) { |
|
|
@IBAction func login(_ sender: UIButton) { |
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
// let username = self.userNameTextField.text! |
|
|
|
|
|
// let password = self.mQwertyTransKey.text! |
|
|
|
|
|
// self.presenter?.login(userName: username, password: password) |
|
|
|
|
|
|
|
|
let username = self.userNameTextField.text! |
|
|
|
|
|
let password = self.passwordTextField.text! |
|
|
|
|
|
self.presenter?.login(userName: username, password: password) |
|
|
} |
|
|
} |
|
|
// MARK: Other Functions |
|
|
// MARK: Other Functions |
|
|
|
|
|
|
|
|
private func setup() { |
|
|
private func setup() { |
|
|
|
|
|
// all setup should be done here |
|
|
setupNavBar() |
|
|
setupNavBar() |
|
|
setupColor() |
|
|
setupColor() |
|
|
setupKeyboard() |
|
|
|
|
|
|
|
|
// showAnimation() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func setupKeyboard() { |
|
|
|
|
|
|
|
|
|
|
|
let iv: Array<String> = ["M", "o", "b", "i", "l", "e", "T", "r" , "a", "n", "s", "K", "e", "y", "1", "0"]; |
|
|
|
|
|
secureKey = NSData(bytes: iv, length: 16) |
|
|
|
|
|
|
|
|
|
|
|
self.showQwertyTranskey() |
|
|
|
|
|
|
|
|
func setupColor() { |
|
|
|
|
|
self.loginButton.backgroundColor = AppConstants.themeRedColor |
|
|
|
|
|
self.headerTitle.textColor = AppConstants.themeRedColor |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func showAnimation() { |
|
|
|
|
|
setupInitialPositionsOfviews() |
|
|
|
|
|
animateViews() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func setupInitialPositionsOfviews() { |
|
|
|
|
|
self.userIdBackgroundView.center.x -= self.view.bounds.width |
|
|
|
|
|
self.passwordBackgroundView.center.x -= self.view.bounds.width |
|
|
|
|
|
self.loginButton.transform = CGAffineTransform.init(scaleX: 0, y: 1) |
|
|
|
|
|
self.headerTitle.alpha = 0 |
|
|
|
|
|
self.headerTitle.center.y -= 200 |
|
|
|
|
|
self.subtitle.alpha = 0 |
|
|
|
|
|
self.forgotPasswordView.alpha = 0 |
|
|
|
|
|
self.logoImageView.center.y += (self.logoImageView.bounds.height + 20) |
|
|
|
|
|
self.loginButton.setTitle("", for: UIControlState.normal) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func showQwertyTranskey() { |
|
|
|
|
|
|
|
|
private func animateViews() { |
|
|
|
|
|
// user id |
|
|
|
|
|
UIView.animate(withDuration: 0.5, animations: { |
|
|
|
|
|
self.userIdBackgroundView.center.x += self.view.bounds.width |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
mQwertyTransKey = TransKey(frame: self.passwordTextField.frame) |
|
|
|
|
|
|
|
|
// password |
|
|
|
|
|
UIView.animate(withDuration: 0.5, delay: 0.3, options: [], animations: { |
|
|
|
|
|
self.passwordBackgroundView.center.x += self.view.bounds.width |
|
|
|
|
|
}, completion: nil) |
|
|
|
|
|
|
|
|
mQwertyTransKey.delegate = self |
|
|
|
|
|
mQwertyTransKey.parent = self |
|
|
|
|
|
let sData = "MobileTransKey10".data(using: .utf8) |
|
|
|
|
|
mQwertyTransKey.setSecure(sData) |
|
|
|
|
|
// mQwertyTransKey.setSecure(secureKey as Data!) |
|
|
|
|
|
mQwertyTransKey.mTK_Supported(byDeviceOrientation: SupportedByDevicePortraitAndLandscape); |
|
|
|
|
|
// mQwertyTransKey.setKeyboardType(-1, maxLength: 8, minLength: 0) |
|
|
|
|
|
mQwertyTransKey.mTK_UseCursor(true) |
|
|
|
|
|
mQwertyTransKey.mTK_UseAllDeleteButton(false) |
|
|
|
|
|
mQwertyTransKey.mTK_SetInputEditboxImage(false) |
|
|
|
|
|
mQwertyTransKey.mTK_SetHint("password", font: Fonts.XLTabBar.itemFont, textAlignment: NSTextAlignment.center) |
|
|
|
|
|
|
|
|
|
|
|
mQwertyTransKey.mTK_UseVoiceOver(false) |
|
|
|
|
|
mQwertyTransKey.mTK_ShowNaviBar(false) |
|
|
|
|
|
mQwertyTransKey.mTK_SetEnable(beforeButton: false) |
|
|
|
|
|
mQwertyTransKey.mTK_Set(beforeButtonAccessibilityLabel: "이전 입력필드로 이동") |
|
|
|
|
|
mQwertyTransKey.mTK_SetNextButtonAccessibilityLabel("다음 입력필드로 이동") |
|
|
|
|
|
mQwertyTransKey.mTK_SetCompleteButtonAccessibilityLabel("입력완료") |
|
|
|
|
|
mQwertyTransKey.mTK_UseShiftOptional(true) |
|
|
|
|
|
mQwertyTransKey.mTK_textAlignCenter(false) |
|
|
|
|
|
mQwertyTransKey.mTK_SetLanguage(1) |
|
|
|
|
|
mQwertyTransKey.mTK_SetInputEditboxImage(true) |
|
|
|
|
|
mQwertyTransKey.mTK_SetBottomSafeArea(true) |
|
|
|
|
|
let res = mQwertyTransKey.mTK_LicenseCheck("license_mtranskey") |
|
|
|
|
|
print("res : %d", res) |
|
|
|
|
|
self.view.addSubview(mQwertyTransKey) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func transKeyDidBeginEditing(_ transKey: TransKey!) { |
|
|
|
|
|
print("TransKeyDidBeginEditing") |
|
|
|
|
|
if transKey != nil{ |
|
|
|
|
|
transKey.clear() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func transKeyShouldInternalReturn(_ transKey:TransKey, btnType type:NSInteger)->Bool { |
|
|
|
|
|
print("TransKeyShouldInternalReturn") |
|
|
|
|
|
|
|
|
// login button |
|
|
|
|
|
UIView.animate(withDuration: 0.5, delay: 0.4, options: [], animations: { |
|
|
|
|
|
self.loginButton.transform = CGAffineTransform.identity |
|
|
|
|
|
}, completion: { (_) in |
|
|
|
|
|
self.loginButton.setTitle("Login", for: UIControlState.normal) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
if type == CompleteCmdType || type == NaviCompleteCmdType{ |
|
|
|
|
|
let qkey = mQwertyTransKey.getSecureKey() |
|
|
|
|
|
qwertyCipherString = mQwertyTransKey.getCipherDataEx() |
|
|
|
|
|
|
|
|
|
|
|
mQwertyTransKey.getPlainDataEx(withKey: qkey, cipherString: qwertyCipherString, plainString: &qwertyPlainData, length: 256) |
|
|
|
|
|
let qwertyPlainString = String(validatingUTF8:qwertyPlainData) |
|
|
|
|
|
|
|
|
|
|
|
let _qwertyCipherLabelText = String(format: "Qwerty Cipher text : %@", qwertyCipherString) |
|
|
|
|
|
let _qwertyPlainLabelText = String(format: "Qwerty Plain text : %@", qwertyPlainString!) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let _numberCipherLabelText = String(format: "Number Cipher Text : %@", qwertyCipherString) |
|
|
|
|
|
let _numberPlainLabelText = String(format: "Number Plain Text : %@", qwertyPlainString!) |
|
|
|
|
|
|
|
|
|
|
|
return true |
|
|
|
|
|
}else if type == NaviBeforeCmdType{ |
|
|
|
|
|
mQwertyTransKey.transkeyBecomeFirstResponder() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// subtitle |
|
|
|
|
|
UIView.animate(withDuration: 0.5, delay: 0.7, options: [], animations: { |
|
|
|
|
|
self.subtitle.alpha = 1 |
|
|
|
|
|
}, completion: nil) |
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func transKeyShouldReturn(_ transKey: TransKey!)->Bool { |
|
|
|
|
|
print("TransKeyShouldReturn") |
|
|
|
|
|
|
|
|
// forgot password |
|
|
|
|
|
UIView.animate(withDuration: 0.5, delay: 0.9, options: [], animations: { |
|
|
|
|
|
self.forgotPasswordView.alpha = 1 |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override func viewDidDisappear(_ animated: Bool) { |
|
|
|
|
|
super.viewDidDisappear(animated) |
|
|
|
|
|
mQwertyTransKey.mTK_ClearDelegateSubviews() |
|
|
|
|
|
mQwertyTransKey.clear() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func setupColor() { |
|
|
|
|
|
self.loginButton.backgroundColor = AppConstants.themeRedColor |
|
|
|
|
|
self.headerTitle.textColor = AppConstants.themeRedColor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// header title |
|
|
|
|
|
// logoimageview |
|
|
|
|
|
UIView.animate(withDuration: 0.7, delay: 0, options: [], animations: { |
|
|
|
|
|
// todo |
|
|
|
|
|
self.headerTitle.alpha = 1 |
|
|
|
|
|
self.headerTitle.center.y += 200 |
|
|
|
|
|
self.logoImageView.center.y -= (self.logoImageView.bounds.height + 20) |
|
|
|
|
|
}, completion: nil) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func setupNavBar() { |
|
|
private func setupNavBar() { |
|
|
self.setupPicturedNavBar() |
|
|
self.setupPicturedNavBar() |
|
|
} |
|
|
} |
|
@ -222,6 +191,3 @@ extension LoginViewController: LoginViewInterface { |
|
|
self.hideProgressHud() |
|
|
self.hideProgressHud() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extension LoginViewController: TransKeyDelegate {} |
|
|
|