Skip to content

Commit

Permalink
Merge pull request #167 from SOPT-all/feat/#166-mapSpeedFast
Browse files Browse the repository at this point in the history
Feat/#166 지도 관련 QA 반영
  • Loading branch information
hooni0918 authored Jan 24, 2025
2 parents a1a1d88 + 2d00edc commit f859c6f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private struct PlaceInfoSection: View {
.customFont(.body2sb)
.lineLimit(1)
.foregroundStyle(.gray900)
Text(place.address)
Text("서울시 \(place.address) 수저")
.customFont(.caption1m)
.foregroundColor(.gray600)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ import SwiftUI
struct PlaceImagesLayout: View {
let images: [String]

private var limitedImages: [String] {
Array(images.prefix(3))
}

var body: some View {
HStack(spacing: 1) {
switch images.count {
switch limitedImages.count {
case 1:
imageView(
urlString: images[0],
urlString: limitedImages[0],
width: nil,
height: 108.adjusted,
corners: [.topLeft, .topRight]
)
case 2:
ForEach(0..<2, id: \.self) { index in
imageView(
urlString: images[index],
urlString: limitedImages[index],
width: nil,
height: 108.adjusted,
corners: index == 0 ? [.topLeft] : [.topRight]
Expand All @@ -33,7 +37,7 @@ struct PlaceImagesLayout: View {
case 3:
ForEach(0..<3, id: \.self) { index in
imageView(
urlString: images[index],
urlString: limitedImages[index],
width: 108.adjusted,
height: 108.adjusted,
corners: index == 0 ? [.topLeft] : (index == 2 ? [.topRight] : [])
Expand Down
38 changes: 22 additions & 16 deletions Spoony-iOS/Spoony-iOS/Source/Feature/Home/NMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ struct NMapView: UIViewRepresentable {
}

func makeCoordinator() -> Coordinator {
Coordinator(selectedPlace: $selectedPlace, defaultMarkerImage: defaultMarker)
Coordinator(
selectedPlace: $selectedPlace,
defaultMarkerImage: defaultMarker,
viewModel: viewModel
)
}

func updateUIView(_ mapView: NMFMapView, context: Context) {
Expand Down Expand Up @@ -168,28 +172,30 @@ final class Coordinator: NSObject, NMFMapViewTouchDelegate {
@Binding var selectedPlace: CardPlace?
var markers: [NMFMarker] = []
private let defaultMarkerImage: NMFOverlayImage
private let viewModel: HomeViewModel

init(selectedPlace: Binding<CardPlace?>, defaultMarkerImage: NMFOverlayImage) {
init(selectedPlace: Binding<CardPlace?>,
defaultMarkerImage: NMFOverlayImage,
viewModel: HomeViewModel) {
self._selectedPlace = selectedPlace
self.defaultMarkerImage = defaultMarkerImage
self.viewModel = viewModel
}

func mapView(_ mapView: NMFMapView, didTap symbol: NMFSymbol) -> Bool {
@MainActor func mapView(_ mapView: NMFMapView, didTapMap latlng: NMGLatLng) -> Bool {
selectedPlace = nil
return true
}

func mapView(_ mapView: NMFMapView, didTapMap latlng: NMGLatLng) -> Bool {
if selectedPlace != nil {
selectedPlace = nil
markers.forEach { marker in
marker.mapView = nil
marker.iconImage = defaultMarkerImage
// 지도를 탭했을 때도 캡션 설정 유지
marker.mapView = mapView

markers.forEach { marker in
marker.iconImage = defaultMarkerImage
marker.captionMinZoom = 10
}

if !viewModel.focusedPlaces.isEmpty {
DispatchQueue.main.async {
self.viewModel.clearFocusedPlaces()
}
return true
}
return false

return true
}
}

0 comments on commit f859c6f

Please sign in to comment.