Skip to content

Commit

Permalink
Merge pull request #2379 from HedvigInsurance/fix/remove-dialog-info-…
Browse files Browse the repository at this point in the history
…from-backend

Change bottom sheet info to not come from backend
  • Loading branch information
StylianosGakis authored Jan 21, 2025
2 parents fabc980 + 335816c commit 97959b6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,4 @@ fragment MoveAddonQuoteFragment on MoveAddonQuote {
addonVariant {
...AddonVariantFragment
}
removeDialogInfo {
title
description
confirmButtonTitle
cancelButtonTitle
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.DisplayItem
import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.MoveHomeQuote
import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.MoveHomeQuote.Deductible
import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.MoveMtaQuote
import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.UserExcludable.ExclusionDialogInfo
import kotlinx.datetime.LocalDate
import kotlinx.serialization.Serializable
import octopus.feature.movingflow.fragment.MoveIntentQuotesFragment
Expand Down Expand Up @@ -89,7 +88,6 @@ internal data class MovingFlowQuotes(
override val exposureName: String,
override val addonVariant: AddonVariant,
override val isExcludedByUser: Boolean,
override val exclusionDialogInfo: ExclusionDialogInfo?,
) : AddonQuote, UserExcludable

@Serializable
Expand All @@ -105,16 +103,6 @@ internal data class MovingFlowQuotes(

internal interface UserExcludable {
val isExcludedByUser: Boolean
val exclusionDialogInfo: ExclusionDialogInfo?

@Serializable
data class ExclusionDialogInfo(
val addonId: AddonId,
val title: String,
val description: String,
val confirmButtonTitle: String,
val cancelButtonTitle: String,
)
}
}

Expand Down Expand Up @@ -157,15 +145,6 @@ internal fun MoveIntentQuotesFragment.toMovingFlowQuotes(): MovingFlowQuotes {
)
},
addonVariant = addon.addonVariant.toAddonVariant(),
exclusionDialogInfo = addon.removeDialogInfo?.let { removeDialogInfo ->
ExclusionDialogInfo(
addonId = AddonId(addon.addonId),
title = removeDialogInfo.title,
description = removeDialogInfo.description,
confirmButtonTitle = removeDialogInfo.confirmButtonTitle,
cancelButtonTitle = removeDialogInfo.cancelButtonTitle,
)
},
isExcludedByUser = false,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.DisplayItem
import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.MoveHomeQuote
import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.MoveHomeQuote.Deductible
import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.MoveMtaQuote
import com.hedvig.android.feature.movingflow.data.MovingFlowQuotes.UserExcludable.ExclusionDialogInfo
import com.hedvig.android.feature.movingflow.ui.MovingFlowTopAppBar
import com.hedvig.android.feature.movingflow.ui.summary.SummaryUiState.Content
import com.hedvig.android.feature.movingflow.ui.summary.SummaryUiState.Content.SubmitError.Generic
Expand Down Expand Up @@ -206,11 +205,11 @@ private fun SummaryScreen(
}
val exclusionBottomSheetState = rememberHedvigBottomSheetState<ExclusionDialogInfo>()
HedvigBottomSheet(exclusionBottomSheetState) { data ->
HedvigText(data.title)
HedvigText(data.description, color = HedvigTheme.colorScheme.textSecondary)
HedvigText(stringResource(R.string.ADDON_REMOVE_TITLE, data.addonName))
HedvigText(stringResource(R.string.ADDON_REMOVE_DESCRIPTION), color = HedvigTheme.colorScheme.textSecondary)
Spacer(Modifier.height(32.dp))
HedvigButton(
text = data.confirmButtonTitle,
text = stringResource(R.string.ADDON_REMOVE_CONFIRM_BUTTON, data.addonName),
onClick = {
exclusionBottomSheetState.dismiss()
toggleHomeAddonExclusion(data.addonId)
Expand All @@ -221,7 +220,7 @@ private fun SummaryScreen(
)
Spacer(Modifier.height(8.dp))
HedvigButton(
text = data.cancelButtonTitle,
text = stringResource(R.string.ADDON_REMOVE_CANCEL_BUTTON),
onClick = { exclusionBottomSheetState.dismiss() },
enabled = true,
buttonStyle = Ghost,
Expand All @@ -247,8 +246,8 @@ private fun SummaryScreen(
quote = addonQuote,
canExcludeAddons = content.canExcludeAddons,
toggleHomeAddonExclusion = {
if (addonQuote.exclusionDialogInfo != null && !addonQuote.isExcludedByUser) {
exclusionBottomSheetState.show(addonQuote.exclusionDialogInfo)
if (!addonQuote.isExcludedByUser) {
exclusionBottomSheetState.show(ExclusionDialogInfo(addonQuote.addonId, addonQuote.exposureName))
} else {
toggleHomeAddonExclusion(addonQuote.addonId)
}
Expand Down Expand Up @@ -467,6 +466,11 @@ private fun QuestionsAndAnswers(modifier: Modifier = Modifier) {
}
}

private data class ExclusionDialogInfo(
val addonId: AddonId,
val addonName: String,
)

@HedvigMultiScreenPreview
@Preview(device = "spec:width=1080px,height=3800px,dpi=440")
@Composable
Expand Down Expand Up @@ -575,13 +579,6 @@ private class SummaryUiStateProvider : PreviewParameterProvider<SummaryUiState>
),
exposureName = "exposureName",
addonVariant = addonVariant,
exclusionDialogInfo = ExclusionDialogInfo(
addonId = AddonId(it.toString()),
title = "title",
description = "description",
confirmButtonTitle = "confirmButtonTitle",
cancelButtonTitle = "cancelButtonTitle",
),
isExcludedByUser = true,
)
},
Expand Down

0 comments on commit 97959b6

Please sign in to comment.