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] Assignment4 #8

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

[Feat] Assignment4 #8

wants to merge 5 commits into from

Conversation

daminoworld
Copy link
Contributor

@daminoworld daminoworld commented May 15, 2022

๐ŸŒฑ ์ž‘์—…ํ•œ ๋‚ด์šฉ

๊ธฐ๋ณธ ๊ณผ์ œ

  • ์ธ์Šคํƒ€๊ทธ๋žจ ํด๋ก ์•ฑ ๋‚ด ๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž…์„ Alamofier๋ฅผ ์‚ฌ์šฉํ•ด API ๊ธฐ๋ฐ˜ ์—ฐ๊ฒฐ ๊ตฌํ˜„
    ๋„์ „ ๊ณผ์ œ - 1
  • GET ํ†ต์‹ ์„ ์ด์šฉํ•ด์„œ picsum ์‚ฌ์ดํŠธ์˜ api๋ฅผ ์ด์šฉํ•ด ์ด๋ฏธ์ง€ url์„ ๋‹ด๊ณ  ์žˆ๋Š” Json ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ

๋„์ „๊ณผ์ œ - 2 ๊ฐ€์ ธ์˜จ ์ด๋ฏธ์ง€ url์„ ์ด์šฉํ•ด ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์™€ ํ”ผ๋“œ ์ด๋ฏธ์ง€์— ๋„์›Œ์ฃผ๋Š”๊ฑด๋ฐ ์‹œ๊ฐ„์ด ์—†์–ด ๊ตฌํ˜„ํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค..
์‹œ๊ฐ„ ๋  ๋•Œ ์ถ”๊ฐ€์ ์œผ๋กœ ๊ตฌํ˜„ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹คใ… 

๐ŸŒฑ PR Point

PR Point 1

  • ๊ธฐ๋ณธ ๊ณผ์ œ์— ์žˆ๋Š”๊ฑฐ๋Š” ๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž…์— ์„ฑ๊ณตํ–ˆ์„๋•Œ ๋ฉ”์‹œ์ง€๋งŒ ์•Œ๋ฆผ์ฐฝ์œผ๋กœ ๋„์›Œ์ฃผ๋Š”๊ฒƒ์ด์˜€๋Š”๋ฐ
    ์‹คํŒจํ–ˆ์„๋•Œ ์‘๋‹ต์„ status ์ฝ”๋“œ๋กœ ๋ถ„๊ธฐ์ฒ˜๋ฆฌํ•˜๊ณ  ๋ฉ”์‹œ์ง€๋ฅผ ๋ณ€๊ฒฝํ•ด ์™œ ์‹คํŒจ ํ–ˆ๋Š”์ง€
    ( ex. ์ค‘๋ณต ์•„์ด๋””(ํšŒ์›๊ฐ€์ž…), ๋น„๋ฐ€๋ฒˆํ˜ธ ํ‹€๋ฆผ(๋กœ๊ทธ์ธ))๋ฅผ ํ‘œ์‹œํ•ด ์ฃผ์—ˆ๊ณ 
    ํŠนํžˆ ํšŒ์›๊ฐ€์ž…์—์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ๊นŒ์ง€ ์ž…๋ ฅ์™„๋ฃŒํ•˜๊ณ  ์•„์ด๋”” ์ค‘๋ณต์œผ๋กœ ์‹คํŒจํ–ˆ์„๋•Œ
    ์ค‘๋ณต ์•Œ๋ฆผ ๋ฉ”์‹œ์ง€์™€ ํ•จ๊ป˜ ์•„์ด๋”” ์ž…๋ ฅํŽ˜์ด์ง€๋กœ ๋‹ค์‹œ ๋Œ์•„๊ฐ€๊ฒŒ ํ•ด์„œ ๊ณผ์ œ ๋‚ด์—์„œ UX ๊ฒฝํ—˜์„ ๊ฐœ์„ ํ•˜๋ ค๊ณ  ๋…ธ๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค^^

  • ๊ทธ๋Ÿฌ๋‚˜ signUpPasswordViewController์—์„œ ๋ถ„๊ธฐ์ฒ˜๋ฆฌ๋ฅผ ํ• ๋•Œ
    ํ†ต์‹ ํ•จ์ˆ˜( signUp() ) ๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ํ•˜๊ณ  ๊ทธ ์•ˆ์—์„œ ์‘๋‹ต ์ฝ”๋“œ์— ๋”ฐ๋ผ
    ์„ฑ๊ณต์˜ ์œ ๋ฌด๋ฅผ ํŒ๋‹จํ•˜๋Š” Bool ํƒ€์ž… ๋ณ€์ˆ˜ isSignUpSuccess๋กœ ๊ฐ’์„ ๋ณ€๊ฒฝํ•ด์ฃผ์–ด
    ๊ทธ ๊ฐ’์— ๋”ฐ๋ผ ์–ด๋–ป๊ฒŒ ํ™”๋ฉด ์ „ํ™˜์„ ํ• ์ง€ ๊ฒฐ์ •ํ•˜๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ
    ๋น„๋™๊ธฐ์ ์œผ๋กœ signUp ํ•จ์ˆ˜๊ฐ€ ๋๋‚˜๊ธฐ๋„ ์ „์— ( isSignUpSuccess๊ฐ€ ๋ฐ”๋€Œ๊ธฐ๋„ ์ „์—)
    ๊ธฐ์กด ๊ฐ’์œผ๋กœ ํ™”๋ฉด์ „ํ™˜์ด ์ด๋ฃจ์–ด์ง€๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ด์„œ

๊ฒฐ๊ณผ์ ์œผ๋กœ ์•„๋ž˜์™€ ๊ฐ™์ด ์•„์˜ˆ ์‘๋‹ต์„ ๋ฐ›๋Š” ํ•จ์ˆ˜ ์•ˆ์— ๋ถ„๊ธฐ์ฒ˜๋ฆฌ๋กœ case์— ๋”ฐ๋ผ ํ™”๋ฉด ์ „ํ™˜์ด ๋˜๋„๋ก ํ–ˆ๋Š”๋ฐ ์ด๋Ÿฐ์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜๋Š”๊ฒŒ ์ข€ ์•„๋‹Œ๊ฒƒ ๊ฐ™์•„์„œ ํ”ผ๋“œ๋ฐฑ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค!ใ… 
Screen Shot 2022-05-15 at 11 47 45 PM

๐Ÿ“ธ ์Šคํฌ๋ฆฐ์ƒท

แ„‹แ…กแ„‹แ…ตแ„ƒแ…ต แ„Œแ…ฎแ†ผแ„‡แ…ฉแ†จ แ„’แ…ฌแ„‹แ…ฏแ†ซแ„€แ…กแ„‹แ…ตแ†ธ แ„‰แ…ฅแ†ผแ„€แ…ฉแ†ผ
แ„’แ…ฌแ„‹แ…ฏแ†ซแ„€แ…กแ„‹แ…ตแ†ธ แ„‰แ…ตแ†ฏแ„‘แ…ข - แ„‹แ…กแ„‹แ…ตแ„ƒแ…ต แ„Œแ…ฎแ†ผแ„‡แ…ฉแ†จ แ„’แ…ฌแ„‹แ…ฏแ†ซแ„€แ…กแ„‹แ…ตแ†ธ แ„‰แ…ฅแ†ผแ„€แ…ฉแ†ผ
แ„‹แ…กแ„‹แ…ตแ„ƒแ…ต แ„‡แ…ฎแ†ฏแ„‹แ…ตแ†ฏแ„Žแ…ต แ„…แ…ฉแ„€แ…ณแ„‹แ…ตแ†ซ แ„‰แ…ฅแ†ผแ„€แ…ฉแ†ผ
แ„‹แ…กแ„‹แ…ตแ„ƒแ…ต แ„‡แ…ฎแ†ฏแ„‹แ…ตแ†ฏแ„Žแ…ต แ„…แ…ฉแ„€แ…ณแ„‹แ…ตแ†ซ แ„‰แ…ฅแ†ผแ„€แ…ฉแ†ผ

๐Ÿ“ฎ ๊ด€๋ จ ์ด์Šˆ

๋นˆ์ค„ ์‚ญ์ œ
- APIConstants, NetworkResult, LoginModel, UserService ํŒŒ์ผ ์ถ”๊ฐ€ ๋ฐ LoginViewController์— ํ†ต์‹  ์ฝ”๋“œ ์ถ”๊ฐ€
- ๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž… API ์—ฐ๊ฒฐ
- ๋กœ๊ทธ์ธ ์„ฑ๊ณต ๋ฐ ์‹คํŒจ ๋ณ„ ์•Œ๋ฆผ ๋ฉ”์‹œ์ง€ ๋ฐ ๋™์ž‘ ๋ณ€๊ฒฝ
- ํšŒ์›๊ฐ€์ž… ์„ฑ๊ณต ๋ฐ ์‹คํŒจ ๋ณ„ ์•Œ๋ฆผ ๋ฉ”์‹œ์ง€ ๋™์ž‘ ๋ณ€๊ฒฝ
- ๊ฐ€์ž… ์™„๋ฃŒ์‹œ์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์„œ๋ฒ„ ํ†ต์‹  ํ•จ์ˆ˜ ๋‚ด๋ถ€์—  
- response code์— ๋”ฐ๋ฅธ ํ™”๋ฉด์ „ํ™˜ ์ฒ˜๋ฆฌ
- Get ํ†ต์‹ ์œผ๋กœ Picsum API ๋ฅผ ํ†ตํ•ด Json์œผ๋กœ ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ ๊นŒ์ง€ ๊ตฌํ˜„ํ•จ
Copy link
Member

@devxsby devxsby left a comment

Choose a reason for hiding this comment

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

๊ณผ์ œ ์ œ์ถœํ•˜์‹œ๋Š๋ผ ๋Šฆ์€ ์‹œ๊ฐ๊นŒ์ง€ ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค. !!!

์„œ๋ฒ„์™€ ์—ฐ๊ฒฐ์„ ํ•˜๋Š” ๊ฒƒ์— ๊ด€ํ•ด ์ƒ๊ฐ์„ ๋งŽ์ด ํ•ด๋ณด์‹ ๊ฒŒ ๋Š๊ปด์ ธ์š” ๐Ÿ‘

์ถ”๊ฐ€๋กœ gitignore์— ์ฝ”์ฝ”์•„ํŒŸ์ด ์—†์–ด์„œ ๊ด€๋ จ ํŒŒ์ผ์ด ๋‹ค ์˜ฌ๋ผ์˜ค๋Š” ๊ฒƒ ๊ฐ™์€๋ฐ ์ถ”๊ฐ€ํ•˜์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์šฉ ๐Ÿ˜

PR ํฌ์ธํŠธ์— ์ ์€ ์‚ฌํ•ญ๋„ ์ œ๊ฐ€ ์•„๋Š” ๋ถ€๋ถ„์—์„œ ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊ฒผ๋Š”๋ฐ ํ•ด๊ฒฐ์ด ๋  ์ง„ ๋ชจ๋ฅด๊ฒ ์œผ๋‚˜, ๊ณ„์† ๊ณ ๋ฏผํ•ด๋ณด๊ณ  ์ถ”ํ›„์— ๋ฆฌํŒฉํ† ๋ง์œผ๋กœ ๊ฐœ์„ ๋œ ์ฝ”๋“œ๊ฐ€ ๋˜๋ฉด ๋” ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค~~~

์ด์ œ ๋‹น๊ทผ.. ํ•˜๋Ÿฌ ๊ฐ€์‹œ์ฃ ... ๐Ÿ‘ฉ๐Ÿปโ€๐ŸŒพ๐Ÿฅ•

Comment on lines +82 to +86
passwordTextField.isSecureTextEntry.toggle()
passwordEyeButton.isSelected.toggle()
let eyeImage = passwordEyeButton.isSelected ? "icn_password_shown" : "icn_password_hidden"
passwordEyeButton.setImage(UIImage(named: eyeImage), for: .normal)
passwordEyeButton.tintColor = .clear
Copy link
Member

Choose a reason for hiding this comment

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

passwordEyeButton.isSelected.toggle() ์ด ์ฝ”๋“œ ๋ง๊ณ ๋Š” ๋‹ค ์Šคํ† ๋ฆฌ๋ณด๋“œ์—์„œ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฑธ๋กœ ์•„๋Š”๋ฐ, ์ฝ”๋“œ๋ง๊ณ  ์Šค๋ณด๋กœ ํ•ด๋ณด์‹œ๋Š” ๊ฒƒ๋„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹น~~

Comment on lines +115 to +117
guard let name = userNameTextField.text else { return }
guard let email = userNameTextField.text else { return }
guard let password = passwordTextField.text else { return }
Copy link
Member

Choose a reason for hiding this comment

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

guard let ๊ตฌ๋ฌธ ์ข‹๋„ค์š” ๐Ÿ‘

Comment on lines +126 to +144
case .success(let data):
guard let data = data as? LoginResponse else { return }

var message:String
// LoginResponse์˜ ์ƒํƒœ์— ๋”ฐ๋ฅธ ๋ฉ”์‹œ์ง€ ๋ถ„๊ธฐ์ฒ˜๋ฆฌ
switch data.status {
case 404:
message = "์ผ์น˜ํ•˜๋Š” ์•„์ด๋””๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."
self.isLoginSuccess = false
case 409:
message = "๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."
self.isLoginSuccess = false
default:
message = data.message
self.isLoginSuccess = true
guard let signInCompletedVC = UIStoryboard(name: "SignInCompleted", bundle: nil).instantiateViewController(withIdentifier: "SignInCompletedViewController") as? SignInCompletedViewController else {return}
signInCompletedVC.userName = self.userNameTextField.text

self.navigationController?.pushViewController(signInCompletedVC, animated: true)
Copy link
Member

Choose a reason for hiding this comment

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

switch ๊ตฌ๋ฌธ์—์„œ case .success ์ฝ”๋“œ ์•ˆ์— ๋˜ switch ๊ตฌ๋ฌธ์œผ๋กœ request์—๋Ÿฌ ํƒ€์ž…์„ ๋„ฃ์œผ์‹  ๊ฑฐ๋Š” ์–ด๋–ค ์ด์œ ์ด์‹ค๊นŒ์š”...? PR ํฌ์ธํŠธ1์— ๊ด€ํ•œ ๋‚ด์šฉ์ผ๊นŒ์š”??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

success = ํ†ต์‹  ๋์„๋•Œ ๋ผ๊ณ  ์ƒ๊ฐํ•˜๊ณ  ๊ทธ๋ƒฅ requestErr๋ฅผ ๋”ฐ๋กœ ๊ตฌ๋ถ„ ์•ˆํ•˜๊ณ  ๋กœ๊ทธ์ธ ๋ฉ”์‹œ์ง€๋งŒ ๊ตฌ๋ถ„ํ•˜๋ ค๊ณ  switch๊ตฌ๋ฌธ์— ๊ฐ™์ด ๋„ฃ์–ด์คฌ์Šต๋‹ˆ๋‹ค..๊ทผ๋ฐ ์ด๊ฒƒ๋„ ๋”ฐ๋กœ request์—๋Ÿฌ๋ฅผ ๊ตฌ๋ถ„ํ•ด์ค˜์•ผ๊ฒ ๋„ค์š”ใ…Žใ…Ž ์ข‹์€ ์ง€์  ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹คใ…Žใ…Ž

// ์„ฑ๊ณต ์‹œ์—๋Š” ๋„˜๊ฒจ๋ฐ›์€ ๋ฐ์ดํ„ฐ๋ฅผ decode(ํ•ด๋…)ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœ
// statusCode๊ฐ€ 200~400๋Œ€ ์ผ๋•Œ๋Š” ํ†ต์‹ ์— ์ด์ƒ์žˆ๋Š”๊ฒƒ์ด ์•„๋‹ˆ๋ผ ๋‘˜๋‹ค isValidLoginDataํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœ
case 200..<300: return isVaildLoginData(data: data)
case 400..<500: return isVaildLoginData(data: data)
Copy link
Member

@devxsby devxsby May 17, 2022

Choose a reason for hiding this comment

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

isVaildLoginDataํ•จ์ˆ˜๋Š” .success(decodedData as Any)๋ฅผ ๋ฆฌํ„ดํ•˜๊ธฐ ๋•Œ๋ฌธ์—,
์—ฌ๊ธฐ ๋ถ€๋ถ„์€ isInVaildLoginData ํ•จ์ˆ˜๋ฅผ ๋”ฐ๋กœ ๋งŒ๋“ค์–ด์„œ .requestErr(decodedData)์„ ๋ฆฌํ„ดํ•˜๋„๋ก ํ•˜๋Š”๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค..!

private func isInVaildSignUpData(data: Data) -> NetworkResult<Any> {
         let decoder = JSONDecoder()
         guard let decodedData = try? decoder.decode(SignUpResponse.self, from: data)
         else { return .pathErr }
          
         return.requestErr(decodedData)
     }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

์•„ ๋„ค๋„ค ๋งž์Šต๋‹ˆ๋‹ค ์—ญ์‹œ ์ˆ˜๋นˆ์„ ๋ฐฐ ๋ฐ”๋กœ ์ฐพ์œผ์…จ๋„ค์š”ใ…Žใ…Ž ์‚ฌ์‹ค ์ฒ˜์Œ์— .success๊ฐ€ ํ†ต์‹ ์ด ๋๋‚˜ ์•ˆ๋๋‚˜๋ผ๊ณ  ์ƒ๊ฐํ•ด์„œ success ๋์„๋•Œ๋„ ๊ทธ๋ƒฅ isValid ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰์‹œ์ผœ์คฌ๋Š”๋ฐ ๋‹ค์‹œ ๋ณด๋‹ˆ๊นŒ ์ˆ˜๋นˆ๋‹˜ ๋ง์”€ํ•˜์‹  ๊ฒƒ์ฒ˜๋Ÿผ ํ•จ์ˆ˜๋ฅผ ๋”ฐ๋กœ ๋งŒ๋“ค์–ด์„œ requestErr๋ฅผ ๊ตฌ๋ถ„ํ•ด์•ผ๊ฒ ๋”๋ผ๊ตฌ์š”,,, ๋งค๋ฒˆ ์นœ์ ˆํ•œ ์ง€์  ์ข‹์•„์š”ใ…Žใ…Ž ์‹œ๊ฐ„๋‚ ๋•Œ ๋‹ค๋ฅธ๊ฒƒ๊นŒ์ง€ ๊ฐ™์ด ๋ฆฌํŒฉํ† ๋ง ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค,,๐Ÿ˜†

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] iOS 4์ฐจ ๊ณผ์ œ
2 participants