Skip to content

Commit

Permalink
feat: 공모가 정상적으로 게시되었을 시 "공모가 게시되었어요!" 라는 토스트를 띄우고 공모글 작성 프래그먼트를 종료하는 …
Browse files Browse the repository at this point in the history
…기능 구현
  • Loading branch information
songpink committed Aug 6, 2024
1 parent 0599a74 commit ee74cf5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class OfferingWriteFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
(activity as MainActivity).hideBottomNavigation()
observeInvalidInputEvent()
observeFinishEvent()
selectDeadline()
searchPlace()
}
Expand Down Expand Up @@ -173,6 +174,13 @@ class OfferingWriteFragment : Fragment() {
}
}

private fun observeFinishEvent() {
viewModel.finishEvent.observe(viewLifecycleOwner) {
parentFragmentManager.popBackStack()
showToast(R.string.write_success_writing)
}
}

private fun showToast(
@StringRes message: Int,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class OfferingWriteViewModel(
private val _invalidEachPriceEvent: MutableSingleLiveData<Boolean> = MutableSingleLiveData()
val invalidEachPriceEvent: SingleLiveData<Boolean> get() = _invalidEachPriceEvent

private val _finishEvent: MutableSingleLiveData<Boolean> = MutableSingleLiveData()
val finishEvent: SingleLiveData<Boolean> get() = _finishEvent

private val _splitPrice: MediatorLiveData<Int> = MediatorLiveData(ERROR_INTEGER_FORMAT)
val splitPrice: LiveData<Int> get() = _splitPrice

Expand Down Expand Up @@ -204,6 +207,7 @@ class OfferingWriteViewModel(
description = description,
),
).onSuccess {
makeFinishEvent()
Log.d("alsong", "success")
}.onFailure {
Log.e("alsong", it.message.toString())
Expand Down Expand Up @@ -244,6 +248,10 @@ class OfferingWriteViewModel(
_invalidEachPriceEvent.setValue(true)
}

private fun makeFinishEvent() {
_finishEvent.setValue(true)
}

companion object {
private const val ERROR_INTEGER_FORMAT = -1
private const val ERROR_FLOAT_FORMAT = -1f
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,6 @@
<string name="write_discount_rate_value">%.1f</string>
<string name="write_selected_date">%d년 %d월 %d일</string>
<string name="write_selected_time">%s %d시 %d분</string>
<string name="write_success_writing">공모가 게시되었어요!</string>

</resources>

0 comments on commit ee74cf5

Please sign in to comment.