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

레시피 리스트UI를 생성해보았습니다. #9

Merged
merged 36 commits into from
Jul 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6764431
Feat: SearchBar 정의
GeonH0 Jun 19, 2024
10c4c85
Feat: RecipeListView 정의
GeonH0 Jun 19, 2024
69b6ba0
Feat: RecipeListCell 정의
GeonH0 Jun 19, 2024
b740a44
Feat: RecipeListViewController 정의
GeonH0 Jun 19, 2024
68d17da
Fix: ViewModel을 Interactor로 변경해서 ViewController에 적용
GeonH0 Jun 24, 2024
145bd41
Fix: SearchBar final 처리
GeonH0 Jun 24, 2024
db5e2ef
Fix: searchText에 retrun제거
GeonH0 Jun 24, 2024
7a3ba89
Fix: RecipeListView에 final 추가
GeonH0 Jun 24, 2024
db38695
Fix: RecipeListViewCell에 final 추가
GeonH0 Jun 24, 2024
22ee02b
Fix: collectionView를 private 처리
GeonH0 Jun 24, 2024
6edb8bb
Fix: recipelistView를 recipeListView로 네이밍 변경
GeonH0 Jun 24, 2024
2a6372c
Fix: SearchBar 선언 수정
GeonH0 Jun 24, 2024
2be84eb
Fix: 마진 값을 변수로 뺌
GeonH0 Jun 25, 2024
ee35fb9
Fix: imageView 네이밍 변경
GeonH0 Jun 25, 2024
34985f7
Feat: Fonts 객체 정의
GeonH0 Jun 25, 2024
24d0856
Fix: Fonts 객체 적용
GeonH0 Jun 25, 2024
24a71e2
Fix: 이미지 설정코드 setupUI로 이동
GeonH0 Jun 25, 2024
72e9fe8
Feat: loadImage메서드를 extension으로 분리
GeonH0 Jun 25, 2024
cf0c78c
Fix: extension으로 분리된 loadImage 적용
GeonH0 Jun 25, 2024
15f80f0
Fix: RecipeListViewController final 추가
GeonH0 Jun 25, 2024
833b474
Fix: RecipeListViewModelDelegate을 extension으로 확장
GeonH0 Jun 25, 2024
be060c4
Feat: String extenstion에 isBlank 프러퍼티를 추가
GeonH0 Jun 25, 2024
99c274e
Fix: String extenstion에 isBlank 프러퍼티 적용
GeonH0 Jun 25, 2024
c0bd5a0
Fix: didFetchRecipes를 fetchedRecipes로 네이밍 변경
GeonH0 Jun 25, 2024
05b2a58
Merge branch 'main' into feature/feedListView
GeonH0 Jun 25, 2024
52d89ea
Fix: 핸들러에 [weak self] 추가
GeonH0 Jun 25, 2024
1a760ca
Fix: Metric 적용
GeonH0 Jun 26, 2024
3c03347
Fix: 불필요한 return 제거
GeonH0 Jun 29, 2024
7077713
Fix: ViewController에 UICollectionViewDataSource와 UICollectionViewDel…
GeonH0 Jul 1, 2024
c1bc9a0
Fix: RecipeListView에 UICollectionViewDataSource,UICollectionViewDeleg…
GeonH0 Jul 1, 2024
4eb8154
Fix: RecipeListInteractor에서 mapping 기능 제거, result타입으로 전달해서 에러 처리
GeonH0 Jul 1, 2024
e57455d
Fix: Delegate에 didFail제거, 상세화면을 보여주는 메서드 showRecipeDetail정의
GeonH0 Jul 1, 2024
f0115b8
Feat: RecipeListViewDelegate정의,RecipeListInteractorDelegate정의
GeonH0 Jul 1, 2024
d3dcc4e
Fix: Mark 추가
GeonH0 Jul 1, 2024
76fdeba
Feat: 기본 이미지 추가
GeonH0 Jul 1, 2024
e1a3fc2
Fix: RecipeListViewCell에서 기본 이미지 설정
GeonH0 Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// RecipeListViewCell.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/12/24.
//

import UIKit

class RecipeListViewCell: UICollectionViewCell {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 final 챙겨주세요~

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[db38695] 변경했습니다


private let imageView = UIImageView()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네이밍이 좀 더 구체적이면 어떨까요? (예. recipeThumbnailView)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ee35fb9] 변경했습니다

private let titleLabel = UILabel()

override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupUI() {
contentView.addSubview(imageView)
contentView.addSubview(titleLabel)

imageView.translatesAutoresizingMaskIntoConstraints = false
titleLabel.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
imageView.topAnchor.constraint(equalTo: topAnchor),
imageView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 10),
imageView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -10),
imageView.heightAnchor.constraint(equalTo: heightAnchor, multiplier: 0.75),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

75%면 3:4 사진 비율인건가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 3:4입니다


titleLabel.topAnchor.constraint(equalTo: imageView.bottomAnchor, constant: 10),
titleLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 10),
titleLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -10),
titleLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -10),
titleLabel.heightAnchor.constraint(equalTo: heightAnchor, multiplier: 0.15)
])

titleLabel.font = .systemFont(ofSize: 16, weight: .bold)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

폰트를 한군데서 정의해서 관리하면 어때요? 나중에 다른데서도 통일성있는 폰트를 사용할 수 있을 것 같아요.

Copy link
Collaborator Author

@GeonH0 GeonH0 Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[34985f7],[24d0856] 변경했습니다

titleLabel.textAlignment = .center
}

func configure(with viewModel: RecipeListItemViewModel) {
titleLabel.text = viewModel.name
if let imageUrl = viewModel.imageURL {
loadImage(from: imageUrl)
} else {
imageView.image = nil
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이미지가 없으면 이미지뷰에 기본 이미지는 없나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기본이미지를 추가하겠습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[76fdeba],[e1a3fc2] 기본이미지를 추가했습니다


imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 한번만 선언해주면 되는 것 같은데 configure 메서드에 있기보다 setupUI로 이동하면 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[24a71e2] 변경했습니다

}

private func loadImage(from url: URL) {
URLSession.shared.dataTask(with: url) { data, response, error in
guard let data = data, error == nil else { return }
DispatchQueue.main.async {
self.imageView.image = UIImage(data: data)
}
}.resume()
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ImageView 에 extension 으로 빠져있으면 다른 화면에서 재사용이 가능한 로직으로 보이는데
재사용할 수 있도록 빼놓는 건 어떻게 생각하시나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[72e9fe8],[cf0c78c] 변경했습니다

}