diff --git a/app/src/main/java/org/simple/clinic/summary/compose/StatinNudgeView.kt b/app/src/main/java/org/simple/clinic/summary/compose/StatinNudgeView.kt
index 7dbabdb8226..bd91072a003 100644
--- a/app/src/main/java/org/simple/clinic/summary/compose/StatinNudgeView.kt
+++ b/app/src/main/java/org/simple/clinic/summary/compose/StatinNudgeView.kt
@@ -7,7 +7,6 @@ import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
@@ -23,6 +22,11 @@ import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableFloatStateOf
+import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@@ -30,6 +34,7 @@ import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
@@ -41,6 +46,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.compose.ui.unit.toSize
import org.simple.clinic.R
import org.simple.clinic.common.ui.components.FilledButton
import org.simple.clinic.common.ui.theme.SimpleInverseTheme
@@ -72,55 +78,61 @@ fun StatinNudge(
Card(
modifier = modifier
) {
- BoxWithConstraints(
- modifier = Modifier.padding(16.dp)
+ var startOffset by remember { mutableFloatStateOf(0f) }
+ var endOffset by remember { mutableFloatStateOf(0f) }
+ var columnWidth by remember { mutableIntStateOf(0) }
+
+ Column(
+ modifier = Modifier
+ .padding(16.dp)
+ .onSizeChanged { intSize ->
+ val size = intSize.toSize()
+ val (start, end) = getOffsets(statinInfo.cvdRisk, size)
+ startOffset = start
+ endOffset = end
+ columnWidth = intSize.width
+ }
) {
- val constraints = constraints
- val size = Size(constraints.maxWidth.toFloat(), constraints.maxHeight.toFloat())
- val (startOffset, endOffset) = getOffsets(statinInfo.cvdRisk, size)
-
- Column {
- RiskText(
- startOffset = startOffset,
- endOffset = endOffset,
+ RiskText(
+ startOffset = startOffset,
+ endOffset = endOffset,
+ statinInfo = statinInfo,
+ parentWidth = columnWidth,
+ )
+ Spacer(modifier = Modifier.height(12.dp))
+ RiskProgressBar(
+ startOffset = startOffset,
+ endOffset = endOffset
+ )
+ Spacer(modifier = Modifier.height(16.dp))
+ DescriptionText(
+ isLabBasedStatinNudgeEnabled = isLabBasedStatinNudgeEnabled,
+ isNonLabBasedStatinNudgeEnabled = isNonLabBasedStatinNudgeEnabled,
+ statinInfo = statinInfo,
+ useVeryHighRiskAsThreshold = useVeryHighRiskAsThreshold
+ )
+
+ val shouldShowButtonsForNonLabNudge = isNonLabBasedStatinNudgeEnabled && !statinInfo.hasDiabetes
+ val shouldShowButtonsForLabNudge = isLabBasedStatinNudgeEnabled &&
+ statinInfo.cvdRisk?.canPrescribeStatin == true
+
+ val shouldShowAddButtons = !statinInfo.hasCVD &&
+ (shouldShowButtonsForNonLabNudge || shouldShowButtonsForLabNudge)
+
+ if (shouldShowAddButtons) {
+ StainNudgeAddButtons(
statinInfo = statinInfo,
- parentWidth = constraints.maxWidth,
- )
- Spacer(modifier = Modifier.height(12.dp))
- RiskProgressBar(
- startOffset = startOffset,
- endOffset = endOffset
- )
- Spacer(modifier = Modifier.height(16.dp))
- DescriptionText(
- isLabBasedStatinNudgeEnabled = isLabBasedStatinNudgeEnabled,
isNonLabBasedStatinNudgeEnabled = isNonLabBasedStatinNudgeEnabled,
- statinInfo = statinInfo,
- useVeryHighRiskAsThreshold = useVeryHighRiskAsThreshold
+ isLabBasedStatinNudgeEnabled = isLabBasedStatinNudgeEnabled,
+ addTobaccoUseClicked = addTobaccoUseClicked,
+ addBMIClick = addBMIClick,
+ addCholesterol = addCholesterol,
)
-
- val shouldShowButtonsForNonLabNudge = isNonLabBasedStatinNudgeEnabled && !statinInfo.hasDiabetes
- val shouldShowButtonsForLabNudge = isLabBasedStatinNudgeEnabled &&
- statinInfo.cvdRisk?.canPrescribeStatin == true
-
- val shouldShowAddButtons = !statinInfo.hasCVD &&
- (shouldShowButtonsForNonLabNudge || shouldShowButtonsForLabNudge)
-
- if (shouldShowAddButtons) {
- StainNudgeAddButtons(
- modifier = Modifier.padding(top = 16.dp),
- statinInfo = statinInfo,
- isNonLabBasedStatinNudgeEnabled = isNonLabBasedStatinNudgeEnabled,
- isLabBasedStatinNudgeEnabled = isLabBasedStatinNudgeEnabled,
- addTobaccoUseClicked = addTobaccoUseClicked,
- addBMIClick = addBMIClick,
- addCholesterol = addCholesterol,
- )
- }
}
}
}
}
+ // }
}
@Composable
@@ -171,15 +183,15 @@ fun RiskText(
Text(
modifier = Modifier
- .testTag("STATIN_NUDGE_RISK_TEXT")
- .offset {
- IntOffset(
- x = clampedOffsetX.toInt(),
- y = 0
- )
- }
- .background(riskColor, shape = RoundedCornerShape(50))
- .padding(horizontal = 8.dp, vertical = 4.dp),
+ .testTag("STATIN_NUDGE_RISK_TEXT")
+ .offset {
+ IntOffset(
+ x = clampedOffsetX.toInt(),
+ y = 0
+ )
+ }
+ .background(riskColor, shape = RoundedCornerShape(50))
+ .padding(horizontal = 8.dp, vertical = 4.dp),
style = SimpleTheme.typography.material.button,
color = SimpleTheme.colors.onToolbarPrimary,
text = riskText
@@ -200,64 +212,70 @@ fun RiskProgressBar(
)
val indicatorColor = Color(0xFF2F363D)
+ var progressBarWidth by remember { mutableFloatStateOf(0f) }
- BoxWithConstraints(
+ Box(
modifier = Modifier
- .fillMaxWidth()
- .height(14.dp)
- .drawWithContent {
- drawContent()
-
- drawLine(
- color = indicatorColor,
- start = Offset(startOffset, 0f),
- end = Offset(startOffset, size.height),
- strokeWidth = 2.dp.toPx()
- )
- drawLine(
- color = indicatorColor,
- start = Offset(endOffset, 0f),
- end = Offset(endOffset, size.height),
- strokeWidth = 2.dp.toPx()
- )
- },
+ .fillMaxWidth()
+ .height(14.dp)
+ .onSizeChanged { intSize ->
+ progressBarWidth = intSize.width.toFloat()
+ }
+ .drawWithContent {
+ drawContent()
+
+ drawLine(
+ color = indicatorColor,
+ start = Offset(startOffset, 0f),
+ end = Offset(startOffset, size.height),
+ strokeWidth = 2.dp.toPx()
+ )
+ drawLine(
+ color = indicatorColor,
+ start = Offset(endOffset, 0f),
+ end = Offset(endOffset, size.height),
+ strokeWidth = 2.dp.toPx()
+ )
+ },
contentAlignment = Alignment.Center,
) {
- val totalSegments = riskColors.size
- val segmentWidthPx = constraints.maxWidth.toFloat() / totalSegments
-
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .height(4.dp)
- .clip(RoundedCornerShape(50))
- ) {
- riskColors.forEachIndexed { index, color ->
- val segmentStartPx = index * segmentWidthPx
- val segmentEndPx = (index + 1) * segmentWidthPx
-
- Box(
- modifier = Modifier
- .weight(1f)
- .fillMaxHeight()
- .drawWithContent {
- drawRect(color.copy(alpha = 0.5f))
-
- val visibleStart = maxOf(segmentStartPx, startOffset)
- val visibleEnd = minOf(segmentEndPx, endOffset)
-
- if (visibleStart < visibleEnd) {
- drawRect(
- color = color.copy(alpha = 1.0f),
- topLeft = Offset(x = visibleStart - segmentStartPx, y = 0f),
- size = Size(
- width = visibleEnd - visibleStart,
- height = size.height
- )
- )
- }
- }
- )
+ if (progressBarWidth > 0f) {
+ val totalSegments = riskColors.size
+ val segmentWidthPx = progressBarWidth / totalSegments
+
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .height(4.dp)
+ .clip(RoundedCornerShape(50))
+ ) {
+ riskColors.forEachIndexed { index, color ->
+ val segmentStartPx = index * segmentWidthPx
+ val segmentEndPx = (index + 1) * segmentWidthPx
+
+ Box(
+ modifier = Modifier
+ .weight(1f)
+ .fillMaxHeight()
+ .drawWithContent {
+ drawRect(color.copy(alpha = 0.5f))
+
+ val visibleStart = maxOf(segmentStartPx, startOffset)
+ val visibleEnd = minOf(segmentEndPx, endOffset)
+
+ if (visibleStart < visibleEnd) {
+ drawRect(
+ color = color.copy(alpha = 1.0f),
+ topLeft = Offset(x = visibleStart - segmentStartPx, y = 0f),
+ size = Size(
+ width = visibleEnd - visibleStart,
+ height = size.height
+ )
+ )
+ }
+ }
+ )
+ }
}
}
}
@@ -293,7 +311,6 @@ fun DescriptionText(
@Composable
fun StainNudgeAddButtons(
- modifier: Modifier = Modifier,
statinInfo: StatinInfo,
isNonLabBasedStatinNudgeEnabled: Boolean,
isLabBasedStatinNudgeEnabled: Boolean,
@@ -303,15 +320,16 @@ fun StainNudgeAddButtons(
) {
SimpleInverseTheme {
Row(
- modifier = modifier.fillMaxWidth(),
+ modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
if (statinInfo.isSmoker == Answer.Unanswered) {
StainNudgeAddButton(
text = stringResource(R.string.statin_alert_add_tobacco_use),
modifier = Modifier
- .testTag("STATIN_NUDGE_ADD_TOBACCO_USE")
- .weight(1f),
+ .padding(top = 16.dp)
+ .testTag("STATIN_NUDGE_ADD_TOBACCO_USE")
+ .weight(1f),
onClick = addTobaccoUseClicked
)
}
@@ -320,8 +338,9 @@ fun StainNudgeAddButtons(
StainNudgeAddButton(
text = stringResource(R.string.statin_alert_add_bmi),
modifier = Modifier
- .testTag("STATIN_NUDGE_ADD_BMI")
- .weight(1f),
+ .padding(top = 16.dp)
+ .testTag("STATIN_NUDGE_ADD_BMI")
+ .weight(1f),
onClick = addBMIClick
)
}
@@ -330,8 +349,9 @@ fun StainNudgeAddButtons(
StainNudgeAddButton(
text = stringResource(R.string.statin_alert_add_cholesterol),
modifier = Modifier
- .testTag("STATIN_NUDGE_ADD_CHOLESTEROL")
- .weight(1f),
+ .padding(top = 16.dp)
+ .testTag("STATIN_NUDGE_ADD_CHOLESTEROL")
+ .weight(1f),
onClick = addCholesterol
)
}
@@ -347,9 +367,9 @@ fun StainNudgeAddButton(
) {
FilledButton(
modifier = modifier
- .height(36.dp)
- .fillMaxWidth()
- .clip(RoundedCornerShape(50)),
+ .height(36.dp)
+ .fillMaxWidth()
+ .clip(RoundedCornerShape(50)),
onClick = onClick
) {
BasicText(
diff --git a/app/src/main/res/values-am-rET/strings.xml b/app/src/main/res/values-am-rET/strings.xml
index 1e5bd79c0c3..82bce30b338 100644
--- a/app/src/main/res/values-am-rET/strings.xml
+++ b/app/src/main/res/values-am-rET/strings.xml
@@ -338,6 +338,9 @@
ታሪክ
ባለፈው ወር ውስጥ ህመምተኞው በማንኛውም ጊዜ የBP መድሃኒት ወስዷል? (አስፈላጊ)
በሽተኛው ባለፈው ወር ውስጥ የስኳር በሽታ መድኃኒቶችን ወስዶ ነበር? (ያስፈልጋል)
+ ማጨስ
+ ጭስ አልባ ቶባኮ
+
ምንም
ያስወግዱ
diff --git a/app/src/main/res/values-bn-rBD/strings.xml b/app/src/main/res/values-bn-rBD/strings.xml
index 5a8e02231c5..c1c05f143d2 100644
--- a/app/src/main/res/values-bn-rBD/strings.xml
+++ b/app/src/main/res/values-bn-rBD/strings.xml
@@ -338,6 +338,8 @@
ইতিহাস
গত মাসে রোগী কি কোনও সময় বিপি-র ওষুধ খেয়েছিলেন? (আবশ্যিক)
গত মাসে রোগী কি কোনও সময় ডায়াবেটিসের ওষুধ খেয়েছিলেন? (আবশ্যিক)
+ ধূমপান
+ ধোঁয়াবিহীন তামাক
কোনটিই নয়
diff --git a/app/src/main/res/values-om-rET/strings.xml b/app/src/main/res/values-om-rET/strings.xml
index 02e8fdd452b..54363f882a8 100644
--- a/app/src/main/res/values-om-rET/strings.xml
+++ b/app/src/main/res/values-om-rET/strings.xml
@@ -339,6 +339,9 @@
Seenaa
Dhukubsataan ji\'a darbe yeroo ta\'e keessa dawaa BP fudhateeraa? (Barbaadamaa)
Ji\'a darbe keessa dhukkubsatichi dawaawwan sukkaaraa fudhatee jiraa? (Barbaadama)
+ Aara
+ Tamboo aara hin qabne
+
Hin jiru
Balleessi
diff --git a/app/src/main/res/values-si-rLK/strings.xml b/app/src/main/res/values-si-rLK/strings.xml
index 4d15283f5c9..e43a9b985cf 100644
--- a/app/src/main/res/values-si-rLK/strings.xml
+++ b/app/src/main/res/values-si-rLK/strings.xml
@@ -338,6 +338,8 @@
ඉතිහාසය
රෝගියා පසුගිය මාසය තුල කිසියම් දිනකදී රුධිර පීඩනය පාලනය කිරීම සඳහා ඖෂධයක් ලබා ගත්තේද? (අවශ්යයි)
රෝගියා පසුගිය මාසය තුල කිසියම් දිනකදී දියවැඩියාව පාලනය කිරීම සඳහා ඖෂධයක් ලබා ගත්තේද? (අවශ්යයි)
+ දුම් පානය කරයි
+ දුම රහිත දුම්කොළ ආශ්රිත නිෂ්පාදන
කිසිවක් නැත
diff --git a/app/src/main/res/values-ta-rLK/strings.xml b/app/src/main/res/values-ta-rLK/strings.xml
index 1e881fe5026..3c7cc3ba48a 100644
--- a/app/src/main/res/values-ta-rLK/strings.xml
+++ b/app/src/main/res/values-ta-rLK/strings.xml
@@ -338,6 +338,8 @@
வரலாறு
கடந்த மாதத்தில் நோயாளர் எப்போதாவது பிபி குளிகைகளை எடுத்துக்கொண்டாரா? (தேவையானவை)
கடந்த மாதத்தில் நோயாளர் எப்போதாவது நீரழிவுநோய் மருந்துகளை எடுத்துக்கொண்டாரா? (தேவையானவை)
+ சுருட்டு புகை
+ புகையற்ற புகையிலை
எதுவுமில்லை