Skip to content

Commit

Permalink
Task/symptoms categories info naming #130 (#132)
Browse files Browse the repository at this point in the history
# *symptoms adjustments*

## ♻️ Current situation & Problem
#130 


## ⚙️ Release Notes 
- The title and selection in the symptom dropdown have always been
identical on Android. Now, as with iOS, the title is more detailed than
the selection
- the value adjustments have been made
- completed the symptom description

## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).

---------

Signed-off-by: Basler182 <[email protected]>
  • Loading branch information
Basler182 authored Nov 3, 2024
1 parent 33caec4 commit dc72363
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 26 deletions.
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,89 @@
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
) {
item {
Text(
text = stringResource(R.string.symptoms_description_title),
style = TextStyles.titleLarge
)
VerticalSpacer()
TitleDescriptionItem(
title = stringResource(R.string.overall_score_title),
description = stringResource(R.string.overall_score_description)
)
TitleDescriptionItem(
title = stringResource(R.string.physical_limits_score_title),
description = stringResource(R.string.physical_limits_score_description)
)
TitleDescriptionItem(
title = stringResource(R.string.social_limits_score_title),
description = stringResource(R.string.social_limits_score_description)
)
TitleDescriptionItem(
title = stringResource(R.string.quality_of_life_score_title),
description = stringResource(R.string.quality_of_life_score_description)
)
TitleDescriptionItem(
title = stringResource(R.string.symptoms_frequency_score_title),
description = stringResource(R.string.specific_symptoms_score_description)
)
TitleDescriptionItem(
title = stringResource(R.string.dizziness_score_title),
description = stringResource(R.string.dizziness_score_description)
)
VerticalSpacer()
}
}
}

@Composable
fun TitleDescriptionItem(title: String, description: String) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = Spacings.small),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = title,
style = TextStyles.titleMedium
)
Text(
text = description,
style = TextStyles.bodyMedium,
textAlign = TextAlign.Center
)
}
}

@ThemePreviews
@Composable
fun SymptomsDescriptionBottomSheetPreview() {
SpeziTheme(isPreview = true) {
SymptomsDescriptionBottomSheet()
}
}
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.layout.wrapContentSize
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.getValue
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.R
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 @@ private fun LazyListScope.listHeader(
onClick = { onAction(SymptomsViewModel.Action.Info) }
) {
Icon(
painter = painterResource(id = edu.stanford.spezi.core.design.R.drawable.ic_info),
imageVector = Icons.Filled.Info,
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
)
}
}
Expand Down Expand Up @@ -280,12 +271,12 @@ fun SymptomsChart(
}

@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)
Icon(Icons.Default.ArrowDropDown, contentDescription = "ArrowDropDown")
}
DropdownMenu(
Expand All @@ -297,7 +288,7 @@ fun SymptomsDropdown(headerData: HeaderData, onAction: (SymptomsViewModel.Action
val isSelected = headerData.selectedSymptomType == symptomType
DropdownMenuItem(
text = {
SymptomTypeText(symptomType)
headerData.selectedSymptomTypeText
},
onClick = {
onAction(SymptomsViewModel.Action.ToggleSymptomTypeDropdown(false))
Expand All @@ -317,16 +308,16 @@ fun SymptomsDropdown(headerData: HeaderData, onAction: (SymptomsViewModel.Action
}

@Composable
fun SymptomTypeText(symptomType: SymptomType) {
private fun SymptomTypeTitleText(symptomType: SymptomType) {
Text(
text =
when (symptomType) {
SymptomType.OVERALL -> stringResource(R.string.symptom_type_overall)
SymptomType.PHYSICAL_LIMITS -> stringResource(R.string.symptom_type_physical)
SymptomType.SOCIAL_LIMITS -> stringResource(R.string.symptom_type_social)
SymptomType.QUALITY_OF_LIFE -> stringResource(R.string.symptom_type_quality)
SymptomType.SYMPTOMS_FREQUENCY -> stringResource(R.string.symptom_type_specific)
SymptomType.DIZZINESS -> stringResource(R.string.symptom_type_dizziness)
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)
}
)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package edu.stanford.bdh.engagehf.health.symptoms

import edu.stanford.bdh.engagehf.R
import edu.stanford.bdh.engagehf.health.AggregatedHealthData
import edu.stanford.bdh.engagehf.health.NewestHealthData
import edu.stanford.bdh.engagehf.health.TableEntryData
import edu.stanford.spezi.core.design.component.StringResource
import edu.stanford.spezi.core.utils.LocaleProvider
import edu.stanford.spezi.core.utils.extensions.roundToDecimalPlaces
import java.time.ZoneId
Expand Down Expand Up @@ -40,13 +42,25 @@ class SymptomsUiStateMapper @Inject constructor(
formattedValue = newestHealthData.formattedValue,
formattedDate = newestHealthData.formattedDate,
selectedSymptomType = selectedSymptomType,
isSelectedSymptomTypeDropdownExpanded = false
isSelectedSymptomTypeDropdownExpanded = false,
selectedSymptomTypeText = getSelectedSymptomTypeText(selectedSymptomType),
),
valueFormatter = ::valueFormatter
)
)
}

private fun getSelectedSymptomTypeText(selectedSymptomType: SymptomType): StringResource {
return when (selectedSymptomType) {
SymptomType.OVERALL -> StringResource(R.string.symptom_type_overall)
SymptomType.PHYSICAL_LIMITS -> StringResource(R.string.symptom_type_physical)
SymptomType.SOCIAL_LIMITS -> StringResource(R.string.symptom_type_social)
SymptomType.QUALITY_OF_LIFE -> StringResource(R.string.symptom_type_quality)
SymptomType.SYMPTOMS_FREQUENCY -> StringResource(R.string.symptom_type_specific)
SymptomType.DIZZINESS -> StringResource(R.string.symptom_type_dizziness)
}
}

private fun valueFormatter(value: Double): String {
val year = value.toInt()
val dayOfYearFraction = value - year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ 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
import edu.stanford.spezi.core.design.component.StringResource
import edu.stanford.spezi.core.logging.speziLogger
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
Expand All @@ -23,6 +25,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 +59,12 @@ class SymptomsViewModel @Inject internal constructor(

fun onAction(action: Action) {
when (action) {
Action.Info -> {}
is Action.Info -> {
appScreenEvents.emit(
AppScreenEvents.Event.SymptomsDescriptionBottomSheet
)
}

is Action.SelectSymptomType -> {
_uiState.update {
(it as? SymptomsUiState.Success)?.let { success ->
Expand Down Expand Up @@ -110,6 +118,7 @@ data class SymptomsUiData(
)

data class HeaderData(
val selectedSymptomTypeText: StringResource,
val formattedValue: String,
val formattedDate: String,
val selectedSymptomType: SymptomType,
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.AddBloodPressu
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 @@ private fun BottomSheetContent(
BottomSheetContent.BLOOD_PRESSURE_DESCRIPTION_INFO -> BloodPressureDescriptionBottomSheet()
BottomSheetContent.HEART_RATE_DESCRIPTION_INFO -> HeartRateDescriptionBottomSheet()
BottomSheetContent.BLUETOOTH_DEVICE_PAIRING -> BLEDevicePairingBottomSheet()
BottomSheetContent.SYMPTOMS_DESCRIPTION_INFO -> SymptomsDescriptionBottomSheet()
}
}

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>
Loading

0 comments on commit dc72363

Please sign in to comment.