Skip to content

Commit

Permalink
✅ Chore: 초기화 단계에서 BaseQuestionTVC의 UI 구현부 호출을 제거하고 함수로 분리 및 파일 위치 이동 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hwangJi-dev committed Oct 16, 2022
1 parent 24cb7e1 commit 9332ebb
Showing 1 changed file with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BaseQuestionTVC: BaseTVC {
$0.sizeToFit()
}

private let commentImgView = UIImageView().then {
let commentImgView = UIImageView().then {
$0.image = UIImage(named: "icComment")
$0.contentMode = .scaleAspectFill
}
Expand All @@ -60,7 +60,6 @@ class BaseQuestionTVC: BaseTVC {
// MARK: init
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
configureUI()
selectionStyle = .none
}

Expand All @@ -72,13 +71,12 @@ class BaseQuestionTVC: BaseTVC {

// MARK: - UI
extension BaseQuestionTVC {

@objc
func configureUI() {
private func configureUI() {
contentView.addSubviews([questionTitleLabel, questionContentLabel, nicknameLabel, questionTimeLabel, commentImgView, commentCountLabel, likeImgView, likeCountLabel])

questionTitleLabel.snp.makeConstraints {
$0.top.leading.equalToSuperview().offset(16)
$0.top.equalToSuperview().offset(12)
$0.leading.equalToSuperview().offset(16)
$0.trailing.equalToSuperview().offset(-16)
}

Expand All @@ -92,7 +90,7 @@ extension BaseQuestionTVC {
nicknameLabel.snp.makeConstraints {
$0.top.equalTo(questionContentLabel.snp.bottom).offset(8)
$0.leading.equalToSuperview().offset(16)
$0.bottom.equalToSuperview().offset(-18)
$0.bottom.equalToSuperview().offset(-19)
}

questionTimeLabel.snp.makeConstraints {
Expand Down Expand Up @@ -126,8 +124,7 @@ extension BaseQuestionTVC {

// MARK: - Custom Methods
extension BaseQuestionTVC {
// TODO: 날잡고 Issue 파서 PostListResModel로 바꿀 예정 (얽혀있는 VC들이 많아서 다음에 작업단위 나눠서 처리할게요-!)
func setData(data: ClassroomPostList) {
private func setPostData(data: PostListResModel) {
questionTitleLabel.text = data.title
questionContentLabel.text = data.content
nicknameLabel.text = data.writer.nickname
Expand All @@ -137,7 +134,7 @@ extension BaseQuestionTVC {
likeImgView.image = data.like.isLiked ? UIImage(named: "heart_filled") : UIImage(named: "btn_heart")
}

func setPostData(data: PostListResModel) {
private func setMypageLikeData(data: MypageLikeQuestionToPersonListModel.LikeList) {
questionTitleLabel.text = data.title
questionContentLabel.text = data.content
nicknameLabel.text = data.writer.nickname
Expand All @@ -146,15 +143,20 @@ extension BaseQuestionTVC {
likeCountLabel.text = "\(data.like.likeCount)"
likeImgView.image = data.like.isLiked ? UIImage(named: "heart_filled") : UIImage(named: "btn_heart")
}
}

// MARK: - Public Methods
extension BaseQuestionTVC {

func setMypageLikeData(data: MypageLikeQuestionToPersonListModel.LikeList) {
questionTitleLabel.text = data.title
questionContentLabel.text = data.content
nicknameLabel.text = data.writer.nickname
questionTimeLabel.text = data.createdAt.serverTimeToString(forUse: .forDefault)
commentCountLabel.text = "\(data.commentCount)"
likeCountLabel.text = "\(data.like.likeCount)"
likeImgView.image = data.like.isLiked ? UIImage(named: "heart_filled") : UIImage(named: "btn_heart")
/// Cell의 필수 구성요소를 설정하는 메서드
func setEssentialCellInfo(data: PostListResModel) {
configureUI()
setPostData(data: data)
}

/// 마이페이지 좋아요 관련 Cell의 필수 구성요소를 설정하는 메서드
func setEssentialMypageLikeCellInfo(data: MypageLikeQuestionToPersonListModel.LikeList) {
configureUI()
setMypageLikeData(data: data)
}
}

0 comments on commit 9332ebb

Please sign in to comment.