Skip to content

Commit

Permalink
Merge pull request #86 from joeuni01/feature/#85
Browse files Browse the repository at this point in the history
[Design] #85-상세 메뉴 UI 수정
  • Loading branch information
0lynny committed Jul 16, 2022
2 parents bbc4439 + 454eb51 commit 0d6efb7
Show file tree
Hide file tree
Showing 20 changed files with 79 additions and 45 deletions.
4 changes: 4 additions & 0 deletions HealthFoodMe/HealthFoodMe/Global/Literals/ImageLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ struct ImageLiterals {
static let addPhotoIcon = UIImage(named: "icn_photoAdd")
static let deletePhotoBtn = UIImage(named: "btn_delete")
}

struct MenuTab {
static let emptyCard = UIImage(named: "img_empty_card")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct I18N {
struct Menu {
static let segmentTitle = ["메뉴", "영양정보"]
static let kcalUnit = "kcal"
static let gUnit = "(-g당)"
static let standard = "1인분 (50g)"
static let carbohydrate = "탄수화물"
static let protein = "단백질"
Expand Down
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" : "img_empty_card.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "img_empty_card@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "img_empty_card@3x.png",
"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
Expand Up @@ -52,18 +52,24 @@ extension MenuCellCVC {
}

func setData(menuData: MenuDataModel) {
menuView.menuImageView.image = UIImage(named: "Image")
menuView.menuImageView.image = menuData.memuImageURL == nil ? ImageLiterals.MenuTab.emptyCard : UIImage(named: "Image")
menuView.titleLabel.text = menuData.menuName
menuView.pickImageView.image = menuData.isPick ? UIImage(named: "icn_pick") : .none

menuView.priceLabel.text = "\(menuData.menuPrice)"
menuView.kcalLabel.text = "\(menuData.menuKcal)"

menuDetailView.titleLabel.text = menuData.menuName
menuDetailView.pickImageView.image = menuData.isPick ? UIImage(named: "icn_pick") : .none
menuDetailView.carbohydrateAmountLabel.text = "\(menuData.carbohydrates)g"
menuDetailView.proteinAmountLabel.text = "\(menuData.protein)g"
menuDetailView.fatsAmountLabel.text = "\(menuData.fat)g"
menuDetailView.kcalLabel.text = "\(menuData.menuKcal)"
if menuData.menuKcal == nil {
menuView.kcalView.isHidden = true
} else {
guard let menuKcal = menuData.menuKcal else { return }
menuView.kcalLabel.text = "\(menuKcal)"
}

// 영양정보 부분
// menuDetailView.titleLabel.text = menuData.menuName
// menuDetailView.pickImageView.image = menuData.isPick ? UIImage(named: "icn_pick") : .none
// menuDetailView.carbohydrateAmountLabel.text = "\(menuData.carbohydrates)g"
// menuDetailView.proteinAmountLabel.text = "\(menuData.protein)g"
// menuDetailView.fatsAmountLabel.text = "\(menuData.fat)g"
// menuDetailView.kcalLabel.text = "\(menuData.menuKcal)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ final class MenuTabVC: UIViewController {
setLayout()
setDelegate()
registerCell()

}
}

Expand All @@ -74,9 +73,6 @@ extension MenuTabVC {

private func registerCell() {
MenuCellCVC.register(target: menuCV)
menuCV.register(HeaderView.self,
forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader,
withReuseIdentifier: HeaderView.className)
}

private func lockCollectionView() {
Expand Down Expand Up @@ -112,21 +108,6 @@ extension MenuTabVC: UICollectionViewDataSource {
return MenuDataModel.sampleMenuData.count
}

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {

switch kind {
case UICollectionView.elementKindSectionHeader :
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: HeaderView.className, for: indexPath)
return headerView
default :
return UICollectionReusableView()
}
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: UIScreen.main.bounds.width, height: 68)
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = menuCV.dequeueReusableCell(withReuseIdentifier: MenuCellCVC.className, for: indexPath) as? MenuCellCVC
else { return UICollectionViewCell() }
Expand All @@ -147,7 +128,7 @@ extension MenuTabVC: UICollectionViewDelegateFlowLayout {
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 20, bottom: 60, right: 20)
return UIEdgeInsets(top: 20, left: 20, bottom: 60, right: 20)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import Foundation
struct MenuDataModel: Codable {
let restaurantID: String
let isPick: Bool
let memuImageURL: String
let memuImageURL: String?
let menuName: String
let menuPrice: Int
let menuKcal: Int
let carbohydrates: Int
let protein: Int
let fat: Int
let menuKcal: Int?
let carbohydrates: Int?
let protein: Int?
let fat: Int?
}

extension MenuDataModel {
static var sampleMenuData: [MenuDataModel] = [
MenuDataModel(restaurantID: "1", isPick: true, memuImageURL: "", menuName: "리코타치즈샐러디", menuPrice: 6900,
MenuDataModel(restaurantID: "1", isPick: true, memuImageURL: nil, menuName: "리코타 치즈 샐러디 리코타 치즈 샐러디 ", menuPrice: 6900,
menuKcal: 297, carbohydrates: 24, protein: 12, fat: 14),
MenuDataModel(restaurantID: "2", isPick: true, memuImageURL: "", menuName: "콥샐러디", menuPrice: 6300,
menuKcal: 219, carbohydrates: 34, protein: 13, fat: 15),
Expand All @@ -35,7 +35,6 @@ extension MenuDataModel {
menuKcal: 219, carbohydrates: 74, protein: 17, fat: 56),
MenuDataModel(restaurantID: "3", isPick: false, memuImageURL: "", menuName: "멕시칸랩", menuPrice: 6300,
menuKcal: 565, carbohydrates: 84, protein: 18, fat: 45),
MenuDataModel(restaurantID: "4", isPick: false, memuImageURL: "", menuName: "존맛탱", menuPrice: 6300,
menuKcal: 565, carbohydrates: 94, protein: 19, fat: 34)
MenuDataModel(restaurantID: "4", isPick: false, memuImageURL: "", menuName: "존맛탱", menuPrice: 6300, menuKcal: nil, carbohydrates: nil, protein: nil, fat: nil)
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ final class HeaderView: UICollectionReusableView {
weak var delegate: MenuCVCDelegate?

// MARK: - UI Components

lazy var segementcontrol: UISegmentedControl = {
let items = I18N.Detail.Menu.segmentTitle
let sc = UISegmentedControl(items: items)
sc.center = self.center
sc.selectedSegmentIndex = 0
sc.addTarget(self, action: #selector(indexChanged(_:)), for: .valueChanged)
return sc
private let segementcontrol: CustomSegmentControl = {
let sc = CustomSegmentControl(titleList: ["메뉴", "영양정보"])
return sc
}()

// MARK: - View Life Cycle
Expand All @@ -46,6 +41,7 @@ extension HeaderView {
private func setLayout() {
self.addSubview(segementcontrol)
segementcontrol.snp.makeConstraints { make in
make.height.equalTo(40)
make.centerX.centerY.equalToSuperview()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ final class MenuView: UIView {

lazy var menuImageView: UIImageView = {
let iv = UIImageView()
iv.image = ImageLiterals.MenuTab.emptyCard
iv.layer.cornerRadius = 8
iv.contentMode = .scaleAspectFill
return iv
Expand All @@ -45,6 +46,7 @@ final class MenuView: UIView {
lazy var titleLabel: UILabel = {
let lb = UILabel()
lb.textColor = .helfmeBlack
lb.numberOfLines = 2
lb.font = .NotoBold(size: 14)
return lb
}()
Expand Down Expand Up @@ -80,6 +82,16 @@ final class MenuView: UIView {
lb.font = .NotoRegular(size: 10)
return lb
}()

lazy var gLabel: UILabel = {
let lb = UILabel()
lb.text = I18N.Detail.Menu.gUnit
lb.textColor = .helfmeWhite
lb.font = .PretendardRegular(size: 8)
// lb.partFontChange(targetString: "(", font: .NotoBold(size: 10))
lb.partFontChange(targetString: "당)", font: .NotoRegular(size: 8))
return lb
}()

lazy var kcalStackView: UIStackView = {
let sv = UIStackView()
Expand All @@ -88,6 +100,7 @@ final class MenuView: UIView {
sv.spacing = 0
sv.addArrangedSubview(kcalLabel)
sv.addArrangedSubview(unitLabel)
sv.addArrangedSubview(gLabel)
return sv
}()

Expand Down Expand Up @@ -146,6 +159,7 @@ extension MenuView {

menuStackView.snp.makeConstraints { make in
make.leading.equalTo(menuImageView.snp.trailing).offset(20)
make.trailing.equalToSuperview().inset(42)
make.top.equalTo(pickImageView).offset(24)
}

Expand All @@ -154,4 +168,8 @@ extension MenuView {
make.centerX.centerY.equalToSuperview()
}
}

private func updateLayout() {

}
}

0 comments on commit 0d6efb7

Please sign in to comment.