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

Feature. 내 리뷰 관리 UI 작업 #177

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
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
108 changes: 104 additions & 4 deletions Pyonsnal-Color/Pyonsnal-Color.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "2ae251365e2bd450b633726d7085f35a9a46a0f82ec34d41708921f1b80bb996",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand Down Expand Up @@ -41,17 +42,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "98a00258d4518b7521253a70b7f70bb76d2120fe",
"version" : "9.2.4"
"revision" : "a637d318ae7ae246b02d7305121275bc75ed5565",
"version" : "9.4.0"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "58d03d22beae762eaddbd30cb5a61af90d4b309f",
"version" : "7.11.3"
"revision" : "57a1d307f42df690fdef2637f3e5b776da02aad6",
"version" : "7.13.3"
}
},
{
Expand Down Expand Up @@ -149,17 +150,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/googleads/swift-package-manager-google-mobile-ads.git",
"state" : {
"revision" : "70516c9e799a366ff90c1a70c09c48f7c076fd8a",
"version" : "10.14.0"
"revision" : "746253bf8803826e4de14c9e619739733ea8fb3b",
"version" : "11.5.0"
}
},
{
"identity" : "swift-package-manager-google-user-messaging-platform",
"kind" : "remoteSourceControl",
"location" : "https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git",
"state" : {
"revision" : "129fa838520cd02174f890ae0cfe0242e60714ae",
"version" : "2.1.0"
"revision" : "9b68aa69fb508f0274853e226c734151a973c7b7",
"version" : "2.4.0"
}
},
{
Expand All @@ -172,5 +173,5 @@
}
}
],
"version" : 2
"version" : 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// ActionButtonCell.swift
// Pyonsnal-Color
//
// Created by 조소정 on 6/2/24.
//

import UIKit
import Combine

protocol ActionButtonCellDelegate: AnyObject {
func actionButtonDidTap()
}

final class ActionButtonCell: UICollectionViewCell {
// MARK: - Interfaces
enum Constants {
enum Size {
static let actionButtonHeight: CGFloat = 40
static let actionButtonRadius: CGFloat = 16
}

enum Text {
static let writeReview = "상품 리뷰 작성 하기"
static let showProduct = "상품 보러 가기"
}
}

weak var delegate: ActionButtonCellDelegate?
private var cancellables = Set<AnyCancellable>()

// MARK: - Initializer
override init(frame: CGRect) {
super.init(frame: .zero)
self.setConstraints()
self.bindActions()
}

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

let actionButton: UIButton = {
let button = UIButton(frame: .zero)
button.makeRounded(with: Constants.Size.actionButtonRadius)
button.backgroundColor = .black
button.titleLabel?.textColor = .white
button.titleLabel?.font = .body2m
return button
}()

// MARK: - Private Methods
private func setConstraints() {
self.addSubview(actionButton)
actionButton.snp.makeConstraints { make in
make.height.equalTo(Constants.Size.actionButtonHeight)
make.top.bottom.equalToSuperview()
make.leading.trailing.equalToSuperview().inset(.spacing16)
}
}

private func bindActions() {
actionButton.tapPublisher.sink { [weak self] in
self?.delegate?.actionButtonDidTap()
}.store(in: &cancellables)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final class ProductCell: UICollectionViewCell {
}.store(in: &cancellable)
}

func updateCell(with product: (ProductDetailEntity)?) {
func updateCell(with product: ProductDetailEntity?) {
guard let product else { return }
self.product = product
viewHolder.titleLabel.text = product.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ extension ProductDetailReviewCell {
make.leading.trailing.equalToSuperview().inset(.spacing16)
}

reviewTagListView.snp.makeConstraints { make in
make.height.equalTo(28)
}

reviewLabel.snp.makeConstraints { make in
make.top.equalTo(contentStackView.snp.bottom).offset(.spacing12)
make.leading.trailing.equalToSuperview().inset(.spacing20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class ProductDetailReviewCell: UICollectionViewCell {

// MARK: - Declaration
struct Payload {
var hasEvaluateView: Bool = true
let review: ReviewEntity
}

Expand Down Expand Up @@ -92,7 +93,6 @@ final class ProductDetailReviewCell: UICollectionViewCell {
} else {
viewHolder.reviewLabel.isHidden = false


viewHolder.reviewLabel.snp.makeConstraints { make in
make.top.equalTo(viewHolder.contentStackView.snp.bottom).offset(.spacing12)
make.leading.trailing.equalToSuperview().inset(.spacing20)
Expand All @@ -114,6 +114,17 @@ final class ProductDetailReviewCell: UICollectionViewCell {
isSelected: review.hateCount.writerIds.contains(UserInfoService.shared.memberID ?? 0),
count: review.hateCount.hateCount
)

if !payload.hasEvaluateView {
viewHolder.goodButton.isHidden = true
viewHolder.badButton.isHidden = true
viewHolder.goodButton.snp.remakeConstraints {
$0.height.equalTo(0)
}
viewHolder.badButton.snp.remakeConstraints {
$0.height.equalTo(0)
}
}
}

@objc private func goodButtonAction(_ sender: UITapGestureRecognizer) {
Expand Down
121 changes: 121 additions & 0 deletions Pyonsnal-Color/Pyonsnal-Color/Common/Review/ProductInfoStackView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//
// ProductInfoStackView.swift
// Pyonsnal-Color
//
// Created by 조소정 on 5/19/24.
//

import UIKit
import SnapKit

class ProductInfoStackView: UIStackView {
enum Mode {
case starRating // 별점
case date // 날짜
case tastes // 취향 태그
}
Comment on lines +11 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩👍


let productImageView: UIImageView = {
let imageView = UIImageView()
imageView.makeBorder(width: 1, color: UIColor.gray200.cgColor)
imageView.makeRounded(with: .spacing16)
return imageView
}()

private let productInformationStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.spacing = .spacing8
stackView.alignment = .leading
stackView.distribution = .equalSpacing
return stackView
}()

let storeImageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFit
return imageView
}()

let productNameLabel: UILabel = {
let label = UILabel()
label.font = .body3m
label.numberOfLines = 2
return label
}()

lazy var starRatedView = StarRatedView(score: 0)

let dateLabel: UILabel = {
let label = UILabel()
label.font = .body3r
label.textColor = .gray400
return label
}()

let tastesLabel: UILabel = {
let label = UILabel()
label.font = .body3r
label.textColor = .red500
label.numberOfLines = 2
return label
}()

init(mode: Mode) {
super.init(frame: .zero)
self.initialize()
self.configureView()
self.addArrangedSubview(with: mode)
}

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

func setTastes(tastesTag: [String]) {
let tastes = tastesTag.map { "# \($0)"}.joined(separator: " ")
self.tastesLabel.text = tastes
}

private func initialize() {
self.axis = .horizontal
self.alignment = .center
self.spacing = .spacing16
self.isLayoutMarginsRelativeArrangement = true
self.layoutMargins = .init(
top: .spacing24,
left: .spacing16,
bottom: .spacing24,
right: .spacing16
)
}

private func configureView() {
self.addArrangedSubview(productImageView)
self.addArrangedSubview(productInformationStackView)

self.productInformationStackView.addArrangedSubview(storeImageView)
self.productInformationStackView.addArrangedSubview(productNameLabel)
self.productNameLabel.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
self.tastesLabel.setContentCompressionResistancePriority(.defaultLow, for: .vertical)

self.productImageView.snp.makeConstraints {
$0.width.height.equalTo(100)
}

self.storeImageView.snp.makeConstraints {
$0.height.equalTo(20)
}
}

private func addArrangedSubview(with mode: Mode) {
switch mode {
case .starRating:
self.productInformationStackView.addArrangedSubview(starRatedView)
case .date:
self.productInformationStackView.addArrangedSubview(dateLabel)
case .tastes:
self.productInformationStackView.addArrangedSubview(tastesLabel)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ final class DetailReviewViewController: UIViewController,
private func configureView() {
view.backgroundColor = .white
viewHolder.detailReviewTextView.text = Constant.textViewPlaceholder
viewHolder.productImageView.setImage(with: productDetail.imageURL)
viewHolder.productNameLabel.text = productDetail.name
viewHolder.productInfoStackView.productImageView.setImage(with: productDetail.imageURL)
viewHolder.productInfoStackView.productNameLabel.text = productDetail.name
setResizedStoreIcon(productDetail.storeType.storeIcon.image)
updateStarRatedView(score: score)
viewHolder.totalScrollView.addTapGesture(
Expand Down Expand Up @@ -167,16 +167,16 @@ final class DetailReviewViewController: UIViewController,
}

private func updateStarRatedView(score: Int) {
viewHolder.starRatedView.updateScore(to: Double(score))
viewHolder.productInfoStackView.starRatedView.updateScore(to: Double(score))
}

private func setResizedStoreIcon(_ image: UIImage?) {
viewHolder.storeImageView.image = image
viewHolder.productInfoStackView.storeImageView.image = image
if let storeIcon = image {
let ratio = storeIcon.size.width / storeIcon.size.height
let newWidth = Constant.storeIconHeight * ratio

viewHolder.storeImageView.snp.makeConstraints {
viewHolder.productInfoStackView.storeImageView.snp.makeConstraints {
$0.width.equalTo(newWidth)
}
}
Expand Down
Loading