Skip to content

Commit

Permalink
#40 feat/리뷰 작성 : 리뷰 작성 flow 에서 '<' 버튼 클릭 시 이전 화면으로 돌아가도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
HayleyKim0716 committed Dec 4, 2022
1 parent 5311b79 commit 0c2c15e
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import kotlinx.coroutines.launch
import kotlinx.parcelize.Parcelize

@AndroidEntryPoint
class CreateReviewFirstStepSelectFloorFragment : Fragment(), SelectResidentialFloorBottomSheet.Listener {
class CreateReviewFirstStepSelectFloorFragment :
Fragment(),
SelectResidentialFloorBottomSheet.Listener {
companion object {
private const val ARGUMENT_KEY = "CREATE_REVIEW_SECOND_STEP_ARGUMENT_KEY"
fun newInstance(address: String): CreateReviewFirstStepSelectFloorFragment {
Expand Down Expand Up @@ -86,6 +88,7 @@ class CreateReviewFirstStepSelectFloorFragment : Fragment(), SelectResidentialFl
when (event) {
CreateReviewFirstStepSelectFloorViewModel.Event.Nothing -> {}
CreateReviewFirstStepSelectFloorViewModel.Event.OnClickResidentialFloor -> showSelectResidentialFloorBottomSheet()
CreateReviewFirstStepSelectFloorViewModel.Event.OnClickBack -> activity?.onBackPressed()
is CreateReviewFirstStepSelectFloorViewModel.Event.OnClickNext -> {
(activity as? Listener)?.onClickNextFromFirstStepResidentialFloor(
event.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class CreateReviewFirstStepSelectFloorViewModel {
sealed class Event {
object Nothing : Event()
object OnClickResidentialFloor : Event()
object OnClickBack : Event()
class OnClickNext(val address: String, val floor: String) : Event()
}

Expand All @@ -33,6 +34,11 @@ class CreateReviewFirstStepSelectFloorViewModel {
_event.value = Event.Nothing
}

fun onClickBack() {
_event.value = Event.OnClickBack
_event.value = Event.Nothing
}

fun onClickNext() {
_event.value = Event.OnClickNext(address.value, residentialFloor.value)
_event.value = Event.Nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class CreateReviewSecondStepReviewFragment : Fragment(), TextListBottomSheet.Lis
TextListBottomSheet.newInstance(getResidentialPeriods(event.periods))
.show(childFragmentManager, TextListBottomSheet::class.simpleName)
}
CreateReviewSecondStepReviewViewModel.State.OnClickBack -> {
activity?.onBackPressed()
}
is CreateReviewSecondStepReviewViewModel.State.OnClickNext -> {
(activity as? Listener)?.onClickNextFromSecondStepReview(
event.rating,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class CreateReviewSecondStepReviewViewModel {
sealed class State {
object None : State()
class OnClickResidentialPeriod(val periods: List<Int>) : State()
object OnClickBack : State()
class OnClickNext(
val rating: Int,
val leftAt: Date,
Expand Down Expand Up @@ -37,6 +38,10 @@ class CreateReviewSecondStepReviewViewModel {
)
}

fun onClickBack() {
_event.value = State.OnClickBack
}

fun onClickNext() {
_event.value = State.OnClickNext(
rating.value.toInt(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class CreateReviewThirdStepSearchCompanyFragment : Fragment() {
when (event) {
CreateReviewThirdStepSearchCompanyViewModel.Event.None -> {}
CreateReviewThirdStepSearchCompanyViewModel.Event.OnClickSearchCompany -> showSearchCompanyActivity()
CreateReviewThirdStepSearchCompanyViewModel.Event.OnClickBack -> activity?.onBackPressed()
is CreateReviewThirdStepSearchCompanyViewModel.Event.OnClickNext -> {
(activity as? Listener)?.onClickNextFromThirdStepSearchCompany(event.company)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CreateReviewThirdStepSearchCompanyViewModel {
sealed class Event {
object None : Event()
object OnClickSearchCompany : Event()
object OnClickBack : Event()
class OnClickNext(val company: String) : Event()
}

Expand All @@ -21,6 +22,11 @@ class CreateReviewThirdStepSearchCompanyViewModel {
_event.value = Event.None
}

fun onClickBack() {
_event.value = Event.OnClickBack
_event.value = Event.None
}

fun onClickNext() {
_event.value = Event.OnClickNext(company.value)
_event.value = Event.None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_size_14"
android:onClick="@{() -> viewModel.onClickBack()}"
app:srcCompat="@drawable/icon_back"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_size_14"
android:onClick="@{() -> viewModel.onClickBack()}"
app:srcCompat="@drawable/icon_back"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down

0 comments on commit 0c2c15e

Please sign in to comment.