Showing
9 changed files
with
90 additions
and
13 deletions
... | ... | @@ -373,12 +373,12 @@ |
373 | 373 | path = ResidentTableViewCell; |
374 | 374 | sourceTree = "<group>"; |
375 | 375 | }; |
376 | - 1764A05A28670B7200847A30 /* NetworkManager */ = { | |
376 | + 1764A05A28670B7200847A30 /* AuthService */ = { | |
377 | 377 | isa = PBXGroup; |
378 | 378 | children = ( |
379 | 379 | 1764A05B28670B9F00847A30 /* AuthService.swift */, |
380 | 380 | ); |
381 | - path = NetworkManager; | |
381 | + path = AuthService; | |
382 | 382 | sourceTree = "<group>"; |
383 | 383 | }; |
384 | 384 | 1774213A2866EDF4002730EE /* Models */ = { |
... | ... | @@ -508,7 +508,7 @@ |
508 | 508 | isa = PBXGroup; |
509 | 509 | children = ( |
510 | 510 | 1721AEEC28704DBF00EC4FDB /* Extensions */, |
511 | - 1764A05A28670B7200847A30 /* NetworkManager */, | |
511 | + 1764A05A28670B7200847A30 /* AuthService */, | |
512 | 512 | 1774213A2866EDF4002730EE /* Models */, |
513 | 513 | 00A48B77285F8F6600EF0A08 /* Protocols */, |
514 | 514 | 00E581B7284F71A700E779FB /* Common */, |
... | ... | @@ -865,7 +865,7 @@ |
865 | 865 | CODE_SIGN_IDENTITY = "Apple Development"; |
866 | 866 | CODE_SIGN_STYLE = Automatic; |
867 | 867 | CURRENT_PROJECT_VERSION = 1; |
868 | - DEVELOPMENT_TEAM = 52KCA3JZ59; | |
868 | + DEVELOPMENT_TEAM = 4X46JG9W6V; | |
869 | 869 | GENERATE_INFOPLIST_FILE = YES; |
870 | 870 | INFOPLIST_FILE = "InterQR-Internship/Info.plist"; |
871 | 871 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; |
... | ... | @@ -894,7 +894,7 @@ |
894 | 894 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; |
895 | 895 | CODE_SIGN_STYLE = Automatic; |
896 | 896 | CURRENT_PROJECT_VERSION = 1; |
897 | - DEVELOPMENT_TEAM = 52KCA3JZ59; | |
897 | + DEVELOPMENT_TEAM = 4X46JG9W6V; | |
898 | 898 | GENERATE_INFOPLIST_FILE = YES; |
899 | 899 | INFOPLIST_FILE = "InterQR-Internship/Info.plist"; |
900 | 900 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; | ... | ... |
... | ... | @@ -36,5 +36,37 @@ |
36 | 36 | landmarkType = "7"> |
37 | 37 | </BreakpointContent> |
38 | 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 | 71 | </Breakpoints> |
40 | 72 | </Bucket> | ... | ... |
... | ... | @@ -74,6 +74,7 @@ class AddResidentsView: UIView { |
74 | 74 | obj.placeholder = .Text.enterResidentName |
75 | 75 | obj.font = .skModernist(type: .regular, ofSize: 14) |
76 | 76 | obj.textPadding = UIEdgeInsets(top: 0, left: 22, bottom: 0, right: 22) |
77 | + obj.returnKeyType = .done | |
77 | 78 | return obj |
78 | 79 | }() |
79 | 80 | |
... | ... | @@ -93,6 +94,7 @@ class AddResidentsView: UIView { |
93 | 94 | obj.font = .skModernist(type: .regular, ofSize: 14) |
94 | 95 | obj.textPadding = UIEdgeInsets(top: 0, left: 22, bottom: 0, right: 45) |
95 | 96 | obj.placeholder = .Text.enterResidentNumber |
97 | + obj.keyboardType = .phonePad | |
96 | 98 | return obj |
97 | 99 | }() |
98 | 100 | ... | ... |
... | ... | @@ -32,6 +32,10 @@ class AddResidentsViewController: UIViewController { |
32 | 32 | if let closeTap = self.closeTap { |
33 | 33 | mainView.transparentView.addGestureRecognizer(closeTap) |
34 | 34 | } |
35 | + addDoneButtonOnKeyboard() | |
36 | + | |
37 | + mainView.nameTextField.delegate = self | |
38 | + mainView.mobileNumberTextField.delegate = self | |
35 | 39 | |
36 | 40 | mainView.closeButton.addTarget(self, action: #selector(didTapCloseButton), for: .touchUpInside) |
37 | 41 | mainView.managerButton.addTarget(self, action: #selector(didTapOnChangeableButtons(_:)), for: .touchUpInside) |
... | ... | @@ -49,6 +53,25 @@ class AddResidentsViewController: UIViewController { |
49 | 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 | 75 | func reloadView() { |
53 | 76 | mainView.mobileNumberTextField.reloadInputViews() |
54 | 77 | } |
... | ... | @@ -165,4 +188,17 @@ extension AddResidentsViewController: CNContactPickerDelegate { |
165 | 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 | 90 | guard var code = sender.text else { |
91 | 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 | 96 | code.removeLast() |
95 | 97 | } else { |
96 | 98 | if code.count == 4 { |
... | ... | @@ -98,7 +100,6 @@ class OTPView: UIView { |
98 | 100 | textField.resignFirstResponder() |
99 | 101 | } |
100 | 102 | } |
101 | - | |
102 | 103 | digitViews.enumerated().forEach { index, item in |
103 | 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 | 8 | import UIKit |
9 | 9 | |
10 | 10 | class CodeVerificationViewController: UIViewController { |
11 | -// var otp: String = "" | |
12 | - | |
13 | 11 | var isKeyboardAppear = false |
14 | 12 | |
15 | 13 | private let mainView = CodeVerificationView() |
16 | 14 | private let networkManager = AuthService() |
15 | + | |
17 | 16 | override func loadView() { |
18 | 17 | view = mainView |
19 | 18 | } |
... | ... | @@ -45,13 +44,14 @@ class CodeVerificationViewController: UIViewController { |
45 | 44 | self.mainView.spinner.startAnimating() |
46 | 45 | } fail: { error in |
47 | 46 | print("3️⃣\(error)") |
47 | + self.errorProcessing() | |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | 51 | func networkingLogin() { |
52 | 52 | guard let loginModel = loginModelFilling() else { return } |
53 | 53 | AuthService.share.loginRequest(model: loginModel) { response in |
54 | - print("4️⃣\(response.message)4️⃣") | |
54 | + print("4️⃣\(String(describing: response.message))4️⃣") | |
55 | 55 | self.errorProcessing() |
56 | 56 | } fail: { error in |
57 | 57 | print("4️⃣⛔️\(error)⛔️") |
... | ... | @@ -144,5 +144,11 @@ extension CodeVerificationViewController: OTPViewDelegate { |
144 | 144 | |
145 | 145 | func didFullCodeCompletion(_ otpView: OTPView) { |
146 | 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 | } | ... | ... |
... | ... | @@ -33,7 +33,7 @@ class SettingsViewController: UIViewController { |
33 | 33 | mainView.logoutButton.addTarget(self, action: #selector(didLogoutAndShowVerificationVC), for: .touchUpInside) |
34 | 34 | } |
35 | 35 | } |
36 | - | |
36 | +//MARK: - Delegate | |
37 | 37 | extension SettingsViewController { |
38 | 38 | @objc private func didShowHomeVC() { |
39 | 39 | navigationController?.popViewController(animated: true) |
... | ... | @@ -43,7 +43,6 @@ extension SettingsViewController { |
43 | 43 | networking() |
44 | 44 | let vc = VerificationViewController() |
45 | 45 | navigationController?.pushViewController(vc, animated: true) |
46 | - | |
47 | 46 | } |
48 | 47 | |
49 | 48 | func networking() { | ... | ... |
Please
register
or
login
to post a comment