Showing
9 changed files
with
90 additions
and
13 deletions
| @@ -373,12 +373,12 @@ | @@ -373,12 +373,12 @@ | ||
| 373 | path = ResidentTableViewCell; | 373 | path = ResidentTableViewCell; |
| 374 | sourceTree = "<group>"; | 374 | sourceTree = "<group>"; |
| 375 | }; | 375 | }; |
| 376 | - 1764A05A28670B7200847A30 /* NetworkManager */ = { | 376 | + 1764A05A28670B7200847A30 /* AuthService */ = { |
| 377 | isa = PBXGroup; | 377 | isa = PBXGroup; |
| 378 | children = ( | 378 | children = ( |
| 379 | 1764A05B28670B9F00847A30 /* AuthService.swift */, | 379 | 1764A05B28670B9F00847A30 /* AuthService.swift */, |
| 380 | ); | 380 | ); |
| 381 | - path = NetworkManager; | 381 | + path = AuthService; |
| 382 | sourceTree = "<group>"; | 382 | sourceTree = "<group>"; |
| 383 | }; | 383 | }; |
| 384 | 1774213A2866EDF4002730EE /* Models */ = { | 384 | 1774213A2866EDF4002730EE /* Models */ = { |
| @@ -508,7 +508,7 @@ | @@ -508,7 +508,7 @@ | ||
| 508 | isa = PBXGroup; | 508 | isa = PBXGroup; |
| 509 | children = ( | 509 | children = ( |
| 510 | 1721AEEC28704DBF00EC4FDB /* Extensions */, | 510 | 1721AEEC28704DBF00EC4FDB /* Extensions */, |
| 511 | - 1764A05A28670B7200847A30 /* NetworkManager */, | 511 | + 1764A05A28670B7200847A30 /* AuthService */, |
| 512 | 1774213A2866EDF4002730EE /* Models */, | 512 | 1774213A2866EDF4002730EE /* Models */, |
| 513 | 00A48B77285F8F6600EF0A08 /* Protocols */, | 513 | 00A48B77285F8F6600EF0A08 /* Protocols */, |
| 514 | 00E581B7284F71A700E779FB /* Common */, | 514 | 00E581B7284F71A700E779FB /* Common */, |
| @@ -865,7 +865,7 @@ | @@ -865,7 +865,7 @@ | ||
| 865 | CODE_SIGN_IDENTITY = "Apple Development"; | 865 | CODE_SIGN_IDENTITY = "Apple Development"; |
| 866 | CODE_SIGN_STYLE = Automatic; | 866 | CODE_SIGN_STYLE = Automatic; |
| 867 | CURRENT_PROJECT_VERSION = 1; | 867 | CURRENT_PROJECT_VERSION = 1; |
| 868 | - DEVELOPMENT_TEAM = 52KCA3JZ59; | 868 | + DEVELOPMENT_TEAM = 4X46JG9W6V; |
| 869 | GENERATE_INFOPLIST_FILE = YES; | 869 | GENERATE_INFOPLIST_FILE = YES; |
| 870 | INFOPLIST_FILE = "InterQR-Internship/Info.plist"; | 870 | INFOPLIST_FILE = "InterQR-Internship/Info.plist"; |
| 871 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; | 871 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; |
| @@ -894,7 +894,7 @@ | @@ -894,7 +894,7 @@ | ||
| 894 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; | 894 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; |
| 895 | CODE_SIGN_STYLE = Automatic; | 895 | CODE_SIGN_STYLE = Automatic; |
| 896 | CURRENT_PROJECT_VERSION = 1; | 896 | CURRENT_PROJECT_VERSION = 1; |
| 897 | - DEVELOPMENT_TEAM = 52KCA3JZ59; | 897 | + DEVELOPMENT_TEAM = 4X46JG9W6V; |
| 898 | GENERATE_INFOPLIST_FILE = YES; | 898 | GENERATE_INFOPLIST_FILE = YES; |
| 899 | INFOPLIST_FILE = "InterQR-Internship/Info.plist"; | 899 | INFOPLIST_FILE = "InterQR-Internship/Info.plist"; |
| 900 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; | 900 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; |
| @@ -36,5 +36,37 @@ | @@ -36,5 +36,37 @@ | ||
| 36 | landmarkType = "7"> | 36 | landmarkType = "7"> |
| 37 | </BreakpointContent> | 37 | </BreakpointContent> |
| 38 | </BreakpointProxy> | 38 | </BreakpointProxy> |
| 39 | + <BreakpointProxy | ||
| 40 | + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
| 41 | + <BreakpointContent | ||
| 42 | + uuid = "B21C0B63-1820-47D9-863A-585E52771DA2" | ||
| 43 | + shouldBeEnabled = "Yes" | ||
| 44 | + ignoreCount = "0" | ||
| 45 | + continueAfterRunningActions = "No" | ||
| 46 | + filePath = "InterQR-Internship/Modules/OneTimePasswordScreen/View/OTPView.swift" | ||
| 47 | + startingColumnNumber = "9223372036854775807" | ||
| 48 | + endingColumnNumber = "9223372036854775807" | ||
| 49 | + startingLineNumber = "94" | ||
| 50 | + endingLineNumber = "94" | ||
| 51 | + landmarkName = "didTextFieldChanged(_:)" | ||
| 52 | + landmarkType = "7"> | ||
| 53 | + </BreakpointContent> | ||
| 54 | + </BreakpointProxy> | ||
| 55 | + <BreakpointProxy | ||
| 56 | + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
| 57 | + <BreakpointContent | ||
| 58 | + uuid = "7B1AC08C-6FFC-42BD-8C5C-4D6CE5CBD70C" | ||
| 59 | + shouldBeEnabled = "Yes" | ||
| 60 | + ignoreCount = "0" | ||
| 61 | + continueAfterRunningActions = "No" | ||
| 62 | + filePath = "InterQR-Internship/Modules/OneTimePasswordScreen/ViewController/CodeVerificationViewController.swift" | ||
| 63 | + startingColumnNumber = "9223372036854775807" | ||
| 64 | + endingColumnNumber = "9223372036854775807" | ||
| 65 | + startingLineNumber = "145" | ||
| 66 | + endingLineNumber = "145" | ||
| 67 | + landmarkName = "didFullCodeCompletion(_:)" | ||
| 68 | + landmarkType = "7"> | ||
| 69 | + </BreakpointContent> | ||
| 70 | + </BreakpointProxy> | ||
| 39 | </Breakpoints> | 71 | </Breakpoints> |
| 40 | </Bucket> | 72 | </Bucket> |
| @@ -74,6 +74,7 @@ class AddResidentsView: UIView { | @@ -74,6 +74,7 @@ class AddResidentsView: UIView { | ||
| 74 | obj.placeholder = .Text.enterResidentName | 74 | obj.placeholder = .Text.enterResidentName |
| 75 | obj.font = .skModernist(type: .regular, ofSize: 14) | 75 | obj.font = .skModernist(type: .regular, ofSize: 14) |
| 76 | obj.textPadding = UIEdgeInsets(top: 0, left: 22, bottom: 0, right: 22) | 76 | obj.textPadding = UIEdgeInsets(top: 0, left: 22, bottom: 0, right: 22) |
| 77 | + obj.returnKeyType = .done | ||
| 77 | return obj | 78 | return obj |
| 78 | }() | 79 | }() |
| 79 | 80 | ||
| @@ -93,6 +94,7 @@ class AddResidentsView: UIView { | @@ -93,6 +94,7 @@ class AddResidentsView: UIView { | ||
| 93 | obj.font = .skModernist(type: .regular, ofSize: 14) | 94 | obj.font = .skModernist(type: .regular, ofSize: 14) |
| 94 | obj.textPadding = UIEdgeInsets(top: 0, left: 22, bottom: 0, right: 45) | 95 | obj.textPadding = UIEdgeInsets(top: 0, left: 22, bottom: 0, right: 45) |
| 95 | obj.placeholder = .Text.enterResidentNumber | 96 | obj.placeholder = .Text.enterResidentNumber |
| 97 | + obj.keyboardType = .phonePad | ||
| 96 | return obj | 98 | return obj |
| 97 | }() | 99 | }() |
| 98 | 100 |
| @@ -32,6 +32,10 @@ class AddResidentsViewController: UIViewController { | @@ -32,6 +32,10 @@ class AddResidentsViewController: UIViewController { | ||
| 32 | if let closeTap = self.closeTap { | 32 | if let closeTap = self.closeTap { |
| 33 | mainView.transparentView.addGestureRecognizer(closeTap) | 33 | mainView.transparentView.addGestureRecognizer(closeTap) |
| 34 | } | 34 | } |
| 35 | + addDoneButtonOnKeyboard() | ||
| 36 | + | ||
| 37 | + mainView.nameTextField.delegate = self | ||
| 38 | + mainView.mobileNumberTextField.delegate = self | ||
| 35 | 39 | ||
| 36 | mainView.closeButton.addTarget(self, action: #selector(didTapCloseButton), for: .touchUpInside) | 40 | mainView.closeButton.addTarget(self, action: #selector(didTapCloseButton), for: .touchUpInside) |
| 37 | mainView.managerButton.addTarget(self, action: #selector(didTapOnChangeableButtons(_:)), for: .touchUpInside) | 41 | mainView.managerButton.addTarget(self, action: #selector(didTapOnChangeableButtons(_:)), for: .touchUpInside) |
| @@ -49,6 +53,25 @@ class AddResidentsViewController: UIViewController { | @@ -49,6 +53,25 @@ class AddResidentsViewController: UIViewController { | ||
| 49 | NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil) | 53 | NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil) |
| 50 | } | 54 | } |
| 51 | 55 | ||
| 56 | + func addDoneButtonOnKeyboard() { | ||
| 57 | + let doneToolbar: UIToolbar = UIToolbar(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 50)) | ||
| 58 | + doneToolbar.barStyle = .default | ||
| 59 | + | ||
| 60 | + let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) | ||
| 61 | + let done: UIBarButtonItem = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(self.doneButtonAction)) | ||
| 62 | + | ||
| 63 | + let items = [flexSpace, done] | ||
| 64 | + doneToolbar.items = items | ||
| 65 | + doneToolbar.sizeToFit() | ||
| 66 | + | ||
| 67 | + mainView.mobileNumberTextField.inputAccessoryView = doneToolbar | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @objc func doneButtonAction(){ | ||
| 71 | + mainView.mobileNumberTextField.resignFirstResponder() | ||
| 72 | + | ||
| 73 | + } | ||
| 74 | + | ||
| 52 | func reloadView() { | 75 | func reloadView() { |
| 53 | mainView.mobileNumberTextField.reloadInputViews() | 76 | mainView.mobileNumberTextField.reloadInputViews() |
| 54 | } | 77 | } |
| @@ -165,4 +188,17 @@ extension AddResidentsViewController: CNContactPickerDelegate { | @@ -165,4 +188,17 @@ extension AddResidentsViewController: CNContactPickerDelegate { | ||
| 165 | mainView.mobileNumberTextField.text = firstPhoneNumber.stringValue | 188 | mainView.mobileNumberTextField.text = firstPhoneNumber.stringValue |
| 166 | } | 189 | } |
| 167 | } | 190 | } |
| 168 | - | 191 | +//MARK: - TextField delegate |
| 192 | +extension AddResidentsViewController: UITextFieldDelegate { | ||
| 193 | + func textFieldShouldReturn(_ textField: UITextField) -> Bool { | ||
| 194 | + guard let text = mainView.nameTextField.text else { return true } | ||
| 195 | + if text.isEmpty{ | ||
| 196 | + let alert = UIAlertController(title: "Enter name field", message: "", preferredStyle: .alert) | ||
| 197 | + alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil)) | ||
| 198 | + present(alert, animated: true, completion: nil) | ||
| 199 | + } else { | ||
| 200 | + mainView.mobileNumberTextField.becomeFirstResponder() | ||
| 201 | + } | ||
| 202 | + return true | ||
| 203 | + } | ||
| 204 | +} |
| @@ -90,7 +90,9 @@ class OTPView: UIView { | @@ -90,7 +90,9 @@ class OTPView: UIView { | ||
| 90 | guard var code = sender.text else { | 90 | guard var code = sender.text else { |
| 91 | return | 91 | return |
| 92 | } | 92 | } |
| 93 | - if code.count > 4 { | 93 | + if code.count == 0 { |
| 94 | + delegate?.didFullCodeCompletion(self) | ||
| 95 | + } else if code.count > 4 { | ||
| 94 | code.removeLast() | 96 | code.removeLast() |
| 95 | } else { | 97 | } else { |
| 96 | if code.count == 4 { | 98 | if code.count == 4 { |
| @@ -98,7 +100,6 @@ class OTPView: UIView { | @@ -98,7 +100,6 @@ class OTPView: UIView { | ||
| 98 | textField.resignFirstResponder() | 100 | textField.resignFirstResponder() |
| 99 | } | 101 | } |
| 100 | } | 102 | } |
| 101 | - | ||
| 102 | digitViews.enumerated().forEach { index, item in | 103 | digitViews.enumerated().forEach { index, item in |
| 103 | item.text = (code.count-1 >= index ? String(code[code.index(code.startIndex, offsetBy: index)]) : "") | 104 | item.text = (code.count-1 >= index ? String(code[code.index(code.startIndex, offsetBy: index)]) : "") |
| 104 | } | 105 | } |
InterQR-Internship/Modules/OneTimePasswordScreen/ViewController/CodeVerificationViewController.swift
| @@ -8,12 +8,11 @@ | @@ -8,12 +8,11 @@ | ||
| 8 | import UIKit | 8 | import UIKit |
| 9 | 9 | ||
| 10 | class CodeVerificationViewController: UIViewController { | 10 | class CodeVerificationViewController: UIViewController { |
| 11 | -// var otp: String = "" | ||
| 12 | - | ||
| 13 | var isKeyboardAppear = false | 11 | var isKeyboardAppear = false |
| 14 | 12 | ||
| 15 | private let mainView = CodeVerificationView() | 13 | private let mainView = CodeVerificationView() |
| 16 | private let networkManager = AuthService() | 14 | private let networkManager = AuthService() |
| 15 | + | ||
| 17 | override func loadView() { | 16 | override func loadView() { |
| 18 | view = mainView | 17 | view = mainView |
| 19 | } | 18 | } |
| @@ -45,13 +44,14 @@ class CodeVerificationViewController: UIViewController { | @@ -45,13 +44,14 @@ class CodeVerificationViewController: UIViewController { | ||
| 45 | self.mainView.spinner.startAnimating() | 44 | self.mainView.spinner.startAnimating() |
| 46 | } fail: { error in | 45 | } fail: { error in |
| 47 | print("3️⃣\(error)") | 46 | print("3️⃣\(error)") |
| 47 | + self.errorProcessing() | ||
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | func networkingLogin() { | 51 | func networkingLogin() { |
| 52 | guard let loginModel = loginModelFilling() else { return } | 52 | guard let loginModel = loginModelFilling() else { return } |
| 53 | AuthService.share.loginRequest(model: loginModel) { response in | 53 | AuthService.share.loginRequest(model: loginModel) { response in |
| 54 | - print("4️⃣\(response.message)4️⃣") | 54 | + print("4️⃣\(String(describing: response.message))4️⃣") |
| 55 | self.errorProcessing() | 55 | self.errorProcessing() |
| 56 | } fail: { error in | 56 | } fail: { error in |
| 57 | print("4️⃣⛔️\(error)⛔️") | 57 | print("4️⃣⛔️\(error)⛔️") |
| @@ -144,5 +144,11 @@ extension CodeVerificationViewController: OTPViewDelegate { | @@ -144,5 +144,11 @@ extension CodeVerificationViewController: OTPViewDelegate { | ||
| 144 | 144 | ||
| 145 | func didFullCodeCompletion(_ otpView: OTPView) { | 145 | func didFullCodeCompletion(_ otpView: OTPView) { |
| 146 | print("code -> \(String(describing: otpView.code))") | 146 | print("code -> \(String(describing: otpView.code))") |
| 147 | + guard let code = otpView.code else { return } | ||
| 148 | + if code.isEmpty { | ||
| 149 | + mainView.otpView.isError.toggle() | ||
| 150 | + otpView.reloadInputViews() | ||
| 151 | + } | ||
| 152 | + | ||
| 147 | } | 153 | } |
| 148 | } | 154 | } |
| @@ -52,6 +52,7 @@ class DisplayNameCell: UITableViewCell, Reusable { | @@ -52,6 +52,7 @@ class DisplayNameCell: UITableViewCell, Reusable { | ||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | private func setup() { | 54 | private func setup() { |
| 55 | + selectionStyle = .none | ||
| 55 | contentView.addSubview(settingsIcon) | 56 | contentView.addSubview(settingsIcon) |
| 56 | contentView.addSubview(titleLabel) | 57 | contentView.addSubview(titleLabel) |
| 57 | contentView.addSubview(descriptionLabel) | 58 | contentView.addSubview(descriptionLabel) |
| @@ -33,7 +33,7 @@ class SettingsViewController: UIViewController { | @@ -33,7 +33,7 @@ class SettingsViewController: UIViewController { | ||
| 33 | mainView.logoutButton.addTarget(self, action: #selector(didLogoutAndShowVerificationVC), for: .touchUpInside) | 33 | mainView.logoutButton.addTarget(self, action: #selector(didLogoutAndShowVerificationVC), for: .touchUpInside) |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 36 | - | 36 | +//MARK: - Delegate |
| 37 | extension SettingsViewController { | 37 | extension SettingsViewController { |
| 38 | @objc private func didShowHomeVC() { | 38 | @objc private func didShowHomeVC() { |
| 39 | navigationController?.popViewController(animated: true) | 39 | navigationController?.popViewController(animated: true) |
| @@ -43,7 +43,6 @@ extension SettingsViewController { | @@ -43,7 +43,6 @@ extension SettingsViewController { | ||
| 43 | networking() | 43 | networking() |
| 44 | let vc = VerificationViewController() | 44 | let vc = VerificationViewController() |
| 45 | navigationController?.pushViewController(vc, animated: true) | 45 | navigationController?.pushViewController(vc, animated: true) |
| 46 | - | ||
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | func networking() { | 48 | func networking() { |
Please
register
or
login
to post a comment