@@ -20,10 +20,6 @@ import androidx.compose.ui.res.dimensionResource
2020import androidx.compose.ui.res.painterResource
2121import androidx.compose.ui.res.stringResource
2222import androidx.compose.ui.unit.dp
23- import androidx.dynamicanimation.animation.DynamicAnimation
24- import androidx.transition.AutoTransition
25- import androidx.transition.Transition
26- import androidx.transition.TransitionManager
2723import com.google.android.material.dialog.MaterialAlertDialogBuilder
2824import com.jakewharton.rxbinding3.view.clicks
2925import com.spotify.mobius.Init
@@ -67,6 +63,7 @@ import org.simple.clinic.scheduleappointment.ScheduleAppointmentSheet
6763import org.simple.clinic.scheduleappointment.facilityselection.FacilitySelectionScreen
6864import org.simple.clinic.summary.addcholesterol.CholesterolEntrySheet
6965import org.simple.clinic.summary.addphone.AddPhoneNumberDialog
66+ import org.simple.clinic.summary.clinicaldecisionsupport.ui.ClinicalDecisionHighBpAlert
7067import org.simple.clinic.summary.compose.StatinNudge
7168import org.simple.clinic.summary.linkId.LinkIdWithPatientSheet.LinkIdWithPatientSheetKey
7269import org.simple.clinic.summary.teleconsultation.contactdoctor.ContactDoctorSheet
@@ -83,7 +80,6 @@ import org.simple.clinic.widgets.UiEvent
8380import org.simple.clinic.widgets.compose.PatientStatusView
8481import org.simple.clinic.widgets.hideKeyboard
8582import org.simple.clinic.widgets.scrollToChild
86- import org.simple.clinic.widgets.spring
8783import java.time.format.DateTimeFormatter
8884import java.util.UUID
8985import java.util.concurrent.TimeUnit
@@ -154,9 +150,6 @@ class PatientSummaryScreen :
154150 private val nextAppointmentFacilityView
155151 get() = binding.nextAppointmentFacilityView
156152
157- private val clinicalDecisionSupportAlertView
158- get() = binding.clinicalDecisionSupportBpHighAlert.rootView
159-
160153 private val composeView
161154 get() = binding.composeView
162155
@@ -200,6 +193,9 @@ class PatientSummaryScreen :
200193
201194 private var showPatientDiedStatusView by mutableStateOf(false )
202195
196+ private var showClinicalDecisionAlert by mutableStateOf(false )
197+ private var animateClinicalDecisionSupportAlert by mutableStateOf(false )
198+
203199 override fun defaultModel (): PatientSummaryModel {
204200 return PatientSummaryModel .from(screenKey.intention, screenKey.patientUuid)
205201 }
@@ -302,6 +298,16 @@ class PatientSummaryScreen :
302298 setViewCompositionStrategy(ViewCompositionStrategy .DisposeOnViewTreeLifecycleDestroyed )
303299 setContent {
304300 SimpleTheme {
301+ ClinicalDecisionHighBpAlert (
302+ showAlert = showClinicalDecisionAlert,
303+ animateExit = animateClinicalDecisionSupportAlert,
304+ modifier = Modifier .padding(
305+ start = dimensionResource(R .dimen.spacing_8),
306+ end = dimensionResource(R .dimen.spacing_8),
307+ top = dimensionResource(R .dimen.spacing_8),
308+ ),
309+ )
310+
305311 StatinNudge (
306312 statinInfo = statinInfo,
307313 modifier = Modifier .padding(start = 8 .dp, end = 8 .dp, top = 8 .dp),
@@ -743,82 +749,23 @@ class PatientSummaryScreen :
743749 }
744750
745751 override fun showClinicalDecisionSupportAlert () {
746- showWithAnimation(clinicalDecisionSupportAlertView)
752+ showClinicalDecisionAlert = true
747753 }
748754
749755 override fun hideClinicalDecisionSupportAlert () {
750- hideWithAnimation(clinicalDecisionSupportAlertView, R .id.tag_clinical_decision_pending_end_listener)
756+ showClinicalDecisionAlert = false
757+ animateClinicalDecisionSupportAlert = true
751758 }
752759
753760 override fun hideClinicalDecisionSupportAlertWithoutAnimation () {
754- clinicalDecisionSupportAlertView.visibility = GONE
761+ showClinicalDecisionAlert = false
762+ animateClinicalDecisionSupportAlert = false
755763 }
756764
757765 override fun updateStatinAlert (statinInfo : StatinInfo ) {
758766 this .statinInfo = statinInfo
759767 }
760768
761- private fun showWithAnimation (view : View ) {
762- view.translationY = view.height.unaryMinus().toFloat()
763-
764- val spring = view.spring(DynamicAnimation .TRANSLATION_Y )
765-
766- val transition = AutoTransition ().apply {
767- excludeChildren(view, true )
768- // We are doing this to wait for the router transitions to be done before we start this.
769- startDelay = 500
770- }
771- val transitionListener = object : Transition .TransitionListener {
772- override fun onTransitionStart (transition : Transition ) {
773- }
774-
775- override fun onTransitionEnd (transition : Transition ) {
776- transition.removeListener(this )
777- spring.animateToFinalPosition(0f )
778- }
779-
780- override fun onTransitionCancel (transition : Transition ) {
781- }
782-
783- override fun onTransitionPause (transition : Transition ) {
784- }
785-
786- override fun onTransitionResume (transition : Transition ) {
787- }
788- }
789- transition.addListener(transitionListener)
790- TransitionManager .beginDelayedTransition(summaryViewsContainer, transition)
791-
792- view.visibility = VISIBLE
793- }
794-
795- private fun hideWithAnimation (view : View , tag : Int ) {
796- if (view.visibility != VISIBLE ) return
797-
798- val spring = view.spring(DynamicAnimation .TRANSLATION_Y )
799- (view.getTag(tag) as ?
800- DynamicAnimation .OnAnimationEndListener )?.let {
801- spring.removeEndListener(it)
802- }
803-
804- val listener = object : DynamicAnimation .OnAnimationEndListener {
805- override fun onAnimationEnd (animation : DynamicAnimation <* >? , canceled : Boolean , value : Float , velocity : Float ) {
806- spring.removeEndListener(this )
807- view.visibility = GONE
808- }
809- }
810- spring.addEndListener(listener)
811- view.setTag(tag, listener)
812-
813- val transition = AutoTransition ().apply {
814- excludeChildren(view, true )
815- }
816- TransitionManager .beginDelayedTransition(summaryViewsContainer, transition)
817-
818- spring.animateToFinalPosition(view.height.unaryMinus().toFloat())
819- }
820-
821-
822769 override fun showReassignPatientWarningSheet (
823770 patientUuid : UUID ,
824771 currentFacility : Facility ,
0 commit comments