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

박스오피스II [STEP 2] yetti, maxhyunm #111

Open
wants to merge 7 commits into
base: ic_9_yetti
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
feat: 텍스트에 다이나믹 타입 적용, auto layout 수정
  • Loading branch information
maxhyunm committed Aug 16, 2023
commit 4d95f8cf00c0a5558e7a3ff80cf98a9726255df2
6 changes: 3 additions & 3 deletions BoxOffice/Controller/BoxOfficeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ extension BoxOfficeViewController {
if isListMode {
dataSource = UICollectionViewDiffableDataSource<NetworkConfiguration, BoxOfficeEntity.BoxOfficeResult.DailyBoxOffice>(collectionView: self.collectionView) { (collectionView, indexPath, data) -> UICollectionViewCell? in
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: BoxOfficeRankingListCell.cellIdentifier, for: indexPath) as? BoxOfficeRankingListCell else {
return UICollectionViewCell()
return BoxOfficeRankingListCell()
}

cell.setUpLabelText(data)
Expand All @@ -162,15 +162,14 @@ extension BoxOfficeViewController {
} else {
dataSource = UICollectionViewDiffableDataSource<NetworkConfiguration, BoxOfficeEntity.BoxOfficeResult.DailyBoxOffice>(collectionView: self.collectionView) { (collectionView, indexPath, data) -> UICollectionViewCell? in
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: BoxOfficeRankingIconCell.cellIdentifier, for: indexPath) as? BoxOfficeRankingIconCell else {
return UICollectionViewCell()
return BoxOfficeRankingIconCell()
}

cell.setUpLabelText(data)

return cell
}
}

}

private func setUpDataSnapshot(_ data: [BoxOfficeEntity.BoxOfficeResult.DailyBoxOffice]) {
Expand Down Expand Up @@ -244,6 +243,7 @@ extension BoxOfficeViewController: BoxOfficeDelegate {
func setUpDate(_ date: Date) {
self.date = date
self.title = getDateString(format: Namespace.dateWithHyphen)

passFetchedData()
}
}
7 changes: 7 additions & 0 deletions BoxOffice/View/BoxOfficeRankingIconCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class BoxOfficeRankingIconCell: UICollectionViewCell {
label.textAlignment = .center
label.font = .preferredFont(forTextStyle: .largeTitle)
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontForContentSizeCategory = true

return label
}()
Expand All @@ -24,6 +25,7 @@ class BoxOfficeRankingIconCell: UICollectionViewCell {
label.textAlignment = .center
label.font = .preferredFont(forTextStyle: .callout)
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontForContentSizeCategory = true

return label
}()
Expand All @@ -32,13 +34,18 @@ class BoxOfficeRankingIconCell: UICollectionViewCell {
let label = UILabel()
label.font = .preferredFont(forTextStyle: .title3)
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontForContentSizeCategory = true
label.numberOfLines = 0

return label
}()

private let audienceLabel: UILabel = {
let label = UILabel()
label.font = .preferredFont(forTextStyle: .callout)
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true

return label
}()
Expand Down
48 changes: 31 additions & 17 deletions BoxOffice/View/BoxOfficeRankingListCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ final class BoxOfficeRankingListCell: UICollectionViewListCell {
label.textAlignment = .center
label.font = .preferredFont(forTextStyle: .largeTitle)
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontForContentSizeCategory = true

return label
}()
Expand All @@ -24,6 +25,7 @@ final class BoxOfficeRankingListCell: UICollectionViewListCell {
label.textAlignment = .center
label.font = .preferredFont(forTextStyle: .callout)
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontForContentSizeCategory = true

return label
}()
Expand All @@ -32,18 +34,31 @@ final class BoxOfficeRankingListCell: UICollectionViewListCell {
let label = UILabel()
label.font = .preferredFont(forTextStyle: .title3)
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontForContentSizeCategory = true
label.numberOfLines = 0

return label
}()

private let audienceLabel: UILabel = {
let label = UILabel()
label.font = .preferredFont(forTextStyle: .body)
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true

return label
}()

private let stackView: UIStackView = {
private let rankingStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.translatesAutoresizingMaskIntoConstraints = false

return stackView
}()

private let informationStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.translatesAutoresizingMaskIntoConstraints = false
Expand All @@ -63,26 +78,25 @@ final class BoxOfficeRankingListCell: UICollectionViewListCell {
private func setUpUI() {
self.accessories = [.outlineDisclosure(options: .init(tintColor: .systemGray))]

stackView.addArrangedSubview(movieNameLabel)
stackView.addArrangedSubview(audienceLabel)
contentView.addSubview(rankLabel)
contentView.addSubview(rankIntensityLabel)
contentView.addSubview(stackView)
rankingStackView.addArrangedSubview(rankLabel)
rankingStackView.addArrangedSubview(rankIntensityLabel)

informationStackView.addArrangedSubview(movieNameLabel)
informationStackView.addArrangedSubview(audienceLabel)

contentView.addSubview(rankingStackView)
contentView.addSubview(informationStackView)

NSLayoutConstraint.activate([
rankLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 10),
rankLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
rankLabel.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.3),

rankIntensityLabel.widthAnchor.constraint(equalTo: rankLabel.widthAnchor),
rankIntensityLabel.topAnchor.constraint(equalTo: rankLabel.bottomAnchor),
rankIntensityLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
rankIntensityLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -10),
rankingStackView.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.3),
rankingStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
rankingStackView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),

stackView.leadingAnchor.constraint(equalTo: rankLabel.trailingAnchor),
stackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
stackView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
informationStackView.leadingAnchor.constraint(equalTo: rankLabel.trailingAnchor),
informationStackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
informationStackView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),

self.heightAnchor.constraint(equalTo: informationStackView.heightAnchor, constant: 30),
self.separatorLayoutGuide.leadingAnchor.constraint(equalTo: rankLabel.leadingAnchor)
])
}
Expand Down
4 changes: 4 additions & 0 deletions BoxOffice/View/MovieDetailStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ final class MovieDetailStackView: UIStackView {
let label = UILabel()
label.font = .preferredFont(forTextStyle: .headline)
label.textAlignment = .center
label.adjustsFontForContentSizeCategory = true
label.numberOfLines = 0

return label
}()

let valueLabel: UILabel = {
let label = UILabel()
label.font = .preferredFont(forTextStyle: .body)
label.lineBreakMode = .byWordWrapping
label.numberOfLines = 0
label.adjustsFontForContentSizeCategory = true

return label
}()
Expand Down