Skip to content

Commit

Permalink
Merge pull request #92 from yungu0010/feature/#87
Browse files Browse the repository at this point in the history
[Design] #87 - 리뷰 탭 Empty View UI 구현
  • Loading branch information
yungu0010 committed Jul 16, 2022
2 parents a0cbbbf + f8992cf commit eb733bc
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 95 deletions.
6 changes: 6 additions & 0 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 @@ -208,6 +209,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 @@ -228,6 +230,8 @@
695758DF2881228700E36789 /* CopingHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopingHeaderView.swift; sourceTree = "<group>"; };
695758E228812B3100E36789 /* CopingDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopingDataModel.swift; sourceTree = "<group>"; };
695758E42881852E00E36789 /* CopingEmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopingEmptyView.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 @@ -428,6 +432,7 @@
3BC01F7A287E89D2006C2181 /* ReviewCVC.swift */,
3B723C8A287FF81800822B7C /* TagCVC.swift */,
3B723C902880037100822B7C /* ReviewPhotoCVC.swift */,
3BDE7F282882054200EE7F47 /* ReviewEmptyViewCVC.swift */,
);
path = Cells;
sourceTree = "<group>";
Expand Down Expand Up @@ -1733,6 +1738,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 */,
695758E328812B3100E36789 /* CopingDataModel.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 @@ -100,4 +100,8 @@ struct ImageLiterals {
struct MenuTab {
static let emptyCard = UIImage(named: "img_empty_card")
}

struct ReviewDetail {
static let reviewEmptyIcon = UIImage(named: "img_review_empty")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum Storyboards: String {
case nicknameChange = "NicknameChange"
case userWithdrawal = "UserWithdrawal"
case copingTab = "CopingTab"
case reviewEmptyView = "ReviewEmptyView"
}

extension UIStoryboard {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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

0 comments on commit eb733bc

Please sign in to comment.