Skip to content

Commit

Permalink
Merge pull request #244 from Team-return/feature/(#220)-companyDetail…
Browse files Browse the repository at this point in the history
…_refactoring

🔗 :: (#220) 기업 상세 리펙토링
  • Loading branch information
ray3238 authored Apr 5, 2024
2 parents 916fd95 + 526c934 commit f96dccf
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,15 @@ import Core
import DesignSystem

public class CompanyDetailViewController: BaseViewController<CompanyDetailViewModel> {
private let companyLogoImageView = UIImageView().then {
$0.clipsToBounds = true
$0.layer.borderWidth = 1.0
$0.layer.borderColor = UIColor.GrayScale.gray30.cgColor
$0.layer.cornerRadius = 8
}
private let companyLabel = UILabel().then {
$0.setJobisText(
"회사 정보 불러오는 중...",
font: .headLine,
color: .GrayScale.gray90
)
}
private let explainCompanyLabel = UILabel().then {
$0.numberOfLines = 0
$0.lineBreakMode = .byWordWrapping
$0.setJobisText(
"-",
font: .body,
color: .GrayScale.gray70
)
}
private let companyDetailProfileView = CompanyDetailProfileView()
private let scrollView = UIScrollView().then {
$0.showsVerticalScrollIndicator = false
}
private let contentView = UIView()
private let mainStackView = UIStackView().then {
$0.spacing = 0
$0.axis = .vertical
}
private let bossLabel = CompanyDetailLabel(menuText: "대표자")
private let startedDayLabel = CompanyDetailLabel(menuText: "설립일")
private let workersNumbersLabel = CompanyDetailLabel(menuText: "근로자 수")
Expand Down Expand Up @@ -61,17 +44,16 @@ public class CompanyDetailViewController: BaseViewController<CompanyDetailViewMo
$0.setText("모집의뢰서 보기")
$0.isHidden = true
}

public override func addView() {
[
scrollView,
recruitmentButton
].forEach(view.addSubview(_:))

scrollView.addSubview(contentView)

[
companyLogoImageView,
companyLabel,
explainCompanyLabel,
bossLabel,
startedDayLabel,
workersNumbersLabel,
Expand All @@ -83,31 +65,20 @@ public class CompanyDetailViewController: BaseViewController<CompanyDetailViewMo
secondManagerLabel,
secondPhoneNumberLabel,
emailLabel,
faxLabel,
faxLabel
].forEach(mainStackView.addArrangedSubview(_:))

[
companyDetailProfileView,
mainStackView,
interviewReviewMenuLabel,
interviewReviewTableView
].forEach(contentView.addSubview(_:))
}

public override func setLayout() {
companyLogoImageView.snp.makeConstraints {
$0.top.equalToSuperview().inset(12)
$0.left.equalToSuperview().inset(24)
$0.width.height.equalTo(48)
}

companyLabel.snp.makeConstraints {
$0.left.equalTo(companyLogoImageView.snp.right).offset(12)
$0.centerY.equalTo(companyLogoImageView)
}

explainCompanyLabel.snp.makeConstraints {
$0.top.equalTo(companyLogoImageView.snp.bottom).offset(8)
$0.left.right.equalToSuperview().inset(24)
}

scrollView.snp.makeConstraints {
$0.top.equalTo(self.view.safeAreaLayoutGuide)
$0.top.equalToSuperview()
$0.leading.trailing.equalTo(self.view.safeAreaLayoutGuide)
$0.bottom.equalTo(recruitmentButton.snp.top).inset(-12)
}
Expand All @@ -118,68 +89,17 @@ public class CompanyDetailViewController: BaseViewController<CompanyDetailViewMo
$0.bottom.equalTo(interviewReviewTableView.snp.bottom).offset(20)
}

bossLabel.snp.makeConstraints {
$0.top.equalTo(explainCompanyLabel.snp.bottom).offset(24)
$0.left.right.equalToSuperview().inset(24)
}

startedDayLabel.snp.makeConstraints {
$0.top.equalTo(bossLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
}

workersNumbersLabel.snp.makeConstraints {
$0.top.equalTo(startedDayLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
}

annualSalesLabel.snp.makeConstraints {
$0.top.equalTo(workersNumbersLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
}

headAddressLabel.snp.makeConstraints {
$0.top.equalTo(annualSalesLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
}

chainAddressLabel.snp.makeConstraints {
$0.top.equalTo(headAddressLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
}

firstManagerLabel.snp.makeConstraints {
$0.top.equalTo(chainAddressLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
}

firstPhoneNumberLabel.snp.makeConstraints {
$0.top.equalTo(firstManagerLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
}

secondManagerLabel.snp.makeConstraints {
$0.top.equalTo(firstPhoneNumberLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
}

secondPhoneNumberLabel.snp.makeConstraints {
$0.top.equalTo(secondManagerLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
}

emailLabel.snp.makeConstraints {
$0.top.equalTo(secondPhoneNumberLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
companyDetailProfileView.snp.makeConstraints {
$0.top.leading.trailing.equalToSuperview()
}

faxLabel.snp.makeConstraints {
$0.top.equalTo(emailLabel.snp.bottom).offset(16)
$0.left.right.equalToSuperview().inset(24)
mainStackView.snp.makeConstraints {
$0.top.equalTo(companyDetailProfileView.snp.bottom).offset(12)
$0.leading.trailing.equalToSuperview()
}

interviewReviewMenuLabel.snp.makeConstraints {
$0.top.equalTo(faxLabel.snp.bottom).offset(20)
$0.top.equalTo(mainStackView.snp.bottom).offset(20)
}

interviewReviewTableView.snp.makeConstraints {
Expand All @@ -204,24 +124,26 @@ public class CompanyDetailViewController: BaseViewController<CompanyDetailViewMo
let output = viewModel.transform(input)

output.companyDetailInfo
.bind(onNext: { companyDetailInfo in
self.companyLogoImageView.setJobisImage(urlString: companyDetailInfo.companyProfileURL)
self.companyLabel.text = companyDetailInfo.companyName
self.explainCompanyLabel.text = companyDetailInfo.companyIntroduce
self.bossLabel.setContent(contentText: companyDetailInfo.representativeName)
self.startedDayLabel.setContent(contentText: companyDetailInfo.foundedAt)
self.workersNumbersLabel.setContent(contentText: companyDetailInfo.workerNumber)
self.annualSalesLabel.setContent(contentText: companyDetailInfo.take)
self.headAddressLabel.setContent(contentText: companyDetailInfo.mainAddress)
self.chainAddressLabel.setContent(contentText: companyDetailInfo.subAddress ?? "-")
self.firstManagerLabel.setContent(contentText: companyDetailInfo.managerName)
self.firstPhoneNumberLabel.setContent(contentText: companyDetailInfo.managerPhoneNo)
self.secondManagerLabel.setContent(contentText: companyDetailInfo.subManagerName ?? "-")
self.secondPhoneNumberLabel.setContent(contentText: companyDetailInfo.subManagerPhoneNo ?? "-")
self.emailLabel.setContent(contentText: companyDetailInfo.email)
self.faxLabel.setContent(contentText: companyDetailInfo.fax ?? "-")
self.viewModel.recruitmentID = companyDetailInfo.recruitmentID
self.recruitmentButton.isHidden = companyDetailInfo.recruitmentID == nil
.bind(onNext: { [weak self] in
self?.companyDetailProfileView.setCompanyProfile(
imageUrl: $0.companyProfileURL,
companyName: $0.companyName,
companyContent: $0.companyIntroduce
)
self?.bossLabel.setContent(contentText: $0.representativeName)
self?.startedDayLabel.setContent(contentText: $0.foundedAt)
self?.workersNumbersLabel.setContent(contentText: $0.workerNumber)
self?.annualSalesLabel.setContent(contentText: $0.take)
self?.headAddressLabel.setContent(contentText: $0.mainAddress)
self?.chainAddressLabel.setContent(contentText: $0.subAddress ?? "-")
self?.firstManagerLabel.setContent(contentText: $0.managerName)
self?.firstPhoneNumberLabel.setContent(contentText: $0.managerPhoneNo)
self?.secondManagerLabel.setContent(contentText: $0.subManagerName ?? "-")
self?.secondPhoneNumberLabel.setContent(contentText: $0.subManagerPhoneNo ?? "-")
self?.emailLabel.setContent(contentText: $0.email)
self?.faxLabel.setContent(contentText: $0.fax ?? "-")
self?.viewModel.recruitmentID = $0.recruitmentID
self?.recruitmentButton.isHidden = $0.recruitmentID == nil
})
.disposed(by: disposeBag)

Expand All @@ -238,7 +160,7 @@ public class CompanyDetailViewController: BaseViewController<CompanyDetailViewMo
public override func configureViewController() { }

public override func configureNavigation() {
self.setSmallTitle(title: "상세 보기")
self.setSmallTitle(title: "기업 상세")
self.navigationItem.largeTitleDisplayMode = .never
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ public final class CompanyDetailLabel: BaseView {

public override func setLayout() {
title.snp.makeConstraints {
$0.top.left.equalToSuperview()
$0.top.equalToSuperview()
$0.leading.equalToSuperview().inset(24)
$0.width.equalTo(64)
}
content.snp.makeConstraints {
$0.top.bottom.equalToSuperview()
$0.left.equalTo(title.snp.right).offset(8)
$0.right.equalToSuperview()
$0.top.equalToSuperview()
$0.leading.equalTo(title.snp.trailing).offset(8)
$0.trailing.equalToSuperview().inset(24)
$0.bottom.equalToSuperview().inset(16)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import UIKit
import SnapKit
import Then
import DesignSystem

public final class CompanyDetailProfileView: BaseView {
private let backStackView = UIStackView().then {
$0.axis = .vertical
$0.spacing = 12
$0.layoutMargins = .init(top: 12, left: 24, bottom: 12, right: 24)
$0.isLayoutMarginsRelativeArrangement = true
}
private let profileStackView = UIStackView().then {
$0.axis = .horizontal
$0.spacing = 12
}
private let companyLogoImageView = UIImageView().then {
$0.clipsToBounds = true
$0.layer.borderWidth = 1.0
$0.layer.borderColor = UIColor.GrayScale.gray30.cgColor
$0.layer.cornerRadius = 8
}
private let companyLabel = UILabel().then {
$0.setJobisText(
"기업 상세 불러오는중...",
font: .headLine,
color: .GrayScale.gray90
)
}
let companyContentLabel = UILabel().then {
$0.setJobisText(
"-",
font: .body,
color: .GrayScale.gray70
)
$0.numberOfLines = 0
$0.lineBreakMode = .byWordWrapping
}

func setCompanyProfile(imageUrl: String, companyName: String, companyContent: String) {
companyLogoImageView.setJobisImage(urlString: imageUrl)
companyLabel.text = companyName
companyContentLabel.text = companyContent
}

public override func addView() {
[
companyLogoImageView,
companyLabel
].forEach(self.profileStackView.addArrangedSubview(_:))

[
profileStackView,
companyContentLabel
].forEach(self.backStackView.addArrangedSubview(_:))
self.addSubview(backStackView)
}

public override func setLayout() {
companyLogoImageView.snp.makeConstraints {
$0.width.height.equalTo(48)
}

backStackView.snp.makeConstraints {
$0.edges.equalToSuperview()
}
}
}

0 comments on commit f96dccf

Please sign in to comment.