-
Notifications
You must be signed in to change notification settings - Fork 24
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
박스오피스 앱 [STEP 4] Matthew, Kyle #57
Open
Changhyun-Kyle
wants to merge
41
commits into
tasty-code:d_Matthew
Choose a base branch
from
kimbs5899:Step4
base: d_Matthew
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
b6b4dc6
feat: UIScrollView 구현
kimbs5899 dfbeca1
feat: UIScrollView에서 사용할 StackView구현
kimbs5899 cf250e9
refactor: UIScrollView 추가를 위한 기존 로직 수정
kimbs5899 7fa5b74
feat: 검색 REST API 모델 구현
Changhyun-Kyle 553324d
chore: 불필요 인덴트 제거
Changhyun-Kyle 4cdee98
refactor: NetworkURL 리팩토링 적용
kimbs5899 2e5a676
refactor: DataTask URLRequest로 구현로직 생성
kimbs5899 471108a
refactor: Kakao 검색 API를 위한 URLRequest 생성 로직 구현
kimbs5899 0f1d566
refactor: 영화 이미지 API 기능 구현
kimbs5899 cac53ec
fix: Json 디코딩 타입 수정
kimbs5899 d8d52e6
refactor: 영화포스터 뷰에 추가
kimbs5899 73a4e21
refactor: Step4 기능 로직 구현중
kimbs5899 bb09d06
chore: 불필요 파일 삭제 및 에셋 이미지 추가
Changhyun-Kyle 0ac9e35
test: 유닛 테스트 로직 작성 중
Changhyun-Kyle 8f239b1
fix: numberOfLines -> 0으로 수정
Changhyun-Kyle 58db67d
chore: Step3 로직 반영
Changhyun-Kyle 60eafb3
feat: BoxOfficeDetailView 데이터 패치 구현
Changhyun-Kyle 186da18
refactor: URLSession 패치 로직 변경에 따른 프로토콜 수정
Changhyun-Kyle 4129046
chore: 프로퍼티 및 메서드 은닉화
Changhyun-Kyle 0dfffa6
refactor: 기존 completion Handler -> async await 로직으로 리팩토링
Changhyun-Kyle a7b94c1
refactor: 기존 url 패치 로직 -> urlRequest 패치로 리팩토링
Changhyun-Kyle 12ed889
chore: Step3 로직 반영
Changhyun-Kyle 217aa92
feat: makeDateFormat 구현
Changhyun-Kyle 85d731a
refactor: 기존 completion Handler -> async await 로직으로 리팩토링
Changhyun-Kyle 4fa307a
refactor: 기존 completion Handler -> async await 로직으로 리팩토링
Changhyun-Kyle fd6e46b
Merge pull request #4 from kimbs5899/Step4_temp
Changhyun-Kyle a49e293
add: URLRequest 생성 파일 추가
Changhyun-Kyle 8df6464
remove: 불필요 테스트 파일 삭제
Changhyun-Kyle fa5fcf2
feat: URLRequest 생성 로직 구현
Changhyun-Kyle 85d4759
refactor: URLRequest 생성 로직 리팩토링
Changhyun-Kyle 5a36a52
test: 로직 리팩토링에 따른 테스트 코드 수정
Changhyun-Kyle e4e760d
feat: 영화 포스터 이미지 사이즈 수정
Changhyun-Kyle c7dcd5c
chore: NetworkURL 폴더링 수정
Changhyun-Kyle 1419c9c
Merge branch 'd_Matthew' into Step4
Changhyun-Kyle 8025c2a
chore: 테스트 로직 변경
Changhyun-Kyle 296fc81
chore: BDD 주석 추가
Changhyun-Kyle a15fe3a
chore: 네트워크 통신 파일 추가 및 삭제
Changhyun-Kyle c5f2c2b
feat: URLRequest 생성 로직 리팩토링
Changhyun-Kyle 7afcf0c
refactor: enum 타입으로 수정 후 View마다 대응할 수 있게 리팩토링
Changhyun-Kyle 5356d9c
refactor: 수정된 로직에 따라 리팩토링
Changhyun-Kyle 9b840be
refactor: 수정된 indicator 로직에 따라 리팩토링
Changhyun-Kyle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// BoxOfficeDetailViewController.swift | ||
// BoxOffice | ||
// | ||
// Created by Matthew on 3/8/24. | ||
// | ||
|
||
import UIKit | ||
|
||
final class BoxOfficeDetailViewController: UIViewController { | ||
private let movieName: String | ||
private let movieCode: String | ||
private let movieManager: MovieManager | ||
private let boxOfficeDetailView = BoxOfficeDetailView() | ||
|
||
init( | ||
movieName: String, | ||
movieCode: String, | ||
movieManager: MovieManager | ||
) { | ||
self.movieName = movieName | ||
self.movieCode = movieCode | ||
self.movieManager = movieManager | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
setupView() | ||
fetchBoxOfficeDetailData() | ||
} | ||
} | ||
|
||
private extension BoxOfficeDetailViewController { | ||
func setupView() { | ||
LoadingIndicatorView.showLoading(in: self.boxOfficeDetailView) | ||
view = boxOfficeDetailView | ||
view.backgroundColor = .white | ||
self.title = movieName | ||
} | ||
|
||
func fetchBoxOfficeDetailData() { | ||
Task { | ||
do { | ||
try await fetchMoiveImageURL() | ||
try await fetchMovieInfo() | ||
try await setupMovieImage() | ||
} catch { | ||
print(error.localizedDescription) | ||
} | ||
LoadingIndicatorView.hideLoading(in: self.boxOfficeDetailView) | ||
} | ||
} | ||
|
||
func fetchMovieInfo() async throws { | ||
let data = try await movieManager.fetchMovieInfoResultData(code: movieCode) | ||
self.boxOfficeDetailView.setupDetailView(data: data) | ||
} | ||
|
||
func fetchMoiveImageURL() async throws { | ||
try await movieManager.fetchMoiveImageURL(movieName: movieName) | ||
} | ||
|
||
func setupMovieImage() async throws { | ||
guard let data = try await movieManager.fetchImageData() else { return } | ||
self.boxOfficeDetailView.setupImage(image: UIImage(data: data)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,20 +17,9 @@ final class BoxOfficeViewController: UIViewController { | |
}() | ||
private lazy var dataSource = BoxOfficeListDataSource(self.boxOfficeListView) | ||
|
||
// init() { | ||
// super.init(nibName: nil, bundle: nil) | ||
// } | ||
// | ||
// required init?(coder: NSCoder) { | ||
// fatalError("init(coder:) has not been implemented") | ||
// } | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
boxOfficeListView.boxOfficeListDelegate = self | ||
boxOfficeListView.delegate = self | ||
boxOfficeListView.dataSource = dataSource | ||
view = boxOfficeListView | ||
setupBoxOfficeListView() | ||
setupBoxOfficeData() | ||
} | ||
} | ||
|
@@ -40,13 +29,22 @@ private extension BoxOfficeViewController { | |
self.title = Date.titleDateFormatter.string(from: date) | ||
} | ||
|
||
func setupBoxOfficeListView() { | ||
LoadingIndicatorView.showLoading(in: self.boxOfficeListView) | ||
boxOfficeListView.boxOfficeListDelegate = self | ||
boxOfficeListView.delegate = self | ||
boxOfficeListView.dataSource = dataSource | ||
view = boxOfficeListView | ||
} | ||
|
||
func setupBoxOfficeData() { | ||
movieManager.fetchBoxOfficeResultData(date: Date.movieDateToString) { result in | ||
switch result { | ||
case .success(let success): | ||
self.reloadCollectionListData(result: success) | ||
case .failure(let failure): | ||
print("fetchBoxOfficeResultData 실패: \(failure)") | ||
Task { | ||
do { | ||
let result = try await movieManager.fetchBoxOfficeResultData(date: Date.movieDateToString) | ||
self.reloadCollectionListData(result: result) | ||
LoadingIndicatorView.hideLoading(in: self.view) | ||
} catch { | ||
print(error.localizedDescription) | ||
} | ||
Comment on lines
+41
to
48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로딩 인디케이터가 사라져야 하는 시점이 언제일지 다시 한번 확인해보세요~ |
||
} | ||
} | ||
|
@@ -60,27 +58,26 @@ private extension BoxOfficeViewController { | |
} | ||
|
||
func updateBoxOfficeList() { | ||
movieManager.fetchBoxOfficeResultData(date: Date.movieDateToString) { [weak self] result in | ||
switch result { | ||
case .success(let result): | ||
DispatchQueue.main.async { | ||
self?.applyBoxOfficeList(result: result) | ||
guard | ||
let date = result.showRange.toDateFromRange() | ||
else { | ||
return | ||
} | ||
self?.configureNavigation(date: date) | ||
Task { | ||
do { | ||
let result = try await self.movieManager.fetchBoxOfficeResultData( | ||
date: Date.movieDateToString | ||
) | ||
self.applyBoxOfficeList(result: result) | ||
guard | ||
let date = result.showRange.toDateFromRange() | ||
else { | ||
return | ||
} | ||
case .failure(let error): | ||
self.configureNavigation(date: date) | ||
} catch { | ||
print(error.localizedDescription) | ||
} | ||
} | ||
} | ||
|
||
func reloadCollectionListData(result: BoxOfficeResult) { | ||
DispatchQueue.main.async { | ||
self.boxOfficeListView.indicatorView.stopAnimating() | ||
self.configureNavigation(date: Date.yesterday) | ||
self.applyBoxOfficeList(result: result) | ||
self.boxOfficeListView.isScrollEnabled = true | ||
|
@@ -90,7 +87,17 @@ private extension BoxOfficeViewController { | |
|
||
extension BoxOfficeViewController: UICollectionViewDelegate { | ||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | ||
self.navigationController?.popViewController(animated: true) | ||
guard | ||
let data = movieManager.setupBoxOfficeDetailData(for: indexPath.row) | ||
else { | ||
return | ||
} | ||
let detailViewController = BoxOfficeDetailViewController( | ||
movieName: data.movieName, | ||
movieCode: data.movieCode, | ||
movieManager: movieManager | ||
) | ||
self.navigationController?.pushViewController(detailViewController, animated: true) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Document.swift | ||
// BoxOffice | ||
// | ||
// Created by 강창현 on 3/8/24. | ||
// | ||
|
||
struct Document: Codable { | ||
let collection: String | ||
let thumbnailURL: String | ||
let imageURL: String | ||
let width: Int | ||
let height: Int | ||
let displaySiteName: String | ||
let docURL: String | ||
let datetime: String | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case collection | ||
case thumbnailURL = "thumbnail_url" | ||
case imageURL = "image_url" | ||
case width | ||
case height | ||
case displaySiteName = "display_sitename" | ||
case docURL = "doc_url" | ||
case datetime | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Meta.swift | ||
// BoxOffice | ||
// | ||
// Created by 강창현 on 3/8/24. | ||
// | ||
|
||
struct Meta: Codable { | ||
let totalCount: Int | ||
let pageableCount: Int | ||
let isEnd: Bool | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case isEnd = "is_end" | ||
case pageableCount = "pageable_count" | ||
case totalCount = "total_count" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
// MovieImage.swift | ||
// BoxOffice | ||
// | ||
// Created by 강창현 on 3/8/24. | ||
// | ||
|
||
struct MovieImage: Codable { | ||
let meta: Meta | ||
let documents: [Document] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 로딩 인디케이터가 사라져야 하는 시점이 언제일지 다시 한번 확인해보세요~