Skip to content

Commit

Permalink
#42 취향찾기 request 영어로 보내기로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
doyeonk429 committed Aug 17, 2024
1 parent 080191a commit 2d11655
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import UIKit

class TasteTestFirstCollectionViewCell: UICollectionViewCell {
var kindEngName : String = ""
let imageView: UIImageView = {
let iv = UIImageView()
iv.layer.cornerRadius = 10
Expand Down Expand Up @@ -52,10 +53,11 @@ class TasteTestFirstCollectionViewCell: UICollectionViewCell {
}
}

func configure(imageName: String) {
func configure(imageName: String, kindName : String) {
if let image = UIImage(named: imageName) {
self.name.text = imageName
imageView.image = image
self.kindEngName = kindName
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import UIKit

class TasteTestSecondCollectionViewCell: UICollectionViewCell {
var nationEngName : String = ""

let View: UIView = {
let v = UIView()
Expand Down Expand Up @@ -65,14 +66,15 @@ class TasteTestSecondCollectionViewCell: UICollectionViewCell {
}
}

func configure(imageName: String) {
func configure(imageName: String, nationName: String) {
if let image = UIImage(named: imageName) {
if (imageName == "기타1") {
self.name.text = "기타"
} else {
self.name.text = imageName
}
imageView.image = image
self.nationEngName = nationName
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit
class ThirdKindTasteTestViewController: UIViewController {

var kind: [String] = ["레드", "화이트", "스파클링", "로제", "주정강화", "네츄럴", "기타"]
var kindEng : [String] = ["Red", "White", "Sparkling", "Rose", "Port", "Natural", "etc"]
var selectedIndexPaths: [IndexPath] = []
var selectedWineName : [String] = []

Expand Down Expand Up @@ -149,7 +150,7 @@ extension ThirdKindTasteTestViewController: UICollectionViewDataSource, UICollec

let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TasteTestFirstCollectionViewCell", for: indexPath) as! TasteTestFirstCollectionViewCell

cell.configure(imageName: kind[indexPath.item])
cell.configure(imageName: kind[indexPath.item], kindName: kindEng[indexPath.item])

return cell
}
Expand All @@ -162,8 +163,9 @@ extension ThirdKindTasteTestViewController: UICollectionViewDataSource, UICollec
cell.imageView.layer.borderWidth = 4 // 테두리 두께 설정

// 선택된 셀의 indexPath를 배열에 추가

selectedIndexPaths.append(indexPath)
selectedWineName.append(cell.name.text ?? "")
selectedWineName.append(cell.kindEngName)
} else {
// 셀이 이미 선택된 상태였을 때 (다시 클릭하면 원래대로)
cell.imageView.layer.borderWidth = 0
Expand All @@ -173,7 +175,7 @@ extension ThirdKindTasteTestViewController: UICollectionViewDataSource, UICollec
selectedIndexPaths.remove(at: index)
}

selectedWineName = selectedWineName.filter{$0 != (cell.name.text ?? "")}
selectedWineName = selectedWineName.filter{$0 != (cell.kindEngName)}
}

// nextButton의 상태 업데이트
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit
class ThirdNationTasteTestViewController: UIViewController {

var nation: [String] = ["프랑스", "이탈리아", "미국", "칠레", "스페인", "호주", "아르헨티나", "독일", "뉴질랜드", "포르투갈", "오스트리아", "그리스", "슬로베니아", "헝가리", "캐나다", "대한민국", "기타1"]
var nationEng: [String] = ["France", "Italy", "United States", "Chile", "Spain", "Australia", "Argentina", "Germany", "New Zealand", "Portugal", "Austria", "Greece", "Slovenia", "Hungary", "Canada", "South Korea", "Other"]
var selectedIndexPaths: [IndexPath] = []
private var selectedNations : [String] = []

Expand Down Expand Up @@ -148,7 +149,7 @@ extension ThirdNationTasteTestViewController: UICollectionViewDataSource, UIColl

let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TasteTestSecondCollectionViewCell", for: indexPath) as! TasteTestSecondCollectionViewCell

cell.configure(imageName: nation[indexPath.item])
cell.configure(imageName: nation[indexPath.item], nationName: nationEng[indexPath.item])

return cell
}
Expand All @@ -162,7 +163,7 @@ extension ThirdNationTasteTestViewController: UICollectionViewDataSource, UIColl

// 선택된 셀의 indexPath를 배열에 추가
selectedIndexPaths.append(indexPath)
selectedNations.append(cell.name.text ?? "")
selectedNations.append(cell.nationEngName)

} else {
// 셀이 이미 선택된 상태였을 때 (다시 클릭하면 원래대로)
Expand All @@ -173,7 +174,7 @@ extension ThirdNationTasteTestViewController: UICollectionViewDataSource, UIColl
selectedIndexPaths.remove(at: index)
}

selectedNations = selectedNations.filter{$0 != (cell.name.text ?? "")}
selectedNations = selectedNations.filter{$0 != (cell.nationEngName)}
}

// nextButton의 상태 업데이트
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class ThirdVarietyTasteTestViewController: UIViewController {
func callAPI(completion: @escaping (Bool) -> Void) {
if let data = self.memberInfoDTO {
provider.request(.patchMember(data: data)) { result in
print(data)
switch result {
case .success(let response):
do {
Expand Down

0 comments on commit 2d11655

Please sign in to comment.