Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] #1 - iOS 1차 과제 #2

Merged
merged 32 commits into from
Apr 16, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9046553
[ADD] 프로젝트 생성
wngus4296 Apr 6, 2022
bd07c26
[ADD] 에셋 이미지 추가
wngus4296 Apr 6, 2022
79277f4
[FEAT] 로그인 UI 구현
wngus4296 Apr 6, 2022
ec8a0b3
[FEAT] 회원가입 UI 구현
wngus4296 Apr 6, 2022
7d209da
[FEAT] 회원가입 VC 연결
wngus4296 Apr 6, 2022
d7a8397
[FEAT] 완료 화면 UI 구현 및 VC 연결
wngus4296 Apr 6, 2022
93de607
[FIX] 로그인 버튼과 아래 레이블 겹치는 오류 수정
wngus4296 Apr 6, 2022
5c40208
[FIX] 로그인 화면 하단 레이블, 버튼 레이아웃 수정
wngus4296 Apr 6, 2022
add19cd
[FEAT] 화면 전환 구현
wngus4296 Apr 7, 2022
4955fd3
[FEAT] 화면 전환 구현 (로그인 버튼 및 완료하기 버튼)
wngus4296 Apr 7, 2022
add76dd
[FIX] 변수명 변경 nextVC -> successVC
wngus4296 Apr 7, 2022
a045cd0
[RENAME] VC명 변경
wngus4296 Apr 7, 2022
5835d71
[FEAT] 데이터 전달 구현
wngus4296 Apr 7, 2022
9bbc8b2
[FEAT, FIX] TextField 옵션 설정 및 버튼 비활성화로 초기화, button 함수명 변경
wngus4296 Apr 7, 2022
01de044
[FEAT] TextField에 따른 버튼 활성화 구현
wngus4296 Apr 8, 2022
b370825
[COMMENT] 주석 수정
wngus4296 Apr 8, 2022
5c0bf03
[REFACTOR] TextField.addTarget 함수화
wngus4296 Apr 8, 2022
4f0ad7f
[FEAT] 비밀번호 입력창의 눈 아이콘 선택에 따른 보안 처리 구현
wngus4296 Apr 8, 2022
60fe638
[COMMENT] toggle() 주석 추가
wngus4296 Apr 8, 2022
328ac05
[FEAT] 눈 버튼 선택된 경우 틴트 컬러를 투명으로 변경
wngus4296 Apr 8, 2022
29946ef
[REMOVE] 필요없는 코드 삭제
wngus4296 Apr 8, 2022
4474535
[FEAT] 회원가입 TextField에 clear 버튼 추가
wngus4296 Apr 8, 2022
3abb9a2
[RENAME] SignupVC 네이밍 변경
wngus4296 Apr 8, 2022
107c9dc
[RENAME] 비밀번호 눈 버튼 관련 변수명 변경
wngus4296 Apr 8, 2022
44916ef
[REFACTOR] viewDidLoad의 버튼 옵션 설정 함수화
wngus4296 Apr 8, 2022
aff446f
[RENAME] storyboardIdentifier 변경
wngus4296 Apr 8, 2022
8394cc9
[FEAT] 로그인 화면으로 돌아올 때 TextField 초기화
wngus4296 Apr 8, 2022
e74bea1
[REFACTOR] TextField 확인 시 text.isEmpty -> .hasText 변경
wngus4296 Apr 8, 2022
dff5b67
[REFACTOR] 비밀번호 눈 버튼 이미지 설정 삼항연산자 사용
wngus4296 Apr 8, 2022
dd54532
[REFACTOR] 비밀번호 눈 버튼 클릭 시 로직 순서 변경
wngus4296 Apr 8, 2022
73994e0
[FIX] userIdTextField -> idTextField로 변수명 변경
wngus4296 Apr 10, 2022
18e351c
[REFACTOR] hasText 자체 리턴 값으로 설정
wngus4296 Apr 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
375 changes: 375 additions & 0 deletions Instagram/Instagram.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
56 changes: 56 additions & 0 deletions Instagram/Instagram/AddNameToSignupViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// AddNameToSignupViewController.swift
// Instagram
//
// Created by 변주현 on 2022/04/07.
//

import UIKit

class AddNameToSignupViewController: UIViewController {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(담인님 리뷰에 썼던거 긁어왔어여..!! 더 이상 상속되지 않는다면 앞에 final 키워드를 붙이면 좋을 것 같습니다~!)

swift에서 더 이상 상속되지 않는 클래스에는 final 키워드를 붙여주면 훨씬 성능이 좋은 코드가 됩니다!!
클래스를 호출할때 스위프트에서는 Dynamic한 방법을 사용하는데 이게 성능을 떨어뜨리는 요소중 하나에요!
그래서 final을 붙여주면 Dynaimc -> Static 한 방식으로 바꿔준답니다,,

요건 링크를 첨부하면 좋을 것 같아서..몇가지 남기고 갑니다..
https://docs.swift.org/swift-book/LanguageGuide/Inheritance.html#ID202
https://velog.io/@ryan-son/Swift-final-%ED%82%A4%EC%9B%8C%EB%93%9C-%EC%99%9C-%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94%EA%B1%B8%EA%B9%8C
https://jellysong.tistory.com/122

그래서 지금 이 SignInViewController가 어디선가 상속될 클래스가 아니라면 final class SignInViewController: UIViewControleller { ~~ 로 적어주심 좋을 것 같아요!!


@IBOutlet weak var userIdTextField: UITextField!
@IBOutlet weak var nextButton: UIButton!
var userName: String?

override func viewDidLoad() {
super.viewDidLoad()

setButtonOption()
setTextFieldOption()
addActionToTextField()
}

private func setButtonOption() {
// 다음 버튼 비활성화
nextButton.isEnabled = false
Comment on lines +24 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요 부분은 초기에 세팅하는 부분인거 같은데 스토리보드를 사용하면 스토리보드 인스펙터 부분에서 Enable 설정해줄수도있어요!!
image

}

private func setTextFieldOption() {
// TextField에 입력하면 Clear 버튼이 나오도록 표시
userIdTextField.clearButtonMode = .whileEditing
}

private func addActionToTextField() {
// TextField에 이벤트 감지 시 함수 실행을 위한 addTarget() 설정
self.userIdTextField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
}

@objc func textFieldDidChange(sender: UITextField) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

질문 있습니다 !! @objc 는 키보드 입력으로 실시간으로 바뀐걸 반응하려고 넣는건가요..? 꼭 넣어야하는건가요...? 코베 어려워요 . . . 🥲

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 궁금합니다 !!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

부족하지만,, 아는 선에서 최대한 자세히 설명해보겠습니다.. 하하
먼저 @objc는 Objective-C 약칭인데요!

저는 TextField에 입력이 되면 버튼을 활성화 시키는 기능을 구현하기 위해서 이벤트 감지 메서드 addTarget()을 사용해주었습니다.
만약 userIdTextField에 입력이 된다면 action에 보이는 #selector()에 적어준 함수가 실행됩니다.
제 코드로 보면 textFieldDidChange함수가 실행되겠죠?!

#selector가 Objective-C의 개념이기 때문에 실행시킬 함수(textFieldDidChange)에 @objc를 적어주는 겁니다!

저도 기능 구현할 때 찾아봤던 내용이라 도움 되었던 자료 공유하겠습니다 🔥
TextField 감지하는 버튼 만들기: https://kirkim.github.io/swift/2021/12/11/backspace.html
selector란?: https://woozzang.tistory.com/120

self.nextButton.isEnabled = sender.hasText ? true : false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sender.hasText자체가 true/false값이기 때문에

self.nextButton.isEnabled = sender.hasText 로만 써도 될 것 같아요!!

}

@IBAction func backButtonDidTap(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}

@IBAction func nextButtonDidTap(_ sender: Any) {
guard let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "AddPasswordToSignupViewController") as? AddPasswordToSignupViewController else { return }

// 회원가입(2) VC로 사용자 이름 전달
nextVC.userId = userIdTextField.text

self.navigationController?.pushViewController(nextVC, animated: true)
}

}
57 changes: 57 additions & 0 deletions Instagram/Instagram/AddPasswordToSignupViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// AddPasswordToSignupViewController.swift
// Instagram
//
// Created by 변주현 on 2022/04/07.
//

import UIKit

class AddPasswordToSignupViewController: UIViewController {

@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var nextButton: UIButton!
var userId: String?

override func viewDidLoad() {
super.viewDidLoad()

setButtonOption()
setTextFieldOption()
addActionToTextField()
}

private func setButtonOption() {
// 다음 버튼 비활성화
nextButton.isEnabled = false
}

private func setTextFieldOption() {
// TextField에 입력하면 Clear 버튼이 나오도록 표시
passwordTextField.clearButtonMode = .whileEditing
}

Comment on lines +24 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요부분도 스토리보드의 장점을 살린다면 스토리보드 인스펙터 창에서 직접 설정해줄 수도 있을 것같아요!!! 하지만 그저 취향차이니까 코드도 좋습니다~!~!!

private func addActionToTextField() {
// TextField에 이벤트 감지 시 함수 실행을 위한 addTarget() 설정
self.passwordTextField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
}

@objc func textFieldDidChange(sender: UITextField) {
self.nextButton.isEnabled = sender.hasText ? true : false
}

@IBAction func backButtonDidTap(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}

@IBAction func nextButtonDidTap(_ sender: Any) {
guard let signinVC = self.storyboard?.instantiateViewController(withIdentifier: "SigninViewController") as? SigninViewController else { return }

signinVC.modalPresentationStyle = .fullScreen
// 회원가입(1)에서 받아온 사용자 id를 로그인 완료 VC로 전달
signinVC.userId = userId

self.present(signinVC, animated: true, completion: nil)
}

}
36 changes: 36 additions & 0 deletions Instagram/Instagram/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// AppDelegate.swift
// Instagram
//
// Created by 변주현 on 2022/04/07.
//

import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Instagram/Instagram/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Instagram Black Logo.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Instagram Black [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Instagram Black [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icn_back_24.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "password hidden eye icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "password hidden eye [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "password hidden eye [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "password shown eye icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "password shown eye [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "password shown eye [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading