Skip to content

Commit 0832b39

Browse files
committed
Fix: setupUI 메서드를 setupLayout,setupScrollView,setupPageControl,setupLabels로 분리
1 parent 4830cf5 commit 0832b39

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

HomeCafeRecipes/HomeCafeRecipes/Presentation/Feed/View/RecipeDetailView.swift

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ final class RecipeDetailView: UIView {
2121
override init(frame: CGRect) {
2222
super.init(frame: frame)
2323
setupUI()
24+
setupLayout()
2425
}
2526

2627
required init?(coder: NSCoder) {
@@ -29,22 +30,12 @@ final class RecipeDetailView: UIView {
2930

3031
private func setupUI() {
3132
backgroundColor = .white
32-
addSubview(scrollView)
33-
addSubview(pageControl)
34-
addSubview(recipeNameLabel)
35-
addSubview(recipeDescriptionLabel)
36-
addSubview(photoIndexLabel)
37-
38-
scrollView.translatesAutoresizingMaskIntoConstraints = false
39-
pageControl.translatesAutoresizingMaskIntoConstraints = false
40-
recipeNameLabel.translatesAutoresizingMaskIntoConstraints = false
41-
recipeDescriptionLabel.translatesAutoresizingMaskIntoConstraints = false
42-
photoIndexLabel.translatesAutoresizingMaskIntoConstraints = false
43-
44-
scrollView.isPagingEnabled = true
45-
scrollView.showsHorizontalScrollIndicator = false
46-
scrollView.delegate = self
33+
setupScrollView()
34+
setupPageControl()
35+
setupLabels()
36+
}
4737

38+
private func setupLayout() {
4839
NSLayoutConstraint.activate([
4940
scrollView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
5041
scrollView.leadingAnchor.constraint(equalTo: leadingAnchor),
@@ -65,6 +56,29 @@ final class RecipeDetailView: UIView {
6556
recipeDescriptionLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 20),
6657
recipeDescriptionLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -20)
6758
])
59+
}
60+
61+
private func setupScrollView() {
62+
addSubview(scrollView)
63+
scrollView.translatesAutoresizingMaskIntoConstraints = false
64+
scrollView.isPagingEnabled = true
65+
scrollView.showsHorizontalScrollIndicator = false
66+
scrollView.delegate = self
67+
}
68+
69+
private func setupPageControl() {
70+
addSubview(pageControl)
71+
pageControl.translatesAutoresizingMaskIntoConstraints = false
72+
}
73+
74+
private func setupLabels() {
75+
addSubview(recipeNameLabel)
76+
addSubview(recipeDescriptionLabel)
77+
addSubview(photoIndexLabel)
78+
79+
recipeNameLabel.translatesAutoresizingMaskIntoConstraints = false
80+
recipeDescriptionLabel.translatesAutoresizingMaskIntoConstraints = false
81+
photoIndexLabel.translatesAutoresizingMaskIntoConstraints = false
6882

6983
recipeNameLabel.font = Fonts.DetailtitleFont
7084
recipeNameLabel.numberOfLines = 0
@@ -76,12 +90,12 @@ final class RecipeDetailView: UIView {
7690
func configure(with viewModel: RecipeDetailViewModel) {
7791
recipeNameLabel.text = viewModel.RecipeName
7892
recipeDescriptionLabel.text = viewModel.RecipeDescription
79-
setupScrollView(with: viewModel.RecipeImageUrls)
93+
setupScrollViewContent(with: viewModel.RecipeImageUrls)
8094
pageControl.numberOfPages = viewModel.RecipeImageUrls.count
8195
updatePhotoIndexLabel(currentPage: 0)
8296
}
8397

84-
private func setupScrollView(with recipeImageUrls: [URL]) {
98+
private func setupScrollViewContent(with recipeImageUrls: [URL]) {
8599
guard !imagesAdded else { return }
86100
let imageViewWidth = UIScreen.main.bounds.width
87101

0 commit comments

Comments
 (0)