-
Notifications
You must be signed in to change notification settings - Fork 1
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
BookCover 엔티티 & MHBook 뷰 구현 #47
Changes from 8 commits
33763a2
0986d47
8e4e69b
8b2d92a
3617498
f05d1ba
6bbb91e
245c1e4
1cd9c3f
5ac4ba4
d519730
8f631b8
0b0b40d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// TODO: 지금 피그잼의 BookCover에서 세분화할 필요성이 느껴짐 (MHBook은 딱 아래 정도만 필요한듯) | ||
Check warning on line 1 in MemorialHouse/MHDomain/MHDomain/Entity/BookCover.swift GitHub Actions / SwiftLint
|
||
public enum BookType { | ||
case beige | ||
case blue | ||
case green | ||
case orange | ||
case pink | ||
} | ||
|
||
public struct BookCover { | ||
public let title: String | ||
public let imageURL: String | ||
public let bookType: BookType | ||
|
||
public init( | ||
title: String, | ||
imageURL: String, | ||
bookType: BookType | ||
) { | ||
self.title = title | ||
self.imageURL = imageURL | ||
self.bookType = bookType | ||
} | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import UIKit | ||
import MHFoundation | ||
import MHDomain | ||
|
||
// TODO: 위치 변경 고려해보기 | ||
Check warning on line 5 in MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHBook.swift GitHub Actions / SwiftLint
|
||
extension BookType { | ||
var image: UIImage { | ||
switch self { | ||
case .blue: .blueBook | ||
case .beige: .beigeBook | ||
case .green: .greenBook | ||
case .orange: .orangeBook | ||
case .pink: .pinkBook | ||
@unknown default: | ||
fatalError("등록되지 않은 책 색상입니다.") | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Domain에 있는 모델이지만 Presentation에서 위처럼 연산 프로퍼티 접근이 가능하면 용이할 것 같아 추가해봤습니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
컴파일러가 띄워준 에러에 자동완성 Fix가 @.unkown default였는데 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3.enum인데 default가 수행되나욤?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. �엇 저는 BookColor의 extension으로 구현하기보단 viewModel에서 대응하는게 더 좋아보입니당..! 그럼 default를 따로 만들지 않아도 될 것 같아요 .. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제 생각에도 default 수행 안될 거 같은데, 다른 모듈에서 접근 제어자 때문에 해당 extension 못 사용하므로 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 컴파일러가 띄워준 에러에 자동완성 Fix가 @.unkown default였는데 |
||
|
||
final class MHBook: UIView { | ||
// MARK: - Property | ||
private let bookImageView = UIImageView() | ||
private let titleLabel = UILabel(style: .default) | ||
private let targetImageView: UIImageView = { | ||
let imageView = UIImageView() | ||
imageView.contentMode = .scaleToFill | ||
imageView.layer.shadowRadius = 4 | ||
imageView.layer.shadowOpacity = 0.4 | ||
imageView.layer.shadowOffset = CGSize(width: 4, height: 4) | ||
|
||
return imageView | ||
}() | ||
private let publisherLabel = UILabel(style: .body2) | ||
|
||
// MARK: - Initializer | ||
init() { | ||
super.init(frame: .zero) | ||
|
||
configureAddSubView() | ||
configureConstraints() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
|
||
configureAddSubView() | ||
configureConstraints() | ||
} | ||
|
||
// MARK: - Configuration | ||
func configure(with bookCover: BookCover) { | ||
titleLabel.text = bookCover.title | ||
bookImageView.image = bookCover.bookType.image | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 여기서 case별로 나눠서 image를 적용해줘도 된다.. 생각합니당.. 뭔가 model의 extension에 computed property가 들어가는게 어색..한 것 같다..? 는 의견입니당.. |
||
targetImageView.image = UIImage(systemName: "person") // TODO: Image Loader로 변경 | ||
Check warning on line 54 in MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHBook.swift GitHub Actions / SwiftLint
|
||
if let publisher = UserDefaults.standard.object(forKey: Constant.houseNameUserDefaultKey) as? String { | ||
// TODO: User 모델 만들어지면 파라미터로 출판소 이름 넘겨주기 | ||
Check warning on line 56 in MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHBook.swift GitHub Actions / SwiftLint
|
||
publisherLabel.text = publisher | ||
} | ||
} | ||
|
||
private func configureAddSubView() { | ||
addSubview(bookImageView) | ||
addSubview(titleLabel) | ||
addSubview(targetImageView) | ||
addSubview(publisherLabel) | ||
} | ||
|
||
private func configureConstraints() { | ||
bookImageView.fillSuperview() | ||
titleLabel.setTop(anchor: topAnchor, constant: 16) | ||
titleLabel.setCenterX(view: self, constant: 8) | ||
targetImageView.setTop(anchor: titleLabel.bottomAnchor, constant: 14) | ||
targetImageView.setCenterX(view: self, constant: 8) | ||
targetImageView.setWidthAndHeight(width: 100, height: 100) | ||
publisherLabel.setBottom(anchor: bottomAnchor, constant: 12) | ||
publisherLabel.setTrailing(anchor: trailingAnchor, constant: 12) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: BookType도 하나의 type이니까 BookCover랑 분리해서 따로 파일을 만들어주는게 좋을 것 같습니당 .ᐟ.ᐟ 엇 그리고 BookType이 아니라 BookColor였던 것 같아요 .ᐟ.ᐟ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UIImage에 대한 건데 Color라는 이름을 쓰기가 애매했습니다..!
아래처럼 사용돼도 괜찮나요 ? (개인적) 전 Type이 나을 거 같은데 어떠신가용
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BookColor가 저희의 비즈니스 모델이니까 괜찮지 않을까요?? 전 개인적으로 괜찮아보이긴합니다 .ᐟ.ᐟ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인정합니다 수정할게욥