-
Notifications
You must be signed in to change notification settings - Fork 24
박스오피스 앱 [STEP4] Jane, Tommy #59
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
Open
jane1choi
wants to merge
35
commits into
tasty-code:d_Tommy
Choose a base branch
from
angryeon7:feat/step4
base: d_Tommy
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
35 commits
Select commit
Hold shift + click to select a range
9ac6ae6
add: MovieEntity 추가
jane1choi 9d9a6af
feat: MovieInfoTableViewCell 기본 UI 구성
jane1choi 81e2537
feat: 영화 상세 뷰 기본 UI 구성
jane1choi 3dd3e49
chore: cell identifier 설정 코드 수정
jane1choi 94ab493
chore: 빈 줄 삭제
jane1choi d35aae1
chore: 파일 경로 수정
jane1choi 8863c93
chore: MovieAPIService 인스턴스 생성 방식 수정
angryeon7 c1e9745
feat: moviedto -> entity 변환 메서드 구현
angryeon7 aa4f585
chore: movieCode 추가
angryeon7 a921b87
feat: MovieRepository 구현
angryeon7 03078cc
feat: MovieUseCase 구현
angryeon7 f843f8d
feat: 배열 변환 메서드 구현
angryeon7 8f191c6
feat: MovieDetailViewModel 구현
angryeon7 7145e1f
feat: movieDetailVC 화면전환 메소드 구현
angryeon7 785a5a1
feat: viewmodel 주입
angryeon7 9f48613
chore: cell 별 데이터 삽입
angryeon7 e174da9
feat: MoviePosterDTO 생성
angryeon7 a4df8ab
feat: MoviePosterEntity 생성
angryeon7 60feb91
refactor: TargetType URL 삭제
angryeon7 f07e7fe
feat: MoviePosterAPI 생성
angryeon7 a3dec89
feat: MoviePosterAPIService 생성
angryeon7 6177f97
feat: PosterRepository 생성
angryeon7 4e4a95a
feat: MoviePosterUseCase 생성
angryeon7 bfea546
feat: DetailViewModel에 PosterUseCase 추가
angryeon7 93cc3ef
feat: ImageCell 생성
angryeon7 66abaed
feat: ImageCell 등록
angryeon7 48e2ab3
feat: DI 코드 추가
angryeon7 59e955d
chore: 셀 설정 코드 강제 옵셔널 추출 코드 수정
jane1choi 7af04a8
chore: cell selectionStyle 설정 및 자잘한 코드 수정
jane1choi e1a0597
fix: 스택뷰 관련 레이아웃이 깨지는 문제 해결
jane1choi db3b894
chore: 자잘한 코드 수정
jane1choi 51585f2
chore: 이미지 contentMode 수정 및 UI 자잘한 코드 수정
jane1choi 290348f
chore: 프린트문 삭제
jane1choi b49421f
fix: 모든 요청에서 networkFail이 발생하는 문제
jane1choi 7a6b0c6
chore: NetworkResult 케이스 추가 및 parsingError 부분 수정
jane1choi 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,46 @@ | ||
| // | ||
| // MoviePosterAPI.swift | ||
| // BoxOffice | ||
| // | ||
| // Created by nayeon on 3/19/24. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum MoviePosterAPI { | ||
| case requestMoviePosterImage(userkey: String, query: String) | ||
| } | ||
|
|
||
| extension MoviePosterAPI: TargetType { | ||
|
|
||
| var baseURL: String { | ||
| return "https://dapi.kakao.com/v2" | ||
| } | ||
|
|
||
| var method: HTTPMethod { | ||
| return .get | ||
| } | ||
|
|
||
| var path: String { | ||
| switch self { | ||
| case .requestMoviePosterImage: | ||
| return "/search/image" | ||
| } | ||
| } | ||
|
|
||
| var parameters: RequestParameters { | ||
| switch self { | ||
| case let .requestMoviePosterImage(_, movieName): | ||
| return .query(["query": "\(movieName) 영화 포스터", | ||
| "size": "1", | ||
| "sort": "accuracy"]) | ||
| } | ||
| } | ||
|
|
||
| var header: HeaderType { | ||
| switch self { | ||
| case let .requestMoviePosterImage(apiKey, _): | ||
| return .custom(["Authorization": "KakaoAK \(apiKey)"]) | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,47 @@ | ||
| // | ||
| // MoviePosterDTO.swift | ||
| // BoxOffice | ||
| // | ||
| // Created by nayeon on 3/19/24. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct MoviePosterDTO: Codable { | ||
| let meta: Meta | ||
| let documents: [Document] | ||
| } | ||
|
|
||
| struct Meta: Codable { | ||
| let totalCount: Int | ||
| let pageableCount: Int | ||
| let isEnd: Bool | ||
|
|
||
| enum CodingKeys: String, CodingKey { | ||
| case totalCount = "total_count" | ||
| case pageableCount = "pageable_count" | ||
| case isEnd = "is_end" | ||
| } | ||
| } | ||
|
|
||
| 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 hidden or 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
37 changes: 37 additions & 0 deletions
37
BoxOffice/Data/Network/Services/MoviePosterAPIService.swift
This file contains hidden or 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,37 @@ | ||
| // | ||
| // MoviePosterAPIService.swift | ||
| // BoxOffice | ||
| // | ||
| // Created by nayeon on 3/19/24. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| final class MoviePosterAPIService: BaseAPIService { | ||
|
|
||
| override init(provider: Requestable) { | ||
| super.init(provider: NetworkProvider()) | ||
| } | ||
|
|
||
| func requestMoviePosterAPI(userKey: String, query: String, completion: @escaping ((NetworkResult<Any>) -> Void)) { | ||
| guard let request = try? MoviePosterAPI | ||
| .requestMoviePosterImage(userkey: userKey, query: query) | ||
| .creatURLRequest() | ||
| else { | ||
| completion(.networkFail) | ||
| return | ||
| } | ||
|
|
||
| provider.request(request) { result in | ||
| switch result { | ||
| case .success(let result): | ||
| let networkResult = self.judgeStatus(by: result.response.statusCode, | ||
| result.data, | ||
| MoviePosterDTO.self) | ||
| completion(networkResult) | ||
| case .failure(_): | ||
| completion(.networkFail) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
73 changes: 73 additions & 0 deletions
73
BoxOffice/Data/Repositories/DefaultMoviePosterRepository.swift
This file contains hidden or 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,73 @@ | ||
| // | ||
| // DefaultMoviePosterRepository.swift | ||
| // BoxOffice | ||
| // | ||
| // Created by nayeon on 3/19/24. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| final class DefaultMoviePosterRepository: MoviePosterRepository { | ||
|
|
||
| private let apiService: MoviePosterAPIService | ||
|
|
||
| init(apiService: MoviePosterAPIService) { | ||
| self.apiService = apiService | ||
| } | ||
|
|
||
| func fetchMoviePoster(query: String, completion: @escaping (NetworkResult<MoviePosterEntity>) -> Void) { | ||
| guard let apiKey = Bundle.main.object(forInfoDictionaryKey: "KAKAO_KEY") as? String else { return } | ||
|
|
||
| apiService.requestMoviePosterAPI(userKey: apiKey, query: query) { result in | ||
| switch result { | ||
| case .success(let data): | ||
| if let dto = data as? MoviePosterDTO, | ||
| let firstImageUrl = dto.documents.first?.imageURL { | ||
| self.loadImage(from: firstImageUrl) { result in | ||
| switch result { | ||
| case .success(let image): | ||
| let posterEntity = MoviePosterEntity(image: image) | ||
| DispatchQueue.main.async { | ||
| completion(.success(posterEntity)) | ||
| } | ||
| case .failure: | ||
| completion(.networkFail) | ||
| } | ||
| } | ||
| } else { | ||
| completion(.parsingError) | ||
| } | ||
| case .pathError: | ||
| completion(.pathError) | ||
| case .parsingError: | ||
| completion(.parsingError) | ||
| case .requestError: | ||
| completion(.requestError) | ||
| case .serverError: | ||
| completion(.serverError) | ||
| case .networkFail: | ||
| completion(.networkFail) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func loadImage(from imageUrl: String, completion: @escaping (Result<UIImage, Error>) -> Void) { | ||
| guard let url = URL(string: imageUrl) else { | ||
| completion(.failure(NetworkError.invalidURL)) | ||
| return | ||
| } | ||
|
|
||
| URLSession.shared.dataTask(with: url) { data, response, error in | ||
| if let error = error { | ||
| completion(.failure(error)) | ||
| return | ||
| } | ||
|
|
||
| guard let data = data, let image = UIImage(data: data) else { | ||
| completion(.failure(NetworkError.invalidURL)) | ||
| return | ||
| } | ||
| completion(.success(image)) | ||
| }.resume() | ||
| } | ||
| } |
This file contains hidden or 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,43 @@ | ||
| // | ||
| // DefaultMovieRepository.swift | ||
| // BoxOffice | ||
| // | ||
| // Created by nayeon on 3/13/24. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| final class DefaultMovieRepository: MovieRepository { | ||
|
|
||
| private let apiService: MovieAPIService | ||
|
|
||
| init(apiService: MovieAPIService) { | ||
| self.apiService = apiService | ||
| } | ||
|
|
||
| func fetchMovieDetail(movieCode: String, completion: @escaping (NetworkResult<MovieEntity>) -> Void) { | ||
| guard let apiKey = Bundle.main.object(forInfoDictionaryKey: "API_KEY") as? String else { return } | ||
|
|
||
| apiService.requestMovieDetailAPI(userKey: apiKey, movieCode: movieCode) { result in | ||
| switch result { | ||
| case .success(let data): | ||
| if let dto = data as? MovieDTO { | ||
| DispatchQueue.main.async { | ||
| let movieEntity = dto.movieInformationResult.detailMovieInformation.toEntity() | ||
| completion(.success(movieEntity)) | ||
| } | ||
| } | ||
| case .pathError: | ||
| completion(.pathError) | ||
| case .parsingError: | ||
| completion(.parsingError) | ||
| case .requestError: | ||
| completion(.requestError) | ||
| case .serverError: | ||
| completion(.serverError) | ||
| case .networkFail: | ||
| completion(.networkFail) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,31 @@ | ||
| // | ||
| // MovieEntity.swift | ||
| // BoxOffice | ||
| // | ||
| // Created by EUNJU on 3/13/24. | ||
| // | ||
|
|
||
| struct MovieEntity { | ||
| let movieName: String | ||
| let director: String | ||
| let productYear: String | ||
| let openDate: String | ||
| let showTime: String | ||
| let watchGrade: String | ||
| let nation: String | ||
| let genres: String | ||
| let actors: String | ||
|
|
||
| func getInfoArray() -> [(title: String, info: String)] { | ||
| return [ | ||
| ("감독:", director), | ||
| ("제작년도:", productYear), | ||
| ("개봉일:", openDate), | ||
| ("상영시간:", showTime), | ||
| ("관람등급:", watchGrade), | ||
| ("제작국가:", nation), | ||
| ("장르:", genres), | ||
| ("배우:", actors) | ||
| ] | ||
| } | ||
| } | ||
This file contains hidden or 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,12 @@ | ||
| // | ||
| // MoviePosterEntity.swift | ||
| // BoxOffice | ||
| // | ||
| // Created by nayeon on 3/19/24. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| struct MoviePosterEntity { | ||
| let image: UIImage | ||
| } |
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.
이 부분을 튜플로 처리하신 이유가 있을까요?
key value 가 있는 형태라면, dictionary도 괜찮았을 것 같은데,
이런 타입을 채택하신 이유가 궁금합니다🤔
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.
dictionary를 사용할 경우 순서를 지킬수 없기 때문에 순서를 지키기위해 튜플을 채택하였습니다.