From 3097d066925ce66429f5e0cb9cd434ef29472b50 Mon Sep 17 00:00:00 2001 From: L-j-h-c Date: Fri, 15 Jul 2022 04:10:46 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[Fix]=20#69=20-=20=EB=B3=84=EC=A0=90=20?= =?UTF-8?q?=EB=B7=B0=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthFoodMe.xcodeproj/project.pbxproj | 2 +- .../Views/DetailSummaryView.swift | 30 ++++++------------- .../Views/MapDetailSummaryView.swift | 2 +- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/HealthFoodMe/HealthFoodMe.xcodeproj/project.pbxproj b/HealthFoodMe/HealthFoodMe.xcodeproj/project.pbxproj index 607d8fa6..db715bf7 100644 --- a/HealthFoodMe/HealthFoodMe.xcodeproj/project.pbxproj +++ b/HealthFoodMe/HealthFoodMe.xcodeproj/project.pbxproj @@ -662,10 +662,10 @@ EB6A44C828737BF700749582 /* Detail */ = { isa = PBXGroup; children = ( + EB6A44C928737C4600749582 /* MainDetailScene */, 3BC01F7C287E91F7006C2181 /* BlogReviewTabScene */, 695758BA287DA4A400E36789 /* ReviewWriteScene */, 697074FB28737D78001A607F /* MenuTabScene */, - EB6A44C928737C4600749582 /* MainDetailScene */, ); path = Detail; sourceTree = ""; diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Detail/MainDetailScene/Views/DetailSummaryView.swift b/HealthFoodMe/HealthFoodMe/Presentation/Detail/MainDetailScene/Views/DetailSummaryView.swift index 23852248..42f4fa27 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Detail/MainDetailScene/Views/DetailSummaryView.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Detail/MainDetailScene/Views/DetailSummaryView.swift @@ -48,11 +48,9 @@ final class DetailSummaryView: UIView { return st }() - private let starStackView: UIStackView = { - let st = UIStackView() - st.axis = .horizontal - st.spacing = 2 - st.distribution = .equalSpacing + private let starRateView: StarRatingView = { + let st = StarRatingView(starScale: 14) + st.rate = 4.3 return st }() @@ -108,8 +106,12 @@ extension DetailSummaryView { } titleStackView.addArrangedSubviews(restaurantNameLabel, starRateStackView) - starRateStackView.addArrangedSubviews(starStackView, rateLabel) - setStarStackView() + starRateStackView.addArrangedSubviews(starRateView, rateLabel) + + starRateView.snp.makeConstraints { make in + make.width.equalTo(70) + make.centerY.equalToSuperview() + } restaurantNameLabel.snp.makeConstraints { make in make.width.lessThanOrEqualTo(200) @@ -124,18 +126,4 @@ extension DetailSummaryView { make.centerY.equalTo(logoImageView) } } - - private func setStarStackView() { - for starNumber in 1...5 { - let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 16, height: 16)) - imageView.contentMode = .scaleAspectFill - if starNumber < 5 { - imageView.image = ImageLiterals.MainDetail.starIcon_filled - } else { - imageView.image = ImageLiterals.MainDetail.starIcon - } - imageView.tag = starNumber - starStackView.addArrangedSubviews(imageView) - } - } } diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Views/MapDetailSummaryView.swift b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Views/MapDetailSummaryView.swift index a55b1716..03106e18 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Views/MapDetailSummaryView.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Views/MapDetailSummaryView.swift @@ -146,7 +146,7 @@ extension MapDetailSummaryView { starRateStackView.addArrangedSubviews(starRateView, rateLabel) starRateView.snp.makeConstraints { make in - make.width.equalTo(87) + make.width.equalTo(70) make.centerY.equalToSuperview() } From 24577115f0326abf28fa172d8b33e40a8e4eec64 Mon Sep 17 00:00:00 2001 From: L-j-h-c Date: Fri, 15 Jul 2022 07:50:03 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[Feat]=20#69=20-=20=EB=82=B4=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=EB=A1=9C=20=EC=9D=B4=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HealthFoodMe/HealthFoodMe/Info.plist | 4 +++ .../Map/MainMapScene/VC/MainMapVC.swift | 27 +++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/HealthFoodMe/HealthFoodMe/Info.plist b/HealthFoodMe/HealthFoodMe/Info.plist index bcfa7a8a..59177397 100644 --- a/HealthFoodMe/HealthFoodMe/Info.plist +++ b/HealthFoodMe/HealthFoodMe/Info.plist @@ -2,6 +2,10 @@ + NSLocationWhenInUseUsageDescription + 사용자의 위치를 받습니다 + NSLocationAlwaysUsageDescription + 사용자의 위치를 받습니다 CFBundleIdentifier UIUserInterfaceStyle diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift index 62fe243f..02cb11df 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift @@ -12,21 +12,20 @@ import NMapsMap import RxSwift import SnapKit -class MainMapVC: UIViewController { +class MainMapVC: UIViewController, NMFLocationManagerDelegate { // MARK: - Properties private let disposeBag = DisposeBag() - private var locationManager = CLLocationManager() + private let locationManager = NMFLocationManager.sharedInstance() private var currentLatitude: Double? private var currentLongitude: Double? var viewModel: MainMapViewModel! // MARK: - UI Components - private lazy var mapView: NMFMapView = { - let map = NMFMapView() - map.locationOverlay.hidden = false + private lazy var mapView: NaverMapContainerView = { + let map = NaverMapContainerView() return map }() @@ -96,11 +95,12 @@ class MainMapVC: UIViewController { return bt }() - private let myLocationButton: UIButton = { + private lazy var myLocationButton: UIButton = { let bt = UIButton() bt.setImage(ImageLiterals.Map.mylocationIcon, for: .normal) bt.addAction(UIAction(handler: { _ in - + let NMGPosition = self.locationManager?.currentLatLng() + self.mapView.moveCameraPosition(NMGPosition ?? NMGLatLng(lat: 37.5666805, lng: 126.9784147)) }), for: .touchUpInside) bt.backgroundColor = .helfmeWhite bt.clipsToBounds = true @@ -272,19 +272,10 @@ extension MainMapVC { navigationController?.isNavigationBarHidden = true } - @objc - private func presentSearchVC() { - let nextVC = ModuleFactory.resolve().makeSearchVC() - self.navigationController?.pushViewController(nextVC, animated: true) + private func setMapView() { + locationManager?.add(self) } - @objc - private func presentDetailVC() { - self.scrapButton.isHidden = true - self.myLocationButton.isHidden = true - self.mapDetailSummaryView.snp.updateConstraints { make in - make.top.equalToSuperview().inset(44) - } UIView.animate(withDuration: 0.3, delay: 0) { self.mapDetailSummaryView.transform = CGAffineTransform(translationX: 0, y: 0) From 4ee7a6e3dfe79aed3dd98532c2384e696427d9e2 Mon Sep 17 00:00:00 2001 From: L-j-h-c Date: Fri, 15 Jul 2022 07:50:42 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[Feat]=20#69=20-=20=EC=83=81=EC=84=B8=20?= =?UTF-8?q?=EC=9A=94=EC=95=BD=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Map/MainMapScene/VC/MainMapVC.swift | 58 +++++++++++++++++-- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift index 02cb11df..5fb7d193 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift @@ -276,12 +276,38 @@ extension MainMapVC { locationManager?.add(self) } + private func bindMapView() { + mapView.rx.mapViewClicked + .subscribe(onNext: { _ in + self.mapView.disableSelectPoint.accept(()) + self.mapDetailSummaryView.snp.updateConstraints { make in + make.top.equalToSuperview().inset(UIScreen.main.bounds.height) + } + UIView.animate(withDuration: 0.3, delay: 0) { + self.mapDetailSummaryView.transform = CGAffineTransform(translationX: 0, y: 0) + self.view.layoutIfNeeded() + } + }).disposed(by: self.disposeBag) - UIView.animate(withDuration: 0.3, delay: 0) { - self.mapDetailSummaryView.transform = CGAffineTransform(translationX: 0, y: 0) - self.view.layoutIfNeeded() - } completion: { _ in - self.transitionAndPresentMainDetailVC() + mapView.setSelectPoint + .subscribe(onNext: { [weak self] dataModel in + let summaryViewHeight: CGFloat = 189 + self?.mapDetailSummaryView.snp.updateConstraints { make in + make.top.equalToSuperview().inset(UIScreen.main.bounds.height - summaryViewHeight) + } + UIView.animate(withDuration: 0.3, delay: 0) { + self?.mapDetailSummaryView.transform = CGAffineTransform(translationX: 0, y: 0) + self?.view.layoutIfNeeded() + } + }).disposed(by: self.disposeBag) + } + + private func sampleViewInputEvent() { + makeDummyPoints() + .bind(to: mapView.rx.pointList) + .disposed(by: self.disposeBag) + } + } } @@ -314,6 +340,28 @@ extension MainMapVC { self.categoryCollectionView.isHidden = true } } + + @objc + private func presentSearchVC() { + let nextVC = ModuleFactory.resolve().makeSearchVC() + self.navigationController?.pushViewController(nextVC, animated: true) + } + + @objc + private func presentDetailVC() { + self.scrapButton.isHidden = true + self.myLocationButton.isHidden = true + self.mapDetailSummaryView.snp.updateConstraints { make in + make.top.equalToSuperview().inset(44) + } + + UIView.animate(withDuration: 0.3, delay: 0) { + self.mapDetailSummaryView.transform = CGAffineTransform(translationX: 0, y: 0) + self.view.layoutIfNeeded() + } completion: { _ in + self.transitionAndPresentMainDetailVC() + } + } } // MARK: - CollectionView Delegate From 3c104770099e5ff15aaab1e09a414e11a96157d8 Mon Sep 17 00:00:00 2001 From: L-j-h-c Date: Fri, 15 Jul 2022 07:51:13 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[Feat]=20#69=20-=20=EC=99=B8=EC=8B=9D=20?= =?UTF-8?q?=EC=A2=85=EB=A5=98=EB=B3=84=20=ED=95=80=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Map/MainMapScene/VC/MainMapVC.swift | 23 +++++- .../ViewModel/MainMapViewModel.swift | 6 +- .../MainMapScene/Views/mapContainerView.swift | 74 ++++++++++++++----- 3 files changed, 81 insertions(+), 22 deletions(-) diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift index 5fb7d193..7904a181 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift @@ -121,6 +121,9 @@ class MainMapVC: UIViewController, NMFLocationManagerDelegate { setDelegate() registerCell() setPanGesture() + setMapView() + bindMapView() + sampleViewInputEvent() self.bindViewModels() } @@ -182,7 +185,7 @@ extension MainMapVC { mapDetailSummaryView.snp.makeConstraints { make in make.leading.trailing.equalToSuperview() - make.top.equalToSuperview().inset(UIScreen.main.bounds.height - 189) + make.top.equalToSuperview().inset(UIScreen.main.bounds.height) make.height.equalTo(UIScreen.main.bounds.height + 300) } @@ -243,7 +246,7 @@ extension MainMapVC { } completion: { _ in self?.transitionAndPresentMainDetailVC() } - + } else { let summaryViewHeight: CGFloat = 189 self?.mapDetailSummaryView.snp.updateConstraints { make in @@ -264,7 +267,7 @@ extension MainMapVC { } private func bindViewModels() { - let input = MainMapViewModel.Input() + let input = MainMapViewModel.Input(myLocationButtonTapped: myLocationButton.rx.tap.asObservable(), scrapButtonTapped: scrapButton.rx.tap.asObservable()) let output = self.viewModel.transform(from: input, disposeBag: self.disposeBag) } @@ -308,6 +311,20 @@ extension MainMapVC { .disposed(by: self.disposeBag) } + private func makeDummyPoints() -> Observable<[MapPointDataModel]> { + return .create { observer in + let pointList: [MapPointDataModel] = .init([ + MapPointDataModel.init(latitude: 37.5666805, longtitude: 126.9784147, type: .normalFood), + MapPointDataModel.init(latitude: 37.567, longtitude: 126.9784147, type: .healthFood), + MapPointDataModel.init(latitude: 37.568, longtitude: 126.9784147, type: .normalFood), + MapPointDataModel.init(latitude: 37.569, longtitude: 126.9784147, type: .normalFood), + MapPointDataModel.init(latitude: 37.557, longtitude: 126.9784147, type: .healthFood), + MapPointDataModel.init(latitude: 37.571, longtitude: 126.9784147, type: .normalFood), + MapPointDataModel.init(latitude: 37.572, longtitude: 126.9784147, type: .normalFood), + MapPointDataModel.init(latitude: 37.010, longtitude: 126.9784147, type: .normalFood) + ]) + observer.onNext(pointList) + return Disposables.create() } } diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/ViewModel/MainMapViewModel.swift b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/ViewModel/MainMapViewModel.swift index 291a833d..d9f0f080 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/ViewModel/MainMapViewModel.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/ViewModel/MainMapViewModel.swift @@ -6,6 +6,7 @@ // import RxSwift +import RxRelay final class MainMapViewModel: ViewModelType { @@ -15,13 +16,14 @@ final class MainMapViewModel: ViewModelType { // MARK: - Inputs struct Input { - + let myLocationButtonTapped: Observable + let scrapButtonTapped: Observable } // MARK: - Outputs struct Output { - + var moveToMyLocation = PublishRelay() } init(useCase: MainMapUseCase) { diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Views/mapContainerView.swift b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Views/mapContainerView.swift index 46ab8d68..38caac55 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Views/mapContainerView.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Views/mapContainerView.swift @@ -16,6 +16,7 @@ final class NaverMapContainerView: UIView { private var markers = [NMFMarker]() private var previousMarker: NMFMarker? private var selectedMarker: NMFMarker? + private var selectedMarkerType: MapPointDataModel? var naverMapView = NMFNaverMapView() var delegate: NMFMapViewTouchDelegate? var pointList = PublishRelay<[MapPointDataModel]>() @@ -40,8 +41,9 @@ final class NaverMapContainerView: UIView { extension NaverMapContainerView { private func setUI() { naverMapView = NMFNaverMapView(frame: self.frame) - naverMapView.showLocationButton = true - naverMapView.mapView.positionMode = .compass + naverMapView.mapView.positionMode = .direction + naverMapView.mapView.locationOverlay.hidden = true + naverMapView.showZoomControls = false addSubview(naverMapView) @@ -51,7 +53,7 @@ extension NaverMapContainerView { } - private func moveCameraPosition(_ point: NMGLatLng) { + func moveCameraPosition(_ point: NMGLatLng) { let cameraUpdate = NMFCameraUpdate(scrollTo: point) cameraUpdate.animation = .fly cameraUpdate.animationDuration = 2 @@ -79,15 +81,31 @@ extension NaverMapContainerView { for point in points { let marker = NMFMarker() marker.position = NMGLatLng.init(lat: point.latitude, lng: point.longtitude) - self.setMarkState(mark: marker, selectState: false) - marker.touchHandler = { _ in - if let seletedMark = self.selectedMarker { - self.setMarkState(mark: seletedMark, selectState: false) + switch point.type { + case .normalFood: + self.setNormalMarkState(mark: marker, selectState: false) + marker.touchHandler = { _ in + if let seletedMark = self.selectedMarker { + self.setNormalMarkState(mark: seletedMark, selectState: false) + } + self.setNormalMarkState(mark: marker, selectState: true) + self.setSelectPoint.accept(point) + self.selectedMarker = marker + self.selectedMarkerType = point + return true + } + case .healthFood: + self.setHealthMarkState(mark: marker, selectState: false) + marker.touchHandler = { _ in + if let seletedMark = self.selectedMarker { + self.setHealthMarkState(mark: seletedMark, selectState: false) + } + self.setHealthMarkState(mark: marker, selectState: true) + self.setSelectPoint.accept(point) + self.selectedMarker = marker + self.selectedMarkerType = point + return true } - self.setMarkState(mark: marker, selectState: true) - self.setSelectPoint.accept(point) - self.selectedMarker = marker - return true } self.markers.append(marker) } @@ -107,20 +125,42 @@ extension NaverMapContainerView { return point.position == NMGPosition }).first else { return } moveCameraPosition(NMGPosition) - if let seletedMark = self.selectedMarker { - setMarkState(mark: seletedMark, selectState: false) + if let seletedMark = self.selectedMarker, + let type = selectedMarkerType?.type { + switch type { + case .healthFood: + setHealthMarkState(mark: seletedMark, selectState: false) + case .normalFood: + setNormalMarkState(mark: seletedMark, selectState: false) + } + } + switch selectedPoint.type { + case .healthFood: + setHealthMarkState(mark: marker, selectState: true) + case .normalFood: + setNormalMarkState(mark: marker, selectState: true) } - setMarkState(mark: marker, selectState: true) self.selectedMarker = marker + self.selectedMarkerType = selectedPoint } private func disableAllMarker() { - guard selectedMarker != nil else { return } - setMarkState(mark: selectedMarker!, selectState: false) + guard selectedMarker != nil, let markerType = selectedMarkerType?.type else { return } + switch markerType { + case .healthFood: + setHealthMarkState(mark: selectedMarker!, selectState: false) + case .normalFood: + setNormalMarkState(mark: selectedMarker!, selectState: false) + } } - private func setMarkState(mark: NMFMarker, selectState: Bool) { + private func setNormalMarkState(mark: NMFMarker, selectState: Bool) { let iconName = selectState ? "icn_normal_seleted" : "icn_normal" mark.iconImage = NMFOverlayImage.init(image: UIImage(named: iconName) ?? UIImage()) } + + private func setHealthMarkState(mark: NMFMarker, selectState: Bool) { + let iconName = selectState ? "icn_diet_selected" : "icn_diet" + mark.iconImage = NMFOverlayImage.init(image: UIImage(named: iconName) ?? UIImage()) + } } From 413174ecff2c5d3362f3c7c933e179c92b61dcd3 Mon Sep 17 00:00:00 2001 From: L-j-h-c Date: Fri, 15 Jul 2022 13:57:00 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[Feat]=20#69=20-=20=EC=B9=B4=ED=85=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=20=EC=84=A0=ED=83=9D=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model/Map/MainMapScene/MainMapModel.swift | 3 ++- .../MainMapScene/Cells/MenuCategoryCVC.swift | 22 ++++++++++++++++--- .../Map/MainMapScene/VC/MainMapVC.swift | 17 ++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/HealthFoodMe/HealthFoodMe/Domain/Model/Map/MainMapScene/MainMapModel.swift b/HealthFoodMe/HealthFoodMe/Domain/Model/Map/MainMapScene/MainMapModel.swift index 9f335e08..8cb69aba 100644 --- a/HealthFoodMe/HealthFoodMe/Domain/Model/Map/MainMapScene/MainMapModel.swift +++ b/HealthFoodMe/HealthFoodMe/Domain/Model/Map/MainMapScene/MainMapModel.swift @@ -21,6 +21,7 @@ enum PointerType { struct MainMapCategory { let menuName: String let menuIcon: UIImage + let isDietMenu: Bool - static let categorySample: [MainMapCategory] = [MainMapCategory(menuName: "샐러드", menuIcon: ImageLiterals.Map.saladIcon!), MainMapCategory(menuName: "포케", menuIcon: ImageLiterals.Map.pokeIcon!), MainMapCategory(menuName: "키토김밥", menuIcon: ImageLiterals.Map.kimbapIcon!), MainMapCategory(menuName: "샌드위치", menuIcon: ImageLiterals.Map.sandwichIcon!), MainMapCategory(menuName: "샤브샤브", menuIcon: ImageLiterals.Map.shabushabuIcon!), MainMapCategory(menuName: "보쌈", menuIcon: ImageLiterals.Map.bossamIcon!), MainMapCategory(menuName: "고깃집", menuIcon: ImageLiterals.Map.meatIcon!), MainMapCategory(menuName: "덮밥", menuIcon: ImageLiterals.Map.dupbapIcon!)] + static let categorySample: [MainMapCategory] = [MainMapCategory(menuName: "샐러드", menuIcon: ImageLiterals.Map.saladIcon!, isDietMenu: true), MainMapCategory(menuName: "포케", menuIcon: ImageLiterals.Map.pokeIcon!, isDietMenu: true), MainMapCategory(menuName: "키토김밥", menuIcon: ImageLiterals.Map.kimbapIcon!, isDietMenu: true), MainMapCategory(menuName: "샌드위치", menuIcon: ImageLiterals.Map.sandwichIcon!, isDietMenu: false), MainMapCategory(menuName: "샤브샤브", menuIcon: ImageLiterals.Map.shabushabuIcon!, isDietMenu: false), MainMapCategory(menuName: "보쌈", menuIcon: ImageLiterals.Map.bossamIcon!, isDietMenu: false), MainMapCategory(menuName: "고깃집", menuIcon: ImageLiterals.Map.meatIcon!, isDietMenu: false), MainMapCategory(menuName: "덮밥", menuIcon: ImageLiterals.Map.dupbapIcon!, isDietMenu: false)] } diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Cells/MenuCategoryCVC.swift b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Cells/MenuCategoryCVC.swift index ba382e1c..963b40d0 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Cells/MenuCategoryCVC.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/Cells/MenuCategoryCVC.swift @@ -14,19 +14,22 @@ final class MenuCategoryCVC: UICollectionViewCell, UICollectionViewRegisterable // MARK: - Properties static var isFromNib: Bool = false - override var isSelected: Bool { didSet { - + resetUI() } } + var isDietMenu: Bool = true + private var originalImage: UIImage = UIImage() // MARK: - UI Components private let menuImageView: UIImageView = { let iv = UIImageView() iv.contentMode = .center - iv.image = ImageLiterals.Map.manifyingIcon + iv.image = UIImage() + iv.adjustsImageSizeForAccessibilityContentSizeCategory = true + iv.tintColor = .helfmeWhite return iv }() @@ -60,6 +63,18 @@ extension MenuCategoryCVC { self.backgroundColor = .white } + private func resetUI() { + if isSelected { + menuNameLabel.textColor = .helfmeWhite + menuImageView.image = menuImageView.image?.withRenderingMode(.alwaysTemplate) + self.backgroundColor = isDietMenu ? .helfmeGreenSubDark : .mainRed + } else { + menuNameLabel.textColor = .helfmeBlack + menuImageView.image = originalImage + self.backgroundColor = .helfmeWhite + } + } + private func setLayout() { self.addSubviews(menuImageView, menuNameLabel) @@ -79,5 +94,6 @@ extension MenuCategoryCVC { func setData(data: MainMapCategory) { self.menuNameLabel.text = data.menuName self.menuImageView.image = data.menuIcon + self.originalImage = data.menuIcon } } diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift index 7904a181..4d63e160 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift @@ -20,6 +20,13 @@ class MainMapVC: UIViewController, NMFLocationManagerDelegate { private let locationManager = NMFLocationManager.sharedInstance() private var currentLatitude: Double? private var currentLongitude: Double? + private var selectedCategories: [Bool] = [false, false, false, + false, false, false, + false, false] { + didSet { + categoryCollectionView.reloadData() + } + } var viewModel: MainMapViewModel! // MARK: - UI Components @@ -78,6 +85,7 @@ class MainMapVC: UIViewController, NMFLocationManagerDelegate { let cv = UICollectionView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 32), collectionViewLayout: layout) cv.showsHorizontalScrollIndicator = false cv.backgroundColor = .clear + cv.allowsMultipleSelection = true return cv }() @@ -384,7 +392,14 @@ extension MainMapVC { // MARK: - CollectionView Delegate extension MainMapVC: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + makeVibrate() + } + func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { + selectedCategories[indexPath.row].toggle() + return true + } } extension MainMapVC: UICollectionViewDelegateFlowLayout { @@ -400,7 +415,9 @@ extension MainMapVC: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MenuCategoryCVC.className, for: indexPath) as? MenuCategoryCVC else { return UICollectionViewCell() } + cell.isDietMenu = MainMapCategory.categorySample[indexPath.row].isDietMenu cell.setData(data: MainMapCategory.categorySample[indexPath.row]) + cell.isSelected = selectedCategories[indexPath.row] return cell } } From 6931cf57bb88181095e79fde709fca3d4c7328c7 Mon Sep 17 00:00:00 2001 From: L-j-h-c Date: Fri, 15 Jul 2022 18:09:43 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[Fix]=20#69=20-=20=EB=94=94=ED=85=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Map/MainMapScene/VC/MainMapVC.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift index 4d63e160..abba456d 100644 --- a/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift +++ b/HealthFoodMe/HealthFoodMe/Presentation/Map/MainMapScene/VC/MainMapVC.swift @@ -18,8 +18,6 @@ class MainMapVC: UIViewController, NMFLocationManagerDelegate { private let disposeBag = DisposeBag() private let locationManager = NMFLocationManager.sharedInstance() - private var currentLatitude: Double? - private var currentLongitude: Double? private var selectedCategories: [Bool] = [false, false, false, false, false, false, false, false] { @@ -40,6 +38,7 @@ class MainMapVC: UIViewController, NMFLocationManagerDelegate { let bt = UIButton() bt.setImage(ImageLiterals.Map.menuIcon, for: .normal) bt.addAction(UIAction(handler: { _ in + self.makeVibrate() let nextVC = ModuleFactory.resolve().makeHamburgerBarVC() nextVC.modalPresentationStyle = .overFullScreen self.present(nextVC, animated: false) @@ -89,11 +88,12 @@ class MainMapVC: UIViewController, NMFLocationManagerDelegate { return cv }() - private let scrapButton: UIButton = { + private lazy var scrapButton: UIButton = { let bt = UIButton() bt.setImage(ImageLiterals.Map.scrapIcon, for: .normal) bt.setImage(ImageLiterals.MainDetail.scrapIcon_filled, for: .selected) bt.addAction(UIAction(handler: { _ in + self.makeVibrate() bt.isSelected.toggle() }), for: .touchUpInside) bt.backgroundColor = .helfmeWhite @@ -107,8 +107,11 @@ class MainMapVC: UIViewController, NMFLocationManagerDelegate { let bt = UIButton() bt.setImage(ImageLiterals.Map.mylocationIcon, for: .normal) bt.addAction(UIAction(handler: { _ in + self.makeVibrate() let NMGPosition = self.locationManager?.currentLatLng() - self.mapView.moveCameraPosition(NMGPosition ?? NMGLatLng(lat: 37.5666805, lng: 126.9784147)) + if let position = NMGPosition { + self.mapView.moveCameraPosition(position) + } }), for: .touchUpInside) bt.backgroundColor = .helfmeWhite bt.clipsToBounds = true @@ -368,6 +371,7 @@ extension MainMapVC { @objc private func presentSearchVC() { + self.makeVibrate() let nextVC = ModuleFactory.resolve().makeSearchVC() self.navigationController?.pushViewController(nextVC, animated: true) }