Skip to content

Commit

Permalink
Merge pull request #2390 from HedvigInsurance/fix/excluded-addons-sho…
Browse files Browse the repository at this point in the history
…uld-stay-shrinked

Fix: Excluded addons should stay shrinked and non-interactive
  • Loading branch information
StylianosGakis authored Jan 24, 2025
2 parents 7001d4f + 821cf96 commit c334801
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ fragment AddonVariantFragment on AddonVariant {
exceptions
colorCode
}
insurableLimits {
label
limit
description
}
documents {
displayName
url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ data class AddonVariant(
val product: String,
val documents: List<InsuranceVariantDocument>,
val perils: List<ProductVariantPeril>,
val insurableLimits: List<InsurableLimit>,
)

fun AddonVariantFragment.toAddonVariant() = AddonVariant(
Expand All @@ -34,11 +33,4 @@ fun AddonVariantFragment.toAddonVariant() = AddonVariant(
colorCode = peril.colorCode,
)
},
insurableLimits = this.insurableLimits.map { insurableLimit ->
InsurableLimit(
label = insurableLimit.label,
limit = insurableLimit.limit,
description = insurableLimit.description,
)
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.windowInsetsBottomHeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ private val fakeTravelAddonQuote1 = TravelAddonQuote(
perils = listOf(),
displayName = "45 days",
product = "",
insurableLimits = listOf(),
),
price = UiMoney(
49.0,
Expand All @@ -564,7 +563,6 @@ private val fakeTravelAddonQuote2 = TravelAddonQuote(
perils = listOf(),
displayName = "60 days",
product = "",
insurableLimits = listOf(),
),
price = UiMoney(
60.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ private class ChooseInsuranceForAddonUiStateProvider :
perils = listOf(),
displayName = "45 days",
product = "",
insurableLimits = listOf(),
),
price = UiMoney(
60.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.hedvig.android.feature.addon.purchase.ui.travelinsuranceplusexplanation

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ private val mockWithoutUpgrade = TravelAddonOffer(
displayName = "45 days",
product = "",
perils = listOf(),
insurableLimits = listOf(),
),
price = UiMoney(
49.0,
Expand All @@ -335,7 +334,6 @@ private val mockWithoutUpgrade = TravelAddonOffer(
displayName = "60 days",
product = "",
perils = listOf(),
insurableLimits = listOf(),
),
price = UiMoney(
60.0,
Expand All @@ -362,7 +360,6 @@ private val mockWithUpgrade = TravelAddonOffer(
displayName = "45 days",
product = "",
perils = listOf(),
insurableLimits = listOf(),
),
price = UiMoney(
60.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ private val newQuote = TravelAddonQuote(
displayName = "45 days",
product = "",
perils = listOf(),
insurableLimits = listOf(),
documents = listOf(
InsuranceVariantDocument(
"Terms and Conditions",
Expand Down Expand Up @@ -139,7 +138,6 @@ private val newQuote2 = TravelAddonQuote(
displayName = "60 days",
product = "",
perils = listOf(),
insurableLimits = listOf(),
documents = listOf(
InsuranceVariantDocument(
"Terms and Conditions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ private val fakeTravelAddonQuote1 = TravelAddonQuote(
displayName = "45 days",
product = "",
perils = listOf(),
insurableLimits = listOf(),
documents = listOf(
InsuranceVariantDocument(
"Terms and Conditions",
Expand All @@ -188,7 +187,6 @@ private val fakeTravelAddonQuote2 = TravelAddonQuote(
displayName = "60 days",
product = "",
perils = listOf(),
insurableLimits = listOf(),
documents = listOf(
InsuranceVariantDocument(
"Terms and Conditions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import com.hedvig.android.feature.change.tier.ui.stepsummary.SummaryState.Making
import com.hedvig.android.feature.change.tier.ui.stepsummary.SummaryState.Success
import com.hedvig.android.tiersandaddons.QuoteCard
import com.hedvig.android.tiersandaddons.QuoteDisplayItem
import com.hedvig.android.tiersandaddons.rememberQuoteCardState
import hedvig.resources.R
import kotlinx.datetime.LocalDate
import kotlinx.datetime.toJavaLocalDate
Expand Down Expand Up @@ -320,6 +321,7 @@ private fun AddonCard(
val startDate = formatStartDate(activationDate)
val subtitle = stringResource(R.string.CHANGE_ADDRESS_ACTIVATION_DATE, startDate)
QuoteCard(
quoteCardState = rememberQuoteCardState(),
displayName = addonQuote.addonVariant.displayName,
contractGroup = null,
insurableLimits = emptyList(),
Expand Down Expand Up @@ -440,7 +442,6 @@ private class ChooseInsuranceUiStateProvider :
addonVariant = AddonVariant(
displayName = "Addon Name",
perils = listOf(),
insurableLimits = listOf(),
documents = listOf(
InsuranceVariantDocument(
"Document name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ private fun PreviewContractDetailScreen() {
),
),
perils = listOf(),
insurableLimits = listOf(),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ private val fakeAddonVariant = AddonVariant(
),
displayName = "Travel Insurance Plus",
product = "",
insurableLimits = listOf(),
)

private val previewInsurableLimits: List<InsurableLimit> = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ private fun PreviewDocumentsScreen() {
InsuranceVariantDocument.InsuranceDocumentType.GENERAL_TERMS,
),
),
insurableLimits = listOf(),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import com.hedvig.android.tiersandaddons.QuoteCard
import com.hedvig.android.tiersandaddons.QuoteCardDefaults
import com.hedvig.android.tiersandaddons.QuoteCardState
import com.hedvig.android.tiersandaddons.QuoteDisplayItem
import com.hedvig.android.tiersandaddons.rememberQuoteCardState
import hedvig.resources.R
import kotlinx.datetime.LocalDate
import kotlinx.datetime.toJavaLocalDate
Expand Down Expand Up @@ -354,12 +355,17 @@ private fun AddonQuoteCard(
quote = quote,
modifier = modifier,
underDetailsContent = { state ->
LaunchedEffect(quote.isExcludedByUser) {
if (quote.isExcludedByUser) {
state.showDetails = false
}
}
Column {
Spacer(Modifier.height(16.dp))
AnimatedVisibility(
visible = canExcludeAddons && state.showDetails && !quote.isExcludedByUser,
enter = expandVertically(expandFrom = Alignment.Top),
exit = shrinkVertically(shrinkTowards = Alignment.Top),
modifier = Modifier.padding(bottom = 8.dp),
) {
HedvigButton(
text = stringResource(R.string.GENERAL_REMOVE),
Expand All @@ -368,7 +374,9 @@ private fun AddonQuoteCard(
buttonStyle = Ghost,
buttonSize = Medium,
border = HedvigTheme.colorScheme.borderPrimary,
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 8.dp),
)
}
if (quote.isExcludedByUser) {
Expand All @@ -378,10 +386,21 @@ private fun AddonQuoteCard(
enabled = true,
buttonStyle = Secondary,
buttonSize = Medium,
modifier = Modifier.fillMaxWidth().padding(top = 16.dp),
modifier = Modifier.fillMaxWidth(),
)
} else {
QuoteCardDefaults.UnderDetailsContent(state)
HedvigButton(
text = if (state.showDetails) {
stringResource(R.string.TIER_FLOW_SUMMARY_HIDE_DETAILS_BUTTON)
} else {
stringResource(R.string.TIER_FLOW_SUMMARY_SHOW_DETAILS)
},
onClick = state::toggleState,
enabled = true,
buttonStyle = Secondary,
buttonSize = Medium,
modifier = Modifier.fillMaxWidth(),
)
}
}
},
Expand Down Expand Up @@ -409,11 +428,21 @@ private fun AddonQuoteCard(
} else {
stringResource(R.string.CHANGE_ADDRESS_ACTIVATION_DATE, startDate)
}
val quoteCardState = rememberQuoteCardState()
QuoteCard(
quoteCardState = object : QuoteCardState {
override var showDetails: Boolean
get() = if (quote is HomeAddonQuote && quote.isExcludedByUser) false else quoteCardState.showDetails
set(value) {
if (quote is HomeAddonQuote && quote.isExcludedByUser) return
quoteCardState.showDetails = value
}
override val isEnabled: Boolean
get() = if (quote is HomeAddonQuote && quote.isExcludedByUser) false else quoteCardState.isEnabled
},
displayName = quote.addonVariant.displayName,
contractGroup = null,
insurableLimits = emptyList(),
// todo: here we don't want to show insurable limits for addons, that may change later
documents = quote.addonVariant.documents,
subtitle = subtitle,
premium = quote.premium.toString(),
Expand Down Expand Up @@ -538,7 +567,6 @@ private class SummaryUiStateProvider : PreviewParameterProvider<SummaryUiState>
),
),
perils = listOf(),
insurableLimits = listOf(),
)
val startDate = LocalDate.parse("2025-01-01")

Expand Down
Loading

0 comments on commit c334801

Please sign in to comment.