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

[Design] #87 - 리뷰 탭 Empty View UI 구현 #92

Merged
merged 12 commits into from
Jul 16, 2022
Merged
16 changes: 5 additions & 11 deletions HealthFoodMe/HealthFoodMe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
3BC01F89287F1DFA006C2181 /* ReviewHeaderCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BC01F88287F1DFA006C2181 /* ReviewHeaderCVC.swift */; };
3BCC441E28745FD800661A12 /* SocialLoginVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BCC441D28745FD800661A12 /* SocialLoginVC.swift */; };
3BCC442028745FE500661A12 /* SocialLogin.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3BCC441F28745FE500661A12 /* SocialLogin.storyboard */; };
3BDE7F292882054200EE7F47 /* ReviewEmptyViewCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BDE7F282882054200EE7F47 /* ReviewEmptyViewCVC.swift */; };
69028BA62874673600373984 /* MenuCellCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69028BA52874673600373984 /* MenuCellCVC.swift */; };
69028BA82874675800373984 /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69028BA72874675800373984 /* MenuView.swift */; };
69028BAA287467F100373984 /* MenuDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69028BA9287467F100373984 /* MenuDetailView.swift */; };
Expand Down Expand Up @@ -202,6 +203,7 @@
3BC01F88287F1DFA006C2181 /* ReviewHeaderCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewHeaderCVC.swift; sourceTree = "<group>"; };
3BCC441D28745FD800661A12 /* SocialLoginVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialLoginVC.swift; sourceTree = "<group>"; };
3BCC441F28745FE500661A12 /* SocialLogin.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = SocialLogin.storyboard; sourceTree = "<group>"; };
3BDE7F282882054200EE7F47 /* ReviewEmptyViewCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewEmptyViewCVC.swift; sourceTree = "<group>"; };
69028BA52874673600373984 /* MenuCellCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuCellCVC.swift; sourceTree = "<group>"; };
69028BA72874675800373984 /* MenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuView.swift; sourceTree = "<group>"; };
69028BA9287467F100373984 /* MenuDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuDetailView.swift; sourceTree = "<group>"; };
Expand All @@ -214,9 +216,8 @@
695758C2287DF04400E36789 /* AddPhotoCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddPhotoCVC.swift; sourceTree = "<group>"; };
695758C4287DF08800E36789 /* ListPhotoCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPhotoCVC.swift; sourceTree = "<group>"; };
695758C7287F1DCF00E36789 /* PhotoDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoDataModel.swift; sourceTree = "<group>"; };
695758C9288057D700E36789 /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Config.swift; path = ../../../../../../../../Downloads/Config.swift; sourceTree = "<group>"; };
695758CF2880ACF000E36789 /* addToolBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = addToolBar.swift; sourceTree = "<group>"; };
695758C9288057D700E36789 /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
695758CF2880ACF000E36789 /* addToolBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = addToolBar.swift; sourceTree = "<group>"; };
6E596B9EBEC8B18D4DE266B6 /* Pods-HealthFoodMe.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HealthFoodMe.release.xcconfig"; path = "Target Support Files/Pods-HealthFoodMe/Pods-HealthFoodMe.release.xcconfig"; sourceTree = "<group>"; };
A9325273287D3065001EDF50 /* SearchResultTVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultTVC.swift; sourceTree = "<group>"; };
A9325276287D4F10001EDF50 /* SearchResultModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -372,14 +373,6 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
249B65B6BB21EF77F0C03089 /* Frameworks */ = {
isa = PBXGroup;
children = (
547BCF0E14A343DF6F4A29EC /* Pods_HealthFoodMe.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
3B089C4C287DDD8900DA80B9 /* ReviewTabScene */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -425,6 +418,7 @@
3BC01F7A287E89D2006C2181 /* ReviewCVC.swift */,
3B723C8A287FF81800822B7C /* TagCVC.swift */,
3B723C902880037100822B7C /* ReviewPhotoCVC.swift */,
3BDE7F282882054200EE7F47 /* ReviewEmptyViewCVC.swift */,
);
path = Cells;
sourceTree = "<group>";
Expand Down Expand Up @@ -754,7 +748,6 @@
isa = PBXGroup;
children = (
EB6A44C928737C4600749582 /* MainDetailScene */,
3BC01F7C287E91F7006C2181 /* BlogReviewTabScene */,
695758BA287DA4A400E36789 /* ReviewWriteScene */,
3B089C4C287DDD8900DA80B9 /* ReviewTabScene */,
697074FB28737D78001A607F /* MenuTabScene */,
Expand Down Expand Up @@ -1699,6 +1692,7 @@
EBF66ACB287227F500DE0ED1 /* String+.swift in Sources */,
695758C8287F1DCF00E36789 /* PhotoDataModel.swift in Sources */,
FD39FAD12880C35000A01CDA /* UpperToastView.swift in Sources */,
3BDE7F292882054200EE7F47 /* ReviewEmptyViewCVC.swift in Sources */,
69028BA82874675800373984 /* MenuView.swift in Sources */,
A9E593C72874266200B0F8B5 /* SearchRecent.swift in Sources */,
EBF66AF2287227F500DE0ED1 /* buttonPress.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ protocol ModuleFactoryProtocol {
// MARK: - Detail
func makeMainDetailVC() -> MainDetailVC
func makeMenuTabVC() -> MenuTabVC
// func makeReviewTabVC() -> ReviewTabVC
func makeReviewDetailVC() -> ReviewDetailVC

// MARK: - Search
Expand Down Expand Up @@ -99,7 +98,6 @@ class ModuleFactory: ModuleFactoryProtocol {
return vc
}


// MARK: - Search
func makeSearchVC() -> SearchVC {
let vc = SearchVC.controllerFromStoryboard(.search)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}

guard let windowScene = (scene as? UIWindowScene) else { return }
let rootViewController = ModuleFactory.resolve().makeMainMapVC()
let rootViewController = ModuleFactory.resolve().makeReviewDetailVC()
let navigation = UINavigationController(rootViewController: rootViewController)
let window = UIWindow(windowScene: windowScene)
window.rootViewController = navigation
Expand Down
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 ReviewDetail {
static let reviewEmptyIcon = UIImage(named: "img_review_empty")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum Storyboards: String {
case reviewDetail = "ReviewDetail"
case nicknameChange = "NicknameChange"
case userWithdrawal = "UserWithdrawal"
case reviewEmptyView = "ReviewEmptyView"
}

extension UIStoryboard {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ struct I18N {
static let protein = "단백질"
static let fats = "지방"
}

struct Review {
static let emptyViewMessage =
"""
아직 작성된 리뷰가 없습니다
첫 리뷰를 작성해 주세요
"""
}
}

struct Alert {
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_review_empty.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "img_review_empty@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "img_review_empty@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 @@ -23,11 +23,6 @@ class BlogReviewCVC: UICollectionViewCell, UICollectionViewRegisterable {
return lb
}()

private lazy var blogReviewImageView: UIImageView = {
let iv = UIImageView()
return iv
}()

private lazy var blogReviewContentsLabel: UILabel = {
let lb = UILabel()
lb.textColor = .helfmeBlack
Expand All @@ -51,72 +46,26 @@ class BlogReviewCVC: UICollectionViewCell, UICollectionViewRegisterable {
return st
}()

private var blogReviewWithImageStackView: UIStackView = {
let st = UIStackView()
st.axis = .horizontal
st.distribution = .equalSpacing
st.alignment = .center
st.spacing = 16
return st
}()

// MARK: - Life Cycle Part

override init(frame: CGRect) {
super.init(frame: frame)
setInitialLayout()
setLayout()
}

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

override func prepareForReuse() {
blogReviewWithImageStackView.removeFromSuperview()
blogReviewStackView.removeFromSuperview()
}
}

// MARK: - Extension

extension BlogReviewCVC {

private func setInitialLayout() {
contentView.addSubviews(reviewSeperatorView)
blogReviewImageView.snp.makeConstraints { make in
make.width.height.equalTo(100)
}
func setLayout() {
contentView.addSubviews(reviewSeperatorView, blogReviewStackView)
blogReviewStackView.addArrangedSubviews(blogReviewTitleLabel, blogReviewContentsLabel)
blogReviewWithImageStackView.addArrangedSubviews(blogReviewStackView, blogReviewImageView)
}
func setLayout(hasImage: Bool) {

if hasImage {

contentView.addSubview(blogReviewStackView)
blogReviewWithImageStackView.addArrangedSubviews(blogReviewStackView, blogReviewImageView)
contentView.addSubview(blogReviewWithImageStackView)
} else {
contentView.addSubview(blogReviewStackView)
setLayoutWithoutImage()
}

}

private func setLayoutWithImage() {
reviewSeperatorView.snp.makeConstraints { make in
make.leading.trailing.top.equalToSuperview()
make.height.equalTo(1)
}

blogReviewWithImageStackView.snp.makeConstraints { make in
make.leading.trailing.equalToSuperview()
make.top.equalTo(reviewSeperatorView.snp.top).offset(28)
}
contentView.layoutIfNeeded()
}

private func setLayoutWithoutImage() {
reviewSeperatorView.snp.makeConstraints { make in
make.leading.trailing.top.equalToSuperview()
make.height.equalTo(1)
Expand All @@ -126,12 +75,10 @@ extension BlogReviewCVC {
make.leading.trailing.equalToSuperview()
make.top.equalTo(reviewSeperatorView.snp.top).offset(28)
}
contentView.layoutIfNeeded()
}

func setData(blogReviewData: BlogReviewDataModel) {
blogReviewTitleLabel.text = blogReviewData.blogReviewTitle
blogReviewContentsLabel.text = blogReviewData.blogReviewContents
blogReviewImageView.image = UIImage(named: blogReviewData.blogReviewImageURL ?? "")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// ReviewEmptyViewCVC.swift
// HealthFoodMe
//
// Created by 강윤서 on 2022/07/16.
//

import UIKit

class ReviewEmptyViewCVC: UICollectionViewCell, UICollectionViewRegisterable {

// MARK: - Properties

static var isFromNib = false

// MARK: - UI Components
private var testLabel: UILabel = {
let lb = UILabel()
lb.text = "SDFSDFSDF"
return lb
}()

private var reviewEmptyViewImageView: UIImageView = {
let iv = UIImageView()
let image = ImageLiterals.ReviewDetail.reviewEmptyIcon
iv.image = image
return iv
}()

private var reviewEmptyViewLabel: UILabel = {
let lb = UILabel()
lb.text = I18N.Detail.Review.emptyViewMessage
lb.font = .NotoRegular(size: 14)
return lb
}()

private var reviewEmptyStackView: UIStackView = {
let st = UIStackView()
st.axis = .vertical
st.spacing = 24
st.distribution = .equalSpacing
st.alignment = .center
return st
}()

// 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 ReviewEmptyViewCVC {
private func setLayout() {

let width = UIScreen.main.bounds.width
reviewEmptyStackView.addArrangedSubviews(reviewEmptyViewImageView,
reviewEmptyViewLabel)
contentView.addSubviews(reviewEmptyStackView)
reviewEmptyStackView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(50)
make.width.equalTo(width - 211)
}
}
}
Loading