diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d563f15144..795786e0317 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Bump Google Service to v4.4.3 - Bump Sentry Android to v5.9.0 - Bump AndroidX ViewModel to v2.9.3 +- Update Compose BOM to v2025.08.01 ### Changes diff --git a/app/src/main/java/org/simple/clinic/patient/businessid/Identifier.kt b/app/src/main/java/org/simple/clinic/patient/businessid/Identifier.kt index b8f62c13800..d17aff91071 100644 --- a/app/src/main/java/org/simple/clinic/patient/businessid/Identifier.kt +++ b/app/src/main/java/org/simple/clinic/patient/businessid/Identifier.kt @@ -2,6 +2,7 @@ package org.simple.clinic.patient.businessid import android.content.res.Resources import android.os.Parcelable +import androidx.annotation.StringRes import androidx.annotation.VisibleForTesting import androidx.room.ColumnInfo import androidx.room.TypeConverter @@ -42,6 +43,7 @@ data class Identifier( "$prefix${Unicode.nonBreakingSpace}$suffix" } + BangladeshNationalId -> value EthiopiaMedicalRecordNumber -> value IndiaNationalHealthId -> { @@ -53,6 +55,7 @@ data class Identifier( "$prefix${Unicode.nonBreakingSpace}$subString1${Unicode.nonBreakingSpace}$subString2${Unicode.nonBreakingSpace}$suffix" } + SriLankaNationalId -> value SriLankaPersonalHealthNumber -> value is Unknown -> value @@ -67,14 +70,19 @@ data class Identifier( } fun displayType(resources: Resources): String { + return resources.getString(displayTypeResId()) + } + + @StringRes + fun displayTypeResId(): Int { return when (type) { - BpPassport -> resources.getString(R.string.identifiertype_bp_passport) - BangladeshNationalId -> resources.getString(R.string.identifiertype_bangladesh_national_id) - EthiopiaMedicalRecordNumber -> resources.getString(R.string.identifiertype_ethiopia_medical_record_number) - IndiaNationalHealthId -> resources.getString(R.string.identifiertype_india_national_health_id) - SriLankaNationalId -> resources.getString(R.string.identifiertype_sri_lanka_national_id) - SriLankaPersonalHealthNumber -> resources.getString(R.string.identifiertype_sri_lanka_personal_health_number) - is Unknown -> resources.getString(R.string.identifiertype_unknown) + BpPassport -> R.string.identifiertype_bp_passport + BangladeshNationalId -> R.string.identifiertype_bangladesh_national_id + EthiopiaMedicalRecordNumber -> R.string.identifiertype_ethiopia_medical_record_number + IndiaNationalHealthId -> R.string.identifiertype_india_national_health_id + SriLankaNationalId -> R.string.identifiertype_sri_lanka_national_id + SriLankaPersonalHealthNumber -> R.string.identifiertype_sri_lanka_personal_health_number + is Unknown -> R.string.identifiertype_unknown } } diff --git a/app/src/main/java/org/simple/clinic/summary/ui/PatientSummaryToolbar.kt b/app/src/main/java/org/simple/clinic/summary/ui/PatientSummaryToolbar.kt index dd879c8be1e..969e99df5f5 100644 --- a/app/src/main/java/org/simple/clinic/summary/ui/PatientSummaryToolbar.kt +++ b/app/src/main/java/org/simple/clinic/summary/ui/PatientSummaryToolbar.kt @@ -25,7 +25,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -49,38 +48,38 @@ import java.util.UUID @Composable fun PatientSummaryToolbar( - patientName: String, - gender: Gender, - age: Int, - address: String, - phoneNumber: PatientPhoneNumber?, - bpPassport: BusinessId?, - alternativeId: BusinessId?, - onBack: () -> Unit, - onContact: () -> Unit, - onEditPatient: () -> Unit, - modifier: Modifier = Modifier + patientName: String, + gender: Gender, + age: Int, + address: String, + phoneNumber: PatientPhoneNumber?, + bpPassport: BusinessId?, + alternativeId: BusinessId?, + onBack: () -> Unit, + onContact: () -> Unit, + onEditPatient: () -> Unit, + modifier: Modifier = Modifier ) { Surface( - color = SimpleTheme.colors.toolbarPrimary, - contentColor = SimpleTheme.colors.onToolbarPrimary, - elevation = AppBarDefaults.TopAppBarElevation, - modifier = modifier, + color = SimpleTheme.colors.toolbarPrimary, + contentColor = SimpleTheme.colors.onToolbarPrimary, + elevation = AppBarDefaults.TopAppBarElevation, + modifier = modifier, ) { Column( - modifier = Modifier.statusBarsPadding() + modifier = Modifier.statusBarsPadding() ) { // Actions Row( - verticalAlignment = Alignment.CenterVertically, + verticalAlignment = Alignment.CenterVertically, ) { IconButton( - onClick = onBack + onClick = onBack ) { Icon( - imageVector = Icons.AutoMirrored.Filled.ArrowBack, - contentDescription = null, - tint = SimpleTheme.colors.onToolbarPrimary, + imageVector = Icons.AutoMirrored.Filled.ArrowBack, + contentDescription = null, + tint = SimpleTheme.colors.onToolbarPrimary, ) } @@ -88,29 +87,29 @@ fun PatientSummaryToolbar( if (phoneNumber != null) { ToolbarActionTextButton( - label = phoneNumber.number, - icon = painterResource(R.drawable.ic_summary_call_icon), - onClick = onContact, + label = phoneNumber.number, + icon = painterResource(R.drawable.ic_summary_call_icon), + onClick = onContact, ) Spacer(Modifier.requiredWidth(8.dp)) } ToolbarActionTextButton( - modifier = Modifier.padding(end = 12.dp), - label = stringResource(R.string.patientsummary_edit), - onClick = onEditPatient + modifier = Modifier.padding(end = 12.dp), + label = stringResource(R.string.patientsummary_edit), + onClick = onEditPatient ) } // Content PatientInfoContent( - gender = gender, - patientName = patientName, - age = age, - address = address, - bpPassport = bpPassport, - alternativeId = alternativeId + gender = gender, + patientName = patientName, + age = age, + address = address, + bpPassport = bpPassport, + alternativeId = alternativeId ) } } @@ -118,64 +117,60 @@ fun PatientSummaryToolbar( @Composable private fun PatientInfoContent( - gender: Gender, - patientName: String, - age: Int, - address: String, - bpPassport: BusinessId?, - alternativeId: BusinessId? + gender: Gender, + patientName: String, + age: Int, + address: String, + bpPassport: BusinessId?, + alternativeId: BusinessId? ) { - val context = LocalContext.current Column( - modifier = Modifier - .fillMaxWidth() - .padding( - start = dimensionResource(id = R.dimen.spacing_16), - end = dimensionResource(id = R.dimen.spacing_16), - bottom = dimensionResource(id = R.dimen.spacing_16) - ) + modifier = Modifier + .fillMaxWidth() + .padding( + start = dimensionResource(id = R.dimen.spacing_16), + end = dimensionResource(id = R.dimen.spacing_16), + bottom = dimensionResource(id = R.dimen.spacing_16) + ) ) { - val resources = context.resources - val genderLetter = resources.getString(gender.displayLetterRes) - val patientNameGenderAge = resources.getString( - R.string.patientsummary_toolbar_title, - patientName, - genderLetter, - age.toString() - ) Text( - text = patientNameGenderAge, - style = MaterialTheme.typography.h6, - maxLines = 1, - color = SimpleTheme.colors.onToolbarPrimary, - modifier = Modifier.padding(top = dimensionResource(id = R.dimen.spacing_8)) + text = stringResource( + R.string.patientsummary_toolbar_title, + patientName, + stringResource(gender.displayLetterRes), + age + ), + style = MaterialTheme.typography.h6, + maxLines = 1, + color = SimpleTheme.colors.onToolbarPrimary, + modifier = Modifier.padding(top = dimensionResource(id = R.dimen.spacing_8)) ) Text( - text = address, - style = MaterialTheme.typography.body2, - color = SimpleTheme.colors.onToolbarPrimary72, - modifier = Modifier.padding(top = dimensionResource(id = R.dimen.spacing_4)) + text = address, + style = MaterialTheme.typography.body2, + color = SimpleTheme.colors.onToolbarPrimary72, + modifier = Modifier.padding(top = dimensionResource(id = R.dimen.spacing_4)) ) Column( - modifier = Modifier.padding(top = dimensionResource(id = R.dimen.spacing_4)) + modifier = Modifier.padding(top = dimensionResource(id = R.dimen.spacing_4)) ) { if (bpPassport != null) { Text( - text = buildBusinessIdString(businessId = bpPassport), - style = MaterialTheme.typography.body2, - color = SimpleTheme.colors.onToolbarPrimary72, - modifier = Modifier.padding(end = dimensionResource(id = R.dimen.spacing_8)) + text = buildBusinessIdString(businessId = bpPassport), + style = MaterialTheme.typography.body2, + color = SimpleTheme.colors.onToolbarPrimary72, + modifier = Modifier.padding(end = dimensionResource(id = R.dimen.spacing_8)) ) } if (alternativeId != null) { Text( - text = buildBusinessIdString(businessId = alternativeId), - style = MaterialTheme.typography.body2, - color = SimpleTheme.colors.onToolbarPrimary72, - modifier = Modifier.padding(top = if (bpPassport != null) dimensionResource(id = R.dimen.spacing_4) else 0.dp) + text = buildBusinessIdString(businessId = alternativeId), + style = MaterialTheme.typography.body2, + color = SimpleTheme.colors.onToolbarPrimary72, + modifier = Modifier.padding(top = if (bpPassport != null) dimensionResource(id = R.dimen.spacing_4) else 0.dp) ) } } @@ -184,44 +179,43 @@ private fun PatientInfoContent( @Composable private fun ToolbarActionTextButton( - label: String, - modifier: Modifier = Modifier, - icon: Painter? = null, - onClick: () -> Unit, + label: String, + modifier: Modifier = Modifier, + icon: Painter? = null, + onClick: () -> Unit, ) { Row( - modifier = Modifier - .then(modifier) - .clip(MaterialTheme.shapes.small) - .clickable { onClick() } - .background(Color.Black.copy(alpha = 0.24f)) - .padding(horizontal = 8.dp, vertical = 4.dp), - verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .then(modifier) + .clip(MaterialTheme.shapes.small) + .clickable { onClick() } + .background(Color.Black.copy(alpha = 0.24f)) + .padding(horizontal = 8.dp, vertical = 4.dp), + verticalAlignment = Alignment.CenterVertically, ) { if (icon != null) { Image( - painter = icon, - contentDescription = null, - modifier = Modifier.requiredSize(16.dp) + painter = icon, + contentDescription = null, + modifier = Modifier.requiredSize(16.dp) ) Spacer(Modifier.requiredWidth(4.dp)) } Text( - text = label.uppercase(), - style = MaterialTheme.typography.button, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - color = MaterialTheme.colors.onPrimary + text = label.uppercase(), + style = MaterialTheme.typography.button, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + color = MaterialTheme.colors.onPrimary ) } } @Composable private fun buildBusinessIdString(businessId: BusinessId): AnnotatedString { - val context = LocalContext.current - val label = businessId.identifier.displayType(context.resources) + val label = stringResource(id = businessId.identifier.displayTypeResId()) val identifier = businessId.identifier return buildAnnotatedString { @@ -229,11 +223,11 @@ private fun buildBusinessIdString(businessId: BusinessId): AnnotatedString { val body2Numeric = SimpleTheme.typography.body2Numeric withStyle( - SpanStyle( - fontSize = body2Numeric.fontSize, - letterSpacing = body2Numeric.letterSpacing, - fontFamily = body2Numeric.fontFamily, - ) + SpanStyle( + fontSize = body2Numeric.fontSize, + letterSpacing = body2Numeric.letterSpacing, + fontFamily = body2Numeric.fontFamily, + ) ) { append(identifier.displayValue()) } @@ -245,57 +239,57 @@ private fun buildBusinessIdString(businessId: BusinessId): AnnotatedString { private fun PatientSummaryToolbarPreview() { SimpleTheme { PatientSummaryToolbar( - patientName = "SpongeBob", - gender = Gender.Male, - age = 25, - address = "124 Conch Street, Bikini Bottom, Pacific Ocean", - phoneNumber = PatientPhoneNumber( - uuid = UUID.fromString("73f2c465-9833-4922-8fb2-6700094fdb3a"), - patientUuid = UUID.fromString("6878819c-aeb1-4b1f-bcb5-22059697329a"), - number = "83217387122", - phoneType = PatientPhoneNumberType.Mobile, - active = true, - createdAt = Instant.parse("2018-01-01T00:00:00Z"), - updatedAt = Instant.parse("2018-01-01T00:00:00Z"), - deletedAt = null, - ), - bpPassport = BusinessId( - uuid = UUID.fromString("d758d820-b8d4-448d-be6c-ed2e970d193f"), - patientUuid = UUID.fromString("4ea1e739-1d5f-4f23-8e73-d42b1445c58e"), - identifier = Identifier( - value = "9828b60b-b6d1-4f8a-bcfc-b9ddfc8fc1e2", - type = Identifier.IdentifierType.BpPassport + patientName = "SpongeBob", + gender = Gender.Male, + age = 25, + address = "124 Conch Street, Bikini Bottom, Pacific Ocean", + phoneNumber = PatientPhoneNumber( + uuid = UUID.fromString("73f2c465-9833-4922-8fb2-6700094fdb3a"), + patientUuid = UUID.fromString("6878819c-aeb1-4b1f-bcb5-22059697329a"), + number = "83217387122", + phoneType = PatientPhoneNumberType.Mobile, + active = true, + createdAt = Instant.parse("2018-01-01T00:00:00Z"), + updatedAt = Instant.parse("2018-01-01T00:00:00Z"), + deletedAt = null, ), - metaDataVersion = BusinessId.MetaDataVersion.BpPassportMetaDataV1, - metaData = "", - createdAt = Instant.parse("2018-01-01T00:00:00Z"), - updatedAt = Instant.parse("2018-01-01T00:00:00Z"), - deletedAt = null, - searchHelp = "123456" - ), - alternativeId = BusinessId( - uuid = UUID.fromString("edfcf367-26a7-40a6-8af7-570c718ab387"), - patientUuid = UUID.fromString("f17756f9-4a45-486e-940d-16cd6c2a2e1b"), - identifier = Identifier( - value = "1276417263891739", - type = Identifier.IdentifierType.BangladeshNationalId + bpPassport = BusinessId( + uuid = UUID.fromString("d758d820-b8d4-448d-be6c-ed2e970d193f"), + patientUuid = UUID.fromString("4ea1e739-1d5f-4f23-8e73-d42b1445c58e"), + identifier = Identifier( + value = "9828b60b-b6d1-4f8a-bcfc-b9ddfc8fc1e2", + type = Identifier.IdentifierType.BpPassport + ), + metaDataVersion = BusinessId.MetaDataVersion.BpPassportMetaDataV1, + metaData = "", + createdAt = Instant.parse("2018-01-01T00:00:00Z"), + updatedAt = Instant.parse("2018-01-01T00:00:00Z"), + deletedAt = null, + searchHelp = "123456" ), - metaDataVersion = BusinessId.MetaDataVersion.BangladeshNationalIdMetaDataV1, - metaData = "", - createdAt = Instant.parse("2018-01-01T00:00:00Z"), - updatedAt = Instant.parse("2018-01-01T00:00:00Z"), - deletedAt = null, - searchHelp = "1276417263891739" - ), - onBack = { - // no-op - }, - onContact = { - // no-op - }, - onEditPatient = { - // no-op - } + alternativeId = BusinessId( + uuid = UUID.fromString("edfcf367-26a7-40a6-8af7-570c718ab387"), + patientUuid = UUID.fromString("f17756f9-4a45-486e-940d-16cd6c2a2e1b"), + identifier = Identifier( + value = "1276417263891739", + type = Identifier.IdentifierType.BangladeshNationalId + ), + metaDataVersion = BusinessId.MetaDataVersion.BangladeshNationalIdMetaDataV1, + metaData = "", + createdAt = Instant.parse("2018-01-01T00:00:00Z"), + updatedAt = Instant.parse("2018-01-01T00:00:00Z"), + deletedAt = null, + searchHelp = "1276417263891739" + ), + onBack = { + // no-op + }, + onContact = { + // no-op + }, + onEditPatient = { + // no-op + } ) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 95d0e7f6c58..f6e58e98dd6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -38,7 +38,7 @@ coroutines = "1.10.2" compose-compiler = "1.5.13" -androidx-compose-bom = "2025.07.00" +androidx-compose-bom = "2025.08.01" composeThemeAdapter = "0.36.0"