From ee74cf54900091193092ce1981368284c37d72d8 Mon Sep 17 00:00:00 2001 From: songpink Date: Tue, 6 Aug 2024 13:49:21 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B3=B5=EB=AA=A8=EA=B0=80=20=EC=A0=95?= =?UTF-8?q?=EC=83=81=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EB=90=98=EC=97=88=EC=9D=84=20=EC=8B=9C=20"=EA=B3=B5=EB=AA=A8?= =?UTF-8?q?=EA=B0=80=20=EA=B2=8C=EC=8B=9C=EB=90=98=EC=97=88=EC=96=B4?= =?UTF-8?q?=EC=9A=94!"=20=EB=9D=BC=EB=8A=94=20=ED=86=A0=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EB=9D=84=EC=9A=B0=EA=B3=A0=20=EA=B3=B5=EB=AA=A8?= =?UTF-8?q?=EA=B8=80=20=EC=9E=91=EC=84=B1=20=ED=94=84=EB=9E=98=EA=B7=B8?= =?UTF-8?q?=EB=A8=BC=ED=8A=B8=EB=A5=BC=20=EC=A2=85=EB=A3=8C=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/view/write/OfferingWriteFragment.kt | 8 ++++++++ .../presentation/view/write/OfferingWriteViewModel.kt | 8 ++++++++ android/app/src/main/res/values/strings.xml | 1 + 3 files changed, 17 insertions(+) diff --git a/android/app/src/main/java/com/zzang/chongdae/presentation/view/write/OfferingWriteFragment.kt b/android/app/src/main/java/com/zzang/chongdae/presentation/view/write/OfferingWriteFragment.kt index cac38b711..f35378235 100644 --- a/android/app/src/main/java/com/zzang/chongdae/presentation/view/write/OfferingWriteFragment.kt +++ b/android/app/src/main/java/com/zzang/chongdae/presentation/view/write/OfferingWriteFragment.kt @@ -46,6 +46,7 @@ class OfferingWriteFragment : Fragment() { super.onViewCreated(view, savedInstanceState) (activity as MainActivity).hideBottomNavigation() observeInvalidInputEvent() + observeFinishEvent() selectDeadline() searchPlace() } @@ -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, ) { diff --git a/android/app/src/main/java/com/zzang/chongdae/presentation/view/write/OfferingWriteViewModel.kt b/android/app/src/main/java/com/zzang/chongdae/presentation/view/write/OfferingWriteViewModel.kt index 39bae1517..d2d3e9804 100644 --- a/android/app/src/main/java/com/zzang/chongdae/presentation/view/write/OfferingWriteViewModel.kt +++ b/android/app/src/main/java/com/zzang/chongdae/presentation/view/write/OfferingWriteViewModel.kt @@ -60,6 +60,9 @@ class OfferingWriteViewModel( private val _invalidEachPriceEvent: MutableSingleLiveData = MutableSingleLiveData() val invalidEachPriceEvent: SingleLiveData get() = _invalidEachPriceEvent + private val _finishEvent: MutableSingleLiveData = MutableSingleLiveData() + val finishEvent: SingleLiveData get() = _finishEvent + private val _splitPrice: MediatorLiveData = MediatorLiveData(ERROR_INTEGER_FORMAT) val splitPrice: LiveData get() = _splitPrice @@ -204,6 +207,7 @@ class OfferingWriteViewModel( description = description, ), ).onSuccess { + makeFinishEvent() Log.d("alsong", "success") }.onFailure { Log.e("alsong", it.message.toString()) @@ -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 diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 5005565f9..e8ba1a6c7 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -112,5 +112,6 @@ %.1f %d년 %d월 %d일 %s %d시 %d분 + 공모가 게시되었어요!