Skip to content

Commit

Permalink
Merge branch 'juri' into refactor/#146-reportNavigationMVI
Browse files Browse the repository at this point in the history
  • Loading branch information
juri123123 committed Jan 24, 2025
2 parents bc3a8a0 + f859c6f commit 6cbf720
Show file tree
Hide file tree
Showing 22 changed files with 581 additions and 316 deletions.
4 changes: 4 additions & 0 deletions Spoony-iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>나는 양수정이다 머리를 조아려라</string>
<key>CFBundleIdentifier</key>
<string></string>
<key>UILaunchScreen</key>
<dict>
<key>UIImageName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ struct CustomNavigationBar: View {

private let style: NavigationBarStyle
private let title: String?
private let onBackTapped: (() -> Void)?
private let tappedAction: (() -> Void)?
private let onClearTapped: (() -> Void)?
private var spoonCount: Int = 0

private var onBackTapped: (() -> Void)?

init(
style: NavigationBarStyle,
title: String? = nil,
searchText: Binding<String> = .constant(""),
spoonCount: Int = 0,
onBackTapped: (() -> Void)? = nil,
tappedAction: (() -> Void)? = nil
tappedAction: (() -> Void)? = nil,
onClearTapped: (() -> Void)? = nil
) {
self.style = style
self.title = title
self._searchText = searchText
self.spoonCount = spoonCount
self.onBackTapped = onBackTapped
self.tappedAction = tappedAction
self.onClearTapped = onClearTapped
}

var body: some View {
Expand Down Expand Up @@ -181,7 +184,10 @@ struct CustomNavigationBar: View {
}

if !searchText.isEmpty {
Button(action: { searchText = "" }) {
Button(action: {
searchText = ""
onClearTapped?()
}) {
Image(.icCloseGray400)
.foregroundStyle(.gray600)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct ExploreCell: View {
HStack(alignment: .bottom, spacing: 4) {
Text(feed.userName)
.customFont(.body2b)
Text("\(feed.userRegion) 수저")
Text("서울시 \(feed.userRegion) 수저")
.customFont(.caption2m)
.foregroundStyle(.gray500)
}
Expand Down
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
2 changes: 1 addition & 1 deletion Spoony-iOS/Spoony-iOS/Source/Feature/Home/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct Home: View {
}
}
}
} // ZStack 닫기
}
.navigationBarHidden(true)
.task {
isBottomSheetPresented = true
Expand Down
68 changes: 52 additions & 16 deletions Spoony-iOS/Spoony-iOS/Source/Feature/Home/NMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ struct NMapView: UIViewRepresentable {
private let defaultZoomLevel: Double = 11.5
private let defaultMarker = NMFOverlayImage(name: "ic_unselected_marker")
private let selectedMarker = NMFOverlayImage(name: "ic_selected_marker")
private let defaultLatitude: Double = 37.5666103
private let defaultLongitude: Double = 126.9783882
private let locationManager = CLLocationManager()
@ObservedObject var viewModel: HomeViewModel
@Binding var selectedPlace: CardPlace?

Expand All @@ -21,6 +24,7 @@ struct NMapView: UIViewRepresentable {
init(viewModel: HomeViewModel,
selectedPlace: Binding<CardPlace?>,
onMoveCamera: ((Double, Double) -> Void)? = nil) {
locationManager.requestWhenInUseAuthorization()
self.viewModel = viewModel
self._selectedPlace = selectedPlace
self.onMoveCamera = onMoveCamera
Expand All @@ -29,11 +33,38 @@ struct NMapView: UIViewRepresentable {

func makeUIView(context: Context) -> NMFMapView {
let mapView = configureMapView(context: context)
checkLocationPermission(mapView)
return mapView
}

private func checkLocationPermission(_ mapView: NMFMapView) {
switch locationManager.authorizationStatus {
case .authorizedWhenInUse, .authorizedAlways:
if let location = locationManager.location {
moveCamera(mapView, to: NMGLatLng(lat: location.coordinate.latitude,
lng: location.coordinate.longitude))
}
case .denied, .restricted:
moveCamera(mapView, to: NMGLatLng(lat: defaultLatitude, lng: defaultLongitude))
case .notDetermined:
locationManager.requestWhenInUseAuthorization()
moveCamera(mapView, to: NMGLatLng(lat: defaultLatitude, lng: defaultLongitude))
default:
moveCamera(mapView, to: NMGLatLng(lat: defaultLatitude, lng: defaultLongitude))
}
}

private func moveCamera(_ mapView: NMFMapView, to coord: NMGLatLng) {
let cameraUpdate = NMFCameraUpdate(scrollTo: coord)
mapView.moveCamera(cameraUpdate)
}

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 @@ -72,6 +103,9 @@ struct NMapView: UIViewRepresentable {
mapView.positionMode = .direction
mapView.zoomLevel = defaultZoomLevel
mapView.touchDelegate = context.coordinator
mapView.logoAlign = .rightTop
mapView.logoInteractionEnabled = true
mapView.logoMargin = UIEdgeInsets(top: 60, left: 0, bottom: 0, right: 12)
return mapView
}

Expand Down Expand Up @@ -138,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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct ChipsContainerView: View {
let horizontalSpacing: CGFloat
let items: [CategoryChip]
var sortedItems: [CategoryChip] {
items.sorted { $0.id > $1.id }
items.sorted { $0.id < $1.id }
}

init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ enum RegisterIntent {
case deleteImage(UploadImage)
case getCategories
case didTapPhoto([PhotosPickerItem])
case updateKeyboardHeight(CGFloat)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ struct RegisterState {

// MARK: - InfoStepView
var placeText: String = ""
var recommendTexts: [TextList] = [.init()]

var toast: Toast?
var keyboardHeight: CGFloat = 0

var toast: Toast?
var recommendTexts: [TextList] = [.init()]
var categorys: [CategoryChip] = []
var selectedCategory: [CategoryChip] = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ final class RegisterStore: ObservableObject {
fetchCategories()
case .didTapPhoto(let items):
validateSelectedPhotoCount(item: items)
case .updateKeyboardHeight(let height):
state.keyboardHeight = height
}
}
}
Expand Down
Loading

0 comments on commit 6cbf720

Please sign in to comment.