Skip to content

Commit

Permalink
Merge branch 'Dev' into DY
Browse files Browse the repository at this point in the history
  • Loading branch information
doyeonk429 authored Aug 18, 2024
2 parents 715a35c + 7ff420f commit c3324d7
Show file tree
Hide file tree
Showing 25 changed files with 401 additions and 217 deletions.
2 changes: 1 addition & 1 deletion Drink-EG/Drink-EG/Resources/APIs/TastingNoteAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension TastingNoteAPI: TargetType {
return "tasting-note/\(noteId)"
case .postNewNote:
return "tasting-note/new-note"
case .patchNote(let wineId, let color, let sugarContent, let acidity, let tannin, let body, let alcohol, let scentAroma, let scentTaste, let scentFinish, let satisfaction, let review):
case .patchNote(let wineId, _, _, _, _, _, _, _, _, _, _, _):
return "wine-note/\(wineId)"
case .deleteNote(let noteId):
return "tasting-note/\(noteId)"
Expand Down
2 changes: 1 addition & 1 deletion Drink-EG/Drink-EG/Resources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
class AppDelegate: UIResponder, UIApplicationDelegate {

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 @@ -13,4 +13,6 @@ struct Wine: Codable {
let imageUrl: String?
let rating: Double
let price: Int
let area: String
let sort: String
}
15 changes: 13 additions & 2 deletions Drink-EG/Drink-EG/Sources/VCs/AddNewNoteViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ class AddNewNoteViewController: UIViewController, UITableViewDataSource, UITable
suggestionTableView.dataSource = self
suggestionTableView.delegate = self
suggestionTableView.register(CustomSuggestionCell.self, forCellReuseIdentifier: "cell")

}

func setupSuggestionTableViewConstraints() {
suggestionTableView.snp.makeConstraints{ make in
make.top.equalTo(wineSearchBar.snp.bottom).offset(35)
make.leading.equalTo(wineSearchBar.snp.leading).offset(13)
make.trailing.equalTo(wineSearchBar.snp.trailing).offset(-13)
make.height.greaterThanOrEqualTo(282)
make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-188)
}
}

Expand All @@ -123,12 +124,21 @@ class AddNewNoteViewController: UIViewController, UITableViewDataSource, UITable
}
}

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 8 // 섹션 간의 간격
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return wineResults.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomSuggestionCell
cell.layer.borderWidth = 2
cell.layer.borderColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.05).cgColor
cell.layer.cornerRadius = 10
cell.backgroundColor = UIColor(red: 0.898, green: 0.898, blue: 0.898, alpha: 1)

let wine = wineResults[indexPath.row]
cell.configure(with: wine, isSelected: false)
return cell
Expand All @@ -147,12 +157,13 @@ class AddNewNoteViewController: UIViewController, UITableViewDataSource, UITable
wineSearchBar.text = selectedWine.name
wineResults = []
suggestionTableView.reloadData()

// 다음 화면으로 이동
let nextVC = WriteNoteViewController()
nextVC.selectedWineName = selectedWine.name
nextVC.selectedWineImage = selectedWine.imageUrl
nextVC.selectedWineId = selectedWine.wineId
nextVC.selectedWineSort = selectedWine.sort
nextVC.selectedWineArea = selectedWine.area
navigationController?.pushViewController(nextVC, animated: true)
}

Expand Down
11 changes: 7 additions & 4 deletions Drink-EG/Drink-EG/Sources/VCs/ChooseTasteViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class ChooseTasteViewController: UIViewController {
var selectedWineId: Int?
var selectedWineImage: String?
var selectedWineName: String?
var selectedWineArea: String?
var selectedWineSort: String?

override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -164,7 +166,7 @@ class ChooseTasteViewController: UIViewController {
wineName.snp.makeConstraints{ make in
make.leading.equalTo(wineImageView.snp.trailing).offset(20)
make.trailing.equalTo(wineView.snp.trailing).offset(-10)
make.top.equalTo(wineView.snp.top).offset(36)
make.centerY.equalTo(wineView.snp.centerY)
}
}

Expand Down Expand Up @@ -302,9 +304,9 @@ class ChooseTasteViewController: UIViewController {
// Determine which section the button belongs to
var section: String?
if tasteOptions[0].contains(sender) {
section = "Aroma"
section = "scentAroma"
} else if tasteOptions[1].contains(sender) {
section = "Taste"
section = "scentTaste"
} else if tasteOptions[2].contains(sender) {
section = "Finish"
}
Expand Down Expand Up @@ -361,7 +363,6 @@ class ChooseTasteViewController: UIViewController {
make.height.equalTo(buttonHeight)
}
}

}

func setupTasteOptionsLabelConstraints() {
Expand Down Expand Up @@ -441,6 +442,8 @@ class ChooseTasteViewController: UIViewController {
nextVC.selectedWineId = selectedWineId
nextVC.selectedWineName = selectedWineName
nextVC.selectedWineImage = selectedWineImage
nextVC.selectedWineArea = selectedWineArea
nextVC.selectedWineSort = selectedWineSort

navigationController?.pushViewController(nextVC, animated: true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ class SelectLoginViewController: UIViewController, ASAuthorizationControllerDele
let joinStackView = UIStackView(arrangedSubviews: [label, joinButton])
joinStackView.axis = .horizontal
joinStackView.distribution = .fillProportionally
joinStackView.spacing = 4
joinStackView.spacing = 6

view.addSubview(joinStackView)
joinStackView.snp.makeConstraints { make in
// make.top.equalTo(loginButton.snp.bottom).offset(50)
make.centerX.equalTo(view.safeAreaLayoutGuide)
make.width.greaterThanOrEqualTo(200)
make.bottom.equalTo(view.safeAreaLayoutGuide).inset(25)
}
}
Expand Down
42 changes: 19 additions & 23 deletions Drink-EG/Drink-EG/Sources/VCs/Main/CartListCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@
import UIKit
import SnapKit

protocol CartListCollectionViewCellDelegate: AnyObject {
func checkButtonTapped(on cell: CartListCollectionViewCell, isSelected: Bool)
}

class CartListCollectionViewCell: UICollectionViewCell {

weak var delegate: CartListCollectionViewCellDelegate?
var changeMarketButtonAction : (() -> Void) = {}

private var quantity: Int = 1 {
var quantity: Int = 1 {
didSet {
updateNumLabel()
}
}

private let CheckImage = UIImage(named: "icon_cartCheck_fill")
private let nCheckImage = UIImage(named: "icon_cartCheck_nfill")
private let CheckButton = UIButton(type: .custom)
let CheckButton = UIButton(type: .custom)
var shop = "PODO"
var price = 27000
var price = 0

private let imageView: UIImageView = {
let iv = UIImageView()
Expand All @@ -43,14 +48,6 @@ class CartListCollectionViewCell: UICollectionViewCell {

let marketNprice = UILabel()

private let score: UILabel = {
let l3 = UILabel()
l3.text = "4.5 ★"
l3.font = .boldSystemFont(ofSize: 12)
l3.textColor = UIColor(hex: "#FF7A6D")
return l3
}()

private let changeMarketButton: UIButton = {
let b = UIButton(type: .system)
b.backgroundColor = UIColor(hex: "#FA735B")
Expand Down Expand Up @@ -126,13 +123,13 @@ class CartListCollectionViewCell: UICollectionViewCell {
return b
}()

private func configureCheckButton() {
func configureCheckButton() {
CheckButton.setImage(nCheckImage?.withRenderingMode(.alwaysOriginal), for: .normal)
CheckButton.backgroundColor = .clear
CheckButton.addTarget(self, action: #selector(CheckButtonTapped), for: .touchUpInside)
}

@objc private func CheckButtonTapped(_ sender: UIButton) {
@objc func CheckButtonTapped(_ sender: UIButton) {
// Bool 값 toggle
sender.isSelected.toggle()

Expand All @@ -146,9 +143,11 @@ class CartListCollectionViewCell: UICollectionViewCell {
self.contentView.backgroundColor = UIColor(hex: "EDEDED")
self.contentView.layer.borderColor = UIColor(hex: "D9D9D9")?.cgColor
}

delegate?.checkButtonTapped(on: self, isSelected: sender.isSelected)
}

private func configureMarketNPlace() {
private func configureMarketNPlace(_ shopName: String, _ priceInt: Int, _ count: Int) {
let firstImageAttachment = NSTextAttachment()
firstImageAttachment.image = UIImage(named: "icon_market")

Expand All @@ -168,15 +167,15 @@ class CartListCollectionViewCell: UICollectionViewCell {
completeText.append(firstAttachmentString)

// 매장 텍스트 추가
let textBeforeSecondImage = NSAttributedString(string: " \(shop) ", attributes: [.font: UIFont.boldSystemFont(ofSize: 12)])
let textBeforeSecondImage = NSAttributedString(string: " \(shopName) ", attributes: [.font: UIFont.boldSystemFont(ofSize: 12)])
completeText.append(textBeforeSecondImage)

// 두 번째 이미지 추가
let secondAttachmentString = NSAttributedString(attachment: secondImageAttachment)
completeText.append(secondAttachmentString)

// 가격 텍스트 추가
let textAfterSecondImage = NSAttributedString(string: " \(price * quantity)", attributes: [.font: UIFont.boldSystemFont(ofSize: 12)])
let textAfterSecondImage = NSAttributedString(string: " \(priceInt * count)", attributes: [.font: UIFont.boldSystemFont(ofSize: 12)])
completeText.append(textAfterSecondImage)

marketNprice.attributedText = completeText
Expand All @@ -195,12 +194,11 @@ class CartListCollectionViewCell: UICollectionViewCell {
//레이아웃까지
private func setupUI() {
configureCheckButton()
configureMarketNPlace()
configureMarketNPlace(self.shop, self.price, self.quantity)

self.contentView.addSubview(imageView)
self.contentView.addSubview(name)
self.contentView.addSubview(marketNprice)
self.contentView.addSubview(score)
self.contentView.addSubview(CheckButton)
self.contentView.addSubview(changeMarketButton)
self.contentView.addSubview(changeNumButton)
Expand Down Expand Up @@ -233,11 +231,6 @@ class CartListCollectionViewCell: UICollectionViewCell {
make.leading.equalTo(name)
}

score.snp.makeConstraints { make in
make.centerY.equalTo(name)
make.leading.equalTo(name.snp.trailing).offset(13)
}

changeMarketButton.snp.makeConstraints { make in
make.bottom.equalToSuperview().inset(14)
make.leading.equalToSuperview().offset(213)
Expand Down Expand Up @@ -272,7 +265,10 @@ class CartListCollectionViewCell: UICollectionViewCell {
self.price = price
self.quantity = count
self.shop = shopName

self.configureMarketNPlace(shopName, price, count)
}

func configure2(isSelected: Bool) {
CheckButton.isSelected = isSelected
}
Expand Down
Loading

0 comments on commit c3324d7

Please sign in to comment.