Skip to content

Commit

Permalink
Close sheet when back is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Dec 19, 2024
1 parent 1e55b00 commit d774e64
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ data object SaveClicked : BMIEntryEvent() {
override val analyticsName = "BMI Entry:Save Clicked"
}

data object BackPressed : BMIEntryEvent() {
override val analyticsName = "BMI Entry::Back Pressed"
}

data object BMISaved : BMIEntryEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class BMIEntryUpdate : Update<BMIEntryModel, BMIEntryEvent, BMIEntryEffect> {
is WeightChanged -> next(model.weightChanged(event.weight))
is WeightBackspaceClicked -> onWeightBackSpaceClicked(model)
is SaveClicked -> dispatch(CreateNewBMIEntry(model.patientUUID, BMIReading(height = model.height, weight = model.weight)))
is BackPressed -> dispatch(CloseSheet)
is BMISaved -> dispatch(CloseSheet)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,15 @@ class BMIEntryUpdateTest {
hasEffects(ChangeFocusToHeight)
))
}

@Test
fun `when back button is pressed, then close the sheet`() {
spec
.given(defaultModel)
.whenEvent(BackPressed)
.then(assertThatNext(
hasNoModel(),
hasEffects(CloseSheet)
))
}
}

0 comments on commit d774e64

Please sign in to comment.