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] 메뉴탭에 메뉴판 전체보기 추가 #234

Merged
merged 5 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 13 additions & 1 deletion HealthFoodMe/HealthFoodMe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
695758EE28830E3F00E36789 /* Splash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 695758ED28830E3F00E36789 /* Splash.storyboard */; };
695758F4288545CC00E36789 /* CopingTabEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 695758F3288545CC00E36789 /* CopingTabEntity.swift */; };
695758F928857FDC00E36789 /* ReviewWriteEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 695758F828857FDC00E36789 /* ReviewWriteEntity.swift */; };
696DD00F28BF950A0011CCEE /* AllImageCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 696DD00E28BF950A0011CCEE /* AllImageCVC.swift */; };
696DD01128BFB93B0011CCEE /* ImageHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 696DD01028BFB93B0011CCEE /* ImageHeaderView.swift */; };
69A878F828BD06C5008D0D97 /* ImageCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69A878F728BD06C5008D0D97 /* ImageCVC.swift */; };
69D7074B2888062E00C2C278 /* ReviewDeleteEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69D7074A2888062E00C2C278 /* ReviewDeleteEntity.swift */; };
69D7074D28885B9900C2C278 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 69D7074C28885B9900C2C278 /* GoogleService-Info.plist */; };
69D7074F28888D6500C2C278 /* ReviewEditEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69D7074E28888D6500C2C278 /* ReviewEditEntity.swift */; };
Expand Down Expand Up @@ -297,6 +300,9 @@
695758ED28830E3F00E36789 /* Splash.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Splash.storyboard; sourceTree = "<group>"; };
695758F3288545CC00E36789 /* CopingTabEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopingTabEntity.swift; sourceTree = "<group>"; };
695758F828857FDC00E36789 /* ReviewWriteEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewWriteEntity.swift; sourceTree = "<group>"; };
696DD00E28BF950A0011CCEE /* AllImageCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllImageCVC.swift; sourceTree = "<group>"; };
696DD01028BFB93B0011CCEE /* ImageHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageHeaderView.swift; sourceTree = "<group>"; };
69A878F728BD06C5008D0D97 /* ImageCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCVC.swift; sourceTree = "<group>"; };
69D7074A2888062E00C2C278 /* ReviewDeleteEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewDeleteEntity.swift; sourceTree = "<group>"; };
69D7074C28885B9900C2C278 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
69D7074E28888D6500C2C278 /* ReviewEditEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewEditEntity.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -800,6 +806,8 @@
isa = PBXGroup;
children = (
69028BA52874673600373984 /* MenuCellCVC.swift */,
69A878F728BD06C5008D0D97 /* ImageCVC.swift */,
696DD00E28BF950A0011CCEE /* AllImageCVC.swift */,
);
path = Cells;
sourceTree = "<group>";
Expand All @@ -818,6 +826,7 @@
69028BAF2874A60E00373984 /* HeaderView.swift */,
69028BA72874675800373984 /* MenuView.swift */,
69028BA9287467F100373984 /* MenuDetailView.swift */,
696DD01028BFB93B0011CCEE /* ImageHeaderView.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -2192,6 +2201,7 @@
EBFAEAFE28851C09009C569C /* UserManager.swift in Sources */,
FD72FC9D288346480092746F /* UserWithdrawlModel.swift in Sources */,
EBF66AFE287227F500DE0ED1 /* makeVibrate.swift in Sources */,
69A878F828BD06C5008D0D97 /* ImageCVC.swift in Sources */,
FDF2E1FC287EFC710007D4F9 /* StarRatingSlider.swift in Sources */,
695758DE28811E9D00E36789 /* Config.swift in Sources */,
EBD19262287DBC1800EA053E /* MapDetailSummaryView.swift in Sources */,
Expand Down Expand Up @@ -2255,6 +2265,7 @@
EBFAEB312885F2F7009C569C /* MyReviewRepository.swift in Sources */,
EBFAEB332885F2F7009C569C /* MyReviewVC.swift in Sources */,
A93252B1287F2AF9001EDF50 /* ScrapVC.swift in Sources */,
696DD00F28BF950A0011CCEE /* AllImageCVC.swift in Sources */,
EBF66AF5287227F500DE0ED1 /* Logger.swift in Sources */,
FD72FC9E288346480092746F /* UserWithdrawalVC.swift in Sources */,
EBFAEB412885F43E009C569C /* MyReviewCVC.swift in Sources */,
Expand All @@ -2280,6 +2291,7 @@
EBFAEB0D28856388009C569C /* LogEventType.swift in Sources */,
EBF66AFD287227F500DE0ED1 /* calculateTopInset.swift in Sources */,
EBF66ACF287227F500DE0ED1 /* Result+.swift in Sources */,
696DD01128BFB93B0011CCEE /* ImageHeaderView.swift in Sources */,
3BB0FCE3288705E200C3862C /* BlogReviewListEntity.swift in Sources */,
A93252C628808B82001EDF50 /* ReviewDeleteAlertView.swift in Sources */,
EBF66AD7287227F500DE0ED1 /* Presentable.swift in Sources */,
Expand Down Expand Up @@ -2509,7 +2521,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.healthFoodMe.release;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = healthFood_dev;
PROVISIONING_PROFILE_SPECIFIER = HealthFoodMe_Dev;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum BaseNotiList: String {
case withdrawalButtonClicked
case moveFromHamburgerBar
case reviewPhotoClicked
case menuPhotoClicked

static func makeNotiName(list: BaseNotiList) -> NSNotification.Name {
return Notification.Name(String(describing: list))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct I18N {
static let carbohydrate = "탄수화물"
static let protein = "단백질"
static let fats = "지방"
static let imageHeader = "메뉴 전체보기"
}

struct Review {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//
// AllImageCVC.swift
// HealthFoodMe
//
// Created by 최영린 on 2022/08/31.
//

import UIKit
import SnapKit

class AllImageCVC: UICollectionViewCell, UICollectionViewRegisterable {

// MARK: - Properties

static var isFromNib = false
let imgURLList = ["123", "123", "123", "123"] // 테스트용

// MARK: - UI Components
lazy var menuImageCV: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.minimumLineSpacing = 0
layout.scrollDirection = .horizontal
layout.sectionInset = .zero

let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.showsHorizontalScrollIndicator = false
cv.backgroundColor = .helfmeWhite
cv.bounces = false
return cv
}()

// MARK: - Life Cycle Part
override init(frame: CGRect) {
super.init(frame: frame)
setLayout()
setDelegate()
registerCell()
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

// MARK: - Methods

extension AllImageCVC {
private func setDelegate() {
menuImageCV.delegate = self
menuImageCV.dataSource = self
}

private func registerCell() {
ImageCVC.register(target: menuImageCV)
}

private func setLayout() {
contentView.addSubviews(menuImageCV)
menuImageCV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
}

extension AllImageCVC: UICollectionViewDataSource {

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4 //임시로 넣어둔 값 (서버 붙일때 수정 예정)
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let allImageCell = menuImageCV.dequeueReusableCell(withReuseIdentifier: ImageCVC.className, for: indexPath) as? ImageCVC
else { return UICollectionViewCell() }
// allImageCell.setData(menuData: MenuTabVC().menuData[indexPath.row])
return allImageCell
}
}

extension AllImageCVC: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let width = UIScreen.main.bounds.width

let cellWidth = width * (107/375)
let cellHeight = cellWidth * (107/107)

return CGSize(width: cellWidth, height: cellHeight)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 8
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let imageSlideData = ImageSlideDataModel.init(clickedIndex: indexPath.row,
imgURLs: imgURLList ?? [])
postObserverAction(.menuPhotoClicked,object: imageSlideData)
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// AllMenuImageCVC.swift
// HealthFoodMe
//
// Created by 최영린 on 2022/08/29.
//

import UIKit

class ImageCVC: UICollectionViewCell, UICollectionViewRegisterable {

// MARK: - Properties

static var isFromNib = false

// MARK: - UI Components

lazy var photoImageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFill
imageView.layer.masksToBounds = true
imageView.image = ImageLiterals.MenuTab.emptyCard
return imageView
}()

// MARK: - Life Cycle Part
override init(frame: CGRect) {
super.init(frame: frame)
setLayout()
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

// MARK: - Methods

extension ImageCVC {
func setImage(_ image: UIImage) {
photoImageView.image = image
}

func setImageURL(_ url: String) {
let url = URL(string: url)
DispatchQueue.global().async {
let data = try? Data(contentsOf: url!)
DispatchQueue.main.async {
self.photoImageView.image = UIImage(data: data!)
}
}
}

func setLayout() {
contentView.addSubviews(photoImageView)
let width = UIScreen.main.bounds.width

photoImageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.width.height.equalTo(width * 107/375)

}
photoImageView.layer.cornerRadius = 8
photoImageView.layer.masksToBounds = true
}
}
Loading