@@ -17,7 +17,10 @@ import androidx.compose.foundation.layout.height
1717import androidx.compose.foundation.layout.offset
1818import androidx.compose.foundation.layout.padding
1919import androidx.compose.foundation.shape.RoundedCornerShape
20+ import androidx.compose.foundation.text.BasicText
21+ import androidx.compose.foundation.text.TextAutoSize
2022import androidx.compose.material.Card
23+ import androidx.compose.material.MaterialTheme
2124import androidx.compose.material.Text
2225import androidx.compose.runtime.Composable
2326import androidx.compose.ui.Alignment
@@ -33,6 +36,7 @@ import androidx.compose.ui.res.stringResource
3336import androidx.compose.ui.text.AnnotatedString
3437import androidx.compose.ui.text.rememberTextMeasurer
3538import androidx.compose.ui.text.style.TextAlign
39+ import androidx.compose.ui.text.style.TextOverflow
3640import androidx.compose.ui.tooling.preview.Preview
3741import androidx.compose.ui.unit.IntOffset
3842import androidx.compose.ui.unit.dp
@@ -289,7 +293,7 @@ fun DescriptionText(
289293
290294@Composable
291295fun 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+
359371fun 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+ }
0 commit comments