Skip to content

Commit b73df5a

Browse files
committed
fix: 장소 패널 title에 검색 화면 결과를 사용하도록 수정
1 parent e9992c6 commit b73df5a

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

domain/src/main/java/com/stop/domain/model/geoLocation/GeoLocationInfo.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ data class GeoLocationInfo(
66
val lotAddress: String,
77
val distance: String
88
)
9+
10+
fun GeoLocationInfo.toClickedGeoLocationInfo(clickedPlaceName: String): GeoLocationInfo {
11+
return this.copy(
12+
title = clickedPlaceName
13+
)
14+
}

presentation/src/main/java/com/stop/ui/map/MapFragment.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class MapFragment : Fragment(), MapHandler {
191191
true
192192
)
193193
tMap.addMarker(Marker.PLACE_MARKER, Marker.PLACE_MARKER_IMG, clickTMapPoint)
194-
setPanel(clickTMapPoint)
194+
setPanel(clickTMapPoint, true)
195195
}
196196
}
197197
}
@@ -211,13 +211,17 @@ class MapFragment : Fragment(), MapHandler {
211211
currentTMapPoint.longitude
212212
)
213213
tMap.addMarker(Marker.PLACE_MARKER, Marker.PLACE_MARKER_IMG, currentTMapPoint)
214-
setPanel(currentTMapPoint)
214+
setPanel(currentTMapPoint, false)
215215
}
216216
}
217217
}
218218

219-
override fun setPanel(tMapPoint: TMapPoint) {
220-
placeSearchViewModel.getGeoLocationInfo(tMapPoint.latitude, tMapPoint.longitude)
219+
override fun setPanel(tMapPoint: TMapPoint, isClickedFromPlaceSearch: Boolean) {
220+
placeSearchViewModel.getGeoLocationInfo(
221+
tMapPoint.latitude,
222+
tMapPoint.longitude,
223+
isClickedFromPlaceSearch
224+
)
221225
}
222226

223227
override fun setOnLocationChangeListener(location: android.location.Location) {

presentation/src/main/java/com/stop/ui/map/MapHandler.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import com.skt.tmap.TMapPoint
44
import com.stop.ui.util.Handler
55

66
interface MapHandler : Handler {
7-
87
fun alertTMapReady()
98

109
fun setOnLocationChangeListener(location: android.location.Location)
1110

1211
fun setOnDisableScrollWIthZoomLevelListener()
1312

14-
fun setPanel(tMapPoint: TMapPoint)
15-
13+
fun setPanel(tMapPoint: TMapPoint, isClickedFromPlaceSearch: Boolean)
1614
}

presentation/src/main/java/com/stop/ui/map/MapTMap.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class MapTMap(
5858
isLongClick = true
5959
tMapView.setCenterPoint(tMapPoint.latitude, tMapPoint.longitude, true)
6060
addMarker(Marker.PLACE_MARKER, Marker.PLACE_MARKER_IMG, tMapPoint)
61-
handler.setPanel(tMapPoint)
61+
handler.setPanel(tMapPoint, false)
6262
}
6363

6464
private val onEnableScrollWithZoomLevelCallback =

presentation/src/main/java/com/stop/ui/placesearch/PlaceSearchViewModel.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.lifecycle.MutableLiveData
66
import androidx.lifecycle.ViewModel
77
import androidx.lifecycle.viewModelScope
88
import com.stop.domain.model.geoLocation.GeoLocationInfo
9+
import com.stop.domain.model.geoLocation.toClickedGeoLocationInfo
910
import com.stop.domain.model.nearplace.PlaceUseCaseItem
1011
import com.stop.domain.usecase.geoLocation.GeoLocationUseCase
1112
import com.stop.domain.usecase.nearplace.DeleteRecentPlaceSearchUseCase
@@ -34,12 +35,11 @@ class PlaceSearchViewModel @Inject constructor(
3435
) : ViewModel() {
3536

3637
// 기본 주소로 서울역 주소 지정
38+
var tMap: MapTMap? = null
3739
var currentLocation = Location(37.553836, 126.969652)
38-
40+
var clickedPlaceName = ""
3941
var panelInfo: com.stop.model.route.Place? = null
4042

41-
var tMap: MapTMap? = null
42-
4343
private val _nearPlaces = MutableStateFlow<List<PlaceUseCaseItem>>(emptyList())
4444
val nearPlaces: StateFlow<List<PlaceUseCaseItem>> = _nearPlaces
4545

@@ -94,6 +94,7 @@ class PlaceSearchViewModel @Inject constructor(
9494

9595
fun setClickPlace(placeUseCaseItem: PlaceUseCaseItem) {
9696
_clickPlaceUseCaseItem.value = Event(placeUseCaseItem)
97+
clickedPlaceName = placeUseCaseItem.name
9798
}
9899

99100
fun setClickCurrentLocation() {
@@ -102,12 +103,18 @@ class PlaceSearchViewModel @Inject constructor(
102103
}
103104
}
104105

105-
fun getGeoLocationInfo(latitude: Double, longitude: Double) {
106+
fun getGeoLocationInfo(latitude: Double, longitude: Double, isClickedFromPlaceSearch: Boolean) {
106107
viewModelScope.launch {
107-
_geoLocation.value = geoLocationUseCase.getGeoLocationInfo(latitude, longitude)
108+
val geoLocationInfo = geoLocationUseCase.getGeoLocationInfo(latitude, longitude)
108109

109-
readySendValue(latitude, longitude)
110+
_geoLocation.value = if (isClickedFromPlaceSearch) {
111+
geoLocationInfo.toClickedGeoLocationInfo(clickedPlaceName)
112+
} else {
113+
geoLocationInfo
114+
}
110115
_panelVisibility.value = View.VISIBLE
116+
117+
readySendValue(latitude, longitude)
111118
getDistance(latitude, longitude)
112119
}
113120
}

0 commit comments

Comments
 (0)