Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import kotlinx.datetime.toLocalDateTime
data class DisplayItem(
val title: String,
val value: DisplayItemValue,
val subtitle: String? = null,
) {
sealed interface DisplayItemValue {
data class DateTime(val localDateTime: LocalDateTime) : DisplayItemValue
Expand All @@ -18,7 +19,7 @@ data class DisplayItem(
}

companion object {
fun fromStrings(title: String, value: String): DisplayItem {
fun fromStrings(title: String, value: String, subtitle: String? = null): DisplayItem {
val displayItemValue: DisplayItemValue = run {
try {
val localDate = LocalDate.parse(value)
Expand All @@ -42,6 +43,7 @@ data class DisplayItem(
return DisplayItem(
title,
displayItemValue,
subtitle,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ fragment AgreementFragment on Agreement {

fragment AgreementDisplayItemFragment on AgreementDisplayItem {
displayTitle
displaySubtitle
displayValue
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private fun ContractFragment.toContract(
}

private fun AgreementDisplayItemFragment.toDisplayItem(): DisplayItem {
return DisplayItem.fromStrings(displayTitle, displayValue)
return DisplayItem.fromStrings(displayTitle, displayValue, displaySubtitle)
}

private fun MonthlyCostFragment.toMonthlyCost(): MonthlyCost {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,18 @@ internal fun YourInfoTab(
modifier = Modifier.padding(horizontal = 16.dp),
)
}
if (allowEditCoInsured && coInsured.isNotEmpty()) {
HorizontalDivider(Modifier.padding(horizontal = 16.dp))
if (allowEditCoInsured || allowEditCoOwners) {
HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
Spacer(Modifier.height(16.dp))
ContractOwnerSection(
coInsuredList = coInsured,
modifier = Modifier.padding(horizontal = 16.dp),
)
if (coInsured.isEmpty() && coOwners.isEmpty()) {
Spacer(Modifier.height(16.dp))
}
}
if (allowEditCoInsured && coInsured.isNotEmpty()) {
CoInsuredSection(
coInsuredList = coInsured,
contractHolderDisplayName = contractHolderDisplayName,
Expand All @@ -321,8 +330,6 @@ internal fun YourInfoTab(
)
}
if (allowEditCoOwners && coOwners.isNotEmpty()) {
HorizontalDivider(Modifier.padding(horizontal = 16.dp))
Spacer(Modifier.height(16.dp))
CoInsuredSection(
coInsuredList = coOwners,
contractHolderDisplayName = contractHolderDisplayName,
Expand Down Expand Up @@ -660,11 +667,16 @@ internal fun CoverageRows(coverageRowItems: List<DisplayItem>, modifier: Modifie
coverageRowItems.forEachIndexed { index, displayItem ->
HorizontalItemsWithMaximumSpaceTaken(
startSlot = {
Row(
verticalAlignment = Alignment.CenterVertically,
Column(
verticalArrangement = Arrangement.Center,
modifier = Modifier.padding(vertical = 16.dp),
) {
HedvigText(displayItem.title)
displayItem.subtitle?.let {
HedvigText(it,
style = HedvigTheme.typography.label,
color = HedvigTheme.colorScheme.textSecondary)
}
}
},
endSlot = {
Expand Down Expand Up @@ -746,6 +758,44 @@ internal fun PriceRow(
)
}

@Composable
internal fun ContractOwnerSection(
coInsuredList: List<CoInsured>,
modifier: Modifier,
) {
Column(modifier = modifier) {
HorizontalItemsWithMaximumSpaceTaken(
startSlot = {
Column(
verticalArrangement = Arrangement.Center,
modifier = Modifier.padding(vertical = 4.dp),
) {
HedvigText(stringResource(Res.string.CHANGE_ADDRESS_CO_INSURED_LABEL))
}
},
endSlot = {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.End,
modifier = Modifier.padding(vertical = 4.dp),
) {
val text = if (coInsuredList.isEmpty()) {
stringResource(Res.string.CHANGE_ADDRESS_ONLY_YOU)
} else {
stringResource(Res.string.CHANGE_ADDRESS_YOU_PLUS, coInsuredList.size)
}
HedvigText(
text = text,
color = HedvigTheme.colorScheme.textSecondary,
textAlign = TextAlign.End,
)
}
},
spaceBetween = 8.dp,
)
}
}

@Composable
internal fun CoInsuredSection(
coInsuredList: List<CoInsured>,
Expand All @@ -757,35 +807,7 @@ internal fun CoInsuredSection(
val dateTimeFormatter = rememberHedvigDateTimeFormatter()
val birthDateTimeFormatter = rememberHedvigBirthDateDateTimeFormatter()
Column(modifier = modifier) {
HorizontalItemsWithMaximumSpaceTaken(
startSlot = {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.padding(vertical = 4.dp),
) {
HedvigText(stringResource(Res.string.CHANGE_ADDRESS_CO_INSURED_LABEL))
}
},
endSlot = {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.End,
modifier = Modifier.padding(vertical = 4.dp),
) {
val text = if (coInsuredList.isEmpty()) {
stringResource(Res.string.CHANGE_ADDRESS_ONLY_YOU)
} else {
stringResource(Res.string.CHANGE_ADDRESS_YOU_PLUS, coInsuredList.size)
}
HedvigText(
text = text,
color = HedvigTheme.colorScheme.textSecondary,
textAlign = TextAlign.End,
)
}
},
spaceBetween = 8.dp,
)

Spacer(Modifier.height(16.dp))
HorizontalDivider()
HorizontalItemsWithMaximumSpaceTaken(
Expand Down
Loading