From f17ea81a9f04bdfdcfe29b1db546a575e447375e Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Thu, 26 Dec 2024 01:19:03 +0900 Subject: [PATCH 01/18] =?UTF-8?q?[Fix]=20#319=20-=20=EC=8B=9D=EB=8B=B9=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20API=20Response=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=B0=94=EC=9D=B8=EB=94=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 위도 경도 카테고리 이미지 추가 서버 대기 중이라 임의 값 넣어둔 상태 --- .../Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift | 3 +++ .../Present/HankkiDetail/View/DetailMapView.swift | 8 +++++++- .../HankkiDetail/View/HankkiDetailViewController.swift | 3 ++- .../Present/HankkiDetail/View/HankkiInfoView.swift | 7 ++----- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Network/Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift b/Hankkijogbo/Hankkijogbo/Network/Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift index 5b238c68..87843e3a 100644 --- a/Hankkijogbo/Hankkijogbo/Network/Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift +++ b/Hankkijogbo/Hankkijogbo/Network/Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift @@ -15,6 +15,9 @@ struct GetHankkiDetailResponseData: Codable { let isLiked: Bool let imageUrls: [String] let menus: [MenuData] + let latitude: Double = 37.502802 + let longitude: Double = 127.0841337 + let categoryImageUrl: String = "" } struct MenuData: Codable { diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift index 052c1f1f..57b29181 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift @@ -107,7 +107,6 @@ final class DetailMapView: BaseView { addressLabel.do { $0.attributedText = UILabel.setupAttributedText( for: PretendardStyle.caption4, - withText: "경기도 수원시 아주대학교 어쩌구", color: .gray700 ) } @@ -127,6 +126,13 @@ final class DetailMapView: BaseView { } } +extension DetailMapView { + + func bindData(latitude: Double, longitude: Double) { + addressLabel.text = "\(latitude) \(longitude)" + } +} + // MARK: - Private Func private extension DetailMapView { diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift index 0a203ffe..1d1a55ed 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift @@ -165,11 +165,12 @@ private extension HankkiDetailViewController { hankkiInfoView.bindData( category: data.category, + categoryImageUrl: data.categoryImageUrl, name: data.name, heartCount: String(data.heartCount), isLiked: data.isLiked ) - // map view bind data 예정 + detailMapView.bindData(latitude: data.latitude, longitude: data.longitude) menuCollectionView.updateLayout(menuSize: data.menus.count) menuCollectionView.collectionView.reloadData() diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiInfoView.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiInfoView.swift index e0a6872f..54607347 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiInfoView.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiInfoView.swift @@ -75,10 +75,6 @@ final class HankkiInfoView: BaseView { $0.backgroundColor = .hankkiWhite } - categoryImageView.do { - $0.image = .icHomeSelected - } - categoryLabel.do { $0.attributedText = UILabel.setupAttributedText(for: PretendardStyle.caption4, color: .gray900) } @@ -116,8 +112,9 @@ final class HankkiInfoView: BaseView { extension HankkiInfoView { - func bindData(category: String, name: String, heartCount: String, isLiked: Bool) { + func bindData(category: String, categoryImageUrl: String, name: String, heartCount: String, isLiked: Bool) { categoryLabel.text = category + categoryImageView.setKFImage(url: categoryImageUrl) nameLabel.text = name if let attributedTitle = UILabel.setupAttributedText( for: PretendardStyle.body8, From 95efb194d39ab50dfe3c694abc51336f247a5e19 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Fri, 27 Dec 2024 00:15:10 +0900 Subject: [PATCH 02/18] =?UTF-8?q?[Chore]=20#319=20-=20Res=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=EA=B0=92=20=EC=84=A4=EC=A0=95=ED=95=B4=EB=91=94=20?= =?UTF-8?q?=EA=B1=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Network/Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift b/Hankkijogbo/Hankkijogbo/Network/Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift index 87843e3a..0d991903 100644 --- a/Hankkijogbo/Hankkijogbo/Network/Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift +++ b/Hankkijogbo/Hankkijogbo/Network/Hankki/DTO/Response/GetHankkiDetailResponseDTO.swift @@ -15,9 +15,9 @@ struct GetHankkiDetailResponseData: Codable { let isLiked: Bool let imageUrls: [String] let menus: [MenuData] - let latitude: Double = 37.502802 - let longitude: Double = 127.0841337 - let categoryImageUrl: String = "" + let latitude: Double + let longitude: Double + let categoryImageUrl: String } struct MenuData: Codable { From 1bbbe3f2e37b0e29b250f243c7443cf24e173024 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Sun, 29 Dec 2024 04:45:41 +0900 Subject: [PATCH 03/18] =?UTF-8?q?[Design]=20#319=20-=20=EC=8B=9D=EB=8B=B9?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EC=B5=9C=EB=8C=80=202=EC=A4=84?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=20=ED=91=9C=EC=8B=9C=EB=90=A0=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EA=B2=8C=20=EB=86=92=EC=9D=B4=20=EC=A0=9C=ED=95=9C=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Present/HankkiDetail/View/HankkiDetailViewController.swift | 1 - .../Hankkijogbo/Present/HankkiDetail/View/HankkiInfoView.swift | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift index 1d1a55ed..5d626eec 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift @@ -113,7 +113,6 @@ final class HankkiDetailViewController: BaseViewController, NetworkResultDelegat hankkiInfoView.snp.makeConstraints { $0.top.equalTo(thumbnailImageView.snp.bottom) $0.leading.trailing.equalToSuperview() - $0.height.equalTo(116) } detailMapView.snp.makeConstraints { diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiInfoView.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiInfoView.swift index e15b8878..7d4b98a2 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiInfoView.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiInfoView.swift @@ -45,7 +45,7 @@ final class HankkiInfoView: BaseView { nameLabel.snp.makeConstraints { $0.top.equalTo(categoryImageView.snp.bottom).offset(2) - $0.leading.equalToSuperview().inset(22) + $0.leading.trailing.equalToSuperview().inset(22) } heartButton.snp.makeConstraints { @@ -76,6 +76,7 @@ final class HankkiInfoView: BaseView { } nameLabel.do { + $0.numberOfLines = 2 $0.attributedText = UILabel.setupAttributedText(for: PretendardStyle.h3, color: .gray900) } From 0b53a6ba3087f42508955910f4b86fa7db737352 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 07:40:16 +0900 Subject: [PATCH 04/18] =?UTF-8?q?[Design]=20#319=20-=20=EB=A9=94=EB=89=B4?= =?UTF-8?q?=EB=AA=85=202=EC=A4=84=20=EC=9D=B4=EC=83=81=EC=9D=BC=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=EB=A5=BC=20=EB=8C=80=EB=B9=84=ED=95=B4=20?= =?UTF-8?q?=EB=8F=99=EC=A0=81=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cell/HankkiMenuCollectionViewCell.swift | 1 - .../View/HankkiDetailViewController.swift | 22 ++++++++++++++++++- .../View/HankkiMenuCollectionView.swift | 20 ++++++++++------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/Cell/HankkiMenuCollectionViewCell.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/Cell/HankkiMenuCollectionViewCell.swift index fa53bf31..e2e0a0f5 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/Cell/HankkiMenuCollectionViewCell.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/Cell/HankkiMenuCollectionViewCell.swift @@ -9,7 +9,6 @@ import UIKit final class HankkiMenuCollectionViewCell: BaseCollectionViewCell { - // MARK: - Properties // MARK: - UI Components private var nameLabel: UILabel = UILabel() diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift index 5d626eec..611a0c56 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift @@ -171,7 +171,6 @@ private extension HankkiDetailViewController { ) detailMapView.bindData(latitude: data.latitude, longitude: data.longitude) - menuCollectionView.updateLayout(menuSize: data.menus.count) menuCollectionView.collectionView.reloadData() } } @@ -370,10 +369,31 @@ extension HankkiDetailViewController: UICollectionViewDataSource, UICollectionVi func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HankkiMenuCollectionViewCell.className, for: indexPath) as? HankkiMenuCollectionViewCell else { return UICollectionViewCell() } + if let data = viewModel.hankkiDetailData { cell.bindData(data.menus[indexPath.item]) + menuCollectionView.updateLayout() return cell } return UICollectionViewCell() } } + +extension HankkiDetailViewController: UICollectionViewDelegateFlowLayout { + + // 메뉴명 label 길이에 따라 다르게 셀 크기 지정 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + if let data = viewModel.hankkiDetailData { + let menuNameLabelSize = NSString(string: data.menus[indexPath.item].name) + .boundingRect( + with: CGSize(width: UIScreen.getDeviceWidth() - 44, height: CGFloat.greatestFiniteMagnitude), + options: .usesLineFragmentOrigin, + attributes: [NSAttributedString.Key.font: UIFont.setupPretendardStyle(of: .body8)], + context: nil + ) + return CGSize(width: UIScreen.getDeviceWidth(), height: menuNameLabelSize.height + 25) + } + + return .zero + } +} diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiMenuCollectionView.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiMenuCollectionView.swift index e5cda280..25ecc0b0 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiMenuCollectionView.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiMenuCollectionView.swift @@ -12,7 +12,7 @@ final class HankkiMenuCollectionView: BaseView { // MARK: - UI Components private let flowLayout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() - lazy var collectionView: UICollectionView = UICollectionView(frame: .init(x: 0, y: 0, width: UIScreen.getDeviceWidth(), height: 179), collectionViewLayout: flowLayout) + lazy var collectionView: UICollectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout) // MARK: - Life Cycle @@ -20,9 +20,16 @@ final class HankkiMenuCollectionView: BaseView { addSubview(collectionView) } + override func setupLayout() { + collectionView.snp.makeConstraints { + $0.edges.equalToSuperview() + $0.width.equalTo(UIScreen.getDeviceWidth()) + $0.height.equalTo(179) + } + } + override func setupStyle() { flowLayout.do { - $0.itemSize = .init(width: UIScreen.getDeviceWidth(), height: 45) $0.scrollDirection = .vertical $0.minimumLineSpacing = 24 $0.headerReferenceSize = .init(width: UIScreen.getDeviceWidth(), height: 20 + 26) @@ -39,14 +46,11 @@ final class HankkiMenuCollectionView: BaseView { extension HankkiMenuCollectionView { - /// 메뉴 데이터 불러온 이후에 메뉴 개수에 따라 높이 동적으로 설정 - func updateLayout(menuSize: Int) { - collectionView.snp.removeConstraints() - collectionView.snp.makeConstraints { + func updateLayout() { + collectionView.snp.updateConstraints { $0.edges.equalToSuperview() $0.width.equalTo(UIScreen.getDeviceWidth()) - $0.height.equalTo(20 + 26 + 18 + (menuSize * (45 + 24)) + 48 + 18) + $0.height.equalTo(collectionView.contentSize.height) } - layoutIfNeeded() } } From 2f9051e8df294b91fa5d1ade03e189b9a4d9277f Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 08:05:05 +0900 Subject: [PATCH 05/18] =?UTF-8?q?[Design]=20#319=20-=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=20=EB=B0=B1=EB=B2=84=ED=8A=BC=20=EC=96=BC=EB=9D=BC=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 다른 디폴트 백버튼이랑 얼라인 좀 맞춤 --- .../HankkiDetail/View/HankkiDetailViewController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift index 611a0c56..0f935e20 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift @@ -100,8 +100,8 @@ final class HankkiDetailViewController: BaseViewController, NetworkResultDelegat } backButton.snp.makeConstraints { - $0.top.equalToSuperview().inset(48.5) - $0.leading.equalToSuperview().inset(7) + $0.top.equalToSuperview().inset(57) + $0.leading.equalToSuperview().inset(8) $0.size.equalTo(40) } From 85eed08ac09cdf19b83c1771ae7ff63f5cc5f649 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 08:19:42 +0900 Subject: [PATCH 06/18] =?UTF-8?q?[Chore]=20#319=20-=20=EC=95=88=20?= =?UTF-8?q?=EC=93=B0=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 내 족보 바텀 시트에서 셀 클릭 시 상세로 가는 코드는 왜 있는 거지 대체...? --- .../View/MyZipListBottomSheetViewController.swift | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/MyZipList/View/MyZipListBottomSheetViewController.swift b/Hankkijogbo/Hankkijogbo/Present/MyZipList/View/MyZipListBottomSheetViewController.swift index d9aca7f9..c30bc0c7 100644 --- a/Hankkijogbo/Hankkijogbo/Present/MyZipList/View/MyZipListBottomSheetViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/MyZipList/View/MyZipListBottomSheetViewController.swift @@ -207,7 +207,6 @@ private extension MyZipListBottomSheetViewController { } func setupDelegate() { - myZipCollectionView.delegate = self myZipCollectionView.dataSource = self } @@ -358,15 +357,3 @@ extension MyZipListBottomSheetViewController: UICollectionViewDataSource { return cell } } - -// MARK: - UICollectionViewDelegate - -extension MyZipListBottomSheetViewController: UICollectionViewDelegate { - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - if let data = viewModel.myZipListFavoriteData { - let hankkiId = data[indexPath.item].id - let hankkiDetailViewController = HankkiDetailViewController(viewModel: HankkiDetailViewModel(hankkiId: hankkiId)) - navigationController?.pushViewController(hankkiDetailViewController, animated: true) - } - } -} From 5d8c35e573b612587fd12192af6bfa62096fca5b Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 08:20:53 +0900 Subject: [PATCH 07/18] =?UTF-8?q?[Feat]=20#319=20-=20=EC=8B=9D=EB=8B=B9=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=EB=A1=9C=20push=20=EB=90=A0=20=EB=95=8C=20?= =?UTF-8?q?=EB=84=A4=EB=B9=84=EB=B0=94=20=EC=84=B8=ED=8C=85=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=BD=94=EB=93=9C=20extension=EC=97=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UIViewController+에 추가 --- .../Global/Extensions/UIViewController+.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Hankkijogbo/Hankkijogbo/Global/Extensions/UIViewController+.swift b/Hankkijogbo/Hankkijogbo/Global/Extensions/UIViewController+.swift index b6a0af1a..04ab680d 100644 --- a/Hankkijogbo/Hankkijogbo/Global/Extensions/UIViewController+.swift +++ b/Hankkijogbo/Hankkijogbo/Global/Extensions/UIViewController+.swift @@ -156,4 +156,20 @@ extension UIViewController { self.view.window!.layer.add(transition, forKey: nil) self.dismiss(animated: true, completion: nil) } + + /// 한끼 네비로 세팅한 후 식당 상세로 push + func pushToDetailWithHankkiNavigation(hankkiId: Int) { + if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, + let rootViewController = windowScene.windows.first?.rootViewController as? HankkiNavigationController { + let type: HankkiNavigationType = HankkiNavigationType(hasBackButton: true, + hasRightButton: false, + mainTitle: .string(""), + rightButton: .string("")) + rootViewController.setupNavigationBar(forType: type) + rootViewController.isNavigationBarHidden = false + + let hankkiDetailViewController = HankkiDetailViewController(viewModel: HankkiDetailViewModel(hankkiId: hankkiId)) + rootViewController.pushViewController(hankkiDetailViewController, animated: true) + } + } } From cc5e660b59b0b2d44f188e2c8eb68494fcc1bf9f Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 08:21:21 +0900 Subject: [PATCH 08/18] =?UTF-8?q?[Feat]=20#319=20-=20=EC=8B=9D=EB=8B=B9=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=EB=A1=9C=20push=20=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EB=AA=A8=EB=93=A0=20=EA=B2=BD=EC=9A=B0=20=EB=84=A4=EB=B9=84?= =?UTF-8?q?=EB=B0=94=20=EC=83=88=EB=A1=9C=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Present/HankkiList/View/HankkiListViewController.swift | 3 +-- .../Present/Report/Complete/ReportCompleteViewController.swift | 3 +-- .../Present/Report/Search/View/SearchViewController.swift | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiList/View/HankkiListViewController.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiList/View/HankkiListViewController.swift index bfeb0ea8..a9333592 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiList/View/HankkiListViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiList/View/HankkiListViewController.swift @@ -241,8 +241,7 @@ extension HankkiListViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) let hankkiId = viewModel.hankkiList[indexPath.item].id - let hankkiDetailViewController = HankkiDetailViewController(viewModel: HankkiDetailViewModel(hankkiId: hankkiId)) - navigationController?.pushViewController(hankkiDetailViewController, animated: true) + pushToDetailWithHankkiNavigation(hankkiId: hankkiId) } } diff --git a/Hankkijogbo/Hankkijogbo/Present/Report/Complete/ReportCompleteViewController.swift b/Hankkijogbo/Hankkijogbo/Present/Report/Complete/ReportCompleteViewController.swift index f755b007..1fef78ab 100644 --- a/Hankkijogbo/Hankkijogbo/Present/Report/Complete/ReportCompleteViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/Report/Complete/ReportCompleteViewController.swift @@ -236,8 +236,7 @@ private extension ReportCompleteViewController { // MARK: - @objc Func @objc func bottomButtonPrimaryHandler() { - let hankkiDetailViewController = HankkiDetailViewController(viewModel: HankkiDetailViewModel(hankkiId: hankkiId)) - navigationController?.pushViewController(hankkiDetailViewController, animated: true) + pushToDetailWithHankkiNavigation(hankkiId: hankkiId) } @objc func addToMyZipListButtonDidTap() { diff --git a/Hankkijogbo/Hankkijogbo/Present/Report/Search/View/SearchViewController.swift b/Hankkijogbo/Hankkijogbo/Present/Report/Search/View/SearchViewController.swift index 1479e23c..c67f69bf 100644 --- a/Hankkijogbo/Hankkijogbo/Present/Report/Search/View/SearchViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/Report/Search/View/SearchViewController.swift @@ -275,8 +275,7 @@ private extension SearchViewController { func pushToHankkiDetail() { guard let hankkiId = viewModel.storeId else { return } - let hankkiDetailViewController = HankkiDetailViewController(viewModel: HankkiDetailViewModel(hankkiId: hankkiId)) - navigationController?.pushViewController(hankkiDetailViewController, animated: true) + pushToDetailWithHankkiNavigation(hankkiId: hankkiId) } } From 9d96f06de1313f9cf2ea49c451bbb84e1e1f1dfe Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 08:52:07 +0900 Subject: [PATCH 09/18] =?UTF-8?q?[Feat]=20#319=20-=20=EC=83=81=EC=84=B8=20?= =?UTF-8?q?=EC=A7=80=EB=8F=84=EC=97=90=20=ED=95=9C=EB=81=BC=20=ED=95=80=20?= =?UTF-8?q?=EB=9D=84=EC=9A=B0=EA=B3=A0=20=EC=B9=B4=EB=A9=94=EB=9D=BC=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Present/HankkiDetail/View/DetailMapView.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift index 04942280..606ff31b 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift @@ -81,6 +81,7 @@ final class DetailMapView: BaseView { } mapView.do { + $0.zoomLevel = 16 $0.clipsToBounds = true $0.layer.cornerRadius = 12 $0.layer.maskedCorners = CACornerMask(arrayLiteral: .layerMinXMinYCorner, .layerMaxXMinYCorner) @@ -130,6 +131,8 @@ extension DetailMapView { func bindData(latitude: Double, longitude: Double) { addressLabel.text = "\(latitude) \(longitude)" + addMapMarker(latitude: latitude, longitude: longitude) + moveMapCamera(latitude: latitude, longitude: longitude) } } @@ -145,6 +148,18 @@ private extension DetailMapView { UIPasteboard.general.string = addressLabel.text } + func addMapMarker(latitude: Double, longitude: Double) { + let marker = NMFMarker() + marker.position = NMGLatLng(lat: latitude, lng: longitude) + marker.iconImage = NMFOverlayImage(image: .icPin) + marker.mapView = mapView + } + + func moveMapCamera(latitude: Double, longitude: Double) { + let cameraUpdate = NMFCameraUpdate(scrollTo: NMGLatLng(lat: latitude, lng: longitude)) + mapView.moveCamera(cameraUpdate) + } + // MARK: - @objc Func @objc func copyButtonDidTap() { From a872e222d1c771f0a3eae2eadb34ea956477cb8a Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 10:52:49 +0900 Subject: [PATCH 10/18] =?UTF-8?q?[Setting]=20#319=20-=20Config=20=EB=B0=8F?= =?UTF-8?q?=20Info.plist=EC=97=90=20Reverse=20Geocoding=20API=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=ED=82=A4=20=EA=B0=92=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Hankkijogbo/Global/Resources/Config.swift | 16 ++++++++++++++++ .../Global/Supporting Files/Info.plist | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Global/Resources/Config.swift b/Hankkijogbo/Hankkijogbo/Global/Resources/Config.swift index 67a963a6..cfd01672 100644 --- a/Hankkijogbo/Hankkijogbo/Global/Resources/Config.swift +++ b/Hankkijogbo/Hankkijogbo/Global/Resources/Config.swift @@ -15,6 +15,8 @@ enum Config { static let baseURL = "BASE_URL" static let NMFClientId = "NMFClientId" static let Amplitude = "Amplitude" + static let reverseGeocodingClientId = "ReverseGeocodingClientId" + static let reverseGeocodingClientSecret = "ReverseGeocodingClientSecret" } } @@ -41,6 +43,20 @@ extension Config { return key }() + static let ReverseGeocodingClientId: String = { + guard let key = Config.infoDictionary[Keys.Plist.reverseGeocodingClientId] as? String else { + fatalError("ReverseGeocodingClientID is not set in plist for this configuration.") + } + return key + }() + + static let ReverseGeocodingClientSecret: String = { + guard let key = Config.infoDictionary[Keys.Plist.reverseGeocodingClientSecret] as? String else { + fatalError("ReverseGeocodingClientSecret is not set in plist for this configuration.") + } + return key + }() + static let Amplitude: String = { guard let key = Config.infoDictionary[Keys.Plist.Amplitude] as? String else { fatalError("Amplitude is not set in plist for this configuration.") diff --git a/Hankkijogbo/Hankkijogbo/Global/Supporting Files/Info.plist b/Hankkijogbo/Hankkijogbo/Global/Supporting Files/Info.plist index 1128bed6..1c23e9d8 100644 --- a/Hankkijogbo/Hankkijogbo/Global/Supporting Files/Info.plist +++ b/Hankkijogbo/Hankkijogbo/Global/Supporting Files/Info.plist @@ -2,10 +2,14 @@ + ReverseGeocodingClientId + $(ReverseGeocodingClientId) + ReverseGeocodingClientSecret + $(ReverseGeocodingClientSecret) Amplitude $(Amplitude) - UIUserInterfaceStyle - Light + UIUserInterfaceStyle + Light BASE_URL $(BASE_URL) ITSAppUsesNonExemptEncryption From f99224a309dd9a7e7b96558122221efe9756355b Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 10:53:31 +0900 Subject: [PATCH 11/18] =?UTF-8?q?[Chore]=20#319=20-=20Reverse=20Geocoding?= =?UTF-8?q?=20BaseURL=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hankkijogbo/Hankkijogbo/Network/Base/URLConstant.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Hankkijogbo/Hankkijogbo/Network/Base/URLConstant.swift b/Hankkijogbo/Hankkijogbo/Network/Base/URLConstant.swift index 306c3459..c501bd0e 100644 --- a/Hankkijogbo/Hankkijogbo/Network/Base/URLConstant.swift +++ b/Hankkijogbo/Hankkijogbo/Network/Base/URLConstant.swift @@ -12,6 +12,7 @@ enum URLConstant { // MARK: - Base URL static let baseURL = Config.baseURL + static let reverseGeocodingBaseURL = "https://naveropenapi.apigw.ntruss.com/map-reversegeocode" // MARK: - URL Path From 76feb7ac288bc61ed7012ae96d1e9961e16d47a2 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 10:55:28 +0900 Subject: [PATCH 12/18] =?UTF-8?q?[Feat]=20#319=20-=20header=20=EB=B0=8F=20?= =?UTF-8?q?utilPath=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit naverMap utilPath일 때는 baseURL도 다르게 처리함 --- .../Network/Base/BaseTargetType.swift | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Network/Base/BaseTargetType.swift b/Hankkijogbo/Hankkijogbo/Network/Base/BaseTargetType.swift index 7f30b78b..bcc512cd 100644 --- a/Hankkijogbo/Hankkijogbo/Network/Base/BaseTargetType.swift +++ b/Hankkijogbo/Hankkijogbo/Network/Base/BaseTargetType.swift @@ -6,7 +6,6 @@ // import Foundation -import UIKit import Moya @@ -25,6 +24,7 @@ enum HeaderType { case loginHeader(accessToken: String) case withdrawHeader(authorizationCode: String) case formdataHeader(multipartData: [MultipartFormData]) + case naverMapHeader(clientId: String, clientSecret: String) } /// 각 API에 따라 공통된 Path 값 (존재하지 않는 경우 빈 String 값) @@ -38,6 +38,7 @@ enum UtilPath: String { case university = "/v1/universities" case location = "/v1/locations" case universityStores = "/v1/university-stores" + case naverMap = "/v2/gc" } protocol BaseTargetType: TargetType { @@ -51,26 +52,33 @@ protocol BaseTargetType: TargetType { extension BaseTargetType { var baseURL: URL { - guard let baseURL = URL(string: URLConstant.baseURL) else { - fatalError("ERROR - BASEURL") + switch utilPath { + case .naverMap: + guard let reverseGeocodingBaseURL = URL(string: URLConstant.reverseGeocodingBaseURL) else { + fatalError("ERROR - NAVER MAP Reverse Geocoding BASEURL") + } + return reverseGeocodingBaseURL + default: + guard let baseURL = URL(string: URLConstant.baseURL) else { + fatalError("ERROR - BASEURL") + } + return baseURL } - return baseURL } var headers: [String: String]? { var header: [String: String] = [:] switch headerType { + case .loginHeader(let accessToken): header["Content-Type"] = "application/json" header["Authorization"] = "\(accessToken)" - return header case .refreshTokenHeader: header["Content-Type"] = "application/json" let refreshToken = UserDefaults.standard.getRefreshToken() header["Authorization"] = URLConstant.bearer + "\(refreshToken)" - return header // 이후부터는 access token이 헤더에 필요합니다. case .withdrawHeader(let authorizationCode): @@ -80,6 +88,10 @@ extension BaseTargetType { case .formdataHeader: header["Content-Type"] = "multipart/form-data" + case .naverMapHeader(let clientId, let clientSecret): + header["x-ncp-apigw-api-key-id"] = clientId + header["x-ncp-apigw-api-key"] = clientSecret + default: header["Content-Type"] = "application/json" } @@ -110,4 +122,3 @@ extension BaseTargetType { } } } - From 1aedc2a199408854423387971523c9e7dd9d044c Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 10:57:08 +0900 Subject: [PATCH 13/18] =?UTF-8?q?[Feat]=20#319=20-=20TargetType=20?= =?UTF-8?q?=EB=B0=8F=20Service=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Hankkijogbo.xcodeproj/project.pbxproj | 36 ++++++++++ .../Network/Base/NetworkService.swift | 1 + .../GetHankkiAddressResponseDTO.swift | 44 +++++++++++++ .../Network/NaverMap/NaverMapAPIService.swift | 38 +++++++++++ .../Network/NaverMap/NaverMapTargetType.swift | 65 +++++++++++++++++++ 5 files changed, 184 insertions(+) create mode 100644 Hankkijogbo/Hankkijogbo/Network/NaverMap/DTO/Response/GetHankkiAddressResponseDTO.swift create mode 100644 Hankkijogbo/Hankkijogbo/Network/NaverMap/NaverMapAPIService.swift create mode 100644 Hankkijogbo/Hankkijogbo/Network/NaverMap/NaverMapTargetType.swift diff --git a/Hankkijogbo/Hankkijogbo.xcodeproj/project.pbxproj b/Hankkijogbo/Hankkijogbo.xcodeproj/project.pbxproj index 0f711693..2375ae61 100644 --- a/Hankkijogbo/Hankkijogbo.xcodeproj/project.pbxproj +++ b/Hankkijogbo/Hankkijogbo.xcodeproj/project.pbxproj @@ -153,6 +153,9 @@ A23D11972C47FFB90023480C /* SearchViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A23D11962C47FFB90023480C /* SearchViewModel.swift */; }; A23D119A2C4811790023480C /* HankkiDebouncer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A23D11992C4811790023480C /* HankkiDebouncer.swift */; }; A23D119C2C4844AE0023480C /* PostHankkiValidateRequestDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = A23D119B2C4844AE0023480C /* PostHankkiValidateRequestDTO.swift */; }; + A23F354F2D2211B200B6F8C8 /* NaverMapAPIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A23F354E2D2211B200B6F8C8 /* NaverMapAPIService.swift */; }; + A23F35512D2211BF00B6F8C8 /* NaverMapTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A23F35502D2211BF00B6F8C8 /* NaverMapTargetType.swift */; }; + A23F35552D22135200B6F8C8 /* GetHankkiAddressResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = A23F35542D22135200B6F8C8 /* GetHankkiAddressResponseDTO.swift */; }; A240EA082C3EF6E0000FF458 /* BufferView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A240EA072C3EF6E0000FF458 /* BufferView.swift */; }; A240EA0C2C3EFD77000FF458 /* CompositionalLayoutFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A240EA0B2C3EFD77000FF458 /* CompositionalLayoutFactory.swift */; }; A240EA192C3F35BC000FF458 /* SearchBarCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A240EA182C3F35BC000FF458 /* SearchBarCollectionViewCell.swift */; }; @@ -384,6 +387,9 @@ A23D11962C47FFB90023480C /* SearchViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewModel.swift; sourceTree = ""; }; A23D11992C4811790023480C /* HankkiDebouncer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HankkiDebouncer.swift; sourceTree = ""; }; A23D119B2C4844AE0023480C /* PostHankkiValidateRequestDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostHankkiValidateRequestDTO.swift; sourceTree = ""; }; + A23F354E2D2211B200B6F8C8 /* NaverMapAPIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NaverMapAPIService.swift; sourceTree = ""; }; + A23F35502D2211BF00B6F8C8 /* NaverMapTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NaverMapTargetType.swift; sourceTree = ""; }; + A23F35542D22135200B6F8C8 /* GetHankkiAddressResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetHankkiAddressResponseDTO.swift; sourceTree = ""; }; A240EA072C3EF6E0000FF458 /* BufferView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BufferView.swift; sourceTree = ""; }; A240EA0B2C3EFD77000FF458 /* CompositionalLayoutFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompositionalLayoutFactory.swift; sourceTree = ""; }; A240EA182C3F35BC000FF458 /* SearchBarCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBarCollectionViewCell.swift; sourceTree = ""; }; @@ -698,6 +704,7 @@ A2EC33A92C4711A000809840 /* Report */, A24A78792CB44E110049B031 /* Menu */, A2EC33AA2C4711A600809840 /* Location */, + A23F354D2D2211A000B6F8C8 /* NaverMap */, ); path = Network; sourceTree = ""; @@ -1361,6 +1368,32 @@ name = ViewModel; sourceTree = ""; }; + A23F354D2D2211A000B6F8C8 /* NaverMap */ = { + isa = PBXGroup; + children = ( + A23F35522D22134300B6F8C8 /* DTO */, + A23F35502D2211BF00B6F8C8 /* NaverMapTargetType.swift */, + A23F354E2D2211B200B6F8C8 /* NaverMapAPIService.swift */, + ); + path = NaverMap; + sourceTree = ""; + }; + A23F35522D22134300B6F8C8 /* DTO */ = { + isa = PBXGroup; + children = ( + A23F35532D22134900B6F8C8 /* Response */, + ); + path = DTO; + sourceTree = ""; + }; + A23F35532D22134900B6F8C8 /* Response */ = { + isa = PBXGroup; + children = ( + A23F35542D22135200B6F8C8 /* GetHankkiAddressResponseDTO.swift */, + ); + path = Response; + sourceTree = ""; + }; A240EA092C3EF712000FF458 /* HankkiReusableView */ = { isa = PBXGroup; children = ( @@ -1976,6 +2009,7 @@ 86880C2A2C47F2DF00CAEF58 /* HankkiListViewModel.swift in Sources */, 8641516B2C67B9AE00E2FD44 /* MyZipListCollectionViewCell.swift in Sources */, A2C9FCB12C49985800868DF7 /* GetZipListResponseDTO.swift in Sources */, + A23F35552D22135200B6F8C8 /* GetHankkiAddressResponseDTO.swift in Sources */, A240EA442C446AB6000FF458 /* HankkiDetailButton.swift in Sources */, A2AF6FDB2CE61AA000F5271D /* MenuResponseDTO.swift in Sources */, 839138DF2C4962E500611D5C /* GetHankkiThumbnailResponseDTO.swift in Sources */, @@ -2008,10 +2042,12 @@ 86880C0F2C47116900CAEF58 /* DeleteZipToHankkRequestiDTO.swift in Sources */, 83DBED942C2564A20042BA48 /* HomeView.swift in Sources */, 86880BF42C46E89C00CAEF58 /* GetMeUniversityResponseDTO.swift in Sources */, + A23F354F2D2211B200B6F8C8 /* NaverMapAPIService.swift in Sources */, A2FF94112C31660E001ADA03 /* BaseDTO.swift in Sources */, A200C66F2D19EA0D0065C749 /* DetailMapView.swift in Sources */, 837F10DC2C4A851A00E3CCE6 /* ReportCompleteViewController.swift in Sources */, 865D59C62C7B72C9004CC517 /* FullLoadingView.swift in Sources */, + A23F35512D2211BF00B6F8C8 /* NaverMapTargetType.swift in Sources */, 86B761232C3EC87A00413059 /* ZipListCollectionViewCellModel.swift in Sources */, 83DBEDCA2C256AE70042BA48 /* UIViewController+.swift in Sources */, A23D11972C47FFB90023480C /* SearchViewModel.swift in Sources */, diff --git a/Hankkijogbo/Hankkijogbo/Network/Base/NetworkService.swift b/Hankkijogbo/Hankkijogbo/Network/Base/NetworkService.swift index ac1df0ae..bf011d4e 100644 --- a/Hankkijogbo/Hankkijogbo/Network/Base/NetworkService.swift +++ b/Hankkijogbo/Hankkijogbo/Network/Base/NetworkService.swift @@ -21,6 +21,7 @@ final class NetworkService { let locationService: LocationAPIServiceProtocol = LocationAPIService() let zipService: ZipAPIServiceProtocol = ZipAPIService() let reportService: ReportAPIServiceProtocol = ReportAPIService() + let naverMapService: NaverMapAPIServiceProtocol = NaverMapAPIService() } extension NetworkService { diff --git a/Hankkijogbo/Hankkijogbo/Network/NaverMap/DTO/Response/GetHankkiAddressResponseDTO.swift b/Hankkijogbo/Hankkijogbo/Network/NaverMap/DTO/Response/GetHankkiAddressResponseDTO.swift new file mode 100644 index 00000000..a4ad2f4a --- /dev/null +++ b/Hankkijogbo/Hankkijogbo/Network/NaverMap/DTO/Response/GetHankkiAddressResponseDTO.swift @@ -0,0 +1,44 @@ +// +// GetHankkiAddressResponseDTO.swift +// Hankkijogbo +// +// Created by 서은수 on 12/30/24. +// + +import Foundation + +// MARK: - Naver Reverse Geocoding API Res + +struct ReverseGeocodingBaseDTO: Decodable { + let code: Int + let name: String + let message: String +} + +struct GetHankkiAddressResponseDTO: Decodable { + let status: ReverseGeocodingBaseDTO + let results: [GetHankkiAddressResult?] +} + +struct GetHankkiAddressResult: Decodable { + let region: Region? + let land: Land? +} + +struct Region: Decodable { + let area1: Area1? + let area2, area3, area4: Area? +} + +struct Area1: Decodable { + let name, alias: String? +} + +struct Area: Decodable { + let name: String? +} + +struct Land: Decodable { + let name: String? + let number1, number2: String? +} diff --git a/Hankkijogbo/Hankkijogbo/Network/NaverMap/NaverMapAPIService.swift b/Hankkijogbo/Hankkijogbo/Network/NaverMap/NaverMapAPIService.swift new file mode 100644 index 00000000..67efc618 --- /dev/null +++ b/Hankkijogbo/Hankkijogbo/Network/NaverMap/NaverMapAPIService.swift @@ -0,0 +1,38 @@ +// +// NaverMapAPIService.swift +// Hankkijogbo +// +// Created by 서은수 on 12/30/24. +// + +import Foundation + +import Moya + +protocol NaverMapAPIServiceProtocol { + func getHankkiAddress(latitude: Double, longitude: Double, completion: @escaping(NetworkResult) -> Void) +} + +final class NaverMapAPIService: BaseAPIService, NaverMapAPIServiceProtocol { + + private let provider = MoyaProvider(plugins: [MoyaPlugin.shared]) + + func getHankkiAddress( + latitude: Double, + longitude: Double, + completion: @escaping (NetworkResult) -> Void) { + provider.request(.getHankkiAddress(latitude: latitude, longitude: longitude)) { result in + switch result { + case .success(let response): + let networkResult: NetworkResult = self.fetchNetworkResult(statusCode: response.statusCode, data: response.data) + print(networkResult) + completion(networkResult) + case .failure(let error): + if let response = error.response { + let networkResult: NetworkResult = self.fetchNetworkResult(statusCode: response.statusCode, data: response.data) + completion(networkResult) + } + } + } + } +} diff --git a/Hankkijogbo/Hankkijogbo/Network/NaverMap/NaverMapTargetType.swift b/Hankkijogbo/Hankkijogbo/Network/NaverMap/NaverMapTargetType.swift new file mode 100644 index 00000000..b7787840 --- /dev/null +++ b/Hankkijogbo/Hankkijogbo/Network/NaverMap/NaverMapTargetType.swift @@ -0,0 +1,65 @@ +// +// NaverMapTargetType.swift +// Hankkijogbo +// +// Created by 서은수 on 12/30/24. +// + +import Foundation + +import Moya + +enum NaverMapTargetType { + + case getHankkiAddress(latitude: Double, longitude: Double) +} + +extension NaverMapTargetType: BaseTargetType { + + var loadingViewType: LoadingViewType { + switch self { + case .getHankkiAddress: return .fullView + } + } + + var headerType: HeaderType { + return .naverMapHeader(clientId: Config.ReverseGeocodingClientId, clientSecret: Config.ReverseGeocodingClientSecret) + } + + var utilPath: UtilPath { return .naverMap } + + var pathParameter: String? { + switch self { + case .getHankkiAddress: + return .none + } + } + + var queryParameter: [String: Any]? { + switch self { + case .getHankkiAddress(let latitude, let longitude): + return .some([ + "coords": "\(longitude),\(latitude)", + "orders": "roadaddr", // 도로명주소 + "output": "json" + ]) + } + } + + var requestBodyParameter: Codable? { + return .none + } + + var path: String { + switch self { + case .getHankkiAddress: + return utilPath.rawValue + } + } + + var method: Moya.Method { + switch self { + case .getHankkiAddress: .get + } + } +} From 74671ed986bebe5a70b8eeaf0c2cfd22e9bb5730 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 11:00:19 +0900 Subject: [PATCH 14/18] =?UTF-8?q?[Feat]=20#319=20-=20ViewModel=EC=97=90=20?= =?UTF-8?q?API=20=ED=98=B8=EC=B6=9C=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=EC=A3=BC=EC=86=8C=20=ED=8F=AC=EB=A7=B7?= =?UTF-8?q?=ED=8C=85=20=ED=95=A8=EC=88=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/HankkiDetailViewModel.swift | 54 +++++++++++++++++-- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift index b3d306d1..a3d1b8c7 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift @@ -18,11 +18,17 @@ final class HankkiDetailViewModel { setHankkiDetailData?() } } + var address: String? { + didSet { + setHankkiDetailData?() + } + } var removeOptions: [String] = [ StringLiterals.RemoveHankki.optionDisappeared, StringLiterals.RemoveHankki.optionNoMore8000, StringLiterals.RemoveHankki.optionImproperHankki ] + weak var delegate: NetworkResultDelegate? var setHankkiDetailData: (() -> Void)? @@ -36,7 +42,6 @@ final class HankkiDetailViewModel { extension HankkiDetailViewModel { - /// 식당 세부 조회 func getHankkiDetailAPI() { NetworkService.shared.hankkiService.getHankkiDetail(id: hankkiId) { [weak self] result in guard let self = self else { return } @@ -47,13 +52,12 @@ extension HankkiDetailViewModel { default: result.handleNetworkResult(delegate: self.delegate) { response in self.hankkiDetailData = response.data + self.getHankkiAddressAPI() // 상세 조회 후 주소도 같이 불러옴 } } - } } - /// 식당 좋아요 추가 func postHankkiHeartAPI() { NetworkService.shared.hankkiService.postHankkiHeart(id: hankkiId) { result in result.handleNetworkResult { _ in @@ -63,7 +67,6 @@ extension HankkiDetailViewModel { } } - /// 식당 좋아요 삭제 func deleteHankkiHeartAPI() { NetworkService.shared.hankkiService.deleteHankkiHeart(id: hankkiId) { result in result.handleNetworkResult { _ in @@ -72,10 +75,51 @@ extension HankkiDetailViewModel { } } - /// 식당 삭제 func deleteHankkiAPI(completion: @escaping () -> Void) { NetworkService.shared.hankkiService.deleteHankki(id: hankkiId) { result in result.handleNetworkResult(onSuccessVoid: completion) } } } + +private extension HankkiDetailViewModel { + + func getHankkiAddressAPI() { + guard let detailData = hankkiDetailData else { return } + NetworkService.shared.naverMapService.getHankkiAddress(latitude: detailData.latitude, longitude: detailData.longitude) { result in + switch result { + case .badRequest: + UIApplication.showBlackToast(message: StringLiterals.Toast.serverError) + case .serverError: + UIApplication.showBlackToast(message: StringLiterals.Toast.serverError) + default: + result.handleNetworkResult { response in + guard let data = response.results.first, + let data = data else { + self.address = "-" + return + } + + self.address = self.formatAddress(from: data) + } + } + } + } + + func formatAddress(from data: GetHankkiAddressResult) -> String { + let address: [String?] = [ + data.region?.area1?.name, + data.region?.area2?.name, + data.region?.area3?.name, + data.region?.area4?.name, + data.land?.name, + data.land?.number1, + data.land?.number2 + ] + + return address + .compactMap { $0 } + .filter { !$0.isEmpty } + .joined(separator: " ") + } +} From 5c8f7c904fde7b779328201d60c318f5391571c2 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 11:01:07 +0900 Subject: [PATCH 15/18] =?UTF-8?q?[Feat]=20#319=20-=20=EC=A3=BC=EC=86=8C=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=B0=94=EC=9D=B8=EB=94=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Present/HankkiDetail/View/DetailMapView.swift | 7 +++---- .../HankkiDetail/View/HankkiDetailViewController.swift | 6 +++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift index 606ff31b..28e8d9c4 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift @@ -11,7 +11,6 @@ import NMapsMap final class DetailMapView: BaseView { - // MARK: - Properties // MARK: - UI Components private let mapView: NMFMapView = NMFMapView() @@ -104,12 +103,12 @@ final class DetailMapView: BaseView { ) } - // TODO: - 위경도 값으로 주소 불러와야 함 addressLabel.do { $0.attributedText = UILabel.setupAttributedText( for: PretendardStyle.caption4, color: .gray700 ) + $0.numberOfLines = 2 } copyButton.do { @@ -129,8 +128,8 @@ final class DetailMapView: BaseView { extension DetailMapView { - func bindData(latitude: Double, longitude: Double) { - addressLabel.text = "\(latitude) \(longitude)" + func bindData(latitude: Double, longitude: Double, address: String) { + addressLabel.text = address addMapMarker(latitude: latitude, longitude: longitude) moveMapCamera(latitude: latitude, longitude: longitude) } diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift index 0f935e20..9be9f4ac 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift @@ -169,7 +169,11 @@ private extension HankkiDetailViewController { heartCount: String(data.heartCount), isLiked: data.isLiked ) - detailMapView.bindData(latitude: data.latitude, longitude: data.longitude) + detailMapView.bindData( + latitude: data.latitude, + longitude: data.longitude, + address: viewModel.address ?? "-" + ) menuCollectionView.collectionView.reloadData() } From 3c0e69b2db710e7faaaa8511ef8742c135732488 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Mon, 30 Dec 2024 11:38:02 +0900 Subject: [PATCH 16/18] =?UTF-8?q?[Design]=20#319=20-=20=EC=A3=BC=EC=86=8C?= =?UTF-8?q?=202=EC=A4=84=EC=9D=BC=20=EA=B2=BD=EC=9A=B0=20=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=95=84=EC=9B=83=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HankkiDetail/View/DetailMapView.swift | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift index 28e8d9c4..a734abca 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift @@ -58,12 +58,7 @@ final class DetailMapView: BaseView { addressGuideLabel.snp.makeConstraints { $0.leading.equalToSuperview().inset(10) - $0.centerY.equalToSuperview() - } - - addressLabel.snp.makeConstraints { - $0.leading.equalTo(addressGuideLabel.snp.trailing).offset(8) - $0.centerY.equalTo(addressGuideLabel) + $0.top.equalToSuperview().inset(11.5) } copyButton.snp.makeConstraints { @@ -72,6 +67,12 @@ final class DetailMapView: BaseView { $0.width.equalTo(36) $0.height.equalTo(25) } + + addressLabel.snp.makeConstraints { + $0.leading.equalTo(addressGuideLabel.snp.trailing).offset(8) + $0.trailing.equalTo(copyButton.snp.leading).offset(-6) + $0.centerY.equalToSuperview() + } } override func setupStyle() { @@ -130,6 +131,8 @@ extension DetailMapView { func bindData(latitude: Double, longitude: Double, address: String) { addressLabel.text = address + + updateAddressViewLayout() addMapMarker(latitude: latitude, longitude: longitude) moveMapCamera(latitude: latitude, longitude: longitude) } @@ -143,6 +146,23 @@ private extension DetailMapView { copyButton.addTarget(self, action: #selector(copyButtonDidTap), for: .touchUpInside) } + func updateAddressViewLayout() { + let maxSize: CGSize = CGSize(width: addressLabel.bounds.width, height: CGFloat.greatestFiniteMagnitude) + let expectedSize: CGSize = addressLabel.sizeThatFits(maxSize) + let spacing: CGFloat = expectedSize.height > 18 ? 8 : 11.5 // 줄 수를 기준으로 + + addressView.snp.updateConstraints { + $0.top.equalTo(mapView.snp.bottom).offset(-1) + $0.leading.trailing.equalTo(mapView) + $0.height.equalTo(spacing + expectedSize.height + spacing) + } + + addressGuideLabel.snp.updateConstraints { + $0.leading.equalToSuperview().inset(10) + $0.top.equalToSuperview().inset(spacing) + } + } + func copyAddressToClipboard() { UIPasteboard.general.string = addressLabel.text } From 5436a15f96ad210f0f49f22a7484ec0472cadd13 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Tue, 31 Dec 2024 21:03:30 +0900 Subject: [PATCH 17/18] =?UTF-8?q?[Fix]=20#319=20-=20VC=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=ED=86=A0=EC=8A=A4=ED=8A=B8=20=EB=9D=84=EC=9A=B0=EB=8A=94=20?= =?UTF-8?q?=EA=B1=B8=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/HankkiDetailViewController.swift | 8 ++++++-- .../ViewModel/HankkiDetailViewModel.swift | 13 ++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift index 9be9f4ac..f1482072 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift @@ -185,8 +185,12 @@ private extension HankkiDetailViewController { primaryButtonText: StringLiterals.Alert.check) } - viewModel.dismiss = { - self.navigationController?.popViewController(animated: false) + viewModel.dismiss = { [weak self] in + self?.navigationController?.popViewController(animated: false) + } + + viewModel.handleDeletedHankki = { [weak self] in + self?.showBlackToast(message: StringLiterals.Toast.deleteAlready) } } diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift index a3d1b8c7..3b5ea358 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift @@ -8,7 +8,6 @@ import Foundation import Moya -import UIKit final class HankkiDetailViewModel { @@ -34,6 +33,8 @@ final class HankkiDetailViewModel { var setHankkiDetailData: (() -> Void)? var showAlert: ((String) -> Void)? var dismiss: (() -> Void)? + var handleMapError: (() -> Void)? + var handleDeletedHankki: (() -> Void)? init(hankkiId: Int) { self.hankkiId = hankkiId @@ -47,8 +48,8 @@ extension HankkiDetailViewModel { guard let self = self else { return } switch result { case .notFound: - UIApplication.showBlackToast(message: StringLiterals.Toast.deleteAlready) - self.dismiss?() + handleDeletedHankki?() + dismiss?() default: result.handleNetworkResult(delegate: self.delegate) { response in self.hankkiDetailData = response.data @@ -88,10 +89,8 @@ private extension HankkiDetailViewModel { guard let detailData = hankkiDetailData else { return } NetworkService.shared.naverMapService.getHankkiAddress(latitude: detailData.latitude, longitude: detailData.longitude) { result in switch result { - case .badRequest: - UIApplication.showBlackToast(message: StringLiterals.Toast.serverError) - case .serverError: - UIApplication.showBlackToast(message: StringLiterals.Toast.serverError) + case .badRequest, .serverError: + self.handleMapError?() default: result.handleNetworkResult { response in guard let data = response.results.first, From fa44118d8824e93612b8aa00733140eeb3c73e27 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Tue, 31 Dec 2024 21:22:22 +0900 Subject: [PATCH 18/18] =?UTF-8?q?[Feat]=20#319=20-=20=EC=A3=BC=EC=86=8C?= =?UTF-8?q?=EB=A5=BC=20=EB=B6=88=EB=9F=AC=EC=98=A4=EC=A7=80=20=EB=AA=BB?= =?UTF-8?q?=ED=96=88=EC=9D=84=20=EA=B2=BD=EC=9A=B0=20=EB=B7=B0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Consts/StringLiterals.swift | 1 + .../HankkiDetail/View/DetailMapView.swift | 51 ++++++++++++++++++- .../View/HankkiDetailViewController.swift | 4 ++ .../ViewModel/HankkiDetailViewModel.swift | 10 ++-- 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Global/Consts/StringLiterals.swift b/Hankkijogbo/Hankkijogbo/Global/Consts/StringLiterals.swift index cc7c70a3..5bf2d9fc 100644 --- a/Hankkijogbo/Hankkijogbo/Global/Consts/StringLiterals.swift +++ b/Hankkijogbo/Hankkijogbo/Global/Consts/StringLiterals.swift @@ -146,6 +146,7 @@ enum StringLiterals { static let myZip = "내 족보" static let address = "주소" static let copy = "복사" + static let mapLoadErrorMessage = "주소를 불러오지 못했어요" static let copyToastMessage = "주소를 복사했습니다" static let menu = "메뉴" static let editMenu = "메뉴 수정/삭제 제보하기" diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift index a734abca..9402de89 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/DetailMapView.swift @@ -19,6 +19,9 @@ final class DetailMapView: BaseView { private let addressLabel: UILabel = UILabel() private let copyButton: UIButton = UIButton() + private let mapErrorView: UIView = UIView() + private let mapErrorLabel: UILabel = UILabel() + // MARK: - Init override init(frame: CGRect) { @@ -83,9 +86,9 @@ final class DetailMapView: BaseView { mapView.do { $0.zoomLevel = 16 $0.clipsToBounds = true - $0.layer.cornerRadius = 12 + $0.layer.cornerRadius = 8 $0.layer.maskedCorners = CACornerMask(arrayLiteral: .layerMinXMinYCorner, .layerMaxXMinYCorner) - $0.makeRoundBorder(cornerRadius: 12, borderWidth: 1, borderColor: .imageLine) + $0.makeRoundBorder(cornerRadius: 8, borderWidth: 1, borderColor: .imageLine) } addressView.do { @@ -124,6 +127,20 @@ final class DetailMapView: BaseView { $0.setAttributedTitle(attributedTitle, for: .normal) } } + + mapErrorView.do { + $0.backgroundColor = .gray100 + $0.makeRoundCorners(corners: [.layerMinXMinYCorner, .layerMaxXMinYCorner], radius: 8) + $0.makeRoundBorder(cornerRadius: 8, borderWidth: 1, borderColor: .imageLine) + } + + mapErrorLabel.do { + $0.attributedText = UILabel.setupAttributedText( + for: PretendardStyle.caption4, + withText: StringLiterals.HankkiDetail.mapLoadErrorMessage, + color: .gray400 + ) + } } } @@ -136,6 +153,11 @@ extension DetailMapView { addMapMarker(latitude: latitude, longitude: longitude) moveMapCamera(latitude: latitude, longitude: longitude) } + + func handleMapLoadError() { + showMapErrorView() + disableCopyButton() + } } // MARK: - Private Func @@ -179,6 +201,31 @@ private extension DetailMapView { mapView.moveCamera(cameraUpdate) } + func showMapErrorView() { + addSubview(mapErrorView) + mapErrorView.addSubview(mapErrorLabel) + + mapErrorView.snp.makeConstraints { + $0.edges.equalTo(mapView) + } + + mapErrorLabel.snp.makeConstraints { + $0.center.equalToSuperview() + } + } + + func disableCopyButton() { + copyButton.isEnabled = false + + if let attributedTitle = UILabel.setupAttributedText( + for: PretendardStyle.caption5, + withText: StringLiterals.HankkiDetail.copy, + color: .gray300 + ) { + copyButton.setAttributedTitle(attributedTitle, for: .normal) + } + } + // MARK: - @objc Func @objc func copyButtonDidTap() { diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift index f1482072..066aa733 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift @@ -192,6 +192,10 @@ private extension HankkiDetailViewController { viewModel.handleDeletedHankki = { [weak self] in self?.showBlackToast(message: StringLiterals.Toast.deleteAlready) } + + viewModel.handleMapLoadError = { [weak self] in + self?.detailMapView.handleMapLoadError() + } } func setupRegister() { diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift index 3b5ea358..1d9bfba2 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift @@ -33,7 +33,7 @@ final class HankkiDetailViewModel { var setHankkiDetailData: (() -> Void)? var showAlert: ((String) -> Void)? var dismiss: (() -> Void)? - var handleMapError: (() -> Void)? + var handleMapLoadError: (() -> Void)? var handleDeletedHankki: (() -> Void)? init(hankkiId: Int) { @@ -89,18 +89,18 @@ private extension HankkiDetailViewModel { guard let detailData = hankkiDetailData else { return } NetworkService.shared.naverMapService.getHankkiAddress(latitude: detailData.latitude, longitude: detailData.longitude) { result in switch result { - case .badRequest, .serverError: - self.handleMapError?() - default: + case .success: result.handleNetworkResult { response in guard let data = response.results.first, let data = data else { - self.address = "-" + self.handleMapLoadError?() return } self.address = self.formatAddress(from: data) } + default: + self.handleMapLoadError?() } } }