Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/symptoms categories info naming #130 #132

Merged
merged 16 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ class AppScreenEvents @Inject constructor(
data object AddBloodPressureRecord : Event
data object AddHeartRateRecord : Event
data class NavigateToTab(val bottomBarItem: BottomBarItem) : Event
data object SymptomsDescriptionBottomSheet : Event
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package edu.stanford.bdh.engagehf.health.symptoms

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import edu.stanford.bdh.engagehf.R
import edu.stanford.spezi.core.design.component.VerticalSpacer
import edu.stanford.spezi.core.design.theme.Spacings
import edu.stanford.spezi.core.design.theme.SpeziTheme
import edu.stanford.spezi.core.design.theme.TextStyles
import edu.stanford.spezi.core.design.theme.ThemePreviews

@Composable
fun SymptomsDescriptionBottomSheet() {
LazyColumn(
modifier = Modifier
.fillMaxWidth()
.padding(Spacings.medium),
horizontalAlignment = Alignment.CenterHorizontally

Check warning on line 26 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L22-L26

Added lines #L22 - L26 were not covered by tests
) {
item {

Check warning on line 28 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L28

Added line #L28 was not covered by tests
Text(
text = stringResource(R.string.symptoms_description_title),
style = TextStyles.titleLarge

Check warning on line 31 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L30-L31

Added lines #L30 - L31 were not covered by tests
)
VerticalSpacer()
TitleDescriptionItem(
title = stringResource(R.string.overall_score_title),
description = stringResource(R.string.overall_score_description)

Check warning on line 36 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L33-L36

Added lines #L33 - L36 were not covered by tests
)
TitleDescriptionItem(
title = stringResource(R.string.physical_limits_score_title),
description = stringResource(R.string.physical_limits_score_description)

Check warning on line 40 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L38-L40

Added lines #L38 - L40 were not covered by tests
)
TitleDescriptionItem(
title = stringResource(R.string.social_limits_score_title),
description = stringResource(R.string.social_limits_score_description)

Check warning on line 44 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L42-L44

Added lines #L42 - L44 were not covered by tests
)
TitleDescriptionItem(
title = stringResource(R.string.quality_of_life_score_title),
description = stringResource(R.string.quality_of_life_score_description)

Check warning on line 48 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L46-L48

Added lines #L46 - L48 were not covered by tests
)
TitleDescriptionItem(
title = stringResource(R.string.symptoms_frequency_score_title),
description = stringResource(R.string.specific_symptoms_score_description)

Check warning on line 52 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L50-L52

Added lines #L50 - L52 were not covered by tests
)
TitleDescriptionItem(
title = stringResource(R.string.dizziness_score_title),
description = stringResource(R.string.dizziness_score_description)

Check warning on line 56 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L54-L56

Added lines #L54 - L56 were not covered by tests
)
VerticalSpacer()
}
}

Check warning on line 60 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L58-L60

Added lines #L58 - L60 were not covered by tests
}

@Composable
fun TitleDescriptionItem(title: String, description: String) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = Spacings.small),
horizontalAlignment = Alignment.CenterHorizontally

Check warning on line 69 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L65-L69

Added lines #L65 - L69 were not covered by tests
) {
Text(
text = title,
style = TextStyles.titleMedium

Check warning on line 73 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L71-L73

Added lines #L71 - L73 were not covered by tests
)
Text(
text = description,
style = TextStyles.bodyMedium.copy(textAlign = TextAlign.Center)

Check warning on line 77 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L75-L77

Added lines #L75 - L77 were not covered by tests
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
)
}

Check warning on line 79 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L79

Added line #L79 was not covered by tests
}

@ThemePreviews
@Composable
fun SymptomsDescriptionBottomSheetPreview() {
SpeziTheme(isPreview = true) {

Check warning on line 85 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L85

Added line #L85 was not covered by tests
SymptomsDescriptionBottomSheet()
}

Check warning on line 87 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsDescriptionBottomSheet.kt#L87

Added line #L87 was not covered by tests
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.stanford.bdh.engagehf.health.symptoms

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -12,9 +11,9 @@
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.outlined.Check
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.DropdownMenu
Expand All @@ -31,9 +30,7 @@
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -71,7 +68,6 @@
import edu.stanford.bdh.engagehf.health.HealthTableItem
import edu.stanford.spezi.core.design.component.CenteredBoxContent
import edu.stanford.spezi.core.design.component.VerticalSpacer
import edu.stanford.spezi.core.design.theme.Colors.onPrimary
import edu.stanford.spezi.core.design.theme.Colors.primary
import edu.stanford.spezi.core.design.theme.Colors.secondary
import edu.stanford.spezi.core.design.theme.Sizes
Expand Down Expand Up @@ -163,14 +159,9 @@
onClick = { onAction(SymptomsViewModel.Action.Info) }
) {
Icon(
painter = painterResource(id = edu.stanford.spezi.core.design.R.drawable.ic_info),
imageVector = Icons.Filled.Info,

Check warning on line 162 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsScreen.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsScreen.kt#L162

Added line #L162 was not covered by tests
contentDescription = stringResource(R.string.info_icon_content_description),
modifier = Modifier
.size(Sizes.Icon.medium)
.background(primary, shape = CircleShape)
.shadow(Spacings.small, CircleShape)
.padding(Spacings.small),
tint = onPrimary
tint = primary

Check warning on line 164 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsScreen.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsScreen.kt#L164

Added line #L164 was not covered by tests
)
}
}
Expand Down Expand Up @@ -280,12 +271,12 @@
}

@Composable
fun SymptomsDropdown(headerData: HeaderData, onAction: (SymptomsViewModel.Action) -> Unit) {
private fun SymptomsDropdown(headerData: HeaderData, onAction: (SymptomsViewModel.Action) -> Unit) {
Box(modifier = Modifier.wrapContentSize(Alignment.TopStart)) {
TextButton(onClick = {
onAction(SymptomsViewModel.Action.ToggleSymptomTypeDropdown(true))
}) {
SymptomTypeText(headerData.selectedSymptomType)
SymptomTypeTitleText(headerData.selectedSymptomType)
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
Icon(Icons.Default.ArrowDropDown, contentDescription = "ArrowDropDown")
}
DropdownMenu(
Expand Down Expand Up @@ -317,7 +308,7 @@
}

@Composable
fun SymptomTypeText(symptomType: SymptomType) {
private fun SymptomTypeText(symptomType: SymptomType) {
Text(
text =
when (symptomType) {
Expand All @@ -330,3 +321,18 @@
}
)
}

@Composable
private fun SymptomTypeTitleText(symptomType: SymptomType) {
Text(

Check warning on line 327 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsScreen.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsScreen.kt#L327

Added line #L327 was not covered by tests
text =
when (symptomType) {
SymptomType.OVERALL -> stringResource(R.string.overall_score_title)
SymptomType.PHYSICAL_LIMITS -> stringResource(R.string.physical_limits_score_title)
SymptomType.SOCIAL_LIMITS -> stringResource(R.string.social_limits_score_title)
SymptomType.QUALITY_OF_LIFE -> stringResource(R.string.quality_of_life_score_title)
SymptomType.SYMPTOMS_FREQUENCY -> stringResource(R.string.symptoms_frequency_score_title)
SymptomType.DIZZINESS -> stringResource(R.string.dizziness_score_title)

Check warning on line 335 in app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsScreen.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/health/symptoms/SymptomsScreen.kt#L330-L335

Added lines #L330 - L335 were not covered by tests
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package edu.stanford.bdh.engagehf.health.symptoms
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import edu.stanford.bdh.engagehf.bluetooth.component.AppScreenEvents
import edu.stanford.bdh.engagehf.health.AggregatedHealthData
import edu.stanford.bdh.engagehf.health.HealthRepository
import edu.stanford.bdh.engagehf.health.TableEntryData
Expand All @@ -23,6 +24,7 @@ import javax.inject.Inject
class SymptomsViewModel @Inject internal constructor(
private val symptomsUiStateMapper: SymptomsUiStateMapper,
private val healthRepository: HealthRepository,
private val appScreenEvents: AppScreenEvents,
) : ViewModel() {
private val logger by speziLogger()

Expand Down Expand Up @@ -56,7 +58,16 @@ class SymptomsViewModel @Inject internal constructor(

fun onAction(action: Action) {
when (action) {
Action.Info -> {}
is Action.Info -> {
val selectedSymptomType =
Basler182 marked this conversation as resolved.
Show resolved Hide resolved
(uiState.value as? SymptomsUiState.Success)?.data?.headerData?.selectedSymptomType
if (selectedSymptomType != null) {
appScreenEvents.emit(
AppScreenEvents.Event.SymptomsDescriptionBottomSheet
)
}
}

is Action.SelectSymptomType -> {
_uiState.update {
(it as? SymptomsUiState.Success)?.let { success ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import edu.stanford.bdh.engagehf.health.bloodpressure.bottomsheet.BloodPressureDescriptionBottomSheet
import edu.stanford.bdh.engagehf.health.heartrate.bottomsheet.AddHeartRateBottomSheet
import edu.stanford.bdh.engagehf.health.heartrate.bottomsheet.HeartRateDescriptionBottomSheet
import edu.stanford.bdh.engagehf.health.symptoms.SymptomsDescriptionBottomSheet
import edu.stanford.bdh.engagehf.health.weight.bottomsheet.AddWeightBottomSheet
import edu.stanford.bdh.engagehf.health.weight.bottomsheet.WeightDescriptionBottomSheet
import edu.stanford.bdh.engagehf.medication.ui.MedicationScreen
Expand Down Expand Up @@ -209,6 +210,7 @@
BottomSheetContent.BLOOD_PRESSURE_DESCRIPTION_INFO -> BloodPressureDescriptionBottomSheet()
BottomSheetContent.HEART_RATE_DESCRIPTION_INFO -> HeartRateDescriptionBottomSheet()
BottomSheetContent.BLUETOOTH_DEVICE_PAIRING -> BLEDevicePairingBottomSheet()
BottomSheetContent.SYMPTOMS_DESCRIPTION_INFO -> SymptomsDescriptionBottomSheet()

Check warning on line 213 in app/src/main/kotlin/edu/stanford/bdh/engagehf/navigation/screens/AppScreen.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/edu/stanford/bdh/engagehf/navigation/screens/AppScreen.kt#L213

Added line #L213 was not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class AppScreenViewModel @Inject constructor(
BottomSheetContent.BLOOD_PRESSURE_DESCRIPTION_INFO
}

AppScreenEvents.Event.SymptomsDescriptionBottomSheet -> BottomSheetContent.SYMPTOMS_DESCRIPTION_INFO

AppScreenEvents.Event.CloseBottomSheet -> {
null
}
Expand Down Expand Up @@ -187,6 +189,7 @@ enum class BottomSheetContent {
ADD_WEIGHT_RECORD,
ADD_BLOOD_PRESSURE_RECORD,
ADD_HEART_RATE_RECORD,
SYMPTOMS_DESCRIPTION_INFO,
BLUETOOTH_DEVICE_PAIRING,
}

Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,20 @@
<string name="your_devices_header_title">Deine Geräte</string>
<string name="last_seen_on">Zuletzt gesehen am %1$s</string>
<string name="sign_out_failed">Abmeldung fehlgeschlagen.</string>
<string name="invitation_code">Einladungscode</string>
<string name="onboarding">Onboarding</string>
<string name="contact">Kontakt</string>
<string name="symptoms_description_title">Ihre Symptome verstehen</string>
<string name="overall_score_title">Gesamt Score</string>
<string name="overall_score_description">Dieser Wert zeigt, wie sich Ihre Herzinsuffizienz insgesamt auf Sie auswirkt. Sie können einen Wert zwischen 0 und 100 erreichen. Ein höherer Wert bedeutet, dass es Ihnen besser geht. Ein Wert über 80 wird oft als gut angesehen. Ein Ziel der Herzmedikamente ist es, diesen Wert im Laufe der Zeit zu verbessern oder zu verhindern, dass er sich verringert.</string>
<string name="physical_limits_score_title">Physikalische Grenzen Score</string>
<string name="physical_limits_score_description">Dieser Wert gibt an, wie sehr Ihr Herz Ihre Fähigkeit, sich zu betätigen, beeinträchtigt. Höhere Werte bedeuten, dass Sie weniger eingeschränkt sind, und ein Wert über 80 wird oft als gut angesehen.</string>
<string name="social_limits_score_title">Soziale Grenzen Score</string>
<string name="social_limits_score_description">Dieser Wert gibt an, wie Ihr Herz Ihre Fähigkeit zu sozialen Aktivitäten beeinflusst. Höhere Werte bedeuten, dass Sie mehr tun können, während niedrigere Werte bedeuten, dass Sie durch Ihr Herz stärker eingeschränkt sind.</string>
<string name="quality_of_life_score_title">Bewertung der Lebensqualität</string>
<string name="quality_of_life_score_description">Dieser Wert gibt an, wie zufrieden Sie mit Ihren Herzsymptomen sind. Höhere Werte bedeuten, dass Sie insgesamt zufriedener sind, während niedrigere Werte bedeuten, dass Sie weniger zufrieden mit Ihrer Situation sind.</string>
<string name="symptoms_frequency_score_title">Symptom Häufigkeit</string>
<string name="specific_symptoms_score_description">Dieser Wert gibt die Häufigkeit an, mit der Sie herzbezogene Symptome verspüren. Höhere Werte bedeuten weniger häufige Symptome und niedrigere Werte bedeuten häufigere Symptome.</string>
<string name="dizziness_score_title">Schwindel Score</string>
<string name="dizziness_score_description">Es ist wichtig, Ihren Schwindel im Auge zu behalten, denn Schwindel kann eine Nebenwirkung Ihres Herzens oder Ihrer Herzmedikamente sein.</string>
</resources>
15 changes: 14 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<string name="symptom_type_physical">Physical</string>
<string name="symptom_type_social">Social</string>
<string name="symptom_type_quality">Quality</string>
<string name="symptom_type_specific">Specific</string>
<string name="symptom_type_specific">Symptoms</string>
<string name="symptom_type_dizziness">Dizziness</string>
<string name="medications_no_recommendations">No medication recommendations</string>
<string name="dosage_information_dose_row_current_dose">Current Dose:</string>
Expand Down Expand Up @@ -108,4 +108,17 @@
<string name="invitation_code">Invitation Code</string>
<string name="onboarding">Onboarding</string>
<string name="contact">Contact</string>
<string name="symptoms_description_title">Understanding Your Symptoms</string>
<string name="overall_score_title">Overall Score</string>
<string name="overall_score_description">This score shows how your heart failure affects you overall. You can score 0 to 100. A higher score means you are doing better. Over 80 is often considered doing well. A goal of heart medicines is to improve this score over time or keep it from decreasing.</string>
<string name="physical_limits_score_title">Physical Limits Score</string>
<string name="physical_limits_score_description">This represents how your heart affects your ability to do activity. Higher scores mean you are less limited, and over 80 is often considered doing well.</string>
<string name="social_limits_score_title">Social Limits Score</string>
<string name="social_limits_score_description">This score represents how your heart affects your ability to do social activities. Higher scores mean you are able to do more, while lower scores mean you are more limited by your heart.</string>
<string name="quality_of_life_score_title">Quality of Life Score</string>
<string name="quality_of_life_score_description">This score represents how content you are with your heart symptoms. Higher scores mean you are overall more content, while lower scores mean you are less satisfied with how you are doing.</string>
<string name="symptoms_frequency_score_title">Symptom Frequency</string>
<string name="specific_symptoms_score_description">This represents the frequency you are experiencing heart-related symptoms. Higher scores mean less frequent symptoms and lower scores mean more frequent symptoms.</string>
<string name="dizziness_score_title">Dizziness Score</string>
<string name="dizziness_score_description">Your dizziness is important to keep track of because dizziness can be a side effect of your heart or your heart medicines.</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package edu.stanford.bdh.engagehf.health.symptoms

import com.google.common.truth.Truth.assertThat
import edu.stanford.bdh.engagehf.bluetooth.component.AppScreenEvents
import edu.stanford.bdh.engagehf.health.HealthRepository
import edu.stanford.spezi.core.testing.CoroutineTestRule
import io.mockk.coEvery
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import kotlinx.coroutines.flow.flowOf
import org.junit.Before
import org.junit.Rule
Expand All @@ -21,6 +23,7 @@ class SymptomsViewModelTest {
private val symptomsUiStateMapper: SymptomsUiStateMapper = mockk()
private val symptomScores = getSymptomScores()
private val successState = SymptomsUiState.Success(getSymptomsUiData())
private val appScreenEvents: AppScreenEvents = mockk(relaxed = true)

private lateinit var viewModel: SymptomsViewModel

Expand Down Expand Up @@ -99,6 +102,18 @@ class SymptomsViewModelTest {
assertThat(uiState).isEqualTo(newState)
}

@Test
fun `it should handle SymptomsDescriptionBottomSheet correctly`() {
// given
createViewModel()

// when
viewModel.onAction(SymptomsViewModel.Action.Info)

// then
verify { appScreenEvents.emit(AppScreenEvents.Event.SymptomsDescriptionBottomSheet) }
}

private fun getSymptomScores() = listOf(
SymptomScore(
overallScore = 80.0,
Expand All @@ -121,6 +136,10 @@ class SymptomsViewModelTest {
)

private fun createViewModel() {
viewModel = SymptomsViewModel(symptomsUiStateMapper, healthRepository)
viewModel = SymptomsViewModel(
symptomsUiStateMapper = symptomsUiStateMapper,
healthRepository = healthRepository,
appScreenEvents = appScreenEvents,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,18 @@ class AppScreenViewModelTest {
val updatedUiState = viewModel.uiState.value
assertThat(updatedUiState.bottomSheetContent).isEqualTo(BottomSheetContent.HEART_RATE_DESCRIPTION_INFO)
}

@Test
fun `given SymptomsDescriptionBottomSheet is received then uiState should be updated`() =
runTestUnconfined {
// Given
val event = AppScreenEvents.Event.SymptomsDescriptionBottomSheet

// When
appScreenEventsFlow.emit(event)

// Then
val updatedUiState = viewModel.uiState.value
assertThat(updatedUiState.bottomSheetContent).isEqualTo(BottomSheetContent.SYMPTOMS_DESCRIPTION_INFO)
}
}
Loading