Skip to content

Commit

Permalink
#40 feat/리뷰 작성 : 주소 검색 화면에서 주소 선택 시 buildingId 를 전달하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
HayleyKim0716 committed Dec 4, 2022
1 parent 2ca7533 commit 6e0c8ad
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ class CreateReviewActivity :
)
}

override fun onClickAddressFromFirstStepAddress(address: String) {
viewModel.setAddress(buildingId = "test")
override fun onClickAddressFromFirstStepAddress(buildingId: String) {
viewModel.setAddress(buildingId)
addFragment(
R.id.fragment_container_view,
CreateReviewFirstStepSelectFloorFragment.newInstance(address),
CreateReviewFirstStepSelectFloorFragment.newInstance(buildingId),
true
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CreateReviewFirstStepInputAddressFragment : Fragment() {
}

interface Listener {
fun onClickAddressFromFirstStepAddress(address: String)
fun onClickAddressFromFirstStepAddress(buildingId: String)
}

private var _binding: FragmentCreateReviewFirstStepInputAddressBinding? = null
Expand Down Expand Up @@ -86,7 +86,7 @@ class CreateReviewFirstStepInputAddressFragment : Fragment() {
when (event) {
is CreateReviewFirstStepInputAddressViewModel.Event.OnClickAddress -> {
hideKeyboard()
(activity as? Listener)?.onClickAddressFromFirstStepAddress(event.address)
(activity as? Listener)?.onClickAddressFromFirstStepAddress(event.buildingId)
}
is CreateReviewFirstStepInputAddressViewModel.Event.Error -> {
Toast.makeText(requireContext(), event.throwable.message, Toast.LENGTH_SHORT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CreateReviewFirstStepInputAddressViewModel(
sealed class Event {
object Nothing : Event()
data class Error(val throwable: Throwable) : Event()
data class OnClickAddress(val address: String) : Event()
data class OnClickAddress(val buildingId: String) : Event()
}

private val _event: MutableStateFlow<Event> = MutableStateFlow(Event.Nothing)
Expand Down Expand Up @@ -54,7 +54,7 @@ class CreateReviewFirstStepInputAddressViewModel(
addresses.map { searchedAddress ->
RecyclerItem(
data = CreateReviewAddressItem(
address = searchedAddress.name,
buildingId = searchedAddress.id,
onClick = { _event.value = Event.OnClickAddress(it) }
),
layoutId = R.layout.list_item_create_review_search_address,
Expand All @@ -70,10 +70,10 @@ class CreateReviewFirstStepInputAddressViewModel(
}

data class CreateReviewAddressItem(
val address: String,
val buildingId: String,
val onClick: (String) -> Unit
) {
fun onClick() {
this.onClick(address)
this.onClick(buildingId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:padding="@dimen/dp_size_16"
android:background="@color/white"
android:onClick="@{() -> item.onClick()}"
android:text="@{item.address}"
android:text="@{item.buildingId}"
android:fontFamily="@font/pretendard_regular"
android:textSize="@dimen/sp_size_14"
android:textColor="@color/gray_900"
Expand Down

0 comments on commit 6e0c8ad

Please sign in to comment.