Skip to content

Commit

Permalink
[Chore] 코드 정리 (#63)
Browse files Browse the repository at this point in the history
- 테스트 용으로 만든 Print 정리
- 검색한 단어 저장 CoreData 코드 없애기
  • Loading branch information
ReeseSR committed May 10, 2022
1 parent cc6f23a commit 3bd95cc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 39 deletions.
13 changes: 0 additions & 13 deletions Hyangyu/Hyangyu/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ import CoreData

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

// MARK: - Core Data
lazy var persistentContainer: NSPersistentContainer = {
// name: Core Data 만든 파일명 지정
let container = NSPersistentContainer(name: "RecentSearchTerm")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error {
fatalError("Unresolved error, \((error as NSError).userInfo)")
}
})
return container
}()


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ final class ProfileEditViewController: UIViewController {
@objc func touchToPickImage() {
actionSheetAlert()
}



private func actionSheetAlert() {
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import UIKit

class ResetCodeViewController: UIViewController {

// MARK: - Properties
var email: String? // 이메일

Expand All @@ -19,15 +19,14 @@ class ResetCodeViewController: UIViewController {
@IBOutlet weak var warningLabel: UILabel!
@IBOutlet weak var completeButton: UIButton!

// MARK: - View Life Cycle
// MARK: - View Life Cycle
override func viewDidLoad() {
print("이거 실행되긴 하니?")
super.viewDidLoad()

initNavigationBar()
setDelegation()
configureUI()

}

// MARK: - Functions
Expand All @@ -41,7 +40,7 @@ class ResetCodeViewController: UIViewController {
@objc private func activateCodeTextField() {
codeTextFieldView.makeRoundedWithBorder(radius: 12, color: UIColor.systemGray2.cgColor)
}

// 텍스트 필드 비활성화
@objc private func inactivateCodeTextField() {
codeTextFieldView.makeRoundedWithBorder(radius: 12, color: UIColor.systemGray6.cgColor)
Expand Down Expand Up @@ -76,52 +75,53 @@ class ResetCodeViewController: UIViewController {
completeButton.isEnabled = true
completeButton.alpha = 1.0
}

private func makeCompleteButtonDisable() {
completeButton.isEnabled = false
completeButton.alpha = 0.3
}

func validateCode(code: String) -> Bool {
// Email 정규식
let codeRegEx = "^[a-z0-9+]{6}$"
let codeTest = NSPredicate(format: "SELF MATCHES %@", codeRegEx)
return codeTest.evaluate(with: code)
}

private func checkCodeFormat(userInput: String) {
if validateCode(code: userInput) {
makeCompleteButtonEnable()
} else {
makeCompleteButtonDisable()
}
}

@IBAction func touchCompleteButton(_ sender: Any) {
print("touched Complete Button")
sendCode()
}

// 화면 터치시 키보드 내림
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}

private func pushToNewPasswordViewController(email: String) {
let newPasswordViewController = NewPasswordViewController.loadFromNib()
self.navigationController?.pushViewController(newPasswordViewController, animated: true)

}

}

// MARK: - UITextFieldDelegate
extension ResetCodeViewController: UITextFieldDelegate {
func textFieldDidEndEditing(_ textField: UITextField) {
print("textFieldDidendEditing")
guard let text = textField.text else {
return
}
checkCodeFormat(userInput: text)
}

func textFieldDidBeginEditing(_ textField: UITextField) {
print("저 실행되었습니다.")
warningLabel.isHidden = true
codeTextFieldView.makeRoundedWithBorder(radius: 12, color: UIColor.systemGray2.cgColor)
completeButton.isEnabled = true
Expand All @@ -136,28 +136,21 @@ extension ResetCodeViewController: UITextFieldDelegate {

extension ResetCodeViewController {
func sendCode() {
print("저 실행됩니다요")
guard let code = codeTextField.text else {
return
}

PasswordAPI.shared.checkCode(completion: { response in
switch response {
case .success(let data):
if let data = data as? String {
self.showToast(message: data)
}
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.dismiss(animated: true)
}
self.pushToNewPasswordViewController()
case .requestErr(let message):
if let message = message as? String {
print(message)
self.showToast(message: message)
}
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.dismiss(animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.dismiss(animated: true)
}
}
print("requestErr", message)
case .pathErr:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="인증번호를 입력하세요" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="D2j-kN-mPg">
<rect key="frame" x="15" y="15" width="344" height="24"/>
<fontDescription key="fontDescription" name="AppleSDGothicNeo-Regular" family="Apple SD Gothic Neo" pointSize="16"/>
<fontDescription key="fontDescription" name="AppleSDGothicNeo-Regular" family="Apple SD Gothic Neo" pointSize="14"/>
<textInputTraits key="textInputTraits" textContentType="email"/>
</textField>
</subviews>
Expand Down

0 comments on commit 3bd95cc

Please sign in to comment.