Skip to content

Commit 90332a5

Browse files
Merge pull request #5478 from simpledotorg/master
2 parents 803fa35 + 7fb4672 commit 90332a5

File tree

3 files changed

+67
-41
lines changed

3 files changed

+67
-41
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- Replace Flipper with Chucker for network inspection
2424
- Update statin risk threshold to 20% for sri Lanka
2525
- Update smoking dialog to a multi-choice tobacco dialog
26+
- Bump AndroidX Room to v2.7.2
2627

2728
## 2025.05.20
2829

app/src/main/java/org/simple/clinic/summary/compose/StatinNudgeView.kt

Lines changed: 62 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import androidx.compose.foundation.layout.height
1717
import androidx.compose.foundation.layout.offset
1818
import androidx.compose.foundation.layout.padding
1919
import androidx.compose.foundation.shape.RoundedCornerShape
20+
import androidx.compose.foundation.text.BasicText
21+
import androidx.compose.foundation.text.TextAutoSize
2022
import androidx.compose.material.Card
23+
import androidx.compose.material.MaterialTheme
2124
import androidx.compose.material.Text
2225
import androidx.compose.runtime.Composable
2326
import androidx.compose.ui.Alignment
@@ -33,6 +36,7 @@ import androidx.compose.ui.res.stringResource
3336
import androidx.compose.ui.text.AnnotatedString
3437
import androidx.compose.ui.text.rememberTextMeasurer
3538
import androidx.compose.ui.text.style.TextAlign
39+
import androidx.compose.ui.text.style.TextOverflow
3640
import androidx.compose.ui.tooling.preview.Preview
3741
import androidx.compose.ui.unit.IntOffset
3842
import androidx.compose.ui.unit.dp
@@ -289,7 +293,7 @@ fun DescriptionText(
289293

290294
@Composable
291295
fun StainNudgeAddButtons(
292-
modifier: Modifier,
296+
modifier: Modifier = Modifier,
293297
statinInfo: StatinInfo,
294298
isNonLabBasedStatinNudgeEnabled: Boolean,
295299
isLabBasedStatinNudgeEnabled: Boolean,
@@ -303,59 +307,67 @@ fun StainNudgeAddButtons(
303307
horizontalArrangement = Arrangement.spacedBy(8.dp)
304308
) {
305309
if (statinInfo.isSmoker == Answer.Unanswered) {
306-
FilledButton(
310+
StainNudgeAddButton(
311+
text = stringResource(R.string.statin_alert_add_tobacco_use),
307312
modifier = Modifier
308313
.testTag("STATIN_NUDGE_ADD_TOBACCO_USE")
309-
.height(36.dp)
310-
.fillMaxWidth()
311-
.weight(1f)
312-
.clip(RoundedCornerShape(50)),
313-
onClick = { addTobaccoUseClicked.invoke() }
314-
) {
315-
Text(
316-
text = stringResource(R.string.statin_alert_add_tobacco_use),
317-
fontSize = 14.sp,
318-
)
319-
}
314+
.weight(1f),
315+
onClick = addTobaccoUseClicked
316+
)
320317
}
321318

322319
if (isNonLabBasedStatinNudgeEnabled && statinInfo.bmiReading == null) {
323-
FilledButton(
320+
StainNudgeAddButton(
321+
text = stringResource(R.string.statin_alert_add_bmi),
324322
modifier = Modifier
325323
.testTag("STATIN_NUDGE_ADD_BMI")
326-
.height(36.dp)
327-
.fillMaxWidth()
328-
.weight(1f)
329-
.clip(RoundedCornerShape(50)),
330-
onClick = { addBMIClick.invoke() }
331-
) {
332-
Text(
333-
text = stringResource(R.string.statin_alert_add_bmi),
334-
fontSize = 14.sp,
335-
)
336-
}
324+
.weight(1f),
325+
onClick = addBMIClick
326+
)
337327
}
338328

339329
if (isLabBasedStatinNudgeEnabled && statinInfo.cholesterol == null) {
340-
FilledButton(
330+
StainNudgeAddButton(
331+
text = stringResource(R.string.statin_alert_add_cholesterol),
341332
modifier = Modifier
342333
.testTag("STATIN_NUDGE_ADD_CHOLESTEROL")
343-
.height(36.dp)
344-
.fillMaxWidth()
345-
.weight(1f)
346-
.clip(RoundedCornerShape(50)),
347-
onClick = { addCholesterol() }
348-
) {
349-
Text(
350-
text = stringResource(R.string.statin_alert_add_cholesterol),
351-
fontSize = 14.sp,
352-
)
353-
}
334+
.weight(1f),
335+
onClick = addCholesterol
336+
)
354337
}
355338
}
356339
}
357340
}
358341

342+
@Composable
343+
fun StainNudgeAddButton(
344+
modifier: Modifier,
345+
text: String,
346+
onClick: () -> Unit,
347+
) {
348+
FilledButton(
349+
modifier = modifier
350+
.height(36.dp)
351+
.fillMaxWidth()
352+
.clip(RoundedCornerShape(50)),
353+
onClick = onClick
354+
) {
355+
BasicText(
356+
text = text,
357+
maxLines = 1,
358+
overflow = TextOverflow.Ellipsis,
359+
autoSize = TextAutoSize.StepBased(
360+
minFontSize = 10.sp,
361+
maxFontSize = 14.sp
362+
),
363+
style = SimpleTheme.typography.buttonBig.copy(
364+
textAlign = TextAlign.Center,
365+
color = MaterialTheme.colors.onPrimary
366+
)
367+
)
368+
}
369+
}
370+
359371
fun getOffsets(cvdRiskRange: CVDRiskRange?, size: Size): Pair<Float, Float> {
360372
val riskRanges = listOf(
361373
0..4, // LOW
@@ -409,3 +421,16 @@ fun StatinNudgePreview() {
409421
)
410422
}
411423
}
424+
425+
@Preview
426+
@Composable
427+
fun StatinNudgeButtonsPreview() {
428+
StainNudgeAddButtons(
429+
statinInfo = StatinInfo(canShowStatinNudge = true),
430+
isNonLabBasedStatinNudgeEnabled = true,
431+
isLabBasedStatinNudgeEnabled = false,
432+
addTobaccoUseClicked = {},
433+
addBMIClick = {},
434+
addCholesterol = {},
435+
)
436+
}

gradle/libs.versions.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ agp = "8.8.2"
44
androidx-cameraView = "1.4.2"
55
androidx-camera = "1.4.2"
66
androidx-paging = "3.3.6"
7-
androidx-room = "2.7.1"
7+
androidx-room = "2.7.2"
88
androidx-work = "2.10.1"
99
androidx-security-crypto = "1.1.0-alpha07"
1010
androidx-viewmodel = "2.8.7"
@@ -36,7 +36,7 @@ coroutines = "1.10.2"
3636

3737
compose-compiler = "1.5.13"
3838

39-
androidx-compose-bom = "2023.07.00-alpha02"
39+
androidx-compose-bom = "2025.07.00"
4040

4141
composeThemeAdapter = "0.36.0"
4242

@@ -203,7 +203,7 @@ zxing = "com.google.zxing:core:3.3.3"
203203

204204
apache-commons-math = "org.apache.commons:commons-math3:3.6.1"
205205

206-
androidx-compose-bom = { module = "dev.chrisbanes.compose:compose-bom", version.ref = "androidx-compose-bom" }
206+
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" }
207207
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
208208
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
209209
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
@@ -230,7 +230,7 @@ kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref =
230230
kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
231231
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
232232
google-services = { id = "com.google.gms.google-services", version = "4.4.2" }
233-
sentry = { id = "io.sentry.android.gradle", version = "5.1.0" }
233+
sentry = { id = "io.sentry.android.gradle", version = "5.8.0" }
234234

235235
[bundles]
236236
androidx-camera = ["androidx-camera-core", "androidx-camera-camera2", "androidx-camera-view", "androidx-camera-lifecycle"]

0 commit comments

Comments
 (0)